openSUSE / wicked

Framework for network configuration
https://en.opensuse.org/Portal:Wicked
GNU General Public License v2.0
101 stars 50 forks source link

rtnl: parse peer address on non-ptp interfaces #988

Closed mtomaschewski closed 11 months ago

mtomaschewski commented 11 months ago

Due to the incomplete parsing the peer address were empty and caused an error in attempts to delete it while ifdown.

mtomaschewski commented 11 months ago

See also further comments in https://github.com/openSUSE/wicked/pull/987

mtomaschewski commented 11 months ago

Reproducer:

cat ifcfg-eth4

STARTMODE=auto
BOOTPROTO=static

IPADDR_40=172.22.49.10
REMOTE_IPADDR_40=172.22.49.1
IPADDR_41=172.22.49.11/24
IPADDR_42=172.22.49.12

IPADDR_60=2001:db8::10
REMOTE_IPADDR_60=2001:db8::1
IPADDR_61=2001:db8::11/64
IPADDR_62=2001:db8::12

ifup eth4

eth4            up

ip addr show dev eth4

5: eth4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:1b:21:53:06:57 brd ff:ff:ff:ff:ff:ff
    altname enp7s0f1
    inet 172.22.49.10 peer 172.22.49.1/32 scope global eth4 <--- OK
       valid_lft forever preferred_lft forever
    inet 172.22.49.11/24 brd 172.22.49.255 scope global eth4
       valid_lft forever preferred_lft forever
    inet 172.22.49.12/32 scope global eth4
       valid_lft forever preferred_lft forever
    inet6 2001:db8::12/128 scope global
       valid_lft forever preferred_lft forever
    inet6 2001:db8::11/64 scope global
       valid_lft forever preferred_lft forever
    inet6 2001:db8::10 peer 2001:db8::1/128 scope global    <--- OK
       valid_lft forever preferred_lft forever
    inet6 fe80::21b:21ff:fe53:657/64 scope link
       valid_lft forever preferred_lft forever

wicked ifstatus eth4

eth4            up
      link:     #5, state up, mtu 1500
      type:     ethernet, hwaddr 00:1b:21:53:06:57
      config:   compat:suse:/etc/sysconfig/network/ifcfg-eth4
      leases:   ipv4 static granted
      leases:   ipv6 static granted
      addr:     ipv4 172.22.49.1/32             <--- !!!
      addr:     ipv6 2001:db8::12/128 [static]
      addr:     ipv6 2001:db8::11/64 [static]
      addr:     ipv6 2001:db8::1/128                <--- !!!
      addr:     ipv4 172.22.49.11/24 [static]
      addr:     ipv4 172.22.49.12/32 [static]

wicked ifstatus --verbose eth4

eth4            up
      link:     #5, state up, mtu 1500
      type:     ethernet, hwaddr 00:1b:21:53:06:57
      control:  none
      config:   compat:suse:/etc/sysconfig/network/ifcfg-eth4,
                uuid: 96a6aba4-c445-5ade-83e9-d1893931919c
      leases:   ipv4 static granted
      leases:   ipv6 static granted
      addr:     ipv6 fe80::21b:21ff:fe53:657/64 scope link
      addr:     ipv6 2001:db8::12/128 scope universe [static]
      addr:     ipv6 2001:db8::11/64 scope universe [static]
      addr:     ipv6 2001:db8::1/128 scope universe                         <--- !!!
      addr:     ipv4 172.22.49.1/32 scope universe label eth4         <--- !!!
      addr:     ipv4 172.22.49.11/24 brd 172.22.49.11 scope universe label eth4 [static]
      addr:     ipv4 172.22.49.12/32 scope universe label eth4 [static]
      route:    ipv4 172.22.49.0/24 type unicast table main scope link protocol kernel pref-src 172.22.49.11
      route:    ipv4 172.22.49.1/32 type unicast table main scope link protocol kernel pref-src 172.22.49.10
      route:    ipv6 2001:db8::1/128 type unicast table main scope universe protocol kernel priority 256
      route:    ipv6 2001:db8::10/128 type unicast table main scope universe protocol kernel priority 256
      route:    ipv6 2001:db8::12/128 type unicast table main scope universe protocol kernel priority 256
      route:    ipv6 2001:db8::/64 type unicast table main scope universe protocol kernel priority 256
      route:    ipv6 fe80::/64 type unicast table main scope universe protocol kernel priority 256

wicked show-xml eth4

