]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit
netfilter: nft_dynset: allow to invert match criteria
authorPablo Neira Ayuso <pablo@netfilter.org>
Wed, 7 Sep 2016 10:22:18 +0000 (12:22 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 12 Sep 2016 16:49:50 +0000 (18:49 +0200)
commitdbd2be0646e3239022630c426cbceefa15714bca
treef3e2edf1b08504893250595b00df4c3681d2c2bb
parent70ca767ea1b2748f45e96192400e515dddbe517c
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

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/uapi/linux/netfilter/nf_tables.h
net/netfilter/nft_dynset.c