]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit - net/netfilter/nf_tables_api.c
netfilter: nf_tables: meter: pick a set backend that supports updates
authorFlorian Westphal <fw@strlen.de>
Wed, 14 Mar 2018 12:37:58 +0000 (13:37 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 20 Mar 2018 12:52:10 +0000 (13:52 +0100)
commit4f2921ca21b71a9faaecd84a9fc74401d3a8d275
treee3c2affba1eb701a8bedd90df150bd22034286fa
parent36fe095606f881e6a3c7f9283c986aec6083f3e6
netfilter: nf_tables: meter: pick a set backend that supports updates

in nftables, 'meter' can be used to instantiate a hash-table at run
time:

rule add filter forward iif "internal" meter hostacct { ip saddr counter}
nft list meter ip filter hostacct
table ip filter {
  meter hostacct {
    type ipv4_addr
    elements = { 192.168.0.1 : counter packets 8 bytes 2672, ..

because elemets get added on the fly, the kernel must chose a set
backend type that implements the ->update() function, otherwise
rule insertion fails with EOPNOTSUPP.

Therefore, skip set types that lack ->update, and also
make sure we do not discard a (bad) candidate when we did yet
find any candidate at all.  This could happen when userspace prefers
low memory footprint -- the set implementation currently checked might
not be a fit at all.  Make sure we pick it anyway (!bops).  In
case next candidate is a better fix, it will be chosen instead.

But in case nothing else is found we at least have a non-ideal
match rather than no match at all.

Fixes: 6c03ae210ce3 ("netfilter: nft_set_hash: add non-resizable hashtable implementation")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_tables_api.c
net/netfilter/nft_set_hash.c