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.

Bug 2014383

Summary: Saving same ip in multiple zones by editing the file, followed by "firewall-cmd --reload" breaks the system connectivity.
Product: Red Hat Enterprise Linux 8 Reporter: Mithil Mhatre <mmhatre>
Component: firewalldAssignee: Eric Garver <egarver>
Status: CLOSED ERRATA QA Contact: Tomas Dolezal <todoleza>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 8.4CC: lassieee, todoleza
Target Milestone: rcKeywords: Triaged, Upstream
Target Release: ---Flags: pm-rhel: mirror+
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: firewalld-0.9.3-11.el8 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-10 15:24:43 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Mithil Mhatre 2021-10-15 06:10:42 UTC
Description of problem:

If same ip is mentioned in more than 1 zone by editing the zone files then "firewall-cmd --reload" command disconnects the system from the network.

Version-Release number of selected component (if applicable):

# cat /etc/redhat-release 
Red Hat Enterprise Linux release 8.4 (Ootpa)

# uname -r
4.18.0-305.el8.x86_64

# rpm -qa kernel
kernel-4.18.0-305.el8.x86_64

# rpm -qa firewalld
firewalld-0.8.2-6.el8.noarch

How reproducible:

Steps to Reproduce:

Mention same ip in more than 1 zone.

Below i have 2 zones public & test. Ip "1.1.1.1/32" is mentioned in both the zones by editing the file.

# cat public.xml
<?xml version="1.0" encoding="utf-8"?>
<zone>
  <short>Public</short>
  <description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>
  <service name="ssh"/>
  <service name="dhcpv6-client"/>
  <service name="cockpit"/>
  <source address="1.1.1.1/32"/>
</zone>


# cat test.xml 
<?xml version="1.0" encoding="utf-8"?>
<zone>
  <short>test</short>
  <description>test</description>
  <service name="ssh"/>
  <source address="1.1.1.1/32"/>
</zone>


Save the files and run "firewall-cmd --reload" command. It gives you below error message.


# firewall-cmd --reload 
Error: COMMAND_FAILED: 'python-nftables' failed: internal:0:0-0: Error: Could not process rule: No such file or directory

internal:0:0-0: Error: Could not process rule: No such file or directory

internal:0:0-0: Error: Could not process rule: No such file or directory

internal:0:0-0: Error: Could not process rule: No such file or directory

internal:0:0-0: Error: Could not process rule: No such file or directory

internal:0:0-0: Error: Could not process rule: No such file or directory

internal:0:0-0: Error: Could not process rule: No such file or directory

internal:0:0-0: Error: Could not process rule: No such file or directory

internal:0:0-0: Error: Could not process rule: No such file or directory


JSON blob:
{"nftables": [{"metainfo": {"json_schema_version": 1}}, {"insert": {"rule": {"family": "inet", "table": "firewalld", "chain": "raw_PREROUTING_ZONES", "expr": [{"match": {"left": {"meta": {"key": "iifname"}}, "op": "==", "right": "ens3"}}, {"goto": {"target": "raw_PRE_public"}}]}}}, {"insert": {"rule": {"family": "inet", "table": "firewalld", "chain": "mangle_PREROUTING_ZONES", "expr": [{"match": {"left": {"meta": {"key": "iifname"}}, "op": "==", "right": "ens3"}}, {"goto": {"target": "mangle_PRE_public"}}]}}}, {"insert": {"rule": {"family": "ip", "table": "firewalld", "chain": "nat_PREROUTING_ZONES", "expr": [{"match": {"left": {"meta": {"key": "iifname"}}, "op": "==", "right": "ens3"}}, {"goto": {"target": "nat_PRE_public"}}]}}}, {"insert": {"rule": {"family": "ip6", "table": "firewalld", "chain": "nat_PREROUTING_ZONES", "expr": [{"match": {"left": {"meta": {"key": "iifname"}}, "op": "==", "right": "ens3"}}, {"goto": {"target": "nat_PRE_public"}}]}}}, {"insert": {"rule": {"family": "ip", "table": "firewalld", "chain": "nat_POSTROUTING_ZONES", "expr": [{"match": {"left": {"meta": {"key": "oifname"}}, "op": "==", "right": "ens3"}}, {"goto": {"target": "nat_POST_public"}}]}}}, {"insert": {"rule": {"family": "ip6", "table": "firewalld", "chain": "nat_POSTROUTING_ZONES", "expr": [{"match": {"left": {"meta": {"key": "oifname"}}, "op": "==", "right": "ens3"}}, {"goto": {"target": "nat_POST_public"}}]}}}, {"insert": {"rule": {"family": "inet", "table": "firewalld", "chain": "filter_INPUT_ZONES", "expr": [{"match": {"left": {"meta": {"key": "iifname"}}, "op": "==", "right": "ens3"}}, {"goto": {"target": "filter_IN_public"}}]}}}, {"insert": {"rule": {"family": "inet", "table": "firewalld", "chain": "filter_FORWARD_IN_ZONES", "expr": [{"match": {"left": {"meta": {"key": "iifname"}}, "op": "==", "right": "ens3"}}, {"goto": {"target": "filter_FWDI_public"}}]}}}, {"insert": {"rule": {"family": "inet", "table": "firewalld", "chain": "filter_FORWARD_OUT_ZONES", "expr": [{"match": {"left": {"meta": {"key": "oifname"}}, "op": "==", "right": "ens3"}}, {"goto": {"target": "filter_FWDO_public"}}]}}}]}


