External Events
ARP can both receive and generate notifications when special conditions come into being. The section "Interaction Between Neighboring Protocols and L3 Transmission Functions" in Chapter 27 gives an overview of how neighboring protocols interact with the rest of the kernel. Here we will see in particular how ARP takes care of these notifications.
Received Events
We saw in the section "ARP Protocol
Initialization" that ARP registers with the kernel for the notification of
device events and that arp_netdev_event is the
handler that takes care of those events. Among the various event types that the function
receives, ARP is interested only in NETDEV_CHANGEADDR, which is generated when the L2 address of a device is
changed (e.g., via manual configuration). The kernel routine that processes the
user-space request to change a device link layer address, and that therefore generates
the NETDEV_CHANGEADDR notification, is do_setlink, defined in net/core/rtnetlink.c.
static int
arp_netdev_event(struct notifier_block *this, unsigned long event, void *ptr)
{
struct net_device *dev = ptr;
switch (event) {
case NETDEV_CHANGEADDR:
neigh_changeaddr(&arp_tbl, dev);
rt_cache_flush(0);
break;
default:
break;
}
return NOTIFY_DONE;
}neigh_changeaddr is described in the section
"Events Received by the Neighboring
Layer" in Chapter 27.
rt_cache_flush flushes the IPv4 routing cache so that the IP layer is forced to start using the new L2 address. This function does not selectively delete the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access