Processing Ingress ARP Packets
As explained in
the section "ARP Protocol
Initialization," ARP registers the arp_rcv
routine as its protocol handler. Let's see how this handler processes incoming ARP
packets.
The ARP packet can be accessed from the skb buffer
that is the function's input argument; in particular, the ARP header is at skb->nh.arph. The function's first task is to make sure the
ARP packet is not fragmented; that is, that it can be accessed linearly in memory. This
task is necessary because sometimes the skb buffer is
fragmented in memory.[*] If it is, arp_rcv calls the generic routine
pskb_may_pull to make sure there is enough room in
the main buffer for the ARP header and payload.
int arp_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt)
{
struct arphdr *arp;
/* ARP header, plus 2 device addresses, plus 2 IP addresses. */
if (!pskb_may_pull(skb, (sizeof(struct arphdr) +
(2 * dev->addr_len) +
(2 * sizeof(u32)))))
goto freeskb;
An input ARP packet is dropped by arp_rcv if one of
the following conditions is met:
It was received on a device that does not use ARP (i.e., one tagged with the
IFF_NOARPflag).The loopback interface is a special case within this category. Packets sent to and from the loopback interface are classified with the
PACKET_LOOPBACKtype. Since such an interface is virtual and does not have a hardware address, there is no need to use ARP.It was not addressed to the receiving interface (i.e., the destination address was not the receiving ...
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