Merge branches 'acpi-resources', 'acpi-battery', 'acpi-doc' and 'acpi-pnp'
[linux-2.6-block.git] / include / linux / rtnetlink.h
CommitLineData
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
10extern int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, u32 group, int echo);
11extern int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid);
1ce85fe4
PNA
12extern void rtnl_notify(struct sk_buff *skb, struct net *net, u32 pid,
13 u32 group, struct nlmsghdr *nlh, gfp_t flags);
97c53cac 14extern void rtnl_set_sk_err(struct net *net, u32 group, int error);
1da177e4 15extern int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics);
e3703b3d 16extern int rtnl_put_cacheinfo(struct sk_buff *skb, struct dst_entry *dst,
87a50699 17 u32 id, long expires, u32 error);
1da177e4 18
7f294054 19void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change, gfp_t flags);
395eea6c
MB
20struct sk_buff *rtmsg_ifinfo_build_skb(int type, struct net_device *dev,
21 unsigned change, gfp_t flags);
22void 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 27extern void rtnl_lock(void);
1da177e4 28extern void rtnl_unlock(void);
6756ae4b 29extern int rtnl_trylock(void);
c9c1014b 30extern int rtnl_is_locked(void);
200b916f
CW
31
32extern wait_queue_head_t netdev_unregistering_wq;
33extern struct mutex net_mutex;
34
a898def2
PM
35#ifdef CONFIG_PROVE_LOCKING
36extern int lockdep_rtnl_is_held(void);
85328240
JF
37#else
38static 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
75static inline struct netdev_queue *dev_ingress_queue(struct net_device *dev)
76{
77 return rtnl_dereference(dev->ingress_queue);
78}
79
4577139b
DB
80struct netdev_queue *dev_ingress_queue_create(struct net_device *dev);
81
82#ifdef CONFIG_NET_CLS_ACT
83void net_inc_ingress_queue(void);
84void net_dec_ingress_queue(void);
85#else
86static inline void net_inc_ingress_queue(void)
87{
88}
89
90static inline void net_dec_ingress_queue(void)
91{
92}
93#endif
24824a09 94
1da177e4 95extern void rtnetlink_init(void);
6756ae4b 96extern void __rtnl_unlock(void);
1da177e4
LT
97
98#define ASSERT_RTNL() do { \
c9c1014b 99 if (unlikely(!rtnl_is_locked())) { \
1da177e4
LT
100 printk(KERN_ERR "RTNL: assertion failed at %s (%d)\n", \
101 __FILE__, __LINE__); \
102 dump_stack(); \
103 } \
104} while(0)
105
77162022
JF
106extern int ndo_dflt_fdb_dump(struct sk_buff *skb,
107 struct netlink_callback *cb,
108 struct net_device *dev,
5d5eacb3 109 struct net_device *filter_dev,
77162022 110 int idx);
090096bf
VY
111extern int ndo_dflt_fdb_add(struct ndmsg *ndm,
112 struct nlattr *tb[],
113 struct net_device *dev,
114 const unsigned char *addr,
f6f6424b
JP
115 u16 vid,
116 u16 flags);
090096bf
VY
117extern int ndo_dflt_fdb_del(struct ndmsg *ndm,
118 struct nlattr *tb[],
119 struct net_device *dev,
f6f6424b
JP
120 const unsigned char *addr,
121 u16 vid);
815cccbf
JF
122
123extern int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
2c3c031c 124 struct net_device *dev, u16 mode,
46c264da 125 u32 flags, u32 mask, int nlflags);
1da177e4 126#endif /* __LINUX_RTNETLINK_H */