]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit - net/netfilter/nf_tables_api.c
netfilter: nf_tables: Speed up selective rule dumps
authorPhil Sutter <phil@nwl.cc>
Wed, 12 Dec 2018 18:29:07 +0000 (19:29 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 17 Dec 2018 23:08:53 +0000 (00:08 +0100)
commit241faeceb849cb02c6439ecb2a08f14bf409dd30
tree199d846826be431d90c87a668025298caf9ada42
parent8294059931448aa1ca112615bdffa3eab552c382
netfilter: nf_tables: Speed up selective rule dumps

If just a table name was given, nf_tables_dump_rules() continued over
the list of tables even after a match was found. The simple fix is to
exit the loop if it reached the bottom and ctx->table was not NULL.

When iterating over the table's chains, the same problem as above
existed. But worse than that, if a chain name was given the hash table
wasn't used to find the corresponding chain. Fix this by introducing a
helper function iterating over a chain's rules (and taking care of the
cb->args handling), then introduce a shortcut to it if a chain name was
given.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_tables_api.c