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 1664829 - iptables-restore: -F and -Z on same table yields RULE_REPLACE error
Summary: iptables-restore: -F and -Z on same table yields RULE_REPLACE error
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: iptables
Version: 8.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: rc
: 8.0
Assignee: Phil Sutter
QA Contact: Robin Hack
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-01-09 18:09 UTC by Eric Garver
Modified: 2019-06-14 00:45 UTC (History)
4 users (show)

Fixed In Version: iptables-1.8.2-6.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-06-14 00:45:56 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
reproducer (178 bytes, text/plain)
2019-01-09 18:09 UTC, Eric Garver
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Debian BTS 914694 0 None None None 2019-01-09 18:09:02 UTC

Description Eric Garver 2019-01-09 18:09:02 UTC
Created attachment 1519544 [details]
reproducer

When using -F and -Z on the same table you get a RULE_REPLACE error. Presumably this is due to the counter zero. Separately they are fine.

# for I in `seq 20`; do sh /tmp/iptables-restore-flush-and-zero.sh || break; done                                                                                               
iptables-restore v1.8.2 (nf_tables): 
line 3: RULE_REPLACE failed (No such file or directory): rule in chain INPUT

# sed 's/-Z//' /tmp/iptables-restore-flush-and-zero.sh > /tmp/iptables-restore-flush.sh

# for I in `seq 20`; do sh /tmp/iptables-restore-flush.sh || break; done
*** no error ***

Comment 1 Eric Garver 2019-01-09 18:58:18 UTC
Oddly, I cannot reproduce this inside of a namespace. Which explains why it wasn't caught by firewalld's testsuite.

I'm bumping severity/priority, as this effectively breaks firewalld in the init namespace.

# ip netns add foobar
# ip netns exec foobar bash
# sh /tmp/iptables-restore-flush-and-zero.sh
** no error **
[root@rhel8 ~]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

Chain INPUT_direct (0 references)
target     prot opt source               destination

Comment 7 Phil Sutter 2019-01-16 13:04:02 UTC
I can't reproduce the issue using upstream iptables and libnftnl on a RHEL8 machine, but I can reproduce it on my testing VM (with very recent upstream kernel) and RHEL8 iptables. Git bisect identified the following upstream commit fixed the problem:

commit 947c51c95edbbf08d6b3c105177ac5cfa238aade
Author: Phil Sutter <phil>
Date:   Thu Dec 20 16:09:12 2018 +0100

    xtables: Implement per chain rule cache
    
    Use recently introduced support for rules inside chains in libnftnl to
    introduce a rule cache per chain instead of a global one.
    
    A tricky bit is to decide if cache should be updated or not. Previously,
    the global rule cache was populated just once and then reused unless
    being flushed completely (via call to flush_rule_cache() with
    NULL-pointer table argument). Resemble this behaviour by introducing a
    boolean indicating cache status and fetch rules for all chains when
    updating the chain cache in nft_chain_list_get().
    
    Signed-off-by: Phil Sutter <phil>
    Signed-off-by: Pablo Neira Ayuso <pablo>

This commit will be backported on behalf of bug 1647925, too.


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