Skip to content
Permalink
Browse files

net/arp: No need of 64bits timer precision on ARP requests

The 32bits one can hold up to about 50 days, this is more than enough
knowing that ARP request timeout is 2 seconds.

So reducing the request start time to 32bits.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
  • Loading branch information...
tbursztyka authored and jukkar committed May 23, 2019
1 parent 79672d1 commit 344d4bdce0f6629f59944663e3699a356037db3d
Showing with 6 additions and 5 deletions.
  1. +5 −4 subsys/net/l2/ethernet/arp.c
  2. +1 −1 subsys/net/l2/ethernet/arp.h
@@ -168,7 +168,7 @@ static void arp_entry_register_pending(struct arp_entry *entry)

sys_slist_append(&arp_pending_entries, &entry->node);

entry->req_start = k_uptime_get();
entry->req_start = k_uptime_get_32();

/* Let's start the timer if necessary */
if (!k_delayed_work_remaining_get(&arp_request_timer)) {
@@ -179,14 +179,15 @@ static void arp_entry_register_pending(struct arp_entry *entry)

static void arp_request_timeout(struct k_work *work)
{
s64_t current = k_uptime_get();
u32_t current = k_uptime_get_32();
struct arp_entry *entry, *next;

ARG_UNUSED(work);

SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&arp_pending_entries,
entry, next, node) {
if ((entry->req_start + ARP_REQUEST_TIMEOUT - current) > 0) {
if ((s32_t)(entry->req_start +
ARP_REQUEST_TIMEOUT - current) > 0) {
break;
}

@@ -451,7 +452,7 @@ static void arp_update(struct net_if *iface,
}

if (entry) {
entry->req_start = k_uptime_get();
entry->req_start = k_uptime_get_32();
entry->iface = iface;
net_ipaddr_copy(&entry->ip, src);
memcpy(&entry->eth, hwaddr, sizeof(entry->eth));
@@ -51,7 +51,7 @@ enum net_verdict net_arp_input(struct net_pkt *pkt,

struct arp_entry {
sys_snode_t node;
s64_t req_start;
u32_t req_start;
struct net_if *iface;
struct in_addr ip;
union {

0 comments on commit 344d4bd

Please sign in to comment.
You can’t perform that action at this time.