Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1#ifndef _NFNETLINK_H
2#define _NFNETLINK_H
3
4#include <linux/netlink.h>
5#include <linux/capability.h>
6#include <net/netlink.h>
7#include <uapi/linux/netfilter/nfnetlink.h>
8
9struct nfnl_callback {
10 int (*call)(struct net *net, struct sock *nl, struct sk_buff *skb,
11 const struct nlmsghdr *nlh,
12 const struct nlattr * const cda[],
13 struct netlink_ext_ack *extack);
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 struct netlink_ext_ack *extack);
18 int (*call_batch)(struct net *net, struct sock *nl, struct sk_buff *skb,
19 const struct nlmsghdr *nlh,
20 const struct nlattr * const cda[],
21 struct netlink_ext_ack *extack);
22 const struct nla_policy *policy; /* netlink attribute policy */
23 const u_int16_t attr_count; /* number of nlattr's */
24};
25
26struct nfnetlink_subsystem {
27 const char *name;
28 __u8 subsys_id; /* nfnetlink subsystem ID */
29 __u8 cb_count; /* number of callbacks */
30 const struct nfnl_callback *cb; /* callback for individual types */
31 int (*commit)(struct net *net, struct sk_buff *skb);
32 int (*abort)(struct net *net, struct sk_buff *skb);
33 bool (*valid_genid)(struct net *net, u32 genid);
34};
35
36int nfnetlink_subsys_register(const struct nfnetlink_subsystem *n);
37int nfnetlink_subsys_unregister(const struct nfnetlink_subsystem *n);
38
39int nfnetlink_has_listeners(struct net *net, unsigned int group);
40int nfnetlink_send(struct sk_buff *skb, struct net *net, u32 portid,
41 unsigned int group, int echo, gfp_t flags);
42int nfnetlink_set_err(struct net *net, u32 portid, u32 group, int error);
43int nfnetlink_unicast(struct sk_buff *skb, struct net *net, u32 portid,
44 int flags);
45
46static inline u16 nfnl_msg_type(u8 subsys, u8 msg_type)
47{
48 return subsys << 8 | msg_type;
49}
50
51void nfnl_lock(__u8 subsys_id);
52void nfnl_unlock(__u8 subsys_id);
53#ifdef CONFIG_PROVE_LOCKING
54bool lockdep_nfnl_is_held(__u8 subsys_id);
55#else
56static inline bool lockdep_nfnl_is_held(__u8 subsys_id)
57{
58 return true;
59}
60#endif /* CONFIG_PROVE_LOCKING */
61
62/*
63 * nfnl_dereference - fetch RCU pointer when updates are prevented by subsys mutex
64 *
65 * @p: The pointer to read, prior to dereferencing
66 * @ss: The nfnetlink subsystem ID
67 *
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 the NFNL subsystem mutex.
71 */
72#define nfnl_dereference(p, ss) \
73 rcu_dereference_protected(p, lockdep_nfnl_is_held(ss))
74
75#define MODULE_ALIAS_NFNL_SUBSYS(subsys) \
76 MODULE_ALIAS("nfnetlink-subsys-" __stringify(subsys))
77
78#endif /* _NFNETLINK_H */