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.
Bug 1744634 - TestOnly: iptables-nft clients are much slower than iptables-legacy clients
Summary: TestOnly: iptables-nft clients are much slower than iptables-legacy clients
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: iptables
Version: ---
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: rc
: 8.2
Assignee: Phil Sutter
QA Contact: Tomas Dolezal
URL:
Whiteboard:
: 1707714 (view as bug list)
Depends On:
Blocks: 1738635 1755139
TreeView+ depends on / blocked
 
Reported: 2019-08-22 15:21 UTC by Dan Winship
Modified: 2023-06-26 15:12 UTC (History)
6 users (show)

Fixed In Version: iptables-1.8.4-4.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-04-28 17:00:25 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-26690 0 None None None 2023-06-26 15:12:53 UTC
Red Hat Product Errata RHEA-2020:1889 0 None None None 2020-04-28 17:00:45 UTC

Description Dan Winship 2019-08-22 15:21:31 UTC
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.

Comment 1 Phil Sutter 2019-08-26 17:15:47 UTC
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

Comment 2 Dan Winship 2019-08-26 17:37:14 UTC
(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.

Comment 4 Phil Sutter 2019-12-05 10:09:32 UTC
*** Bug 1707714 has been marked as a duplicate of this bug. ***

Comment 5 Phil Sutter 2019-12-05 10:12:41 UTC
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

Comment 6 Dan Winship 2019-12-06 15:32:07 UTC
FTR I hadn't actually done any testing beyond what's in comment 0, but I can retry that

Comment 7 Phil Sutter 2019-12-06 17:29:21 UTC
(In reply to Dan Winship from comment #6)
> FTR I hadn't actually done any testing beyond what's in comment 0, but I can
> retry that

OK, thanks!

Comment 13 Jean-Mickael Guerin 2020-03-25 08:00:26 UTC
Dan, please which command was used to update alternatives and test with iptables-legacy ?

Comment 14 Dan Winship 2020-03-25 12:51:30 UTC
There are no iptables-legacy packages in RHEL 8; I was testing on Fedora

Comment 16 errata-xmlrpc 2020-04-28 17:00:25 UTC
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


Note You need to log in before you can comment on or make changes to this bug.