Skip to content

Speed up restoring huge rulesets

Phil Sutter netfilter-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 3 repliesIn review

Changes since RFC from the cover letter

- Introduce patch 1 to catch the only real issue
- Slight performance drop with nft due to the kept standard target check
- Update commit messages

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3nft: Reject standard targets as chain names when restoringiptables/xshared.c iptables/xshared.h iptables/xtables-restore.c+4 -71 reply
2/3libxtables: Implement notargets hash tablelibxtables/xtables.c+75 -01 reply
3/3libxtables: Boost rule target checks by announcing chain namesinclude/xtables.h iptables/iptables-restore.c iptables/xtables-restore.c +1 more+11 -01 reply

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchFlorian Westphal
1/3R-b
2/3A-b
3/3A-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/3] Speed up restoring huge rulesets

The largest penalty when restoring a large ruleset is checking for whether a given target name is a chain or extension. Patch 2 adds a cache to libxtables for failed extension lookups so consecutive ones (e.g. multiple rules jumping to the same chain) are fast.

If a ruleset contains many user-defined chains, there is still a significant slow-down due to the single extension lookup which remains. Patch 3 introduces an announcement mechanism, implying that a chain line in a dump file is never a target.

Testing my OCP ruleset (50k chains, 130k rules, 90k chain jumps) again:

variant before after
-------------------------------------
legacy 1m31s 2.6s
nft 1m47s 13s

The performance gain is large enough to justify the lost warning if a chain name clashes with a non-standard target. The only case which was forbidden before, namely a clash with standard target (DROP, ACCEPT, etc.) is still caught due to patch 1 of this series.

Changes since RFC:
- Introduce patch 1 to catch the only real issue
- Slight performance drop with nft due to the kept standard target check
- Update commit messages

Phil Sutter (3):
nft: Reject standard targets as chain names when restoring
libxtables: Implement notargets hash table
libxtables: Boost rule target checks by announcing chain names

 include/xtables.h           |  3 ++
 iptables/iptables-restore.c |  1 +
 iptables/xshared.c          |  4 +-
 iptables/xshared.h          |  2 +-
 iptables/xtables-restore.c  |  6 +--
 libxtables/xtables.c        | 81 +++++++++++++++++++++++++++++++++++++
 6 files changed, 90 insertions(+), 7 deletions(-)
Signature · 1 line
2.34.1