ETHARP_STATE_STABLE_REREQUESTING: no need for member 'netif' in 'struct etharp_entry' if we re-request only from etharp_output() and use etharp_tmr() to reset the state of such entries to ETHARP_STATE_STABLE: that way, we also only send one ARP request per ARP_TMR_INTERVAL, but only if the entry is really still used.

This commit is contained in:
Simon Goldschmidt 2011-07-21 20:47:29 +02:00
parent 206b1f4631
commit 2694a409c6

View File

@ -107,7 +107,9 @@ struct etharp_entry {
struct pbuf *q;
#endif /* ARP_QUEUEING */
ip_addr_t ipaddr;
#if LWIP_SNMP
struct netif *netif;
#endif /* LWIP_SNMP */
struct eth_addr ethaddr;
u8_t state;
u8_t ctime;
@ -183,12 +185,14 @@ free_entry(int i)
free_etharp_q(arp_table[i].q);
arp_table[i].q = NULL;
}
/* recycle entry for re-use */
/* recycle entry for re-use */
arp_table[i].state = ETHARP_STATE_EMPTY;
#ifdef LWIP_DEBUG
/* for debugging, clean out the complete entry */
arp_table[i].ctime = 0;
#if LWIP_SNMP
arp_table[i].netif = NULL;
#endif /* LWIP_SNMP */
ip_addr_set_zero(&arp_table[i].ipaddr);
arp_table[i].ethaddr = ethzero;
#endif /* LWIP_DEBUG */
@ -224,11 +228,10 @@ etharp_tmr(void)
/* clean up entries that have just been expired */
free_entry(i);
}
else if ((arp_table[i].ctime >= ARP_AGE_REREQUEST_USED) &&
(arp_table[i].state == ETHARP_STATE_STABLE_REREQUESTING)) {
/* stable entry that is in use is about to expire: re-request it to
prevent it from breaking communication when it expires */
etharp_request(arp_table[i].netif, &arp_table[i].ipaddr);
else if (arp_table[i].state == ETHARP_STATE_STABLE_REREQUESTING) {
/* Reset state to stable, so that the next transmitted packet will
re-send an ARP request. */
arp_table[i].state = ETHARP_STATE_STABLE;
}
#if ARP_QUEUEING
/* still pending entry? (not expired) */
@ -478,7 +481,9 @@ update_arp_entry(struct netif *netif, ip_addr_t *ipaddr, struct eth_addr *ethadd
}
/* record network interface */
#if LWIP_SNMP
arp_table[i].netif = netif;
#endif /* LWIP_SNMP */
/* insert in SNMP ARP index tree */
snmp_insert_arpidx_tree(netif, &arp_table[i].ipaddr);