drivers/infiniband/core/netlink.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/core/netlink.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/core/netlink.c- Extension
.c- Size
- 8873 bytes
- Lines
- 333
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/export.hnet/netlink.hnet/net_namespace.hnet/netns/generic.hnet/sock.hrdma/rdma_netlink.hlinux/module.hcore_priv.h
Detected Declarations
function rdma_nl_chk_listenersfunction is_nl_msg_validfunction get_cb_tablefunction rdma_nl_registerfunction rdma_nl_unregisterfunction ibnl_put_attrfunction rdma_nl_rcv_msgfunction rdma_nl_rcv_skbfunction rdma_nl_rcvfunction rdma_nl_unicastfunction rdma_nl_unicast_waitfunction rdma_nl_multicastfunction rdma_nl_initfunction rdma_nl_exitfunction rdma_nl_net_initfunction rdma_nl_net_exitexport rdma_nl_chk_listenersexport rdma_nl_registerexport rdma_nl_unregisterexport ibnl_put_msgexport ibnl_put_attrexport rdma_nl_unicastexport rdma_nl_unicast_waitexport rdma_nl_multicast
Annotated Snippet
#define pr_fmt(fmt) "%s:%s: " fmt, KBUILD_MODNAME, __func__
#include <linux/export.h>
#include <net/netlink.h>
#include <net/net_namespace.h>
#include <net/netns/generic.h>
#include <net/sock.h>
#include <rdma/rdma_netlink.h>
#include <linux/module.h>
#include "core_priv.h"
static struct {
const struct rdma_nl_cbs *cb_table;
/* Synchronizes between ongoing netlink commands and netlink client
* unregistration.
*/
struct rw_semaphore sem;
} rdma_nl_types[RDMA_NL_NUM_CLIENTS];
bool rdma_nl_chk_listeners(unsigned int group)
{
struct rdma_dev_net *rnet = rdma_net_to_dev_net(&init_net);
return netlink_has_listeners(rnet->nl_sock, group);
}
EXPORT_SYMBOL(rdma_nl_chk_listeners);
static bool is_nl_msg_valid(unsigned int type, unsigned int op)
{
static const unsigned int max_num_ops[RDMA_NL_NUM_CLIENTS] = {
[RDMA_NL_IWCM] = RDMA_NL_IWPM_NUM_OPS,
[RDMA_NL_LS] = RDMA_NL_LS_NUM_OPS,
[RDMA_NL_NLDEV] = RDMA_NLDEV_NUM_OPS,
};
/*
* This BUILD_BUG_ON is intended to catch addition of new
* RDMA netlink protocol without updating the array above.
*/
BUILD_BUG_ON(RDMA_NL_NUM_CLIENTS != 6);
if (type >= RDMA_NL_NUM_CLIENTS)
return false;
return op < max_num_ops[type];
}
static const struct rdma_nl_cbs *
get_cb_table(const struct sk_buff *skb, unsigned int type, unsigned int op)
{
const struct rdma_nl_cbs *cb_table;
/*
* Currently only NLDEV client is supporting netlink commands in
* non init_net net namespace.
*/
if (sock_net(skb->sk) != &init_net && type != RDMA_NL_NLDEV)
return NULL;
cb_table = READ_ONCE(rdma_nl_types[type].cb_table);
if (!cb_table) {
/*
* Didn't get valid reference of the table, attempt module
* load once.
*/
up_read(&rdma_nl_types[type].sem);
request_module("rdma-netlink-subsys-%u", type);
down_read(&rdma_nl_types[type].sem);
cb_table = READ_ONCE(rdma_nl_types[type].cb_table);
}
if (!cb_table || (!cb_table[op].dump && !cb_table[op].doit))
return NULL;
return cb_table;
}
void rdma_nl_register(unsigned int index,
const struct rdma_nl_cbs cb_table[])
{
if (WARN_ON(!is_nl_msg_valid(index, 0)) ||
WARN_ON(READ_ONCE(rdma_nl_types[index].cb_table)))
return;
/* Pairs with the READ_ONCE in is_nl_valid() */
smp_store_release(&rdma_nl_types[index].cb_table, cb_table);
}
EXPORT_SYMBOL(rdma_nl_register);
void rdma_nl_unregister(unsigned int index)
Annotation
- Immediate include surface: `linux/export.h`, `net/netlink.h`, `net/net_namespace.h`, `net/netns/generic.h`, `net/sock.h`, `rdma/rdma_netlink.h`, `linux/module.h`, `core_priv.h`.
- Detected declarations: `function rdma_nl_chk_listeners`, `function is_nl_msg_valid`, `function get_cb_table`, `function rdma_nl_register`, `function rdma_nl_unregister`, `function ibnl_put_attr`, `function rdma_nl_rcv_msg`, `function rdma_nl_rcv_skb`, `function rdma_nl_rcv`, `function rdma_nl_unicast`.
- Atlas domain: Driver Families / drivers/infiniband.
- 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.