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 1816612 - support converting host format to subnet format in route-rules config
Summary: support converting host format to subnet format in route-rules config
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: nmstate
Version: 8.2
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: rc
: 8.3
Assignee: Gris Ge
QA Contact: Mingyu Shi
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-03-24 11:30 UTC by Mingyu Shi
Modified: 2020-11-04 03:10 UTC (History)
5 users (show)

Fixed In Version: nmstate-0.3.2-4.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-11-04 03:08:25 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
verified.log (5.25 KB, text/plain)
2020-07-10 07:33 UTC, Mingyu Shi
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Github nmstate nmstate pull 1127 0 None closed ip: canonicalize IP address 2020-08-27 16:29:43 UTC
Red Hat Product Errata RHBA-2020:4696 0 None None None 2020-11-04 03:08:42 UTC

Description Mingyu Shi 2020-03-24 11:30:55 UTC
Description of problem:
When set routing rules like "ip-from: 24.4.4.4/24", it will report error:
  File "/usr/lib64/python3.6/ipaddress.py", line 1519, in __init__
    raise ValueError('%s has host bits set' % self)
ValueError: 24.4.4.4/24 has host bits set
Please do it like what route-config does, to convert it to 24.4.4.0/24 according to subnet mask automatically.

Version-Release number of selected component (if applicable):
nmstate-0.2.6-4.8.el8.noarch
NetworkManager-1.22.8-4.el8.x86_64
DISTRO=RHEL-8.2.0-20200319.n.1
Linux hp-dl388g8-04.rhts.eng.pek2.redhat.com 4.18.0-190.el8.x86_64 #1 SMP Wed Mar 18 09:34:40 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

How reproducible:
100%

Steps to Reproduce:
1.# cat veth0-route.yaml 
---
interfaces:
  - name: veth0
    type: ethernet
    state: up
    ipv4:
      address:
      - ip: 4.4.4.4
        prefix-length: 24
      enabled: true
route-rules:
  config:
  - ip-to: 14.4.4.4/24
    priority: 4
    route-table: 4
  - ip-from: 24.4.4.4/24
    priority: 4
    route-table: 4
routes:
  config:
  - destination: 34.4.4.4/24
    metric: 4
    next-hop-address: 4.4.4.1
    next-hop-interface: veth0
    table-id: 4

2. nmstatectl set veth0-route.yaml
3.

Actual results:
Traceback (most recent call last):
  File "/usr/bin/nmstatectl", line 11, in <module>
    load_entry_point('nmstate==0.2.6', 'console_scripts', 'nmstatectl')()
  File "/usr/lib/python3.6/site-packages/nmstatectl/nmstatectl.py", line 59, in main
    return args.func(args)
  File "/usr/lib/python3.6/site-packages/nmstatectl/nmstatectl.py", line 217, in apply
    statedata, args.verify, args.commit, args.timeout
  File "/usr/lib/python3.6/site-packages/nmstatectl/nmstatectl.py", line 241, in apply_state
    rollback_timeout=timeout,
  File "/usr/lib/python3.6/site-packages/libnmstate/deprecation.py", line 40, in wrapper
    return func(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/libnmstate/nm/nmclient.py", line 98, in wrapped
    ret = func(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/libnmstate/netapplier.py", line 70, in apply
    state.State(desired_state), verify_change, commit, rollback_timeout
  File "/usr/lib/python3.6/site-packages/libnmstate/netapplier.py", line 156, in _apply_ifaces_state
    state2edit, original_desired_state
  File "/usr/lib/python3.6/site-packages/libnmstate/netapplier.py", line 249, in _edit_interfaces
    iface2prepare + proxy_ifaces, original_desired_state
  File "/usr/lib/python3.6/site-packages/libnmstate/nm/applier.py", line 124, in prepare_edited_ifaces_configuration
    original_desired_iface_state=original_desired_iface_state,
  File "/usr/lib/python3.6/site-packages/libnmstate/nm/applier.py", line 404, in _build_connection_profile
    iface_desired_state.get(Interface.IPV4), base_profile
  File "/usr/lib/python3.6/site-packages/libnmstate/nm/ipv4.py", line 85, in create_setting
    config.get(nm_route.ROUTE_RULES_METADATA, []),
  File "/usr/lib/python3.6/site-packages/libnmstate/nm/route.py", line 262, in add_route_rules
    setting_ip.add_routing_rule(_rule_info_to_nm_rule(rule, family))
  File "/usr/lib/python3.6/site-packages/libnmstate/nm/route.py", line 275, in _rule_info_to_nm_rule
    nm_rule.set_from(*iplib.ip_address_full_to_tuple(ip_from))
  File "/usr/lib/python3.6/site-packages/libnmstate/iplib.py", line 50, in ip_address_full_to_tuple
    net = ipaddress.ip_network(addr)
  File "/usr/lib64/python3.6/ipaddress.py", line 74, in ip_network
    return IPv4Network(address, strict)
  File "/usr/lib64/python3.6/ipaddress.py", line 1519, in __init__
    raise ValueError('%s has host bits set' % self)
ValueError: 24.4.4.4/24 has host bits set

Expected results:
Success

Additional info:
nmcli and iproute2 util can deal with it well:
nmcli ipv4> set routing-rules priority 1000 to 100.1.1.1/24 table 50, priority 1001 from 100.9.9.9/24 table 50
nmcli ipv4> save
Connection 'dummy0' (f18985b8-0c57-42d8-b115-993b5d9bbc10) successfully updated.
[19:09:12@hp-dl388g8-04 ~]1# nmcli connection up dummy0
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/896)
[19:09:14@hp-dl388g8-04 ~]0# ip rule | grep 100
1000:	from all to 100.1.1.1/24 lookup 50
1001:	from 100.9.9.9/24 lookup 50
[19:09:22@hp-dl388g8-04 ~]0# ip route get 100.1.1.3
100.1.1.3 via 192.0.2.1 dev dummy0 table 50 src 192.0.2.251 uid 0 
    cache

Comment 4 Mingyu Shi 2020-07-10 07:33:20 UTC
Created attachment 1700552 [details]
verified.log

Verified with versions:
nmstate-0.3.3-2.el8.noarch
NetworkManager-1.26.0-0.2.1.el8.x86_64
DISTRO=RHEL-8.3.0-20200709.n.0
Linux hpe-dl380pgen8-02-vm-11.hpe2.lab.eng.bos.redhat.com 4.18.0-223.el8.x86_64 #1 SMP Tue Jul 7 12:56:57 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Use this yaml:
# cat veth0-route.yaml 
---
interfaces:
  - name: veth0
    type: ethernet
    state: up
    ipv4:
      address:
      - ip: 4.4.4.4
        prefix-length: 24
      enabled: true
    ipv6:
      address:
      - ip: 4::4
        prefix-length: 64
      enabled: true
route-rules:
  config:
  - ip-to: 14.4.4.4/24
    priority: 4
    route-table: 4
  - ip-from: 24.4.4.4/24
    priority: 4
    route-table: 4
  - ip-to: 14::4/64
    priority: 4
    route-table: 4
  - ip-from: 24::4/64
    priority: 4
    route-table: 4
routes:
  config:
  - destination: 34.4.4.4/24
    metric: 4
    next-hop-address: 4.4.4.1
    next-hop-interface: veth0
    table-id: 4
  - destination: 34::4/64
    metric: 4
    next-hop-address: 4::1
    next-hop-interface: veth0
    table-id: 4

Comment 7 errata-xmlrpc 2020-11-04 03:08:25 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 (nmstate 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-2020:4696


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