net/ipv4/arp.c
Source file repositories/reference/linux-study-clean/net/ipv4/arp.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv4/arp.c- Extension
.c- Size
- 38023 bytes
- Lines
- 1525
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/types.hlinux/string.hlinux/kernel.hlinux/capability.hlinux/socket.hlinux/sockios.hlinux/errno.hlinux/hex.hlinux/in.hlinux/mm.hlinux/inet.hlinux/inetdevice.hlinux/netdevice.hlinux/etherdevice.hlinux/fddidevice.hlinux/if_arp.hlinux/skbuff.hlinux/proc_fs.hlinux/seq_file.hlinux/stat.hlinux/init.hlinux/net.hlinux/rcupdate.hlinux/slab.hlinux/sysctl.hnet/net_namespace.hnet/ip.hnet/icmp.hnet/route.hnet/protocol.hnet/tcp.h
Detected Declarations
function arp_mc_mapfunction arp_hashfunction arp_key_eqfunction arp_constructorfunction arp_error_reportfunction arp_send_dstfunction arp_sendfunction arp_solicitfunction arp_ignorefunction arp_acceptfunction arp_filterfunction arp_fwd_proxyfunction VLANfunction whichfunction arp_xmit_finishfunction arp_xmitfunction arp_is_garpfunction arp_processfunction parp_redofunction arp_is_multicastfunction arp_rcvfunction interfacefunction Setfunction arp_req_set_publicfunction arp_req_setfunction arp_state_to_flagsfunction arp_req_getfunction arp_invalidatefunction arp_req_delete_publicfunction arp_req_deletefunction arp_ioctlfunction arp_netdev_eventfunction arp_ifdownfunction ax2asc2function arp_format_neigh_entryfunction arp_format_pneigh_entryfunction arp_seq_showfunction arp_net_initfunction arp_net_exitfunction arp_initexport arp_tblexport arp_sendexport arp_createexport arp_xmit
Annotated Snippet
if (dir) {
memcpy(haddr, dev->broadcast, dev->addr_len);
return 0;
}
}
return -EINVAL;
}
static u32 arp_hash(const void *pkey,
const struct net_device *dev,
__u32 *hash_rnd)
{
return arp_hashfn(pkey, dev, hash_rnd);
}
static bool arp_key_eq(const struct neighbour *neigh, const void *pkey)
{
return neigh_key_eq32(neigh, pkey);
}
static int arp_constructor(struct neighbour *neigh)
{
__be32 addr;
struct net_device *dev = neigh->dev;
struct in_device *in_dev;
struct neigh_parms *parms;
u32 inaddr_any = INADDR_ANY;
if (dev->flags & (IFF_LOOPBACK | IFF_POINTOPOINT))
memcpy(neigh->primary_key, &inaddr_any, arp_tbl.key_len);
addr = *(__be32 *)neigh->primary_key;
rcu_read_lock();
in_dev = __in_dev_get_rcu(dev);
if (!in_dev) {
rcu_read_unlock();
return -EINVAL;
}
neigh->type = inet_addr_type_dev_table(dev_net(dev), dev, addr);
parms = in_dev->arp_parms;
__neigh_parms_put(neigh->parms);
neigh->parms = neigh_parms_clone(parms);
rcu_read_unlock();
if (!dev->header_ops) {
neigh->nud_state = NUD_NOARP;
neigh->ops = &arp_direct_ops;
neigh->output = neigh_direct_output;
} else {
/* Good devices (checked by reading texts, but only Ethernet is
tested)
ARPHRD_ETHER: (ethernet, apfddi)
ARPHRD_FDDI: (fddi)
ARPHRD_IEEE802: (tr)
ARPHRD_METRICOM: (strip)
ARPHRD_ARCNET:
etc. etc. etc.
ARPHRD_IPDDP will also work, if author repairs it.
I did not it, because this driver does not work even
in old paradigm.
*/
if (neigh->type == RTN_MULTICAST) {
neigh->nud_state = NUD_NOARP;
arp_mc_map(addr, neigh->ha, dev, 1);
} else if (dev->flags & (IFF_NOARP | IFF_LOOPBACK)) {
neigh->nud_state = NUD_NOARP;
memcpy(neigh->ha, dev->dev_addr, dev->addr_len);
} else if (neigh->type == RTN_BROADCAST ||
(dev->flags & IFF_POINTOPOINT)) {
neigh->nud_state = NUD_NOARP;
memcpy(neigh->ha, dev->broadcast, dev->addr_len);
}
if (dev->header_ops->cache)
neigh->ops = &arp_hh_ops;
else
neigh->ops = &arp_generic_ops;
if (neigh->nud_state & NUD_VALID)
neigh->output = neigh->ops->connected_output;
else
neigh->output = neigh->ops->output;
}
return 0;
Annotation
- Immediate include surface: `linux/module.h`, `linux/types.h`, `linux/string.h`, `linux/kernel.h`, `linux/capability.h`, `linux/socket.h`, `linux/sockios.h`, `linux/errno.h`.
- Detected declarations: `function arp_mc_map`, `function arp_hash`, `function arp_key_eq`, `function arp_constructor`, `function arp_error_report`, `function arp_send_dst`, `function arp_send`, `function arp_solicit`, `function arp_ignore`, `function arp_accept`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.