include/net/rtnetlink.h
Source file repositories/reference/linux-study-clean/include/net/rtnetlink.h
File Facts
- System
- Linux kernel
- Corpus path
include/net/rtnetlink.h- Extension
.h- Size
- 9192 bytes
- Lines
- 263
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source 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 or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/rtnetlink.hlinux/srcu.hnet/netlink.h
Detected Declarations
struct rtnl_msg_handlerstruct rtnl_newlink_paramsstruct rtnl_link_opsstruct rtnl_af_opsenum rtnl_link_flagsenum rtnl_kindsfunction rtnl_msgtype_kindfunction rtnl_msg_familyfunction dev_net
Annotated Snippet
struct rtnl_msg_handler {
struct module *owner;
int protocol;
int msgtype;
rtnl_doit_func doit;
rtnl_dumpit_func dumpit;
int flags;
};
void rtnl_unregister_all(int protocol);
int __rtnl_register_many(const struct rtnl_msg_handler *handlers, int n);
void __rtnl_unregister_many(const struct rtnl_msg_handler *handlers, int n);
#define rtnl_register_many(handlers) \
__rtnl_register_many(handlers, ARRAY_SIZE(handlers))
#define rtnl_unregister_many(handlers) \
__rtnl_unregister_many(handlers, ARRAY_SIZE(handlers))
static inline int rtnl_msg_family(const struct nlmsghdr *nlh)
{
if (nlmsg_len(nlh) >= sizeof(struct rtgenmsg))
return ((struct rtgenmsg *) nlmsg_data(nlh))->rtgen_family;
else
return AF_UNSPEC;
}
/**
* struct rtnl_newlink_params - parameters of rtnl_link_ops::newlink()
*
* @src_net: Source netns of rtnetlink socket
* @link_net: Link netns by IFLA_LINK_NETNSID, NULL if not specified
* @peer_net: Peer netns
* @tb: IFLA_* attributes
* @data: IFLA_INFO_DATA attributes
*/
struct rtnl_newlink_params {
struct net *src_net;
struct net *link_net;
struct net *peer_net;
struct nlattr **tb;
struct nlattr **data;
};
/* Get effective link netns from newlink params. Generally, this is link_net
* and falls back to src_net. But for compatibility, a driver may * choose to
* use dev_net(dev) instead.
*/
static inline struct net *rtnl_newlink_link_net(struct rtnl_newlink_params *p)
{
return p->link_net ? : p->src_net;
}
/* Get peer netns from newlink params. Fallback to link netns if peer netns is
* not specified explicitly.
*/
static inline struct net *rtnl_newlink_peer_net(struct rtnl_newlink_params *p)
{
return p->peer_net ? : rtnl_newlink_link_net(p);
}
/**
* struct rtnl_link_ops - rtnetlink link operations
*
* @list: Used internally, protected by link_ops_mutex and SRCU
* @srcu: Used internally
* @kind: Identifier
* @netns_refund: Physical device, move to init_net on netns exit
* @peer_type: Peer device specific netlink attribute number (e.g. VETH_INFO_PEER)
* @maxtype: Highest device specific netlink attribute number
* @policy: Netlink policy for device specific attribute validation
* @validate: Optional validation function for netlink/changelink parameters
* @alloc: netdev allocation function, can be %NULL and is then used
* in place of alloc_netdev_mqs(), in this case @priv_size
* and @setup are unused. Returns a netdev or ERR_PTR().
* @priv_size: sizeof net_device private space
* @setup: net_device setup function
* @newlink: Function for configuring and registering a new device
* @changelink: Function for changing parameters of an existing device
* @dellink: Function to remove a device
* @get_size: Function to calculate required room for dumping device
* specific netlink attributes
* @fill_info: Function to dump device specific netlink attributes
* @get_xstats_size: Function to calculate required room for dumping device
* specific statistics
* @fill_xstats: Function to dump device specific statistics
* @get_num_tx_queues: Function to determine number of transmit queues
* to create when creating a new device.
* @get_num_rx_queues: Function to determine number of receive queues
* to create when creating a new device.
Annotation
- Immediate include surface: `linux/rtnetlink.h`, `linux/srcu.h`, `net/netlink.h`.
- Detected declarations: `struct rtnl_msg_handler`, `struct rtnl_newlink_params`, `struct rtnl_link_ops`, `struct rtnl_af_ops`, `enum rtnl_link_flags`, `enum rtnl_kinds`, `function rtnl_msgtype_kind`, `function rtnl_msg_family`, `function dev_net`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source 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.