net/qrtr/ns.c
Source file repositories/reference/linux-study-clean/net/qrtr/ns.c
File Facts
- System
- Linux kernel
- Corpus path
net/qrtr/ns.c- Extension
.c- Size
- 20314 bytes
- Lines
- 838
- 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.
- 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/qrtr.hlinux/workqueue.hnet/sock.hqrtr.htrace/events/sock.htrace/events/qrtr.h
Detected Declarations
struct qrtr_server_filterstruct qrtr_lookupstruct qrtr_serverstruct qrtr_nodefunction server_matchfunction service_announce_newfunction service_announce_delfunction lookup_notifyfunction announce_serversfunction server_delfunction say_hellofunction ctrl_cmd_hellofunction ctrl_cmd_byefunction xa_for_eachfunction ctrl_cmd_del_clientfunction xa_for_eachfunction ctrl_cmd_new_serverfunction ctrl_cmd_del_serverfunction ctrl_cmd_new_lookupfunction xa_for_eachfunction ctrl_cmd_del_lookupfunction list_for_each_safefunction qrtr_ns_workerfunction qrtr_ns_data_readyfunction qrtr_ns_initfunction qrtr_ns_removeexport qrtr_ns_initexport qrtr_ns_remove
Annotated Snippet
struct qrtr_server_filter {
unsigned int service;
unsigned int instance;
unsigned int ifilter;
};
struct qrtr_lookup {
unsigned int service;
unsigned int instance;
struct sockaddr_qrtr sq;
struct list_head li;
};
struct qrtr_server {
unsigned int service;
unsigned int instance;
unsigned int node;
unsigned int port;
struct list_head qli;
};
struct qrtr_node {
unsigned int id;
struct xarray servers;
u32 server_count;
};
/* Max nodes, server, lookup limits are chosen based on the current platform
* requirements. If the requirement changes in the future, these values can be
* increased.
*/
#define QRTR_NS_MAX_NODES 64
#define QRTR_NS_MAX_SERVERS 256
#define QRTR_NS_MAX_LOOKUPS 64
static u8 node_count;
static struct qrtr_node *node_get(unsigned int node_id)
{
struct qrtr_node *node;
node = xa_load(&nodes, node_id);
if (node)
return node;
if (node_count >= QRTR_NS_MAX_NODES) {
pr_err_ratelimited("QRTR clients exceed max node limit!\n");
return NULL;
}
/* If node didn't exist, allocate and insert it to the tree */
node = kzalloc_obj(*node);
if (!node)
return NULL;
node->id = node_id;
xa_init(&node->servers);
if (xa_store(&nodes, node_id, node, GFP_KERNEL)) {
kfree(node);
return NULL;
}
node_count++;
return node;
}
static int server_match(const struct qrtr_server *srv,
const struct qrtr_server_filter *f)
{
unsigned int ifilter = f->ifilter;
if (f->service != 0 && srv->service != f->service)
return 0;
if (!ifilter && f->instance)
ifilter = ~0;
return (srv->instance & ifilter) == f->instance;
}
static int service_announce_new(struct sockaddr_qrtr *dest,
struct qrtr_server *srv)
{
struct qrtr_ctrl_pkt pkt;
struct msghdr msg = { };
struct kvec iv;
Annotation
- Immediate include surface: `linux/module.h`, `linux/qrtr.h`, `linux/workqueue.h`, `net/sock.h`, `qrtr.h`, `trace/events/sock.h`, `trace/events/qrtr.h`.
- Detected declarations: `struct qrtr_server_filter`, `struct qrtr_lookup`, `struct qrtr_server`, `struct qrtr_node`, `function server_match`, `function service_announce_new`, `function service_announce_del`, `function lookup_notify`, `function announce_servers`, `function server_del`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
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.