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 1434763 - Firewalld is unable to save rich rules that use icmp-type statements
Summary: Firewalld is unable to save rich rules that use icmp-type statements
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: firewalld
Version: 7.3
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Thomas Woerner
QA Contact: Tomas Dolezal
URL:
Whiteboard:
Depends On: 1434594
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-03-22 10:36 UTC by Thomas Woerner
Modified: 2017-08-01 16:22 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1434594
Environment:
Last Closed: 2017-08-01 16:22:56 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2017:1934 0 normal SHIPPED_LIVE firewalld bug fix and enhancement update 2017-08-01 17:55:15 UTC

Description Thomas Woerner 2017-03-22 10:36:33 UTC
+++ This bug was initially created as a clone of Bug #1434594 +++

Description of problem:
When creating rich rules that use icmp-type, I was unable to add rules for accepting router-advertisement and neighbor-solicitation packets (while still dropping all other unsolicited traffic) permanently. They are able to be added to the runtime set, but saving them causes errors in the log, and will hose the config for that zone on reload/reboot

Version-Release number of selected component (if applicable):
firewalld-0.4.4.3-2.fc25.noarch


How reproducible:
100%

Steps to Reproduce:
From the router:

[root@Router ~ ]# firewall-cmd --list-all
drop (active)
  target: DROP
  icmp-block-inversion: no
  interfaces: enp0s31f6
  sources: 
  services: dhcpv6-client
  ports: 
  protocols: 
  masquerade: yes
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules:

[root@Router ~]# ping6 google.com
PING google.com(ya-in-x64.1e100.net (2607:f8b0:4002:c03::64)) 56 data bytes
From Router.localdomain (fe80::be5f:f4ff:fe7b:6364%enp0s31f6) icmp_seq=1 Destination unreachable: Address unreachable
From Router.localdomain (fe80::be5f:f4ff:fe7b:6364%enp0s31f6) icmp_seq=2 Destination unreachable: Address unreachable
From Router.localdomain (fe80::be5f:f4ff:fe7b:6364%enp0s31f6) icmp_seq=3 Destination unreachable: Address unreachable

This is due to the firewall not accepting RA or neighbor solicitation packets, thus I add a firewall rule to work around it

[root@Router ~]# firewall-cmd --add-rich-rule='rule family="ipv6" icmp-type name="router-advertisement" accept'
success
[root@Router ~]# firewall-cmd --list-all
drop (active)
  target: DROP
  icmp-block-inversion: no
  interfaces: enp0s31f6
  sources: 
  services: dhcpv6-client
  ports: 
  protocols: 
  masquerade: yes
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 
        rule family="ipv6" icmp-type name="router-advertisement" accept

This all works great, however, if I then go to make it permanent...

[root@Router ~]# firewall-cmd --add-rich-rule='rule family="ipv6" icmp-type name="router-advertisement" accept' --permanent
success
[root@Router ~]# journalctl | tail
Mar 21 17:09:14 Router.localdomain dhcp6c[1112]: copyout_option: set identity association
Mar 21 17:09:14 Router.localdomain dhcp6c[1112]: copy_option: set rapid commit (len 0)
Mar 21 17:09:14 Router.localdomain dhcp6c[1112]: copy_option: set elapsed time (len 2)
Mar 21 17:09:14 Router.localdomain dhcp6c[1112]: copy_option: set option request (len 4)
Mar 21 17:09:14 Router.localdomain dhcp6c[1112]: copyout_option: set IA_PD
Mar 21 17:09:14 Router.localdomain dhcp6c[1112]: client6_send: send solicit to ff02::1:2%enp0s31f6
Mar 21 17:09:14 Router.localdomain dhcp6c[1112]: dhcp6_reset_timer: reset a timer on enp0s31f6, state=SOLICIT, timeo=20, retrans=121944
Mar 21 17:09:59 Router.localdomain audit: NETFILTER_CFG table=filter family=10 entries=164
Mar 21 17:10:58 Router.localdomain firewalld[834]: WARNING: Unknown element '<class 'firewall.core.rich.Rich_IcmpType'>'
Mar 21 17:11:03 Router.localdomain firewalld[834]: ERROR: Failed to load zone file 'drop.xml': INVALID_ZONE: not a valid zone file: not well-formed (invalid token): line 7, column 6

If we look at that file:
[root@Router ~]# cat /etc/firewalld/zones/drop.xml
<?xml version="1.0" encoding="utf-8"?>
<zone target="DROP">
  <short>Drop</short>
  <description>Unsolicited incoming network packets are dropped. Incoming packets that are related to outgoing network connections are accepted. Outgoing network connections are allowed.</description>
  <masquerade/>
  <rule family="ipv6">
    </>
    <accept/>
  </rule>
  <rule family="ipv6">
    </>
    <accept/>
  </rule>
</zone>

Yeah, that doesn't look right, and if we try now to reload:
[root@Router ~]# firewall-cmd --reload
success
[root@Router ~]# firewall-cmd --list-all
drop (active)
  target: DROP
  icmp-block-inversion: no
  interfaces: enp0s31f6
  sources: 
  services: 
  ports: 
  protocols: 
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules:

Blah, everything's gone. So, I attempt to re-add everything

[root@Router ~]# firewall-cmd --add-masquerade --permanent 
success
[root@Router ~]# firewall-cmd --add-masquerade
success
[root@Router ~]# firewall-cmd --add-service=dhcpv6-client 
success
[root@Router ~]# firewall-cmd --list-all
drop (active)
  target: DROP
  icmp-block-inversion: no
  interfaces: enp0s31f6
  sources: 
  services: 
  ports: 
  protocols: 
  masquerade: yes
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 

I can re-add the masquerade rule, and that reloads fine

[root@Router ~]# firewall-cmd --reload
success
[root@Router ~]# cat /etc/firewalld/zones/drop.xml
<?xml version="1.0" encoding="utf-8"?>
<zone target="DROP">
  <short>Drop</short>
  <description>Unsolicited incoming network packets are dropped. Incoming packets that are related to outgoing network connections are accepted. Outgoing network connections are allowed.</description>
  <masquerade/>
</zone>
[root@Router ~]# firewall-cmd --list-all
drop (active)
  target: DROP
  icmp-block-inversion: no
  interfaces: enp0s31f6
  sources: 
  services: 
  ports: 
  protocols: 
  masquerade: yes
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules:

So, stuck having to drop back to direct rules

Actual results:
Rules are not saved, all customizations to the zone have been destroyed, and firewalld informs me that the file for that zone is now corrupt

Expected results:
Firewalld being able to save rich rules involving icmp-types

Additional info:

--- Additional comment from Thomas Woerner on 2017-03-22 06:34:02 EDT ---

Fixed upstream: https://github.com/t-woerner/firewalld/commit/095bf9f3691bb6f45039b7e15ab61cc52ed32ced

Comment 4 Tomas Dolezal 2017-06-09 10:14:40 UTC
verified firewalld-0.4.4.4-5.el7

file saved, loaded, reapplied

<?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"/>
  <rule family="ipv6">
    <icmp-type name="router-advertisement"/>
    <accept/>
  </rule>
</zone>

Comment 5 errata-xmlrpc 2017-08-01 16:22:56 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/RHBA-2017:1934


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