net/ipv4/devinet.c
Source file repositories/reference/linux-study-clean/net/ipv4/devinet.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv4/devinet.c- Extension
.c- Size
- 77039 bytes
- Lines
- 2977
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/uaccess.hlinux/bitops.hlinux/capability.hlinux/module.hlinux/types.hlinux/kernel.hlinux/sched/signal.hlinux/string.hlinux/mm.hlinux/socket.hlinux/sockios.hlinux/in.hlinux/errno.hlinux/interrupt.hlinux/if_addr.hlinux/if_ether.hlinux/inet.hlinux/netdevice.hlinux/etherdevice.hlinux/skbuff.hlinux/init.hlinux/notifier.hlinux/inetdevice.hlinux/igmp.higmp_internal.hlinux/slab.hlinux/hash.hlinux/sysctl.hlinux/kmod.hlinux/netconf.hnet/arp.hnet/ip.h
Detected Declarations
function inet_addr_hashfunction inet_hash_insertfunction inet_hash_removefunction devinet_sysctl_registerfunction devinet_sysctl_unregisterfunction inet_rcu_free_ifafunction inet_free_ifafunction in_dev_free_rcufunction in_dev_finish_destroyfunction inetdev_destroyfunction inet_blackhole_dev_initfunction inet_addr_onlinkfunction __inet_del_ifafunction inet_del_ifafunction __inet_insert_ifafunction inet_insert_ifafunction inet_set_ifafunction in_dev_for_each_ifa_rtnlfunction ip_mc_autojoin_configfunction inet_rtm_deladdrfunction check_lifetimefunction hlist_for_each_entry_rcufunction hlist_for_each_entry_safefunction set_ifa_lifetimefunction inet_validate_rtmfunction in_dev_for_each_ifa_rtnl_netfunction inet_rtm_newaddrfunction inet_abc_lenfunction devinet_ioctlfunction whatfunction inet_gifconffunction in_dev_for_each_ifa_rtnl_netfunction in_dev_select_addrfunction in_dev_for_each_ifa_rcufunction inet_select_addrfunction in_dev_for_each_ifa_rcufunction confirm_addr_indevfunction in_dev_for_each_ifa_rcufunction inet_confirm_addrfunction register_inetaddr_notifierfunction unregister_inetaddr_notifierfunction register_inetaddr_validator_notifierfunction unregister_inetaddr_validator_notifierfunction inetdev_changenamefunction in_dev_for_each_ifa_rtnlfunction inetdev_send_gratuitous_arpfunction in_dev_for_each_ifa_rtnlfunction inetdev_event
Annotated Snippet
if (err) {
in_dev->dead = 1;
neigh_parms_release(&arp_tbl, in_dev->arp_parms);
in_dev_put(in_dev);
in_dev = NULL;
goto out;
}
ip_mc_init_dev(in_dev);
if (dev->flags & IFF_UP)
ip_mc_up(in_dev);
}
/* we can receive as soon as ip_ptr is set -- do this last */
rcu_assign_pointer(dev->ip_ptr, in_dev);
out:
return in_dev ?: ERR_PTR(err);
out_kfree:
kfree(in_dev);
in_dev = NULL;
goto out;
}
static void inetdev_destroy(struct in_device *in_dev)
{
struct net_device *dev;
struct in_ifaddr *ifa;
ASSERT_RTNL();
dev = in_dev->dev;
in_dev->dead = 1;
ip_mc_destroy_dev(in_dev);
while ((ifa = rtnl_dereference(in_dev->ifa_list)) != NULL) {
inet_del_ifa(in_dev, &in_dev->ifa_list, 0);
inet_free_ifa(ifa);
}
RCU_INIT_POINTER(dev->ip_ptr, NULL);
devinet_sysctl_unregister(in_dev);
neigh_parms_release(&arp_tbl, in_dev->arp_parms);
arp_ifdown(dev);
in_dev_put(in_dev);
}
static int __init inet_blackhole_dev_init(void)
{
struct in_device *in_dev;
rtnl_lock();
in_dev = inetdev_init(blackhole_netdev);
rtnl_unlock();
return PTR_ERR_OR_ZERO(in_dev);
}
late_initcall(inet_blackhole_dev_init);
int inet_addr_onlink(struct in_device *in_dev, __be32 a, __be32 b)
{
const struct in_ifaddr *ifa;
rcu_read_lock();
in_dev_for_each_ifa_rcu(ifa, in_dev) {
if (inet_ifa_match(a, ifa)) {
if (!b || inet_ifa_match(b, ifa)) {
rcu_read_unlock();
return 1;
}
}
}
rcu_read_unlock();
return 0;
}
static void __inet_del_ifa(struct in_device *in_dev,
struct in_ifaddr __rcu **ifap,
int destroy, struct nlmsghdr *nlh, u32 portid)
{
struct in_ifaddr *promote = NULL;
struct in_ifaddr *ifa, *ifa1;
struct in_ifaddr __rcu **last_prim;
struct in_ifaddr *prev_prom = NULL;
int do_promote = IN_DEV_PROMOTE_SECONDARIES(in_dev);
ASSERT_RTNL();
Annotation
- Immediate include surface: `linux/uaccess.h`, `linux/bitops.h`, `linux/capability.h`, `linux/module.h`, `linux/types.h`, `linux/kernel.h`, `linux/sched/signal.h`, `linux/string.h`.
- Detected declarations: `function inet_addr_hash`, `function inet_hash_insert`, `function inet_hash_remove`, `function devinet_sysctl_register`, `function devinet_sysctl_unregister`, `function inet_rcu_free_ifa`, `function inet_free_ifa`, `function in_dev_free_rcu`, `function in_dev_finish_destroy`, `function inetdev_destroy`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.