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 1917766

Summary: firewalld with nftables while processing rich rules fails to parse ipv4 address if specified with netmask
Product: Red Hat Enterprise Linux 8 Reporter: Rastislav Hepner <rhepner>
Component: firewalldAssignee: Eric Garver <egarver>
Status: CLOSED ERRATA QA Contact: qe-baseos-daemons
Severity: medium Docs Contact:
Priority: medium    
Version: 8.4CC: jangerrit.kootstra, jmaxwell, mcolombo, sukulkar, todoleza
Target Milestone: rcKeywords: Triaged, Upstream
Target Release: 8.6Flags: 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:
Bug Depends On:    
Bug Blocks: 2006093, 2026666    

Description Rastislav Hepner 2021-01-19 11:17:54 UTC
Description of problem:

firewalld with nftables while processing rich rules fails to parse ipv4 address if specified with netmask 

iptables backend works as expected 

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


How reproducible:
Always 

Steps to Reproduce:

use following zone config file and restart firewalld

cat /etc/firewalld/zones/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"/>
  <rule family="ipv4">
    <source address="192.168.0.1/255.255.255.240"/>
    <protocol value="tcp"/>
    <accept/>
  </rule>
</zone>


Actual results:

Error is generated and subsequently nft table inet firewalld rulesets are not populated with rules. 

table inet firewalld {
}
table ip firewalld {
}
table ip6 firewalld {
}


Expected results:

No errors and rules are applied in nft table inet firewalld

Additional info:

error log suggesting parsing problem in nftables.py. My understanding is that we are missing logic which could digest ipv4 specified in IP/NETMASK format as specified in man page firewalld.zone->option rule.

2021-01-19 12:02:32 DEBUG1: Applying used zones
2021-01-19 12:02:32 DEBUG1: Applying zone 'block'
2021-01-19 12:02:32 DEBUG1: Applying zone 'dmz'
2021-01-19 12:02:32 DEBUG1: Applying zone 'drop'
2021-01-19 12:02:32 DEBUG1: Applying zone 'external'
2021-01-19 12:02:32 DEBUG1: Applying zone 'home'
2021-01-19 12:02:32 DEBUG1: Applying zone 'internal'
2021-01-19 12:02:32 DEBUG1: Applying zone 'public'
2021-01-19 12:02:32 DEBUG1: Applying zone 'trusted'
2021-01-19 12:02:32 DEBUG1: Applying zone 'work'
2021-01-19 12:02:32 DEBUG1: Setting policy to 'ACCEPT'
2021-01-19 12:02:32 DEBUG1: Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/firewall/server/decorators.py", line 53, in handle_exceptions
    return func(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/firewall/server/firewalld.py", line 94, in start
    return self.fw.start()
  File "/usr/lib/python3.6/site-packages/firewall/core/fw.py", line 479, in start
    self._start()
  File "/usr/lib/python3.6/site-packages/firewall/core/fw.py", line 447, in _start
    use_transaction=transaction)
  File "/usr/lib/python3.6/site-packages/firewall/core/fw_zone.py", line 460, in change_default_zone
    self.apply_zone_settings(new_zone, transaction)
  File "/usr/lib/python3.6/site-packages/firewall/core/fw_zone.py", line 339, in apply_zone_settings
    self.__zone_settings(True, zone, use_transaction)
  File "/usr/lib/python3.6/site-packages/firewall/core/fw_zone.py", line 319, in __zone_settings
    transaction)
  File "/usr/lib/python3.6/site-packages/firewall/core/fw_zone.py", line 661, in __rule
    self._rule_prepare(enable, zone, rule, transaction)
  File "/usr/lib/python3.6/site-packages/firewall/core/fw_zone.py", line 1648, in _rule_prepare
    enable, zone, protocol, None, rule)
  File "/usr/lib/python3.6/site-packages/firewall/core/nftables.py", line 1173, in build_zone_protocol_rules
    expr_fragments.append(self._rich_rule_source_fragment(rich_rule.source))
  File "/usr/lib/python3.6/site-packages/firewall/core/nftables.py", line 1114, in _rich_rule_source_fragment
    return self._rule_addr_fragment("saddr", address, invert=rich_source.invert)
  File "/usr/lib/python3.6/site-packages/firewall/core/nftables.py", line 1073, in _rule_addr_fragment
    address = {"prefix": {"addr": addr_len[0], "len": int(addr_len[1])}}
ValueError: invalid literal for int() with base 10: '255.255.255.240'

Comment 1 Rastislav Hepner 2021-01-19 11:25:48 UTC
workaround is either to use iptables as backend or substitute netmask with prefix in ip address definition.

Comment 3 sushil kulkarni 2021-04-22 13:26:04 UTC
Dropping from the RPL based on votes (see Devel Whiteboard)

Comment 4 Eric Garver 2021-09-15 19:11:33 UTC
upstream:

e635bdffa630 ("test(zone): source with netmask")
9e9f94061b12 ("test(rich): source address with netmask")
3809fef17dc7 ("fix(nftables): rich: source address with netmask")

Comment 9 ir. Jan Gerrit Kootstra 2021-11-30 09:39:46 UTC
When will the rpm be released?

We have been waiting for the update since january this year (2021).

Comment 10 Eric Garver 2021-11-30 13:40:27 UTC
(In reply to ir. Jan Gerrit Kootstra from comment #9)
> When will the rpm be released?

The current target release is RHEL-8.6.0. This bug is currently on track.

Comment 17 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