net/qrtr/af_qrtr.c
Source file repositories/reference/linux-study-clean/net/qrtr/af_qrtr.c
File Facts
- System
- Linux kernel
- Corpus path
net/qrtr/af_qrtr.c- Extension
.c- Size
- 30924 bytes
- Lines
- 1326
- 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/netlink.hlinux/qrtr.hlinux/termios.hlinux/spinlock.hlinux/wait.hnet/sock.hqrtr.h
Detected Declarations
struct qrtr_hdr_v1struct qrtr_hdr_v2struct qrtr_cbstruct qrtr_sockstruct qrtr_nodestruct qrtr_tx_flowfunction __qrtr_node_releasefunction qrtr_node_releasefunction qrtr_tx_resumefunction qrtr_tx_waitfunction qrtr_tx_flow_failedfunction qrtr_node_enqueuefunction qrtr_node_releasefunction qrtr_node_assignfunction qrtr_endpoint_postfunction qrtr_alloc_ctrl_packetfunction qrtr_endpoint_registerfunction qrtr_endpoint_unregisterfunction qrtr_port_putfunction qrtr_port_putfunction qrtr_port_removefunction qrtr_port_assignfunction qrtr_reset_portsfunction __qrtr_bindfunction qrtr_autobindfunction qrtr_bindfunction qrtr_local_enqueuefunction qrtr_bcast_enqueuefunction qrtr_sendmsgfunction qrtr_send_resume_txfunction qrtr_recvmsgfunction qrtr_connectfunction qrtr_getnamefunction qrtr_ioctlfunction qrtr_releasefunction qrtr_createfunction qrtr_proto_initfunction qrtr_proto_finiexport qrtr_endpoint_postexport qrtr_endpoint_registerexport qrtr_endpoint_unregister
Annotated Snippet
static const struct proto_ops qrtr_proto_ops = {
.owner = THIS_MODULE,
.family = AF_QIPCRTR,
.bind = qrtr_bind,
.connect = qrtr_connect,
.socketpair = sock_no_socketpair,
.accept = sock_no_accept,
.listen = sock_no_listen,
.sendmsg = qrtr_sendmsg,
.recvmsg = qrtr_recvmsg,
.getname = qrtr_getname,
.ioctl = qrtr_ioctl,
.gettstamp = sock_gettstamp,
.poll = datagram_poll,
.shutdown = sock_no_shutdown,
.release = qrtr_release,
.mmap = sock_no_mmap,
};
static struct proto qrtr_proto = {
.name = "QIPCRTR",
.owner = THIS_MODULE,
.obj_size = sizeof(struct qrtr_sock),
};
static int qrtr_create(struct net *net, struct socket *sock,
int protocol, int kern)
{
struct qrtr_sock *ipc;
struct sock *sk;
if (sock->type != SOCK_DGRAM)
return -EPROTOTYPE;
sk = sk_alloc(net, AF_QIPCRTR, GFP_KERNEL, &qrtr_proto, kern);
if (!sk)
return -ENOMEM;
sock_set_flag(sk, SOCK_ZAPPED);
sock_init_data(sock, sk);
sock->ops = &qrtr_proto_ops;
ipc = qrtr_sk(sk);
ipc->us.sq_family = AF_QIPCRTR;
ipc->us.sq_node = qrtr_local_nid;
ipc->us.sq_port = 0;
return 0;
}
static const struct net_proto_family qrtr_family = {
.owner = THIS_MODULE,
.family = AF_QIPCRTR,
.create = qrtr_create,
};
static int __init qrtr_proto_init(void)
{
int rc;
rc = proto_register(&qrtr_proto, 1);
if (rc)
return rc;
rc = sock_register(&qrtr_family);
if (rc)
goto err_proto;
rc = qrtr_ns_init();
if (rc)
goto err_sock;
return 0;
err_sock:
sock_unregister(qrtr_family.family);
err_proto:
proto_unregister(&qrtr_proto);
return rc;
}
postcore_initcall(qrtr_proto_init);
static void __exit qrtr_proto_fini(void)
{
qrtr_ns_remove();
sock_unregister(qrtr_family.family);
proto_unregister(&qrtr_proto);
}
module_exit(qrtr_proto_fini);
Annotation
- Immediate include surface: `linux/module.h`, `linux/netlink.h`, `linux/qrtr.h`, `linux/termios.h`, `linux/spinlock.h`, `linux/wait.h`, `net/sock.h`, `qrtr.h`.
- Detected declarations: `struct qrtr_hdr_v1`, `struct qrtr_hdr_v2`, `struct qrtr_cb`, `struct qrtr_sock`, `struct qrtr_node`, `struct qrtr_tx_flow`, `function __qrtr_node_release`, `function qrtr_node_release`, `function qrtr_tx_resume`, `function qrtr_tx_wait`.
- 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.