History

netfilter: nft_dynset: allow to invert match criteria

The dynset expression matches if we can fit a new entry into the set. If there is no room for it, then it breaks the rule evaluation. This patch introduces the inversion flag so you can add rules to explicitly drop packets that don't fit into the set. For example: # nft filter input flow table xyz size 4 { ip saddr timeout 120s counter } overflow drop This is useful to provide a replacement for connlimit. For the rule above, every new entry uses the IPv4 address as key in the set, this entry gets a timeout of 120 seconds that gets refresh on every packet seen. If we get new flow and our set already contains 4 entries already, then this packet is dropped. You can already express this in positive logic, assuming default policy to drop: # nft filter input flow table xyz size 4 { ip saddr timeout 10s counter } accept

Pablo Neira Ayuso committed 10 years ago

Commit dbd2be01 parent 70ca7672 files · +25 −1Browse files

Showing the changes to include/uapi (1 of 2 files). Show all

Unified · Split

include/uapi/linux/netfilter/nf_tables.h+6−0
@@ -575,6 +575,10 @@ enum nft_dynset_ops { · 574 unmodified lines
575575 NFT_DYNSET_OP_UPDATE,
576576 };
577577
578+enum nft_dynset_flags {
579+ NFT_DYNSET_F_INV = (1 << 0),
580+};
581+
578582 /**
579583 * enum nft_dynset_attributes - dynset expression attributes
580584 *
@@ -585,6 +589,7 @@ enum nft_dynset_ops { · 4 unmodified lines
585589 * @NFTA_DYNSET_SREG_DATA: source register of the data (NLA_U32)
586590 * @NFTA_DYNSET_TIMEOUT: timeout value for the new element (NLA_U64)
587591 * @NFTA_DYNSET_EXPR: expression (NLA_NESTED: nft_expr_attributes)
592+ * @NFTA_DYNSET_FLAGS: flags (NLA_U32)
588593 */
589594 enum nft_dynset_attributes {
590595 NFTA_DYNSET_UNSPEC,
@@ -596,6 +601,7 @@ enum nft_dynset_attributes { · 5 unmodified lines
596601 NFTA_DYNSET_TIMEOUT,
597602 NFTA_DYNSET_EXPR,
598603 NFTA_DYNSET_PAD,
604+ NFTA_DYNSET_FLAGS,
599605 __NFTA_DYNSET_MAX,
600606 };
601607 #define NFTA_DYNSET_MAX (__NFTA_DYNSET_MAX - 1)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t