net/ipv4/ipconfig.c
Source file repositories/reference/linux-study-clean/net/ipv4/ipconfig.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv4/ipconfig.c- Extension
.c- Size
- 44288 bytes
- Lines
- 1848
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source 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.
- 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/types.hlinux/string.hlinux/kernel.hlinux/jiffies.hlinux/random.hlinux/init.hlinux/utsname.hlinux/in.hlinux/if.hlinux/inet.hlinux/inetdevice.hlinux/netdevice.hlinux/if_arp.hlinux/skbuff.hlinux/ip.hlinux/socket.hlinux/route.hlinux/udp.hlinux/proc_fs.hlinux/seq_file.hlinux/major.hlinux/root_dev.hlinux/delay.hlinux/nfs_fs.hlinux/slab.hlinux/export.hnet/net_namespace.hnet/arp.hnet/ip.hnet/ipconfig.hnet/route.hlinux/uaccess.h
Detected Declarations
struct ic_devicestruct bootp_pktfunction ic_is_init_devfunction ic_open_devsfunction for_each_netdevfunction secs_to_jiffiesfunction for_each_netdevfunction ic_close_devsfunction set_sockaddrfunction ic_setup_iffunction ic_setup_routesfunction ic_defaultsfunction ic_rarp_initfunction ic_rarp_cleanupfunction ic_rarp_recvfunction ic_rarp_send_iffunction ic_nameservers_predeffunction ic_ntp_servers_predeffunction ic_dhcp_init_optionsfunction ic_bootp_init_extfunction ic_bootp_initfunction ic_bootp_cleanupfunction ic_bootp_send_iffunction ic_bootp_stringfunction ic_do_bootp_extfunction ic_bootp_recvfunction ic_dynamicfunction pnp_seq_showfunction ipconfig_proc_net_initfunction ipconfig_proc_net_createfunction ntp_servers_showfunction root_nfs_parse_addrfunction wait_for_devicesfunction for_each_netdevfunction ip_auto_configfunction insufficientfunction driverfunction ic_proto_namefunction ip_auto_config_setupfunction strcmpfunction nfsaddrs_config_setupfunction vendor_class_identifier_setupfunction set_carrier_timeout
Annotated Snippet
struct ic_device {
struct ic_device *next;
struct net_device *dev;
unsigned short flags;
short able;
__be32 xid;
};
static struct ic_device *ic_first_dev __initdata; /* List of open device */
static struct ic_device *ic_dev __initdata; /* Selected device */
static bool __init ic_is_init_dev(struct net_device *dev)
{
if (dev->flags & IFF_LOOPBACK)
return false;
return user_dev_name[0] ? !strcmp(dev->name, user_dev_name) :
(!(dev->flags & IFF_LOOPBACK) &&
(dev->flags & (IFF_POINTOPOINT|IFF_BROADCAST)) &&
strncmp(dev->name, "dummy", 5));
}
static int __init ic_open_devs(void)
{
struct ic_device *d, **last;
struct net_device *dev;
unsigned short oflags;
unsigned long start, next_msg;
last = &ic_first_dev;
rtnl_lock();
/* bring loopback device up first */
for_each_netdev(&init_net, dev) {
if (!(dev->flags & IFF_LOOPBACK))
continue;
if (dev_change_flags(dev, dev->flags | IFF_UP, NULL) < 0)
pr_err("IP-Config: Failed to open %s\n", dev->name);
}
for_each_netdev(&init_net, dev) {
if (ic_is_init_dev(dev)) {
int able = 0;
if (dev->mtu >= 364)
able |= IC_BOOTP;
else
pr_warn("DHCP/BOOTP: Ignoring device %s, MTU %d too small\n",
dev->name, dev->mtu);
if (!(dev->flags & IFF_NOARP))
able |= IC_RARP;
able &= ic_proto_enabled;
if (ic_proto_enabled && !able)
continue;
oflags = dev->flags;
if (dev_change_flags(dev, oflags | IFF_UP, NULL) < 0) {
pr_err("IP-Config: Failed to open %s\n",
dev->name);
continue;
}
if (!(d = kmalloc_obj(struct ic_device))) {
rtnl_unlock();
return -ENOMEM;
}
d->dev = dev;
*last = d;
last = &d->next;
d->flags = oflags;
d->able = able;
if (able & IC_BOOTP)
get_random_bytes(&d->xid, sizeof(__be32));
else
d->xid = 0;
ic_proto_have_if |= able;
pr_debug("IP-Config: %s UP (able=%d, xid=%08x)\n",
dev->name, able, d->xid);
}
}
/* Devices with a complex topology like SFP ethernet interfaces needs
* the rtnl_lock at init. The carrier wait-loop must therefore run
* without holding it.
*/
rtnl_unlock();
/* no point in waiting if we could not bring up at least one device */
if (!ic_first_dev)
goto have_carrier;
/* wait for a carrier on at least one device */
start = jiffies;
next_msg = start + secs_to_jiffies(20);
while (time_before(jiffies, start +
Annotation
- Immediate include surface: `linux/types.h`, `linux/string.h`, `linux/kernel.h`, `linux/jiffies.h`, `linux/random.h`, `linux/init.h`, `linux/utsname.h`, `linux/in.h`.
- Detected declarations: `struct ic_device`, `struct bootp_pkt`, `function ic_is_init_dev`, `function ic_open_devs`, `function for_each_netdev`, `function secs_to_jiffies`, `function for_each_netdev`, `function ic_close_devs`, `function set_sockaddr`, `function ic_setup_if`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
- 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.