Blame view

include/linux/rtnetlink.h 4.46 KB
b24413180   Greg Kroah-Hartman   License cleanup: ...
1
  /* SPDX-License-Identifier: GPL-2.0 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
3
  #ifndef __LINUX_RTNETLINK_H
  #define __LINUX_RTNETLINK_H
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
4

6756ae4b4   Stephen Hemminger   [NET]: Convert RT...
5
  #include <linux/mutex.h>
3b42a96dc   Andy Whitcroft   net: rtnetlink.h ...
6
  #include <linux/netdevice.h>
200b916f3   Cong Wang   rtnetlink: wait f...
7
  #include <linux/wait.h>
6f99528e9   Vlad Buslov   net: core: netlin...
8
  #include <linux/refcount.h>
607ca46e9   David Howells   UAPI: (Scripted) ...
9
  #include <uapi/linux/rtnetlink.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
10

97c53cacf   Denis V. Lunev   [NET]: Make rtnet...
11
12
  extern int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, u32 group, int echo);
  extern int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid);
1ce85fe40   Pablo Neira Ayuso   netlink: change n...
13
14
  extern void rtnl_notify(struct sk_buff *skb, struct net *net, u32 pid,
  			u32 group, struct nlmsghdr *nlh, gfp_t flags);
97c53cacf   Denis V. Lunev   [NET]: Make rtnet...
15
  extern void rtnl_set_sk_err(struct net *net, u32 group, int error);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
16
  extern int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics);
e3703b3de   Thomas Graf   [RTNETLINK]: Add ...
17
  extern int rtnl_put_cacheinfo(struct sk_buff *skb, struct dst_entry *dst,
87a50699c   David S. Miller   rtnetlink: Remove...
18
  			      u32 id, long expires, u32 error);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
19

7f2940540   Alexei Starovoitov   net: fix rtnl not...
20
  void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change, gfp_t flags);
6621dd29e   Nicolas Dichtel   dev: advertise th...
21
  void rtmsg_ifinfo_newnet(int type, struct net_device *dev, unsigned int change,
38e01b305   Nicolas Dichtel   dev: advertise th...
22
  			 gfp_t flags, int *new_nsid, int new_ifindex);
395eea6cc   Mahesh Bandewar   rtnetlink: delay ...
23
  struct sk_buff *rtmsg_ifinfo_build_skb(int type, struct net_device *dev,
3d3ea5af5   Vlad Yasevich   rtnl: Add support...
24
  				       unsigned change, u32 event,
38e01b305   Nicolas Dichtel   dev: advertise th...
25
26
  				       gfp_t flags, int *new_nsid,
  				       int new_ifindex);
395eea6cc   Mahesh Bandewar   rtnetlink: delay ...
27
28
  void rtmsg_ifinfo_send(struct sk_buff *skb, struct net_device *dev,
  		       gfp_t flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
29

6756ae4b4   Stephen Hemminger   [NET]: Convert RT...
30
  /* RTNL is used as a global lock for all changes to network configuration  */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
31
  extern void rtnl_lock(void);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
32
  extern void rtnl_unlock(void);
6756ae4b4   Stephen Hemminger   [NET]: Convert RT...
33
  extern int rtnl_trylock(void);
c9c1014b2   Patrick McHardy   [RTNETLINK]: Fix ...
34
  extern int rtnl_is_locked(void);
79ffdfc65   Kirill Tkhai   net: Add rtnl_loc...
35
  extern int rtnl_lock_killable(void);
6f99528e9   Vlad Buslov   net: core: netlin...
36
  extern bool refcount_dec_and_rtnl_lock(refcount_t *r);
200b916f3   Cong Wang   rtnetlink: wait f...
37
38
  
  extern wait_queue_head_t netdev_unregistering_wq;
4420bf21f   Kirill Tkhai   net: Rename net_s...
39
  extern struct rw_semaphore pernet_ops_rwsem;
f0b07bb15   Kirill Tkhai   net: Introduce ne...
40
  extern struct rw_semaphore net_rwsem;
200b916f3   Cong Wang   rtnetlink: wait f...
41

a898def29   Paul E. McKenney   net: Add checking...
42
  #ifdef CONFIG_PROVE_LOCKING
0cbf33437   Yaowei Bai   net/core: lockdep...
43
  extern bool lockdep_rtnl_is_held(void);
85328240c   John Fastabend   net: allow netdev...
44
  #else
0cbf33437   Yaowei Bai   net/core: lockdep...
45
  static inline bool lockdep_rtnl_is_held(void)
85328240c   John Fastabend   net: allow netdev...
46
  {
0cbf33437   Yaowei Bai   net/core: lockdep...
47
  	return true;
85328240c   John Fastabend   net: allow netdev...
48
  }
a898def29   Paul E. McKenney   net: Add checking...
49
  #endif /* #ifdef CONFIG_PROVE_LOCKING */
6756ae4b4   Stephen Hemminger   [NET]: Convert RT...
50

a6e0fc851   Eric Dumazet   net: introduce rc...
51
52
53
54
55
  /**
   * rcu_dereference_rtnl - rcu_dereference with debug checking
   * @p: The pointer to read, prior to dereferencing
   *
   * Do an rcu_dereference(p), but check caller either holds rcu_read_lock()
29fa060ea   David S. Miller   net: relax rtnl_d...
56
   * or RTNL. Note : Please prefer rtnl_dereference() or rcu_dereference()
a6e0fc851   Eric Dumazet   net: introduce rc...
57
58
   */
  #define rcu_dereference_rtnl(p)					\
