Bug 1434594

Summary: Firewalld is unable to save rich rules that use icmp-type statements
Product: [Fedora] Fedora Reporter: Sean Pryor <spryor>
Component: firewalldAssignee: Eric Garver <egarver>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 25CC: spryor, twoerner, vcojot
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1434763 (view as bug list) Environment:
Last Closed: 2017-12-12 10:40:06 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:
Bug Depends On:    
Bug Blocks: 1434763    

Description Sean Pryor 2017-03-21 21:24:34 UTC
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:

Comment 2 Sean Pryor 2017-03-22 14:50:22 UTC
Applied fix from upstream, can confirm it resolves the issue

Comment 3 Fedora End Of Life 2017-11-16 18:38:54 UTC
This message is a reminder that Fedora 25 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 25. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '25'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 25 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 4 Fedora End Of Life 2017-12-12 10:40:06 UTC
Fedora 25 changed to end-of-life (EOL) status on 2017-12-12. Fedora 25 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.