net/can/raw.c
Source file repositories/reference/linux-study-clean/net/can/raw.c
File Facts
- System
- Linux kernel
- Corpus path
net/can/raw.c- Extension
.c- Size
- 26945 bytes
- Lines
- 1143
- 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.
- 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/module.hlinux/init.hlinux/uio.hlinux/net.hlinux/slab.hlinux/netdevice.hlinux/socket.hlinux/if_arp.hlinux/skbuff.hlinux/can.hlinux/can/can-ml.hlinux/can/core.hlinux/can/skb.hlinux/can/raw.hnet/can.hnet/sock.hnet/net_namespace.h
Detected Declarations
struct uniqframestruct raw_sockfunction raw_rcvfunction this_cpu_ptrfunction raw_enable_filtersfunction raw_enable_errfilterfunction raw_disable_filtersfunction raw_disable_errfilterfunction raw_disable_allfiltersfunction raw_enable_allfiltersfunction raw_notifyfunction raw_notifierfunction raw_sock_destructfunction raw_initfunction raw_releasefunction raw_bindfunction raw_getnamefunction raw_setsockoptfunction raw_getsockoptfunction raw_put_canxl_vcidfunction raw_check_txframefunction raw_sendmsgfunction raw_recvmsgfunction raw_sock_no_ioctlcmdfunction raw_module_initfunction raw_module_exitmodule init raw_module_init
Annotated Snippet
static const struct proto_ops raw_ops = {
.family = PF_CAN,
.release = raw_release,
.bind = raw_bind,
.connect = sock_no_connect,
.socketpair = sock_no_socketpair,
.accept = sock_no_accept,
.getname = raw_getname,
.poll = datagram_poll,
.ioctl = raw_sock_no_ioctlcmd,
.gettstamp = sock_gettstamp,
.listen = sock_no_listen,
.shutdown = sock_no_shutdown,
.setsockopt = raw_setsockopt,
.getsockopt_iter = raw_getsockopt,
.sendmsg = raw_sendmsg,
.recvmsg = raw_recvmsg,
.mmap = sock_no_mmap,
};
static struct proto raw_proto __read_mostly = {
.name = "CAN_RAW",
.owner = THIS_MODULE,
.obj_size = sizeof(struct raw_sock),
.init = raw_init,
};
static const struct can_proto raw_can_proto = {
.type = SOCK_RAW,
.protocol = CAN_RAW,
.ops = &raw_ops,
.prot = &raw_proto,
};
static struct notifier_block canraw_notifier = {
.notifier_call = raw_notifier
};
static __init int raw_module_init(void)
{
int err;
pr_info("can: raw protocol\n");
err = register_netdevice_notifier(&canraw_notifier);
if (err)
return err;
err = can_proto_register(&raw_can_proto);
if (err < 0) {
pr_err("can: registration of raw protocol failed\n");
goto register_proto_failed;
}
return 0;
register_proto_failed:
unregister_netdevice_notifier(&canraw_notifier);
return err;
}
static __exit void raw_module_exit(void)
{
can_proto_unregister(&raw_can_proto);
unregister_netdevice_notifier(&canraw_notifier);
}
module_init(raw_module_init);
module_exit(raw_module_exit);
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/uio.h`, `linux/net.h`, `linux/slab.h`, `linux/netdevice.h`, `linux/socket.h`, `linux/if_arp.h`.
- Detected declarations: `struct uniqframe`, `struct raw_sock`, `function raw_rcv`, `function this_cpu_ptr`, `function raw_enable_filters`, `function raw_enable_errfilter`, `function raw_disable_filters`, `function raw_disable_errfilter`, `function raw_disable_allfilters`, `function raw_enable_allfilters`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: pattern 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.