aboutsummaryrefslogtreecommitdiffstats
path: root/include/uapi/linux
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2015-04-14 18:51:19 -0400
committerDavid S. Miller <davem@davemloft.net>2015-04-14 18:51:19 -0400
commitbae97d84100ae7a8dc3b79233ecd3a8f7c19ea57 (patch)
tree975f812d346f61d988a8dc5a0989539293700ad9 /include/uapi/linux
parent87ffabb1f055e14e7d171c6599539a154d647904 (diff)
parent97bb43c3e06e9bfdc9e3140a312004df462685b9 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next
Pablo Neira Ayuso says: ==================== Netfilter updates for net-next A final pull request, I know it's very late but this time I think it's worth a bit of rush. The following patchset contains Netfilter/nf_tables updates for net-next, more specifically concatenation support and dynamic stateful expression instantiation. This also comes with a couple of small patches. One to fix the ebtables.h userspace header and another to get rid of an obsolete example file in tree that describes a nf_tables expression. This time, I decided to paste the original descriptions. This will result in a rather large commit description, but I think these bytes to keep. Patrick McHardy says: ==================== netfilter: nf_tables: concatenation support The following patches add support for concatenations, which allow multi dimensional exact matches in O(1). The basic idea is to split the data registers, currently consisting of 4 registers of 16 bytes each, into smaller units, 16 registers of 4 bytes each, and making sure each register store always leaves the full 32 bit in a well defined state, meaning smaller stores will zero the remaining bits. Based on that, we can load multiple adjacent registers with different values, thereby building a concatenated bigger value, and use that value for set lookups. Sets are changed to use variable sized extensions for their key and data values, removing the fixed limit of 16 bytes while saving memory if less space is needed. As a side effect, these patches will allow some nice optimizations in the future, like using jhash2 in nft_hash, removing the masking in nft_cmp_fast, optimized data comparison using 32 bit word size etc. These are not done so far however. The patches are split up as follows: * the first five patches add length validation to register loads and stores to make sure we stay within bounds and prepare the validation functions for the new addressing mode * the next patches prepare for changing to 32 bit addressing by introducing a struct nft_regs, which holds the verdict register as well as the data registers. The verdict members are moved to a new struct nft_verdict to allow to pull struct nft_data out of the stack. * the next patches contain preparatory conversions of expressions and sets to use 32 bit addressing * the next patch introduces so far unused register conversion helpers for parsing and dumping register numbers over netlink * following is the real conversion to 32 bit addressing, consisting of replacing struct nft_data in struct nft_regs by an array of u32s and actually translating and validating the new register numbers. * the final two patches add support for variable sized data items and variable sized keys / data in set elements The patches have been verified to work correctly with nft binaries using both old and new addressing. ==================== Patrick McHardy says: ==================== netfilter: nf_tables: dynamic stateful expression instantiation The following patches are the grand finale of my nf_tables set work, using all the building blocks put in place by the previous patches to support something like iptables hashlimit, but a lot more powerful. Sets are extended to allow attaching expressions to set elements. The dynset expression dynamically instantiates these expressions based on a template when creating new set elements and evaluates them for all new or updated set members. In combination with concatenations this effectively creates state tables for arbitrary combinations of keys, using the existing expression types to maintain that state. Regular set GC takes care of purging expired states. We currently support two different stateful expressions, counter and limit. Using limit as a template we can express the functionality of hashlimit, but completely unrestricted in the combination of keys. Using counter we can perform accounting for arbitrary flows. The following examples from patch 5/5 show some possibilities. Userspace syntax is still WIP, especially the listing of state tables will most likely be seperated from normal set listings and use a more structured format: 1. Limit the rate of new SSH connections per host, similar to iptables hashlimit: flow ip saddr timeout 60s \ limit 10/second \ accept 2. Account network traffic between each set of /24 networks: flow ip saddr & 255.255.255.0 . ip daddr & 255.255.255.0 \ counter 3. Account traffic to each host per user: flow skuid . ip daddr \ counter 4. Account traffic for each combination of source address and TCP flags: flow ip saddr . tcp flags \ counter The resulting set content after a Xmas-scan look like this: { 192.168.122.1 . fin | psh | urg : counter packets 1001 bytes 40040, 192.168.122.1 . ack : counter packets 74 bytes 3848, 192.168.122.1 . psh | ack : counter packets 35 bytes 3144 } In the future the "expressions attached to elements" will be extended to also support user created non-stateful expressions to allow to efficiently select beween a set of parameter sets, f.i. a set of log statements with different prefixes based on the interface, which currently require one rule each. This will most likely have to wait until the next kernel version though. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/uapi/linux')
-rw-r--r--include/uapi/linux/netfilter/nf_tables.h40
-rw-r--r--include/uapi/linux/netfilter_bridge/ebtables.h2
2 files changed, 39 insertions, 3 deletions
diff --git a/include/uapi/linux/netfilter/nf_tables.h b/include/uapi/linux/netfilter/nf_tables.h
index 05ee1e0804a3..5fa1cd04762e 100644
--- a/include/uapi/linux/netfilter/nf_tables.h
+++ b/include/uapi/linux/netfilter/nf_tables.h
@@ -5,16 +5,45 @@
5#define NFT_CHAIN_MAXNAMELEN 32 5#define NFT_CHAIN_MAXNAMELEN 32
6#define NFT_USERDATA_MAXLEN 256 6#define NFT_USERDATA_MAXLEN 256
7 7
8/**
9 * enum nft_registers - nf_tables registers
10 *
11 * nf_tables used to have five registers: a verdict register and four data
12 * registers of size 16. The data registers have been changed to 16 registers
13 * of size 4. For compatibility reasons, the NFT_REG_[1-4] registers still
14 * map to areas of size 16, the 4 byte registers are addressed using
15 * NFT_REG32_00 - NFT_REG32_15.
16 */
8enum nft_registers { 17enum nft_registers {
9 NFT_REG_VERDICT, 18 NFT_REG_VERDICT,
10 NFT_REG_1, 19 NFT_REG_1,
11 NFT_REG_2, 20 NFT_REG_2,
12 NFT_REG_3, 21 NFT_REG_3,
13 NFT_REG_4, 22 NFT_REG_4,
14 __NFT_REG_MAX 23 __NFT_REG_MAX,
24
25 NFT_REG32_00 = 8,
26 MFT_REG32_01,
27 NFT_REG32_02,
28 NFT_REG32_03,
29 NFT_REG32_04,
30 NFT_REG32_05,
31 NFT_REG32_06,
32 NFT_REG32_07,
33 NFT_REG32_08,
34 NFT_REG32_09,
35 NFT_REG32_10,
36 NFT_REG32_11,
37 NFT_REG32_12,
38 NFT_REG32_13,
39 NFT_REG32_14,
40 NFT_REG32_15,
15}; 41};
16#define NFT_REG_MAX (__NFT_REG_MAX - 1) 42#define NFT_REG_MAX (__NFT_REG_MAX - 1)
17 43
44#define NFT_REG_SIZE 16
45#define NFT_REG32_SIZE 4
46
18/** 47/**
19 * enum nft_verdicts - nf_tables internal verdicts 48 * enum nft_verdicts - nf_tables internal verdicts
20 * 49 *
@@ -209,6 +238,7 @@ enum nft_rule_compat_attributes {
209 * @NFT_SET_INTERVAL: set contains intervals 238 * @NFT_SET_INTERVAL: set contains intervals
210 * @NFT_SET_MAP: set is used as a dictionary 239 * @NFT_SET_MAP: set is used as a dictionary
211 * @NFT_SET_TIMEOUT: set uses timeouts 240 * @NFT_SET_TIMEOUT: set uses timeouts
241 * @NFT_SET_EVAL: set contains expressions for evaluation
212 */ 242 */
213enum nft_set_flags { 243enum nft_set_flags {
214 NFT_SET_ANONYMOUS = 0x1, 244 NFT_SET_ANONYMOUS = 0x1,
@@ -216,6 +246,7 @@ enum nft_set_flags {
216 NFT_SET_INTERVAL = 0x4, 246 NFT_SET_INTERVAL = 0x4,
217 NFT_SET_MAP = 0x8, 247 NFT_SET_MAP = 0x8,
218 NFT_SET_TIMEOUT = 0x10, 248 NFT_SET_TIMEOUT = 0x10,
249 NFT_SET_EVAL = 0x20,
219}; 250};
220 251
221/** 252/**
@@ -293,6 +324,7 @@ enum nft_set_elem_flags {
293 * @NFTA_SET_ELEM_TIMEOUT: timeout value (NLA_U64) 324 * @NFTA_SET_ELEM_TIMEOUT: timeout value (NLA_U64)
294 * @NFTA_SET_ELEM_EXPIRATION: expiration time (NLA_U64) 325 * @NFTA_SET_ELEM_EXPIRATION: expiration time (NLA_U64)
295 * @NFTA_SET_ELEM_USERDATA: user data (NLA_BINARY) 326 * @NFTA_SET_ELEM_USERDATA: user data (NLA_BINARY)
327 * @NFTA_SET_ELEM_EXPR: expression (NLA_NESTED: nft_expr_attributes)
296 */ 328 */
297enum nft_set_elem_attributes { 329enum nft_set_elem_attributes {
298 NFTA_SET_ELEM_UNSPEC, 330 NFTA_SET_ELEM_UNSPEC,
@@ -302,6 +334,7 @@ enum nft_set_elem_attributes {
302 NFTA_SET_ELEM_TIMEOUT, 334 NFTA_SET_ELEM_TIMEOUT,
303 NFTA_SET_ELEM_EXPIRATION, 335 NFTA_SET_ELEM_EXPIRATION,
304 NFTA_SET_ELEM_USERDATA, 336 NFTA_SET_ELEM_USERDATA,
337 NFTA_SET_ELEM_EXPR,
305 __NFTA_SET_ELEM_MAX 338 __NFTA_SET_ELEM_MAX
306}; 339};
307#define NFTA_SET_ELEM_MAX (__NFTA_SET_ELEM_MAX - 1) 340#define NFTA_SET_ELEM_MAX (__NFTA_SET_ELEM_MAX - 1)
@@ -359,6 +392,9 @@ enum nft_data_attributes {
359}; 392};
360#define NFTA_DATA_MAX (__NFTA_DATA_MAX - 1) 393#define NFTA_DATA_MAX (__NFTA_DATA_MAX - 1)
361 394
395/* Maximum length of a value */
396#define NFT_DATA_VALUE_MAXLEN 64
397
362/** 398/**
363 * enum nft_verdict_attributes - nf_tables verdict netlink attributes 399 * enum nft_verdict_attributes - nf_tables verdict netlink attributes
364 * 400 *
@@ -531,6 +567,7 @@ enum nft_dynset_ops {
531 * @NFTA_DYNSET_SREG_KEY: source register of the key (NLA_U32) 567 * @NFTA_DYNSET_SREG_KEY: source register of the key (NLA_U32)
532 * @NFTA_DYNSET_SREG_DATA: source register of the data (NLA_U32) 568 * @NFTA_DYNSET_SREG_DATA: source register of the data (NLA_U32)
533 * @NFTA_DYNSET_TIMEOUT: timeout value for the new element (NLA_U64) 569 * @NFTA_DYNSET_TIMEOUT: timeout value for the new element (NLA_U64)
570 * @NFTA_DYNSET_EXPR: expression (NLA_NESTED: nft_expr_attributes)
534 */ 571 */
535enum nft_dynset_attributes { 572enum nft_dynset_attributes {
536 NFTA_DYNSET_UNSPEC, 573 NFTA_DYNSET_UNSPEC,
@@ -540,6 +577,7 @@ enum nft_dynset_attributes {
540 NFTA_DYNSET_SREG_KEY, 577 NFTA_DYNSET_SREG_KEY,
541 NFTA_DYNSET_SREG_DATA, 578 NFTA_DYNSET_SREG_DATA,
542 NFTA_DYNSET_TIMEOUT, 579 NFTA_DYNSET_TIMEOUT,
580 NFTA_DYNSET_EXPR,
543 __NFTA_DYNSET_MAX, 581 __NFTA_DYNSET_MAX,
544}; 582};
545#define NFTA_DYNSET_MAX (__NFTA_DYNSET_MAX - 1) 583#define NFTA_DYNSET_MAX (__NFTA_DYNSET_MAX - 1)
diff --git a/include/uapi/linux/netfilter_bridge/ebtables.h b/include/uapi/linux/netfilter_bridge/ebtables.h
index ba993360dbe9..773dfe8924c7 100644
--- a/include/uapi/linux/netfilter_bridge/ebtables.h
+++ b/include/uapi/linux/netfilter_bridge/ebtables.h
@@ -12,9 +12,7 @@
12 12
13#ifndef _UAPI__LINUX_BRIDGE_EFF_H 13#ifndef _UAPI__LINUX_BRIDGE_EFF_H
14#define _UAPI__LINUX_BRIDGE_EFF_H 14#define _UAPI__LINUX_BRIDGE_EFF_H
15#include <linux/if.h>
16#include <linux/netfilter_bridge.h> 15#include <linux/netfilter_bridge.h>
17#include <linux/if_ether.h>
18 16
19#define EBT_TABLE_MAXNAMELEN 32 17#define EBT_TABLE_MAXNAMELEN 32
20#define EBT_CHAIN_MAXNAMELEN EBT_TABLE_MAXNAMELEN 18#define EBT_CHAIN_MAXNAMELEN EBT_TABLE_MAXNAMELEN