Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) #ifndef __NET_RTNETLINK_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #define __NET_RTNETLINK_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include <linux/rtnetlink.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #include <net/netlink.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) typedef int (*rtnl_doit_func)(struct sk_buff *, struct nlmsghdr *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 			      struct netlink_ext_ack *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) typedef int (*rtnl_dumpit_func)(struct sk_buff *, struct netlink_callback *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) enum rtnl_link_flags {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 	RTNL_FLAG_DOIT_UNLOCKED = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) void rtnl_register(int protocol, int msgtype,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 		   rtnl_doit_func, rtnl_dumpit_func, unsigned int flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) int rtnl_register_module(struct module *owner, int protocol, int msgtype,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 			 rtnl_doit_func, rtnl_dumpit_func, unsigned int flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) int rtnl_unregister(int protocol, int msgtype);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) void rtnl_unregister_all(int protocol);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) static inline int rtnl_msg_family(const struct nlmsghdr *nlh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	if (nlmsg_len(nlh) >= sizeof(struct rtgenmsg))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 		return ((struct rtgenmsg *) nlmsg_data(nlh))->rtgen_family;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 		return AF_UNSPEC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  *	struct rtnl_link_ops - rtnetlink link operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  *	@list: Used internally
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  *	@kind: Identifier
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  *	@netns_refund: Physical device, move to init_net on netns exit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  *	@maxtype: Highest device specific netlink attribute number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  *	@policy: Netlink policy for device specific attribute validation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  *	@validate: Optional validation function for netlink/changelink parameters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  *	@priv_size: sizeof net_device private space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  *	@setup: net_device setup function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  *	@newlink: Function for configuring and registering a new device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  *	@changelink: Function for changing parameters of an existing device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  *	@dellink: Function to remove a device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  *	@get_size: Function to calculate required room for dumping device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)  *		   specific netlink attributes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)  *	@fill_info: Function to dump device specific netlink attributes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)  *	@get_xstats_size: Function to calculate required room for dumping device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)  *			  specific statistics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  *	@fill_xstats: Function to dump device specific statistics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  *	@get_num_tx_queues: Function to determine number of transmit queues
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)  *			    to create when creating a new device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  *	@get_num_rx_queues: Function to determine number of receive queues
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  *			    to create when creating a new device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  *	@get_link_net: Function to get the i/o netns of the device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  *	@get_linkxstats_size: Function to calculate the required room for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  *			      dumping device-specific extended link stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  *	@fill_linkxstats: Function to dump device-specific extended link stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) struct rtnl_link_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	struct list_head	list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	const char		*kind;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	size_t			priv_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	void			(*setup)(struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	bool			netns_refund;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	unsigned int		maxtype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	const struct nla_policy	*policy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	int			(*validate)(struct nlattr *tb[],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 					    struct nlattr *data[],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 					    struct netlink_ext_ack *extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	int			(*newlink)(struct net *src_net,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 					   struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 					   struct nlattr *tb[],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 					   struct nlattr *data[],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 					   struct netlink_ext_ack *extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	int			(*changelink)(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 					      struct nlattr *tb[],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 					      struct nlattr *data[],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 					      struct netlink_ext_ack *extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	void			(*dellink)(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 					   struct list_head *head);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	size_t			(*get_size)(const struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	int			(*fill_info)(struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 					     const struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	size_t			(*get_xstats_size)(const struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	int			(*fill_xstats)(struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 					       const struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	unsigned int		(*get_num_tx_queues)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	unsigned int		(*get_num_rx_queues)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	unsigned int		slave_maxtype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	const struct nla_policy	*slave_policy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	int			(*slave_changelink)(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 						    struct net_device *slave_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 						    struct nlattr *tb[],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 						    struct nlattr *data[],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 						    struct netlink_ext_ack *extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	size_t			(*get_slave_size)(const struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 						  const struct net_device *slave_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	int			(*fill_slave_info)(struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 						   const struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 						   const struct net_device *slave_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	struct net		*(*get_link_net)(const struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	size_t			(*get_linkxstats_size)(const struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 						       int attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	int			(*fill_linkxstats)(struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 						   const struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 						   int *prividx, int attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) int __rtnl_link_register(struct rtnl_link_ops *ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) void __rtnl_link_unregister(struct rtnl_link_ops *ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) int rtnl_link_register(struct rtnl_link_ops *ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) void rtnl_link_unregister(struct rtnl_link_ops *ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)  * 	struct rtnl_af_ops - rtnetlink address family operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)  *	@list: Used internally
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)  * 	@family: Address family
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)  * 	@fill_link_af: Function to fill IFLA_AF_SPEC with address family
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)  * 		       specific netlink attributes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)  * 	@get_link_af_size: Function to calculate size of address family specific
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)  * 			   netlink attributes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)  *	@validate_link_af: Validate a IFLA_AF_SPEC attribute, must check attr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)  *			   for invalid configuration settings.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)  * 	@set_link_af: Function to parse a IFLA_AF_SPEC attribute and modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)  *		      net_device accordingly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) struct rtnl_af_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	struct list_head	list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	int			family;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	int			(*fill_link_af)(struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 						const struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 						u32 ext_filter_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	size_t			(*get_link_af_size)(const struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 						    u32 ext_filter_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	int			(*validate_link_af)(const struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 						    const struct nlattr *attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	int			(*set_link_af)(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 					       const struct nlattr *attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	int			(*fill_stats_af)(struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 						 const struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	size_t			(*get_stats_af_size)(const struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) void rtnl_af_register(struct rtnl_af_ops *ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) void rtnl_af_unregister(struct rtnl_af_ops *ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) struct net *rtnl_link_get_net(struct net *src_net, struct nlattr *tb[]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) struct net_device *rtnl_create_link(struct net *net, const char *ifname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 				    unsigned char name_assign_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 				    const struct rtnl_link_ops *ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 				    struct nlattr *tb[],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 				    struct netlink_ext_ack *extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) int rtnl_delete_link(struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) int rtnl_configure_link(struct net_device *dev, const struct ifinfomsg *ifm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) int rtnl_nla_parse_ifla(struct nlattr **tb, const struct nlattr *head, int len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 			struct netlink_ext_ack *exterr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) struct net *rtnl_get_net_ns_capable(struct sock *sk, int netnsid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) #define MODULE_ALIAS_RTNL_LINK(kind) MODULE_ALIAS("rtnl-link-" kind)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) #endif