<!--  [...] -->
    <addresses>
      <assigned-address>
        <local>172.22.49.1/32</local>               <!- <--- !!! -->
        <scope>universe</scope>
        <flags>128</flags>
        <label>eth4</label>
      </assigned-address>
      <assigned-address>
        <local>fe80::21b:21ff:fe53:657/64</local>
        <scope>link</scope>
        <flags>128</flags>
      </assigned-address>
      <assigned-address>
        <local>2001:db8::12/128</local>
        <scope>universe</scope>
        <flags>128</flags>
        <owner>static</owner>
      </assigned-address>
      <assigned-address>
        <local>2001:db8::11/64</local>
        <scope>universe</scope>
        <flags>128</flags>
        <owner>static</owner>
      </assigned-address>
      <assigned-address>
        <local>2001:db8::1/128</local>              <!- <-- !!! -->
        <scope>universe</scope>
        <flags>128</flags>
      </assigned-address>
      <assigned-address>
        <local>172.22.49.11/24</local>
        <broadcast>172.22.49.255</broadcast>
        <scope>universe</scope>
        <flags>128</flags>
        <label>eth4</label>
        <owner>static</owner>
      </assigned-address>
      <assigned-address>
        <local>172.22.49.12/32</local>
        <scope>universe</scope>
        <flags>128</flags>
        <label>eth4</label>
        <owner>static</owner>
      </assigned-address>
    </addresses>
<!-- [...] -->

wicked ifdown eth4

eth4            device-ready

ip a s dev eth4

5: eth4: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 00:1b:21:53:06:57 brd ff:ff:ff:ff:ff:ff
    altname enp7s0f1
    inet 172.22.49.10 peer 172.22.49.1/32 scope global eth4 <--- !!!
       valid_lft forever preferred_lft forever

journalctl -u wickedd.service -f

Okt 17 13:00:51 nemesis wickedd[5182]: __ni_rtnl_send_deladdr(172.22.49.1/32): rtnl_talk failed: Invalid address for specified address family
mtomaschewski commented 11 months ago

Verification

cat ifcfg-eth4

STARTMODE=auto
BOOTPROTO=static

IPADDR_40=172.22.49.10
REMOTE_IPADDR_40=172.22.49.1
IPADDR_41=172.22.49.11/24
IPADDR_42=172.22.49.12

IPADDR_60=2001:db8::10
REMOTE_IPADDR_60=2001:db8::1
IPADDR_61=2001:db8::11/64
IPADDR_62=2001:db8::12

ifup eth4

eth4            up

ip addr show dev eth4

5: eth4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:1b:21:53:06:57 brd ff:ff:ff:ff:ff:ff
    altname enp7s0f1
    inet 172.22.49.10 peer 172.22.49.1/32 scope global eth4                                     <--- OK
       valid_lft forever preferred_lft forever
    inet 172.22.49.11/24 brd 172.22.49.255 scope global eth4
       valid_lft forever preferred_lft forever
    inet 172.22.49.12/32 scope global eth4
       valid_lft forever preferred_lft forever
    inet6 2001:db8::12/128 scope global
       valid_lft forever preferred_lft forever
    inet6 2001:db8::11/64 scope global
       valid_lft forever preferred_lft forever
    inet6 2001:db8::10 peer 2001:db8::1/128 scope global                                        <--- OK
       valid_lft forever preferred_lft forever
    inet6 fe80::21b:21ff:fe53:657/64 scope link
       valid_lft forever preferred_lft forever

wicked ifstatus eth4

eth4            up
      link:     #5, state up, mtu 1500
      type:     ethernet, hwaddr 00:1b:21:53:06:57
      config:   compat:suse:/etc/sysconfig/network/ifcfg-eth4
      leases:   ipv4 static granted
      leases:   ipv6 static granted
      addr:     ipv6 2001:db8::12/128 [static]                                                  <--- fixed
      addr:     ipv6 2001:db8::11/64 [static]
      addr:     ipv6 2001:db8::10/128 [static]
      addr:     ipv4 172.22.49.10/32 [static]                                                   <--- fixed
      addr:     ipv4 172.22.49.11/24 [static]
      addr:     ipv4 172.22.49.12/32 [static]

wicked ifstatus --verbose eth4

