net/can/isotp.c
Source file repositories/reference/linux-study-clean/net/can/isotp.c
File Facts
- System
- Linux kernel
- Corpus path
net/can/isotp.c- Extension
.c- Size
- 46108 bytes
- Lines
- 1771
- 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.
- 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/init.hlinux/interrupt.hlinux/spinlock.hlinux/hrtimer.hlinux/wait.hlinux/uio.hlinux/net.hlinux/netdevice.hlinux/socket.hlinux/if_arp.hlinux/skbuff.hlinux/can.hlinux/can/core.hlinux/can/skb.hlinux/can/isotp.hlinux/slab.hnet/can.hnet/sock.hnet/net_namespace.h
Detected Declarations
struct tpconstruct isotp_sockfunction isotp_bc_flagsfunction isotp_register_rxidfunction isotp_rx_timer_handlerfunction isotp_send_fcfunction isotp_rcv_skbfunction padlenfunction check_optimizedfunction check_padfunction isotp_rcv_fcfunction isotp_rcv_sffunction isotp_rcv_fffunction isotp_rcv_cffunction isotp_rcvfunction isotp_fill_dataframefunction isotp_send_cframefunction isotp_create_fframefunction isotp_rcv_echofunction isotp_tx_timer_handlerfunction isotp_txfr_timer_handlerfunction isotp_sendmsgfunction isotp_recvmsgfunction isotp_releasefunction isotp_bindfunction isotp_getnamefunction isotp_setsockopt_lockedfunction isotp_setsockoptfunction isotp_getsockoptfunction isotp_notifyfunction isotp_notifierfunction isotp_sock_destructfunction isotp_initfunction isotp_pollfunction isotp_sock_no_ioctlcmdfunction isotp_module_initfunction isotp_module_exitmodule init isotp_module_init
Annotated Snippet
static const struct proto_ops isotp_ops = {
.family = PF_CAN,
.release = isotp_release,
.bind = isotp_bind,
.connect = sock_no_connect,
.socketpair = sock_no_socketpair,
.accept = sock_no_accept,
.getname = isotp_getname,
.poll = isotp_poll,
.ioctl = isotp_sock_no_ioctlcmd,
.gettstamp = sock_gettstamp,
.listen = sock_no_listen,
.shutdown = sock_no_shutdown,
.setsockopt = isotp_setsockopt,
.getsockopt = isotp_getsockopt,
.sendmsg = isotp_sendmsg,
.recvmsg = isotp_recvmsg,
.mmap = sock_no_mmap,
};
static struct proto isotp_proto __read_mostly = {
.name = "CAN_ISOTP",
.owner = THIS_MODULE,
.obj_size = sizeof(struct isotp_sock),
.init = isotp_init,
};
static const struct can_proto isotp_can_proto = {
.type = SOCK_DGRAM,
.protocol = CAN_ISOTP,
.ops = &isotp_ops,
.prot = &isotp_proto,
};
static struct notifier_block canisotp_notifier = {
.notifier_call = isotp_notifier
};
static __init int isotp_module_init(void)
{
int err;
max_pdu_size = max_t(unsigned int, max_pdu_size, MAX_12BIT_PDU_SIZE);
max_pdu_size = min_t(unsigned int, max_pdu_size, MAX_PDU_SIZE);
pr_info("can: isotp protocol (max_pdu_size %d)\n", max_pdu_size);
err = can_proto_register(&isotp_can_proto);
if (err < 0)
pr_err("can: registration of isotp protocol failed %pe\n", ERR_PTR(err));
else
register_netdevice_notifier(&canisotp_notifier);
return err;
}
static __exit void isotp_module_exit(void)
{
can_proto_unregister(&isotp_can_proto);
unregister_netdevice_notifier(&canisotp_notifier);
}
module_init(isotp_module_init);
module_exit(isotp_module_exit);
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/interrupt.h`, `linux/spinlock.h`, `linux/hrtimer.h`, `linux/wait.h`, `linux/uio.h`, `linux/net.h`.
- Detected declarations: `struct tpcon`, `struct isotp_sock`, `function isotp_bc_flags`, `function isotp_register_rxid`, `function isotp_rx_timer_handler`, `function isotp_send_fc`, `function isotp_rcv_skb`, `function padlen`, `function check_optimized`, `function check_pad`.
- 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.