aboutsummaryrefslogtreecommitdiffstats
path: root/include/uapi/linux
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2013-10-13 18:06:06 -0400
committerPablo Neira Ayuso <pablo@netfilter.org>2013-10-14 12:00:04 -0400
commit0ca743a5599199152a31a7146b83213c786c2eb2 (patch)
treefd5cd87e1e1cf3f43d5868304c7c45f9bf11cef5 /include/uapi/linux
parent9370761c56b66aa5c65e069a7b010111a025018d (diff)
netfilter: nf_tables: add compatibility layer for x_tables
This patch adds the x_tables compatibility layer. This allows you to use existing x_tables matches and targets from nf_tables. This compatibility later allows us to use existing matches/targets for features that are still missing in nf_tables. We can progressively replace them with native nf_tables extensions. It also provides the userspace compatibility software that allows you to express the rule-set using the iptables syntax but using the nf_tables kernel components. In order to get this compatibility layer working, I've done the following things: * add NFNL_SUBSYS_NFT_COMPAT: this new nfnetlink subsystem is used to query the x_tables match/target revision, so we don't need to use the native x_table getsockopt interface. * emulate xt structures: this required extending the struct nft_pktinfo to include the fragment offset, which is already obtained from ip[6]_tables and that is used by some matches/targets. * add support for default policy to base chains, required to emulate x_tables. * add NFTA_CHAIN_USE attribute to obtain the number of references to chains, required by x_tables emulation. * add chain packet/byte counters using per-cpu. * support 32-64 bits compat. For historical reasons, this patch includes the following patches that were posted in the netfilter-devel mailing list. From Pablo Neira Ayuso: * nf_tables: add default policy to base chains * netfilter: nf_tables: add NFTA_CHAIN_USE attribute * nf_tables: nft_compat: private data of target and matches in contiguous area * nf_tables: validate hooks for compat match/target * nf_tables: nft_compat: release cached matches/targets * nf_tables: x_tables support as a compile time option * nf_tables: fix alias for xtables over nftables module * nf_tables: add packet and byte counters per chain * nf_tables: fix per-chain counter stats if no counters are passed * nf_tables: don't bump chain stats * nf_tables: add protocol and flags for xtables over nf_tables * nf_tables: add ip[6]t_entry emulation * nf_tables: move specific layer 3 compat code to nf_tables_ipv[4|6] * nf_tables: support 32bits-64bits x_tables compat * nf_tables: fix compilation if CONFIG_COMPAT is disabled From Patrick McHardy: * nf_tables: move policy to struct nft_base_chain * nf_tables: send notifications for base chain policy changes From Alexander Primak: * nf_tables: remove the duplicate NF_INET_LOCAL_OUT From Nicolas Dichtel: * nf_tables: fix compilation when nf-netlink is a module Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'include/uapi/linux')
-rw-r--r--include/uapi/linux/netfilter/Kbuild1
-rw-r--r--include/uapi/linux/netfilter/nf_tables.h32
-rw-r--r--include/uapi/linux/netfilter/nf_tables_compat.h38
-rw-r--r--include/uapi/linux/netfilter/nfnetlink.h3
4 files changed, 73 insertions, 1 deletions
diff --git a/include/uapi/linux/netfilter/Kbuild b/include/uapi/linux/netfilter/Kbuild
index 6ce0b7f566a7..17c3af2c4bb9 100644
--- a/include/uapi/linux/netfilter/Kbuild
+++ b/include/uapi/linux/netfilter/Kbuild
@@ -6,6 +6,7 @@ header-y += nf_conntrack_sctp.h
6header-y += nf_conntrack_tcp.h 6header-y += nf_conntrack_tcp.h
7header-y += nf_conntrack_tuple_common.h 7header-y += nf_conntrack_tuple_common.h
8header-y += nf_tables.h 8header-y += nf_tables.h
9header-y += nf_tables_compat.h
9header-y += nf_nat.h 10header-y += nf_nat.h
10header-y += nfnetlink.h 11header-y += nfnetlink.h
11header-y += nfnetlink_acct.h 12header-y += nfnetlink_acct.h
diff --git a/include/uapi/linux/netfilter/nf_tables.h b/include/uapi/linux/netfilter/nf_tables.h
index 779cf951c8de..1563875e6942 100644
--- a/include/uapi/linux/netfilter/nf_tables.h
+++ b/include/uapi/linux/netfilter/nf_tables.h
@@ -115,7 +115,10 @@ enum nft_table_attributes {
115 * @NFTA_CHAIN_HANDLE: numeric handle of the chain (NLA_U64) 115 * @NFTA_CHAIN_HANDLE: numeric handle of the chain (NLA_U64)
116 * @NFTA_CHAIN_NAME: name of the chain (NLA_STRING) 116 * @NFTA_CHAIN_NAME: name of the chain (NLA_STRING)
117 * @NFTA_CHAIN_HOOK: hook specification for basechains (NLA_NESTED: nft_hook_attributes) 117 * @NFTA_CHAIN_HOOK: hook specification for basechains (NLA_NESTED: nft_hook_attributes)
118 * @NFTA_CHAIN_POLICY: numeric policy of the chain (NLA_U32)
119 * @NFTA_CHAIN_USE: number of references to this chain (NLA_U32)
118 * @NFTA_CHAIN_TYPE: type name of the string (NLA_NUL_STRING) 120 * @NFTA_CHAIN_TYPE: type name of the string (NLA_NUL_STRING)
121 * @NFTA_CHAIN_COUNTERS: counter specification of the chain (NLA_NESTED: nft_counter_attributes)
119 */ 122 */
120enum nft_chain_attributes { 123enum nft_chain_attributes {
121 NFTA_CHAIN_UNSPEC, 124 NFTA_CHAIN_UNSPEC,
@@ -123,7 +126,10 @@ enum nft_chain_attributes {
123 NFTA_CHAIN_HANDLE, 126 NFTA_CHAIN_HANDLE,
124 NFTA_CHAIN_NAME, 127 NFTA_CHAIN_NAME,
125 NFTA_CHAIN_HOOK, 128 NFTA_CHAIN_HOOK,
129 NFTA_CHAIN_POLICY,
130 NFTA_CHAIN_USE,
126 NFTA_CHAIN_TYPE, 131 NFTA_CHAIN_TYPE,
132 NFTA_CHAIN_COUNTERS,
127 __NFTA_CHAIN_MAX 133 __NFTA_CHAIN_MAX
128}; 134};
129#define NFTA_CHAIN_MAX (__NFTA_CHAIN_MAX - 1) 135#define NFTA_CHAIN_MAX (__NFTA_CHAIN_MAX - 1)
@@ -135,6 +141,7 @@ enum nft_chain_attributes {
135 * @NFTA_RULE_CHAIN: name of the chain containing the rule (NLA_STRING) 141 * @NFTA_RULE_CHAIN: name of the chain containing the rule (NLA_STRING)
136 * @NFTA_RULE_HANDLE: numeric handle of the rule (NLA_U64) 142 * @NFTA_RULE_HANDLE: numeric handle of the rule (NLA_U64)
137 * @NFTA_RULE_EXPRESSIONS: list of expressions (NLA_NESTED: nft_expr_attributes) 143 * @NFTA_RULE_EXPRESSIONS: list of expressions (NLA_NESTED: nft_expr_attributes)
144 * @NFTA_RULE_COMPAT: compatibility specifications of the rule (NLA_NESTED: nft_rule_compat_attributes)
138 */ 145 */
139enum nft_rule_attributes { 146enum nft_rule_attributes {
140 NFTA_RULE_UNSPEC, 147 NFTA_RULE_UNSPEC,
@@ -142,11 +149,36 @@ enum nft_rule_attributes {
142 NFTA_RULE_CHAIN, 149 NFTA_RULE_CHAIN,
143 NFTA_RULE_HANDLE, 150 NFTA_RULE_HANDLE,
144 NFTA_RULE_EXPRESSIONS, 151 NFTA_RULE_EXPRESSIONS,
152 NFTA_RULE_COMPAT,
145 __NFTA_RULE_MAX 153 __NFTA_RULE_MAX
146}; 154};
147#define NFTA_RULE_MAX (__NFTA_RULE_MAX - 1) 155#define NFTA_RULE_MAX (__NFTA_RULE_MAX - 1)
148 156
149/** 157/**
158 * enum nft_rule_compat_flags - nf_tables rule compat flags
159 *
160 * @NFT_RULE_COMPAT_F_INV: invert the check result
161 */
162enum nft_rule_compat_flags {
163 NFT_RULE_COMPAT_F_INV = (1 << 1),
164 NFT_RULE_COMPAT_F_MASK = NFT_RULE_COMPAT_F_INV,
165};
166
167/**
168 * enum nft_rule_compat_attributes - nf_tables rule compat attributes
169 *
170 * @NFTA_RULE_COMPAT_PROTO: numerice value of handled protocol (NLA_U32)
171 * @NFTA_RULE_COMPAT_FLAGS: bitmask of enum nft_rule_compat_flags (NLA_U32)
172 */
173enum nft_rule_compat_attributes {
174 NFTA_RULE_COMPAT_UNSPEC,
175 NFTA_RULE_COMPAT_PROTO,
176 NFTA_RULE_COMPAT_FLAGS,
177 __NFTA_RULE_COMPAT_MAX
178};
179#define NFTA_RULE_COMPAT_MAX (__NFTA_RULE_COMPAT_MAX - 1)
180
181/**
150 * enum nft_set_flags - nf_tables set flags 182 * enum nft_set_flags - nf_tables set flags
151 * 183 *
152 * @NFT_SET_ANONYMOUS: name allocation, automatic cleanup on unlink 184 * @NFT_SET_ANONYMOUS: name allocation, automatic cleanup on unlink
diff --git a/include/uapi/linux/netfilter/nf_tables_compat.h b/include/uapi/linux/netfilter/nf_tables_compat.h
new file mode 100644
index 000000000000..8310f5f76551
--- /dev/null
+++ b/include/uapi/linux/netfilter/nf_tables_compat.h
@@ -0,0 +1,38 @@
1#ifndef _NFT_COMPAT_NFNETLINK_H_
2#define _NFT_COMPAT_NFNETLINK_H_
3
4enum nft_target_attributes {
5 NFTA_TARGET_UNSPEC,
6 NFTA_TARGET_NAME,
7 NFTA_TARGET_REV,
8 NFTA_TARGET_INFO,
9 __NFTA_TARGET_MAX
10};
11#define NFTA_TARGET_MAX (__NFTA_TARGET_MAX - 1)
12
13enum nft_match_attributes {
14 NFTA_MATCH_UNSPEC,
15 NFTA_MATCH_NAME,
16 NFTA_MATCH_REV,
17 NFTA_MATCH_INFO,
18 __NFTA_MATCH_MAX
19};
20#define NFTA_MATCH_MAX (__NFTA_MATCH_MAX - 1)
21
22#define NFT_COMPAT_NAME_MAX 32
23
24enum {
25 NFNL_MSG_COMPAT_GET,
26 NFNL_MSG_COMPAT_MAX
27};
28
29enum {
30 NFTA_COMPAT_UNSPEC = 0,
31 NFTA_COMPAT_NAME,
32 NFTA_COMPAT_REV,
33 NFTA_COMPAT_TYPE,
34 __NFTA_COMPAT_MAX,
35};
36#define NFTA_COMPAT_MAX (__NFTA_COMPAT_MAX - 1)
37
38#endif
diff --git a/include/uapi/linux/netfilter/nfnetlink.h b/include/uapi/linux/netfilter/nfnetlink.h
index d276c3bd55b8..288959404d54 100644
--- a/include/uapi/linux/netfilter/nfnetlink.h
+++ b/include/uapi/linux/netfilter/nfnetlink.h
@@ -54,6 +54,7 @@ struct nfgenmsg {
54#define NFNL_SUBSYS_CTNETLINK_TIMEOUT 8 54#define NFNL_SUBSYS_CTNETLINK_TIMEOUT 8
55#define NFNL_SUBSYS_CTHELPER 9 55#define NFNL_SUBSYS_CTHELPER 9
56#define NFNL_SUBSYS_NFTABLES 10 56#define NFNL_SUBSYS_NFTABLES 10
57#define NFNL_SUBSYS_COUNT 11 57#define NFNL_SUBSYS_NFT_COMPAT 11
58#define NFNL_SUBSYS_COUNT 12
58 59
59#endif /* _UAPI_NFNETLINK_H */ 60#endif /* _UAPI_NFNETLINK_H */