Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #ifndef __LINUX_RTNETLINK_H |
2 | #define __LINUX_RTNETLINK_H | |
3 | ||
1da177e4 | 4 | |
6756ae4b | 5 | #include <linux/mutex.h> |
3b42a96d | 6 | #include <linux/netdevice.h> |
200b916f | 7 | #include <linux/wait.h> |
607ca46e | 8 | #include <uapi/linux/rtnetlink.h> |
1da177e4 | 9 | |
97c53cac DL |
10 | extern int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, u32 group, int echo); |
11 | extern int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid); | |
1ce85fe4 PNA |
12 | extern void rtnl_notify(struct sk_buff *skb, struct net *net, u32 pid, |
13 | u32 group, struct nlmsghdr *nlh, gfp_t flags); | |
97c53cac | 14 | extern void rtnl_set_sk_err(struct net *net, u32 group, int error); |
1da177e4 | 15 | extern int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics); |
e3703b3d | 16 | extern int rtnl_put_cacheinfo(struct sk_buff *skb, struct dst_entry *dst, |
87a50699 | 17 | u32 id, long expires, u32 error); |
1da177e4 | 18 | |
7f294054 | 19 | void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change, gfp_t flags); |
395eea6c MB |
20 | struct sk_buff *rtmsg_ifinfo_build_skb(int type, struct net_device *dev, |
21 | unsigned change, gfp_t flags); | |
22 | void rtmsg_ifinfo_send(struct sk_buff *skb, struct net_device *dev, | |
23 | gfp_t flags); | |
24 | ||
1da177e4 | 25 | |
6756ae4b | 26 | /* RTNL is used as a global lock for all changes to network configuration */ |
1da177e4 | 27 | extern void rtnl_lock(void); |
1da177e4 | 28 | extern void rtnl_unlock(void); |
6756ae4b | 29 | extern int rtnl_trylock(void); |
c9c1014b | 30 | extern int rtnl_is_locked(void); |
200b916f CW |
31 | |
32 | extern wait_queue_head_t netdev_unregistering_wq; | |
33 | extern struct mutex net_mutex; | |
34 | ||
a898def2 PM |
35 | #ifdef CONFIG_PROVE_LOCKING |
36 | extern int lockdep_rtnl_is_held(void); | |
85328240 JF |
37 | #else |
38 | static inline int lockdep_rtnl_is_held(void) | |
39 | { | |
40 | return 1; | |
41 | } | |
a898def2 | 42 | #endif /* #ifdef CONFIG_PROVE_LOCKING */ |
6756ae4b | 43 | |
a6e0fc85 ED |
44 | /** |
45 | * rcu_dereference_rtnl - rcu_dereference with debug checking | |
46 | * @p: The pointer to read, prior to dereferencing | |
47 | * | |
48 | * Do an rcu_dereference(p), but check caller either holds rcu_read_lock() | |
29fa060e | 49 | * or RTNL. Note : Please prefer rtnl_dereference() or rcu_dereference() |
a6e0fc85 ED |
50 | */ |
51 | #define rcu_dereference_rtnl(p) \ | |
d8bf4ca9 | 52 | rcu_dereference_check(p, lockdep_rtnl_is_held()) |
a6e0fc85 | 53 | |
331b7292 JF |
54 | /** |
55 | * rcu_dereference_bh_rtnl - rcu_dereference_bh with debug checking | |
56 | * @p: The pointer to read, prior to dereference | |
57 | * | |
58 | * Do an rcu_dereference_bh(p), but check caller either holds rcu_read_lock_bh() | |
59 | * or RTNL. Note : Please prefer rtnl_dereference() or rcu_dereference_bh() | |
60 | */ | |
61 | #define rcu_dereference_bh_rtnl(p) \ | |
62 | rcu_dereference_bh_check(p, lockdep_rtnl_is_held()) | |
63 | ||
7dff59ef | 64 | /** |
29fa060e | 65 | * rtnl_dereference - fetch RCU pointer when updates are prevented by RTNL |
7dff59ef ED |
66 | * @p: The pointer to read, prior to dereferencing |
67 | * | |
29fa060e DM |
68 | * Return the value of the specified RCU-protected pointer, but omit |
69 | * both the smp_read_barrier_depends() and the ACCESS_ONCE(), because | |
70 | * caller holds RTNL. | |
7dff59ef ED |
71 | */ |
72 | #define rtnl_dereference(p) \ | |
29fa060e | 73 | rcu_dereference_protected(p, lockdep_rtnl_is_held()) |
7dff59ef | 74 | |
24824a09 ED |
75 | static inline struct netdev_queue *dev_ingress_queue(struct net_device *dev) |
76 | { | |
77 | return rtnl_dereference(dev->ingress_queue); | |
78 | } | |
79 | ||
4577139b DB |
80 | struct netdev_queue *dev_ingress_queue_create(struct net_device *dev); |
81 | ||
82 | #ifdef CONFIG_NET_CLS_ACT | |
83 | void net_inc_ingress_queue(void); | |
84 | void net_dec_ingress_queue(void); | |
4577139b | 85 | #endif |
24824a09 | 86 | |
1da177e4 | 87 | extern void rtnetlink_init(void); |
6756ae4b | 88 | extern void __rtnl_unlock(void); |
1da177e4 LT |
89 | |
90 | #define ASSERT_RTNL() do { \ | |
c9c1014b | 91 | if (unlikely(!rtnl_is_locked())) { \ |
1da177e4 LT |
92 | printk(KERN_ERR "RTNL: assertion failed at %s (%d)\n", \ |
93 | __FILE__, __LINE__); \ | |
94 | dump_stack(); \ | |
95 | } \ | |
96 | } while(0) | |
97 | ||
77162022 JF |
98 | extern int ndo_dflt_fdb_dump(struct sk_buff *skb, |
99 | struct netlink_callback *cb, | |
100 | struct net_device *dev, | |
5d5eacb3 | 101 | struct net_device *filter_dev, |
77162022 | 102 | int idx); |
090096bf VY |
103 | extern int ndo_dflt_fdb_add(struct ndmsg *ndm, |
104 | struct nlattr *tb[], | |
105 | struct net_device *dev, | |
106 | const unsigned char *addr, | |
f6f6424b JP |
107 | u16 vid, |
108 | u16 flags); | |
090096bf VY |
109 | extern int ndo_dflt_fdb_del(struct ndmsg *ndm, |
110 | struct nlattr *tb[], | |
111 | struct net_device *dev, | |
f6f6424b JP |
112 | const unsigned char *addr, |
113 | u16 vid); | |
815cccbf JF |
114 | |
115 | extern int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq, | |
2c3c031c | 116 | struct net_device *dev, u16 mode, |
46c264da | 117 | u32 flags, u32 mask, int nlflags); |
1da177e4 | 118 | #endif /* __LINUX_RTNETLINK_H */ |