NOTE:- You may not get the above error at first but running "firewall-cmd --reload" command twice or thrice will show you the above error. The connectivity to the system breaks completely, cannot ssh the system.

NOTE:- We are not talking here about adding source address via command, A command obviously gives an error. But in customer's environment many engineers works on firewall zones, So if someone adds an ip which is already set in some other zone and reload the firewalld the system gets cut off(cannot ssh) from the other systems in the network and customer had to login in the system from the console, search for the duplicate ip remove it and then reload the firewalld to bring the system back online.

NOTE:- If the issue does not get reproduced after running "firewall-cmd --reload" multiple time then reboot the system with the incorrect config. Afterwards if you boot with correct config and do the changes followed with the firewall reload you will see the error.

Actual results:

Gets the above long error and the systems gets cut off from the network.

Expected results:

Below are the expectation of how the firewalld should behave.

a) a proper error message instead of a very vague one (like the one you had yourself) that doesn't actually mention the fact that the same IP address has been found in >1 zones and that this is a bad thing
b) for firewalld not to "break" (with break I mean stop accepting any incoming connections and having to use the VMware console to clear the firewalld zones files)

Comment 1 Eric Garver 2021-10-15 11:58:50 UTC
> NOTE:- You may not get the above error at first but running "firewall-cmd --reload" command twice or thrice will show you the above error. The connectivity to the system breaks completely, cannot ssh the system.

The vague error is actually coming from nftables (it rejects the rule set update). Probably due to previous errors that didn't get addressed.

> b) for firewalld not to "break" (with break I mean stop accepting any incoming connections and having to use the VMware console to clear the firewalld zones files)

The configuration is invalid. What behavior would you like to see? Would an implicit configuration check upon --reload help (bug 1869451) ?

Ideally the user would only modify the config with the firewalld tools: firewall-cmd, firewall-offline-cmd. Manually editing the XML avoids all the configuration checks. Reloading firewalld can fail if the configuration is valid.

Comment 2 lassieee 2021-10-22 07:27:05 UTC
Hi, I am the customer that opened a support call at RedHat for this issue.
Thank you for looking into this.

Unfortunately, doing an implicit (or explicit for that matter) configuration check with 'firewall-cmd --check-config' does not help in the case of duplicate IP addresses:

