]> git.karo-electronics.de Git - karo-tx-linux.git/blob - include/linux/netfilter/nfnetlink.h
Merge tag 'platform-drivers-x86-v4.11-2' of git://git.infradead.org/linux-platform...
[karo-tx-linux.git] / include / linux / netfilter / nfnetlink.h
1 #ifndef _NFNETLINK_H
2 #define _NFNETLINK_H
3
4
5 #include <linux/netlink.h>
6 #include <linux/capability.h>
7 #include <net/netlink.h>
8 #include <uapi/linux/netfilter/nfnetlink.h>
9
10 struct nfnl_callback {
11         int (*call)(struct net *net, struct sock *nl, struct sk_buff *skb,
12                     const struct nlmsghdr *nlh,
13                     const struct nlattr * const cda[]);
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[]);
17         int (*call_batch)(struct net *net, struct sock *nl, struct sk_buff *skb,
18                           const struct nlmsghdr *nlh,
19                           const struct nlattr * const cda[]);
20         const struct nla_policy *policy;        /* netlink attribute policy */
21         const u_int16_t attr_count;             /* number of nlattr's */
22 };
23
24 struct nfnetlink_subsystem {
25         const char *name;
26         __u8 subsys_id;                 /* nfnetlink subsystem ID */
27         __u8 cb_count;                  /* number of callbacks */
28         const struct nfnl_callback *cb; /* callback for individual types */
29         int (*commit)(struct net *net, struct sk_buff *skb);
30         int (*abort)(struct net *net, struct sk_buff *skb);
31         bool (*valid_genid)(struct net *net, u32 genid);
32 };
33
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);
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
44 void nfnl_lock(__u8 subsys_id);
45 void nfnl_unlock(__u8 subsys_id);
46 #ifdef CONFIG_PROVE_LOCKING
47 bool lockdep_nfnl_is_held(__u8 subsys_id);
48 #else
49 static inline bool lockdep_nfnl_is_held(__u8 subsys_id)
50 {
51         return true;
52 }
53 #endif /* CONFIG_PROVE_LOCKING */
54
55 /*
56  * nfnl_dereference - fetch RCU pointer when updates are prevented by subsys mutex
57  *
58  * @p: The pointer to read, prior to dereferencing
59  * @ss: The nfnetlink subsystem ID
60  *
61  * Return the value of the specified RCU-protected pointer, but omit
62  * both the smp_read_barrier_depends() and the ACCESS_ONCE(), because
63  * caller holds the NFNL subsystem mutex.
64  */
65 #define nfnl_dereference(p, ss)                                 \
66         rcu_dereference_protected(p, lockdep_nfnl_is_held(ss))
67
68 #define MODULE_ALIAS_NFNL_SUBSYS(subsys) \
69         MODULE_ALIAS("nfnetlink-subsys-" __stringify(subsys))
70
71 #endif  /* _NFNETLINK_H */