]>
Commit | Line | Data |
---|---|---|
f9e815b3 HW |
1 | #ifndef _NFNETLINK_H |
2 | #define _NFNETLINK_H | |
ac6d439d | 3 | |
f9e815b3 | 4 | |
080774a2 | 5 | #include <linux/netlink.h> |
f9e815b3 | 6 | #include <linux/capability.h> |
df6fb868 | 7 | #include <net/netlink.h> |
94d0ec58 | 8 | #include <uapi/linux/netfilter/nfnetlink.h> |
f9e815b3 | 9 | |
d94d9fee | 10 | struct nfnl_callback { |
7b8002a1 | 11 | int (*call)(struct net *net, struct sock *nl, struct sk_buff *skb, |
6b75e3e8 ED |
12 | const struct nlmsghdr *nlh, |
13 | const struct nlattr * const cda[]); | |
7b8002a1 PNA |
14 | int (*call_rcu)(struct net *net, struct sock *nl, struct sk_buff *skb, |
15 | const struct nlmsghdr *nlh, | |
16 | const struct nlattr * const cda[]); | |
633c9a84 | 17 | int (*call_batch)(struct net *net, struct sock *nl, struct sk_buff *skb, |
0628b123 PNA |
18 | const struct nlmsghdr *nlh, |
19 | const struct nlattr * const cda[]); | |
e3730578 PM |
20 | const struct nla_policy *policy; /* netlink attribute policy */ |
21 | const u_int16_t attr_count; /* number of nlattr's */ | |
f9e815b3 HW |
22 | }; |
23 | ||
d94d9fee | 24 | struct nfnetlink_subsystem { |
f9e815b3 | 25 | const char *name; |
7c8d4cb4 PM |
26 | __u8 subsys_id; /* nfnetlink subsystem ID */ |
27 | __u8 cb_count; /* number of callbacks */ | |
28 | const struct nfnl_callback *cb; /* callback for individual types */ | |
5913beaf PNA |
29 | int (*commit)(struct net *net, struct sk_buff *skb); |
30 | int (*abort)(struct net *net, struct sk_buff *skb); | |
8c4d4e8b | 31 | bool (*valid_genid)(struct net *net, u32 genid); |
f9e815b3 HW |
32 | }; |
33 | ||
a0f4ecf3 JP |
34 | int nfnetlink_subsys_register(const struct nfnetlink_subsystem *n); |
35 | int nfnetlink_subsys_unregister(const struct nfnetlink_subsystem *n); | |
36 | ||
37 | int nfnetlink_has_listeners(struct net *net, unsigned int group); | |
a0f4ecf3 JP |
38 | int nfnetlink_send(struct sk_buff *skb, struct net *net, u32 portid, |
39 | unsigned int group, int echo, gfp_t flags); | |
40 | int nfnetlink_set_err(struct net *net, u32 portid, u32 group, int error); | |
41 | int nfnetlink_unicast(struct sk_buff *skb, struct net *net, u32 portid, | |
42 | int flags); | |
43 | ||
dedb67c4 PNA |
44 | static inline u16 nfnl_msg_type(u8 subsys, u8 msg_type) |
45 | { | |
46 | return subsys << 8 | msg_type; | |
47 | } | |
48 | ||
a0f4ecf3 JP |
49 | void nfnl_lock(__u8 subsys_id); |
50 | void nfnl_unlock(__u8 subsys_id); | |
0eb5db7a | 51 | #ifdef CONFIG_PROVE_LOCKING |
875e0829 | 52 | bool lockdep_nfnl_is_held(__u8 subsys_id); |
0eb5db7a | 53 | #else |
875e0829 | 54 | static inline bool lockdep_nfnl_is_held(__u8 subsys_id) |
0eb5db7a | 55 | { |
875e0829 | 56 | return true; |
0eb5db7a PM |
57 | } |
58 | #endif /* CONFIG_PROVE_LOCKING */ | |
59 | ||
60 | /* | |
61 | * nfnl_dereference - fetch RCU pointer when updates are prevented by subsys mutex | |
62 | * | |
63 | * @p: The pointer to read, prior to dereferencing | |
64 | * @ss: The nfnetlink subsystem ID | |
65 | * | |
66 | * Return the value of the specified RCU-protected pointer, but omit | |
67 | * both the smp_read_barrier_depends() and the ACCESS_ONCE(), because | |
68 | * caller holds the NFNL subsystem mutex. | |
69 | */ | |
70 | #define nfnl_dereference(p, ss) \ | |
71 | rcu_dereference_protected(p, lockdep_nfnl_is_held(ss)) | |
e6a7d3c0 | 72 | |
0ab43f84 HW |
73 | #define MODULE_ALIAS_NFNL_SUBSYS(subsys) \ |
74 | MODULE_ALIAS("nfnetlink-subsys-" __stringify(subsys)) | |
75 | ||
f9e815b3 | 76 | #endif /* _NFNETLINK_H */ |