>[root@localhost zones]# firewall-cmd --state
>running
>[root@localhost zones]# firewall-cmd --check-config
>success
>[root@localhost zones]# firewall-cmd --reload
>Error: COMMAND_FAILED: 'python-nftables' failed: internal:0:0-0: Error: Could not process rule: No such file or directory
>
>internal:0:0-0: Error: Could not process rule: No such file or directory
>
>internal:0:0-0: Error: Could not process rule: No such file or directory
>
>internal:0:0-0: Error: Could not process rule: No such file or directory
>
>internal:0:0-0: Error: Could not process rule: No such file or directory
>
>internal:0:0-0: Error: Could not process rule: No such file or directory
>
>internal:0:0-0: Error: Could not process rule: No such file or directory
>
>internal:0:0-0: Error: Could not process rule: No such file or directory
>
>internal:0:0-0: Error: Could not process rule: No such file or directory
>
>
>JSON blob:
>{"nftables": [{"metainfo": {"json_schema_version": 1}}, {"insert": {"rule": {"family": "inet", "table": "firewalld", "chain": "raw_PREROUTING_ZONES", "expr": [{"match": {"left": {"meta": {"key": "iifname"}}, "op": "==", "right": "enp0s7"}}, {"goto": {"target": "raw_PRE_pu
>blic"}}]}}}, {"insert": {"rule": {"family": "inet", "table": "firewalld", "chain": "mangle_PREROUTING_ZONES", "expr": [{"match": {"left": {"meta": {"key": "iifname"}}, "op": "==", "right": "enp0s7"}}, {"goto": {"target": "mangle_PRE_public"}}]}}}, {"insert": {"rule": {"family": "ip", "table": "firewalld", "chain": "nat_PREROUTING_ZONES", "expr": [{"match": {"left": {"meta": {"key": "iifname"}}, "op": "==", "right": "enp0s7"}}, {"goto": {"target": "nat_PRE_public"}}]}}}, {"insert": {"rule": {"family": "ip6", "table": "firewalld", "chain": "nat_PREROUTING_ZONES", "expr": [{"match": {"left": {"meta": {"key": "iifname"}}, "op": "==", "right": "enp0s7"}}, {"goto": {"target": "nat_PRE_public"}}]}}}, {"insert": {"rule": {"family": "ip", "table": "firewalld", "chain": "nat_POSTROUTING_ZONES", "expr": [{"match": {"left": {"meta": {"key": "oifname"}}, "op": "==", "right": "enp0s7"}}, {"goto": {"target": "nat_POST_public"}}]}}}, {"insert": {"rule": {"family": "ip6", "table": "firewalld", "chain": "nat_POSTROUTING_ZONES", "expr": [{"match": {"left": {"meta": {"key": "oifname"}}, "op": "==", "right": "enp0s7"}}, {"goto": {"target": "nat_POST_public"}}]}}}, {"insert": {"rule": {"family": "inet", "table": "firewalld", "chain": "filter_INPUT_ZONES", "expr": [{"match": {"left": {"meta": {"key": "iifname"}}, "op": "==", "right": "enp0s7"}}, {"goto": {"target": "filter_IN_public"}}]}}}, {"insert": {"rule": {"family": "inet", "table": "firewalld", "chain": "filter_FORWARD_IN_ZONES", "expr": [{"match": {"left": {"meta": {"key": "iifname"}}, "op": "==", "right": "enp0s7"}}, {"goto": {"target": "filter_FWDI_public"}}]}}}, {"insert": {"rule": {"family": "inet", "table": "firewalld", "chain": "filter_FORWARD_OUT_ZONES", "expr": [{"match": {"left": {"meta": {"key": "oifname"}}, "op": "==", "right": "enp0s7"}}, {"goto": {"target": "filter_FWDO_public"}}]}}}]}
>[root@localhost zones]#

When there is a duplicate IP, doing a 'firewall-cmd '--reload gives the error mentioned above. Doing another 'firewall-cmd --reload' results in the machine being inaccessible, so I have to use the console to remove the duplicate IP and reload firewalld to get firewalld functional again. Added a duplicate IP and reloading firewalld again does not show the error and the machine immediately looses the connection.

After rebooting the machine, with a valid firewalld config, I can do a 'firewall-cmd --reload' once again without firewalld breaking (giving above error but still functioning), but after issuing another 'firewall-cmd --reload', it breaks, rendering the machine inaccessible. So basically after a reboot it's possible to reload firewalld once without breaking, this seems a bit strange.

I think the main issue here is that there currently is no proper way to determine if the firewalld config is valid (e.g. no duplicate IP addresses) using firewalld tools, like e.g. 'firewall-cmd --check-config'. We use ansible to create a new directory where we copy all our XML zone files and do "/usr/bin/grep -H -o '<source address=[^>]*>' /etc/firewalld-check/zones/*.xml | /usr/bin/sort -t: -k2 -k1 | /usr/bin/tr ':' ' ' | /usr/bin/uniq -D -f1" to find any duplicate IP addresses.

Kind regards,
Casper

Comment 3 Eric Garver 2021-10-25 13:25:18 UTC
(In reply to lassieee from comment #2)
> Hi, I am the customer that opened a support call at RedHat for this issue.
> Thank you for looking into this.
> 
> Unfortunately, doing an implicit (or explicit for that matter) configuration
> check with 'firewall-cmd --check-config' does not help in the case of
> duplicate IP addresses:

Then `--check-config` needs to be enhanced to detect this scenario.

Comment 4 Eric Garver 2021-10-27 19:50:01 UTC
Upstream commits:

6f68d295ac5e ("test(zone): detect same source/interface in zones")
4b721abb087a ("fix(zone): detect same source/interface in zones")
35d4facc8962 ("fix(io/functions): check_config against on disk conf")
3aec1dfe449d ("fix(fw_config): zone: on rename remove then add")

Comment 13 errata-xmlrpc 2022-05-10 15:24:43 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 (firewalld bug fix and enhancement update), 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/RHBA-2022:2063