net/802/psnap.c
Source file repositories/reference/linux-study-clean/net/802/psnap.c
File Facts
- System
- Linux kernel
- Corpus path
net/802/psnap.c- Extension
.c- Size
- 3405 bytes
- Lines
- 165
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/module.hlinux/netdevice.hlinux/skbuff.hlinux/slab.hnet/datalink.hnet/llc.hnet/psnap.hlinux/mm.hlinux/in.hlinux/init.hlinux/rculist.h
Detected Declarations
function list_for_each_entry_rcufunction snap_rcvfunction snap_requestfunction snap_initfunction snap_exitfunction intfunction unregister_snap_clientmodule init snap_initexport register_snap_clientexport unregister_snap_client
Annotated Snippet
module_init(snap_init);
static void __exit snap_exit(void)
{
llc_sap_put(snap_sap);
}
module_exit(snap_exit);
/*
* Register SNAP clients. We don't yet use this for IP.
*/
struct datalink_proto *register_snap_client(const unsigned char *desc,
int (*rcvfunc)(struct sk_buff *,
struct net_device *,
struct packet_type *,
struct net_device *))
{
struct datalink_proto *proto = NULL;
spin_lock_bh(&snap_lock);
if (find_snap_client(desc))
goto out;
proto = kmalloc_obj(*proto, GFP_ATOMIC);
if (proto) {
memcpy(proto->type, desc, 5);
proto->rcvfunc = rcvfunc;
proto->header_length = 5 + 3; /* snap + 802.2 */
proto->request = snap_request;
list_add_rcu(&proto->node, &snap_list);
}
out:
spin_unlock_bh(&snap_lock);
return proto;
}
/*
* Unregister SNAP clients. Protocols no longer want to play with us ...
*/
void unregister_snap_client(struct datalink_proto *proto)
{
spin_lock_bh(&snap_lock);
list_del_rcu(&proto->node);
spin_unlock_bh(&snap_lock);
synchronize_net();
kfree(proto);
}
MODULE_DESCRIPTION("SNAP data link layer. Derived from 802.2");
MODULE_LICENSE("GPL");
Annotation
- Immediate include surface: `linux/module.h`, `linux/netdevice.h`, `linux/skbuff.h`, `linux/slab.h`, `net/datalink.h`, `net/llc.h`, `net/psnap.h`, `linux/mm.h`.
- Detected declarations: `function list_for_each_entry_rcu`, `function snap_rcv`, `function snap_request`, `function snap_init`, `function snap_exit`, `function int`, `function unregister_snap_client`, `module init snap_init`, `export register_snap_client`, `export unregister_snap_client`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration 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.