eth4            up
      link:     #5, state up, mtu 1500
      type:     ethernet, hwaddr 00:1b:21:53:06:57
      control:  none
      config:   compat:suse:/etc/sysconfig/network/ifcfg-eth4,
                uuid: 96a6aba4-c445-5ade-83e9-d1893931919c
      leases:   ipv4 static granted
      leases:   ipv6 static granted
      addr:     ipv6 fe80::21b:21ff:fe53:657/64 scope link
      addr:     ipv6 2001:db8::12/128 scope universe [static]
      addr:     ipv6 2001:db8::11/64 scope universe [static]
      addr:     ipv6 2001:db8::10/128 peer 2001:db8::1 scope universe [static]                  <--- fixed
      addr:     ipv4 172.22.49.10/32 peer 172.22.49.1 scope universe label eth4 [static]        <--- fixed
      addr:     ipv4 172.22.49.11/24 brd 172.22.49.11 scope universe label eth4 [static]
      addr:     ipv4 172.22.49.12/32 scope universe label eth4 [static]
      route:    ipv4 172.22.49.0/24 type unicast table main scope link protocol kernel pref-src 172.22.49.11
      route:    ipv4 172.22.49.1/32 type unicast table main scope link protocol kernel pref-src 172.22.49.10
      route:    ipv6 2001:db8::1/128 type unicast table main scope universe protocol kernel priority 256
      route:    ipv6 2001:db8::10/128 type unicast table main scope universe protocol kernel priority 256
      route:    ipv6 2001:db8::12/128 type unicast table main scope universe protocol kernel priority 256
      route:    ipv6 2001:db8::/64 type unicast table main scope universe protocol kernel priority 256
      route:    ipv6 fe80::/64 type unicast table main scope universe protocol kernel priority 256

wicked show-xml eth4

<!-- [...] -->
    <addresses>
      <assigned-address>
        <local>fe80::21b:21ff:fe53:657/64</local>
        <scope>link</scope>
        <flags>128</flags>
      </assigned-address>
      <assigned-address>
        <local>2001:db8::12/128</local>
        <scope>universe</scope>
        <flags>128</flags>
        <owner>static</owner>
      </assigned-address>
      <assigned-address>
        <local>2001:db8::11/64</local>
        <scope>universe</scope>
        <flags>128</flags>
        <owner>static</owner>
      </assigned-address>
      <assigned-address>
        <local>2001:db8::10/128</local>                                                         <--- fixed
        <peer>2001:db8::1</peer>                                                                <--- fixed
        <scope>universe</scope>
        <flags>128</flags>
        <owner>static</owner>
      </assigned-address>
      <assigned-address>
        <local>172.22.49.10/32</local>                                                          <--- fixed
        <peer>172.22.49.1</peer>                                                                <--- fixed
        <scope>universe</scope>
        <flags>128</flags>
        <label>eth4</label>
        <owner>static</owner>
      </assigned-address>
      <assigned-address>
        <local>172.22.49.11/24</local>
        <broadcast>172.22.49.255</broadcast>
        <scope>universe</scope>
        <flags>128</flags>
        <label>eth4</label>
        <owner>static</owner>
      </assigned-address>
      <assigned-address>
        <local>172.22.49.12/32</local>
        <scope>universe</scope>
        <flags>128</flags>
        <label>eth4</label>
        <owner>static</owner>
      </assigned-address>
    </addresses>
<!-- [...] -->

wicked ifdown eth4

eth4            device-ready

ip addr show dev eth4

5: eth4: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 00:1b:21:53:06:57 brd ff:ff:ff:ff:ff:ff
    altname enp7s0f1

the inet 172.22.49.10 peer 172.22.49.1/32 has been removed <--- fixed

journalctl -u wickedd.service -b | grep ni_rtnl_send_deladdr

no ni_rtnl_send_deladdr error <--- fixed

mtomaschewski commented 11 months ago

The https://github.com/openSUSE/wicked/compare/1653700bb34a80e153acd8bff9313adab9252ea0..d3fa3575fe00c901ff85aa56f03237859f2c0061 changes are fixing checkpatch issues reported by the CI:

------------------------------------------------------------------------
Commit a26c45aca49e ("rtnl: pass ifname in newaddr parsing and logging")
------------------------------------------------------------------------
WARNING:LONG_LINE: line length of 122 exceeds 120 columns
#55: FILE: src/iflist.c:2830:
+__ni_rtnl_parse_newaddr(const char *ifname, unsigned ifflags, struct nlmsghdr *h, struct ifaddrmsg *ifa, ni_address_t *ap)

WARNING:UNSPECIFIED_INT: Prefer 'unsigned int' to bare use of 'unsigned'
#55: FILE: src/iflist.c:2830:
+__ni_rtnl_parse_newaddr(const char *ifname, unsigned ifflags, struct nlmsghdr *h, struct ifaddrmsg *ifa, ni_address_t *ap)

WARNING:UNSPECIFIED_INT: Prefer 'unsigned int' to bare use of 'unsigned'
#104: FILE: src/kernel.h:123:
+extern int __ni_rtnl_parse_newaddr(const char *, unsigned, struct nlmsghdr *, struct ifaddrmsg *, ni_address_t *);
mtomaschewski commented 11 months ago

JFYI: Test RPMs built by the CI are in https://download.opensuse.org/repositories/network:/wicked:/testing/