net/core/net-procfs.c
Source file repositories/reference/linux-study-clean/net/core/net-procfs.c
File Facts
- System
- Linux kernel
- Corpus path
net/core/net-procfs.c- Extension
.c- Size
- 9882 bytes
- Lines
- 418
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/netdevice.hlinux/proc_fs.hlinux/seq_file.hnet/wext.hnet/hotdata.hdev.h
Detected Declarations
struct ptype_iter_statefunction for_each_netdev_dumpfunction dev_seq_stopfunction dev_seq_printf_statsfunction dev_seq_showfunction softnet_input_pkt_queue_lenfunction softnet_process_queue_lenfunction softnet_seq_stopfunction for_each_netdev_rcufunction list_for_each_entry_rcufunction list_for_each_entry_rcufunction list_for_each_entry_rcufunction list_for_each_entry_rcufunction for_each_netdev_continue_rcufunction ptype_seq_stopfunction ptype_seq_showfunction dev_proc_net_initfunction dev_proc_net_exitfunction dev_mc_seq_showfunction dev_mc_net_initfunction dev_mc_net_exitfunction dev_proc_init
Annotated Snippet
struct ptype_iter_state {
struct seq_net_private p;
struct net_device *dev;
};
static void *ptype_get_idx(struct seq_file *seq, loff_t pos)
{
struct ptype_iter_state *iter = seq->private;
struct list_head *ptype_list = NULL;
struct packet_type *pt = NULL;
struct net_device *dev;
loff_t i = 0;
int t;
for_each_netdev_rcu(seq_file_net(seq), dev) {
ptype_list = &dev->ptype_all;
list_for_each_entry_rcu(pt, ptype_list, list) {
if (i == pos) {
iter->dev = dev;
return pt;
}
++i;
}
}
iter->dev = NULL;
list_for_each_entry_rcu(pt, &seq_file_net(seq)->ptype_all, list) {
if (i == pos)
return pt;
++i;
}
list_for_each_entry_rcu(pt, &seq_file_net(seq)->ptype_specific, list) {
if (i == pos)
return pt;
++i;
}
for (t = 0; t < PTYPE_HASH_SIZE; t++) {
list_for_each_entry_rcu(pt, &ptype_base[t], list) {
if (i == pos)
return pt;
++i;
}
}
return NULL;
}
static void *ptype_seq_start(struct seq_file *seq, loff_t *pos)
__acquires(RCU)
{
rcu_read_lock();
return *pos ? ptype_get_idx(seq, *pos - 1) : SEQ_START_TOKEN;
}
static void *ptype_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{
struct ptype_iter_state *iter = seq->private;
struct net *net = seq_file_net(seq);
struct net_device *dev;
struct packet_type *pt;
struct list_head *nxt;
int hash;
++*pos;
if (v == SEQ_START_TOKEN)
return ptype_get_idx(seq, 0);
pt = v;
nxt = READ_ONCE(pt->list.next);
dev = iter->dev;
if (dev) {
if (nxt != &dev->ptype_all)
goto found;
for_each_netdev_continue_rcu(seq_file_net(seq), dev) {
nxt = READ_ONCE(dev->ptype_all.next);
if (nxt != &dev->ptype_all) {
iter->dev = dev;
goto found;
}
}
iter->dev = NULL;
nxt = READ_ONCE(net->ptype_all.next);
goto net_ptype_all;
}
if (pt->af_packet_net) {
net_ptype_all:
Annotation
- Immediate include surface: `linux/netdevice.h`, `linux/proc_fs.h`, `linux/seq_file.h`, `net/wext.h`, `net/hotdata.h`, `dev.h`.
- Detected declarations: `struct ptype_iter_state`, `function for_each_netdev_dump`, `function dev_seq_stop`, `function dev_seq_printf_stats`, `function dev_seq_show`, `function softnet_input_pkt_queue_len`, `function softnet_process_queue_len`, `function softnet_seq_stop`, `function for_each_netdev_rcu`, `function list_for_each_entry_rcu`.
- 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.
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.