d8bf4ca9c   Michal Hocko   rcu: treewide: Do...
59
  	rcu_dereference_check(p, lockdep_rtnl_is_held())
a6e0fc851   Eric Dumazet   net: introduce rc...
60

7dff59efb   Eric Dumazet   net: add rtnl_der...
61
  /**
331b72922   John Fastabend   net: sched: RCU c...
62
63
64
65
66
67
68
69
70
71
   * rcu_dereference_bh_rtnl - rcu_dereference_bh with debug checking
   * @p: The pointer to read, prior to dereference
   *
   * Do an rcu_dereference_bh(p), but check caller either holds rcu_read_lock_bh()
   * or RTNL. Note : Please prefer rtnl_dereference() or rcu_dereference_bh()
   */
  #define rcu_dereference_bh_rtnl(p)				\
  	rcu_dereference_bh_check(p, lockdep_rtnl_is_held())
  
  /**
29fa060ea   David S. Miller   net: relax rtnl_d...
72
   * rtnl_dereference - fetch RCU pointer when updates are prevented by RTNL
7dff59efb   Eric Dumazet   net: add rtnl_der...
73
74
   * @p: The pointer to read, prior to dereferencing
   *
29fa060ea   David S. Miller   net: relax rtnl_d...
75
   * Return the value of the specified RCU-protected pointer, but omit
1ba9c5e6c   Paul E. McKenney   rtnetlink: Update...
76
   * the READ_ONCE(), because caller holds RTNL.
7dff59efb   Eric Dumazet   net: add rtnl_der...
77
78
   */
  #define rtnl_dereference(p)					\
29fa060ea   David S. Miller   net: relax rtnl_d...
79
  	rcu_dereference_protected(p, lockdep_rtnl_is_held())
7dff59efb   Eric Dumazet   net: add rtnl_der...
80

24824a09e   Eric Dumazet   net: dynamic ingr...
81
82
83
84
  static inline struct netdev_queue *dev_ingress_queue(struct net_device *dev)
  {
  	return rtnl_dereference(dev->ingress_queue);
  }
3a7d0d07a   Vlad Buslov   net: sched: exten...
85
86
87
88
  static inline struct netdev_queue *dev_ingress_queue_rcu(struct net_device *dev)
  {
  	return rcu_dereference(dev->ingress_queue);
  }
4577139b2   Daniel Borkmann   net: use jump lab...
89
  struct netdev_queue *dev_ingress_queue_create(struct net_device *dev);
1cf51900f   Pablo Neira   net: add CONFIG_N...
90
  #ifdef CONFIG_NET_INGRESS
4577139b2   Daniel Borkmann   net: use jump lab...
91
92
  void net_inc_ingress_queue(void);
  void net_dec_ingress_queue(void);
4577139b2   Daniel Borkmann   net: use jump lab...
93
  #endif
24824a09e   Eric Dumazet   net: dynamic ingr...
94

1f211a1b9   Daniel Borkmann   net, sched: add c...
95
96
97
98
  #ifdef CONFIG_NET_EGRESS
  void net_inc_egress_queue(void);
  void net_dec_egress_queue(void);
  #endif
1b5c5493e   Eric Dumazet   net_sched: add th...
99
100
101
  void rtnetlink_init(void);
  void __rtnl_unlock(void);
  void rtnl_kfree_skbs(struct sk_buff *head, struct sk_buff *tail);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
102

66364bdf3   Leon Romanovsky   rtnetlink: Replac...
103
104
105
106
  #define ASSERT_RTNL() \
  	WARN_ONCE(!rtnl_is_locked(), \
  		  "RTNL: assertion failed at %s (%d)
  ", __FILE__,  __LINE__)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
107

77162022a   John Fastabend   net: add generic ...
108
109
110
  extern int ndo_dflt_fdb_dump(struct sk_buff *skb,
  			     struct netlink_callback *cb,
  			     struct net_device *dev,
5d5eacb34   Jamal Hadi Salim   bridge: fdb dumpi...
111
  			     struct net_device *filter_dev,
d297653dd   Roopa Prabhu   rtnetlink: fdb du...
112
  			     int *idx);
090096bf3   Vlad Yasevich   net: generic fdb ...
113
114
115
116
  extern int ndo_dflt_fdb_add(struct ndmsg *ndm,
  			    struct nlattr *tb[],
  			    struct net_device *dev,
  			    const unsigned char *addr,
f6f6424ba   Jiri Pirko   net: make vid as ...
117
118
  			    u16 vid,
  			    u16 flags);
090096bf3   Vlad Yasevich   net: generic fdb ...
119
120
121
  extern int ndo_dflt_fdb_del(struct ndmsg *ndm,
  			    struct nlattr *tb[],
  			    struct net_device *dev,
f6f6424ba   Jiri Pirko   net: make vid as ...
122
123
  			    const unsigned char *addr,
  			    u16 vid);
815cccbf1   John Fastabend   ixgbe: add setlin...
124
125
  
  extern int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
2c3c031c8   Scott Feldman   bridge: add brpor...
126
  				   struct net_device *dev, u16 mode,
7d4f8d871   Scott Feldman   switchdev; add VL...
127
128
129
130
131
  				   u32 flags, u32 mask, int nlflags,
  				   u32 filter_mask,
  				   int (*vlan_fill)(struct sk_buff *skb,
  						    struct net_device *dev,
  						    u32 filter_mask));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
132
  #endif	/* __LINUX_RTNETLINK_H */