net/6lowpan/debugfs.c
Source file repositories/reference/linux-study-clean/net/6lowpan/debugfs.c
File Facts
- System
- Linux kernel
- Corpus path
net/6lowpan/debugfs.c- Extension
.c- Size
- 6846 bytes
- Lines
- 279
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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
net/6lowpan.h6lowpan_i.h
Detected Declarations
function lowpan_ctx_flag_active_setfunction lowpan_ctx_flag_active_getfunction lowpan_ctx_flag_c_setfunction lowpan_ctx_flag_c_getfunction lowpan_ctx_plen_setfunction lowpan_ctx_plen_getfunction lowpan_ctx_pfx_showfunction lowpan_ctx_pfx_openfunction lowpan_ctx_pfx_writefunction lowpan_dev_debugfs_ctx_initfunction lowpan_context_showfunction lowpan_short_addr_getfunction lowpan_dev_debugfs_802154_initfunction lowpan_dev_debugfs_initfunction lowpan_dev_debugfs_exitfunction lowpan_debugfs_initfunction lowpan_debugfs_exit
Annotated Snippet
static const struct file_operations lowpan_ctx_pfx_fops = {
.open = lowpan_ctx_pfx_open,
.read = seq_read,
.write = lowpan_ctx_pfx_write,
.llseek = seq_lseek,
.release = single_release,
};
static void lowpan_dev_debugfs_ctx_init(struct net_device *dev,
struct dentry *ctx, u8 id)
{
struct lowpan_dev *ldev = lowpan_dev(dev);
struct dentry *root;
char buf[32];
if (WARN_ON_ONCE(id >= LOWPAN_IPHC_CTX_TABLE_SIZE))
return;
sprintf(buf, "%d", id);
root = debugfs_create_dir(buf, ctx);
debugfs_create_file("active", 0644, root, &ldev->ctx.table[id],
&lowpan_ctx_flag_active_fops);
debugfs_create_file("compression", 0644, root, &ldev->ctx.table[id],
&lowpan_ctx_flag_c_fops);
debugfs_create_file("prefix", 0644, root, &ldev->ctx.table[id],
&lowpan_ctx_pfx_fops);
debugfs_create_file("prefix_len", 0644, root, &ldev->ctx.table[id],
&lowpan_ctx_plen_fops);
}
static int lowpan_context_show(struct seq_file *file, void *offset)
{
struct lowpan_iphc_ctx_table *t = file->private;
int i;
seq_printf(file, "%3s|%-43s|%c\n", "cid", "prefix", 'C');
seq_puts(file, "-------------------------------------------------\n");
spin_lock_bh(&t->lock);
for (i = 0; i < LOWPAN_IPHC_CTX_TABLE_SIZE; i++) {
if (!lowpan_iphc_ctx_is_active(&t->table[i]))
continue;
seq_printf(file, "%3d|%39pI6c/%-3d|%d\n", t->table[i].id,
&t->table[i].pfx, t->table[i].plen,
lowpan_iphc_ctx_is_compression(&t->table[i]));
}
spin_unlock_bh(&t->lock);
return 0;
}
DEFINE_SHOW_ATTRIBUTE(lowpan_context);
static int lowpan_short_addr_get(void *data, u64 *val)
{
struct wpan_dev *wdev = data;
rtnl_lock();
*val = le16_to_cpu(wdev->short_addr);
rtnl_unlock();
return 0;
}
DEFINE_DEBUGFS_ATTRIBUTE(lowpan_short_addr_fops, lowpan_short_addr_get, NULL,
"0x%04llx\n");
static void lowpan_dev_debugfs_802154_init(const struct net_device *dev,
struct lowpan_dev *ldev)
{
struct dentry *root;
if (!lowpan_is_ll(dev, LOWPAN_LLTYPE_IEEE802154))
return;
root = debugfs_create_dir("ieee802154", ldev->iface_debugfs);
debugfs_create_file("short_addr", 0444, root,
lowpan_802154_dev(dev)->wdev->ieee802154_ptr,
&lowpan_short_addr_fops);
}
void lowpan_dev_debugfs_init(struct net_device *dev)
{
struct lowpan_dev *ldev = lowpan_dev(dev);
Annotation
- Immediate include surface: `net/6lowpan.h`, `6lowpan_i.h`.
- Detected declarations: `function lowpan_ctx_flag_active_set`, `function lowpan_ctx_flag_active_get`, `function lowpan_ctx_flag_c_set`, `function lowpan_ctx_flag_c_get`, `function lowpan_ctx_plen_set`, `function lowpan_ctx_plen_get`, `function lowpan_ctx_pfx_show`, `function lowpan_ctx_pfx_open`, `function lowpan_ctx_pfx_write`, `function lowpan_dev_debugfs_ctx_init`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: pattern 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.