STRUCT RTNL_LINK_OPS(9)
๐ struct rtnl_link_ops(9) ๐
okay bestie, buckle up โ this one lives in the Kernel API Manual, and it's literally the blueprint for how rtnetlink link operations get defined โจ it's the struct that tells the kernel "hey, here's a new kind of link and here's how to make it, change it, kill it, and brag about it in netlink attributes" ๐
๐ธ NAME ๐ธ
struct rtnl_link_ops โ rtnetlink link operations, no cap ๐
โจ SYNOPSIS โจ
struct rtnl_link_ops {
struct list_head list;
struct srcu_struct srcu;
const char *kind;
size_t priv_size;
struct net_device *(*alloc)(struct nlattr *tb[], const char
*ifname, unsigned char name_assign_type, unsigned int num_tx_queues,
unsigned int num_rx_queues);
void (*setup)(struct net_device *dev);
bool netns_refund;
const u16 peer_type;
unsigned int maxtype;
const struct nla_policy *policy;
int (*validate)(struct nlattr *tb[], struct nlattr *data[], struct
netlink_ext_ack *extack);
int (*newlink)(struct net_device *dev, struct rtnl_newlink_params
*params, struct netlink_ext_ack *extack);
int (*changelink)(struct net_device *dev, struct nlattr *tb[],
struct nlattr *data[], struct netlink_ext_ack *extack);
void (*dellink)(struct net_device *dev, struct list_head *head);
size_t (*get_size)(const struct net_device *dev);
int (*fill_info)(struct sk_buff *skb, const struct net_device *dev);
size_t (*get_xstats_size)(const struct net_device *dev);
int (*fill_xstats)(struct sk_buff *skb, const struct net_device
*dev);
unsigned int (*get_num_tx_queues)(void);
unsigned int (*get_num_rx_queues)(void);
unsigned int slave_maxtype;
const struct nla_policy *slave_policy;
int (*slave_changelink)(struct net_device *dev, struct net_device
*slave_dev, struct nlattr *tb[], struct nlattr *data[], struct
netlink_ext_ack *extack);
size_t (*get_slave_size)(const struct net_device *dev, const struct
net_device *slave_dev);
int (*fill_slave_info)(struct sk_buff *skb, const struct net_device
*dev, const struct net_device *slave_dev);
struct net *(*get_link_net)(const struct net_device
*dev);
size_t (*get_linkxstats_size)(const struct net_device *dev, int
attr);
int (*fill_linkxstats)(struct sk_buff *skb, const struct net_device
*dev, int *prividx, int attr);
};
๐ฆ Members ๐ฆ
like, here's the whole cast of characters, one by one, main character energy only ๐
listโ Used internally, protected bylink_ops_mutexand SRCU ๐ internal business, don't touch.srcuโ Used internally. that's it, that's the description ๐kindโ Identifier ๐ท๏ธpriv_sizeโsizeofnet_device private space ๐allocโ the netdev allocation function. it can beNULL, and when it is, it's then used in place ofalloc_netdev_mqsโ and in that casepriv_sizeandsetupare unused. Returns a netdev orERR_PTR๐ญ so yes, handle your error pointers, bestie.setupโ net_device setup function ๐ ๏ธnetns_refundโ Physical device, move toinit_neton 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 โ optional is the key word herenewlinkโ 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. ๐ฅget_link_netโ Function to get the i/o netns of the device ๐get_linkxstats_sizeโ Function to calculate the required room for dumping device-specific extended link stats ๐งฎfill_linkxstatsโ Function to dump device-specific extended link stats ๐
fyi bestie ๐ โ the struct up in the synopsis also showsslave_maxtype,slave_policy,slave_changelink,get_slave_sizeandfill_slave_info, and this page's Members list doesn't give them their own descriptions. don't come for me, i'm just matching what the page says ๐ซถ
๐ SEE ALSO ๐
- Kernel file
./include/net/rtnetlink.hstruct rtnl_msg_handler(9),struct rtnl_newlink_params(9),struct rtnl_af_ops(9)๐ go read the whole cinematic universe
okay that's the whole page, you ate that ๐
๐ this gem came from ./include/net and it's dated October 2026 โ yes, future vibes only, periodt โญ๐๐ฆ
๐ฆ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms