diff --git a/CHANGELOG b/CHANGELOG index 45ed3bfd..909a3ed0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -49,6 +49,10 @@ HISTORY ++ Bugfixes: + 2011-11-22: Simon Goldschmidt + * netif.c, etharp.h/.c: fixed bug #34684: Clear the arp table cache when + netif is brought down + 2011-10-28: Simon Goldschmidt * tcp_in.c: fixed bug #34638: Dead code in tcp_receive - pcb->dupacks diff --git a/src/core/netif.c b/src/core/netif.c index 342aa87d..07908cc5 100644 --- a/src/core/netif.c +++ b/src/core/netif.c @@ -497,6 +497,11 @@ void netif_set_down(struct netif *netif) snmp_get_sysuptime(&netif->ts); #endif +#if LWIP_ARP + if (netif->flags & NETIF_FLAG_ETHARP) { + etharp_cleanup_netif(netif); + } +#endif /* LWIP_ARP */ NETIF_STATUS_CALLBACK(netif); } } diff --git a/src/include/netif/etharp.h b/src/include/netif/etharp.h index 691575fa..859608df 100644 --- a/src/include/netif/etharp.h +++ b/src/include/netif/etharp.h @@ -190,6 +190,7 @@ err_t etharp_request(struct netif *netif, ip_addr_t *ipaddr); * nodes to update an entry in their ARP cache. * From RFC 3220 "IP Mobility Support for IPv4" section 4.6. */ #define etharp_gratuitous(netif) etharp_request((netif), &(netif)->ip_addr) +void etharp_cleanup_netif(struct netif *netif); #if ETHARP_SUPPORT_STATIC_ENTRIES err_t etharp_add_static_entry(ip_addr_t *ipaddr, struct eth_addr *ethaddr); diff --git a/src/netif/etharp.c b/src/netif/etharp.c index b63d577b..286f7fe3 100644 --- a/src/netif/etharp.c +++ b/src/netif/etharp.c @@ -106,9 +106,7 @@ 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; @@ -574,6 +572,23 @@ etharp_remove_static_entry(ip_addr_t *ipaddr) } #endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ +/** + * Remove all ARP table entries of the specified netif. + * + * @param netif points to a network interface + */ +void etharp_cleanup_netif(struct netif *netif) +{ + u8_t i; + + for (i = 0; i < ARP_TABLE_SIZE; ++i) { + u8_t state = arp_table[i].state; + if ((state != ETHARP_STATE_EMPTY) && (arp_table[i].netif == netif)) { + etharp_free_entry(i); + } + } +} + /** * Finds (stable) ethernet/IP address pair from ARP table * using interface and IP address index.