Page MenuHomeVyOS Platform

show interfaces | strip-private fails
Closed, ResolvedPublicBUG

Description

Cannot use strip-private modifier with show interfaces either when viewing all interfaces or when specifying any single interface (i.e. show interfaces ethernet eth0):

$ show interfaces | strip-private
Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down
Interface        IP Address                        S/L  Description
---------        ----------                        ---  -----------
eth0             xxx.xxx.28.90/23                   u/u  WAN
eth1             xxx.xxx.0.1/24                       u/u
                 xxx.xxx.0.251/24
Traceback (most recent call last):
  File "/usr/libexec/vyos/strip-private.py", line 141, in <module>
    strip_lines(stripping_rules)
  File "/usr/libexec/vyos/strip-private.py", line 84, in strip_lines
    line = strip_address(line)
  File "/usr/libexec/vyos/strip-private.py", line 76, in strip_address
    return ipv4_re.sub(lambda match: ip_match(match, ipv4_subst), ipv6_re.sub(lambda match: ip_match(match, ipv6_subst), line))
  File "/usr/libexec/vyos/strip-private.py", line 76, in <lambda>
    return ipv4_re.sub(lambda match: ip_match(match, ipv4_subst), ipv6_re.sub(lambda match: ip_match(match, ipv6_subst), line))
  File "/usr/libexec/vyos/strip-private.py", line 61, in ip_match
    addr = IPAddress(result)
  File "/usr/lib/python3/dist-packages/netaddr/ip/__init__.py", line 280, in __init__
    % self.__class__.__name__)
ValueError: IPAddress() does not support netmasks or subnet prefixes! See documentation for details.

Details

Version
1.4-rolling-202103191617
Is it a breaking change?
Unspecified (possibly destroys the router)

Event Timeline

Post the migration of the script from /opt/vyatta/bin/vyos-strip-config.pl to /usr/libexec/vyos/strip-private.py, the strip-private seems to be not working when the ipv6 address is configured to an interface.

The change was done in the task: https://phabricator.vyos.net/T3354

It was working till 1.4-rolling-202103130218 version:

vyos@vyos:~$ sh int | strip-private
Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down
Interface        IP Address                        S/L  Description
---------        ----------                        ---  -----------
eth0             xxx.xxx.255.101/24                u/u
eth1             xxxx:xxxx::1/64                    u/u
eth2             -                                 u/u
eth3             -                                 u/u
lo               xxx.xxx.0.1/8                       u/u
                 ::1/128

vyos@vyos:~$ sh int eth eth1 | strip-private
eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP grou0
    link/ether XX:XX:XX:XX:XX:01 brd XX:XX:XX:XX:XX:ff
    inet6 xxxx:xxxx::1/64 scope global
       valid_lft forever preferred_lft forever
    inet6 fe80::xxxx:xxxx:fe01:1/64 scope link
       valid_lft forever preferred_lft forever

    RX:  bytes  packets  errors  dropped  overrun       mcast
             0        0       0        0        0           0
    TX:  bytes  packets  errors  dropped  carrier  collisions
           992        8       0        0        0           0

vyos@vyos:~$ sh ver

Version:          VyOS 1.4-rolling-202103130218
Release Train:    sagitta

Built by:         autobuild@vyos.net
Built on:         Sat 13 Mar 2021 02:18 UTC
Build UUID:       2d786b7b-4aaf-4c3b-9389-d905ff8cba25
Build Commit ID:  b54996f34ccd75

Architecture:     x86_64
Boot via:         installed image
System type:      KVM guest

Latest rolling output:

Interface        IP Address                        S/L  Description
---------        ----------                        ---  -----------
eth0             xxx.xxx.255.101/24                u/u
Traceback (most recent call last):
  File "/usr/libexec/vyos/strip-private.py", line 141, in <module>
    strip_lines(stripping_rules)
  File "/usr/libexec/vyos/strip-private.py", line 84, in strip_lines
    line = strip_address(line)
  File "/usr/libexec/vyos/strip-private.py", line 76, in strip_address
    return ipv4_re.sub(lambda match: ip_match(match, ipv4_subst), ipv6_re.sub(lambda match: ip_match(match, ipv6_subst), line))
  File "/usr/libexec/vyos/strip-private.py", line 76, in <lambda>
    return ipv4_re.sub(lambda match: ip_match(match, ipv4_subst), ipv6_re.sub(lambda match: ip_match(match, ipv6_subst), line))
  File "/usr/libexec/vyos/strip-private.py", line 61, in ip_match
    addr = IPAddress(result)
  File "/usr/lib/python3/dist-packages/netaddr/ip/__init__.py", line 280, in __init__
    % self.__class__.__name__)
ValueError: IPAddress() does not support netmasks or subnet prefixes! See documentation for details.

No issues seen when only ipv4 addresses are configured.

Fixed in the latest version:1.4-rolling-202103230217

vyos@vyos:~$ sh int | strip-private
Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down
Interface        IP Address                        S/L  Description
---------        ----------                        ---  -----------
eth0             xxx.xxx.255.101/24                u/u
eth1             xxxx:xxxx::1/64                    u/u
eth2             -                                 u/u
eth3             -                                 u/u
lo               xxx.xxx.0.1/8                       u/u
                 ::1/128


vyos@vyos:~$ sh int eth eth1 | strip-private
eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP grou0
    link/ether 50:0c:00:01:00:01 brd ff:ff:ff:ff:ff:ff
    inet6 xxxx:xxxx::1/64 scope global
       valid_lft forever preferred_lft forever
    inet6 fe80::520c:ff:fe01:1/64 scope link
       valid_lft forever preferred_lft forever

    RX:  bytes  packets  errors  dropped  overrun       mcast
           724        8       0        0        0           0
    TX:  bytes  packets  errors  dropped  carrier  collisions
           992        8       0        0        0           0
vyos@vyos:~$ sh ver

Version:          VyOS 1.4-rolling-202103230217
Release Train:    sagitta

Built by:         autobuild@vyos.net
Built on:         Tue 23 Mar 2021 02:17 UTC
Build UUID:       6d73c9f3-95b4-49d4-9f3b-7cdc063afe2e
Build Commit ID:  30180961225ce0

Works fine for me as well, thanks.