Skip to content

Speed up iptables-nft-save

Phil Sutter netfilter-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4nft: Simplify immediate parsingiptables/nft-arp.c iptables/nft-bridge.c iptables/nft-ipv4.c +3 more+14 -471 reply
2/4nft: Speed up immediate parsingiptables/nft-bridge.c iptables/nft-shared.c+19 -190 replies
3/4xshared: Prefer xtables_chain_protos lookup over getprotoentiptables/xshared.c libxtables/xtables.c+10 -173 replies
4/4nft: Don't pass command state opaque to family ops callbacksiptables/nft-arp.c iptables/nft-bridge.c iptables/nft-ipv4.c +5 more+84 -1021 reply

Reviews trailers per patch

3 of 4 patches have a Reviewed-by or Acked-by.

PatchFlorian Westphal
1/4R-b
2/4
3/4A-b
4/4A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [iptables PATCH 0/4] Speed up iptables-nft-save

OpenShift tends to create huge rulesets[*] and consequently wonders why iptables is slow. Anyway, iptables-nft-save really does odd things:

* For each jump target, it checks if such extension exists, despite already knowing whether the target is a chain or not. This is solved in patch 2, with patch 1 preparing nft_parse_immediate() to make the change simpler.

* Every l4proto match causes a call to getprotobynumber() which in turn opens /etc/protocols. One could cache the lookups, but preferring the builtin fallback list of protocol names and numbers is much simpler. Do that in patch 3, aligning said list with /etc/protocols to not change output unexpectedly.

[*] I have a "real-life" dump adding 50k chains and 130k rules. Dumping
it to /dev/null took 45s on my testing VM, with these patches applied I'm down to 2.7s.

The last patch is fallout from the above, simplifying family ops callbacks a bit given that there is only a single *tables_command_state struct left.

Phil Sutter (4):
nft: Simplify immediate parsing
nft: Speed up immediate parsing
xshared: Prefer xtables_chain_protos lookup over getprotoent
nft: Don't pass command state opaque to family ops callbacks

 iptables/nft-arp.c    | 32 ++++++------------
 iptables/nft-bridge.c | 55 +++++++++++++------------------
 iptables/nft-ipv4.c   | 40 ++++++++---------------
 iptables/nft-ipv6.c   | 40 ++++++++---------------
 iptables/nft-shared.c | 75 ++++++++++++++++++++-----------------------
 iptables/nft-shared.h | 35 ++++++++++----------
 iptables/nft.c        |  4 +--
 iptables/nft.h        |  2 +-
 iptables/xshared.c    |  8 ++---
 libxtables/xtables.c  | 19 ++++-------
 10 files changed, 126 insertions(+), 184 deletions(-)
Signature · 1 line
2.34.1