Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
On systems using iptables-nft, the clients are much much slower when there are lots of iptables rules than on systems using iptables-legacy:
using legacy:
> for i in $(seq 1 30000); do iptables -A INPUT -s 10.1.$(($i / 256).$(($i % 256)) -j DROP; done
> time iptables-save > /dev/null
real 0m0.038s
user 0m0.020s
sys 0m0.018s
> time iptables -C INPUT -s 1.2.3.4 -j ACCEPT
iptables: Bad rule (does a matching rule exist in that chain?)
real 0m0.021s
user 0m0.006s
sys 0m0.015s
> time iptables -A INPUT -s 1.2.3.4 -j ACCEPT
real 0m0.021s
user 0m0.005s
sys 0m0.016s
> time iptables -t NAT -C PREROUTING -s 1.2.3.4 -j ACCEPT
iptables: Bad rule (does a matching rule exist in that chain?)
real 0m0.005s
user 0m0.002s
sys 0m0.003s
using nft (after rebooting and updating alternatives)
> for i in $(seq 1 30000); do iptables -A INPUT -s 10.1.$(($i / 256).$(($i % 256)) -j DROP; done
> time iptables-save > /dev/null
real 0m0.470s
user 0m0.117s
sys 0m0.348s
> time iptables -C INPUT -s 1.2.3.4 -j ACCEPT
iptables: Bad rule (does a matching rule exist in that chain?)
real 0m0.445s
user 0m0.102s
sys 0m0.340s
> time iptables -A INPUT -s 1.2.3.4 -j ACCEPT
real 0m0.414s
user 0m0.081s
sys 0m0.341s
> time iptables -t NAT -C PREROUTING -s 1.2.3.4 -j ACCEPT
iptables: Bad rule (does a matching rule exist in that chain?)
real 0m0.426s
user 0m0.081s
sys 0m0.341s
so, "iptables-save" is 10 times slower, and with iptables-nft, everything seems to take the same amount of time as "iptables-save". (And of particular note: iptables-legacy operations are only slow if the table they are operating on is large, whereas iptables-nft operations appear to be slow if *any* table is large.)
iptables 1.8.2 and iptables git master give similar results.
Hi Dan,
Thanks for your analysis. The problem is known and I'm currently working on
improving the situation. Due to how cache management works in iptables-nft (and
nftables), I fear we won't be able to get all use-cases on par with legacy
iptables. E.g. deleting a rule from a chain with many rules will always require
to fetch at least that chain with all its rules to perform the rule lookup. In
theory though, there should be no situation where iptables-nft can't be at
least close to legacy iptables performance-wise.
Cheers, Phil
(In reply to Phil Sutter from comment #1)
> I fear we won't be able to get all use-cases on par with legacy
> iptables. E.g. deleting a rule from a chain with many rules will always
> require to fetch at least that chain with all its rules
That would actually be a vast improvement over iptables-legacy, which always requires fetching all of the rules in the entire *table* you are operating on.
Hi Dan,
I consider this ticket resolved by iptables rebase to 1.8.4 which considerably
improved cache handling but would like to have your confirmation first. So
could you please give iptables-1.8.4-4.el8 a thorough test regarding
performance?
Thanks, Phil
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory, and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.
https://access.redhat.com/errata/RHEA-2020:1889
On systems using iptables-nft, the clients are much much slower when there are lots of iptables rules than on systems using iptables-legacy: using legacy: > for i in $(seq 1 30000); do iptables -A INPUT -s 10.1.$(($i / 256).$(($i % 256)) -j DROP; done > time iptables-save > /dev/null real 0m0.038s user 0m0.020s sys 0m0.018s > time iptables -C INPUT -s 1.2.3.4 -j ACCEPT iptables: Bad rule (does a matching rule exist in that chain?) real 0m0.021s user 0m0.006s sys 0m0.015s > time iptables -A INPUT -s 1.2.3.4 -j ACCEPT real 0m0.021s user 0m0.005s sys 0m0.016s > time iptables -t NAT -C PREROUTING -s 1.2.3.4 -j ACCEPT iptables: Bad rule (does a matching rule exist in that chain?) real 0m0.005s user 0m0.002s sys 0m0.003s using nft (after rebooting and updating alternatives) > for i in $(seq 1 30000); do iptables -A INPUT -s 10.1.$(($i / 256).$(($i % 256)) -j DROP; done > time iptables-save > /dev/null real 0m0.470s user 0m0.117s sys 0m0.348s > time iptables -C INPUT -s 1.2.3.4 -j ACCEPT iptables: Bad rule (does a matching rule exist in that chain?) real 0m0.445s user 0m0.102s sys 0m0.340s > time iptables -A INPUT -s 1.2.3.4 -j ACCEPT real 0m0.414s user 0m0.081s sys 0m0.341s > time iptables -t NAT -C PREROUTING -s 1.2.3.4 -j ACCEPT iptables: Bad rule (does a matching rule exist in that chain?) real 0m0.426s user 0m0.081s sys 0m0.341s so, "iptables-save" is 10 times slower, and with iptables-nft, everything seems to take the same amount of time as "iptables-save". (And of particular note: iptables-legacy operations are only slow if the table they are operating on is large, whereas iptables-nft operations appear to be slow if *any* table is large.) iptables 1.8.2 and iptables git master give similar results.