initscripts icon indicating copy to clipboard operation
initscripts copied to clipboard

[RHBZ] ifdown on alias removes all IPv6 addresses of parent interface

Open deekej opened this issue 9 years ago • 2 comments

Shutting down an (ipv4) interface alias (e.g. eth0:1) flushes/removes all ipv6 addresses on the parent interface (e.g. eth0). [RHBZ #870271 | RHBZ #842421]

Steps to Reproduce:

  1. configure some interface aliases - parent eth0 has ipv6 connectivity (ipv6 autoconfig):
$ ifconfig | egrep 'Link|inet'
eth0       Link encap:Ethernet  HWaddr 52:54:00:37:1D:02
          inet addr:192.0.2.1  Bcast:192.0.2.255  Mask:255.255.255.0
          inet6 addr: 2001:db8::5054:ff:fe37:1d02/64 Scope:Global
          inet6 addr: fe80::5054:ff:fe37:1d02/64 Scope:Link
eth0:2    Link encap:Ethernet  HWaddr 52:54:00:37:1D:02
          inet addr:192.0.2.2  Bcast:192.0.2.255  Mask:255.255.255.0
eth0:3    Link encap:Ethernet  HWaddr 52:54:00:37:1D:02  
          inet addr:192.0.2.3  Bcast:192.0.2.255  Mask:255.255.255.0

The interface alias is shutdown, however all ipv6 addresses of the parent interface are also removed:

$ ifconfig | egrep 'Link|inet'
eth0      Link encap:Ethernet  HWaddr 52:54:00:37:1D:02  
          inet addr:192.0.2.1  Bcast:192.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe37:1d02/64 Scope:Link
eth0:2    Link encap:Ethernet  HWaddr 52:54:00:37:1D:02  
          inet addr:192.0.2.2  Bcast:192.0.2.255  Mask:255.255.255.0

/sbin/ifdown calls ifdown-eth which correctly shuts down the alias address and then calls ifdown-ipv6 on the alias device.

ifdown-ipv6 munges the alias device name from "eth0:X" to the realdevice name of "eth0" and then issues an "ipv6_cleanup_device eth0" which erroneously removes all addresses on the parent device.

We have fixed this by modifying ifdown-ipv6 to only attempt to shutdown the alias, which will be a silent noop because the 'eth0:X' alias interface has no ipv6 addresses:

% diff -ur ifdown-ipv6.*
--- ifdown-ipv6.a   2012-10-26 12:22:52.000000000 +1030
+++ ifdown-ipv6.b   2012-10-26 12:22:59.000000000 +1030
@@ -46,6 +46,7 @@
 source_config

 REALDEVICE=${DEVICE%%:*}
+DEVICE=$REALDEVICE

 [ -f /etc/sysconfig/network-scripts/network-functions-ipv6 ] || exit 1
 . /etc/sysconfig/network-scripts/network-functions-ipv6
@@ -131,4 +132,4 @@
 fi

 # Delete all current configured IPv6 addresses on this interface
-ipv6_cleanup_device $REALDEVICE
+ipv6_cleanup_device $DEVICE

NOTE: Similar behaviour for IPv4 has been fixed by this commit.

deekej avatar Oct 27 '16 08:10 deekej

According to @lnykryn: "ifdown-ipv6 will still call some sysctl on parent device and I don't think that this is desired behavior."

deekej avatar Oct 27 '16 08:10 deekej

Additional steps to reproduce this:


No IPv6 IPs established:

sl112-0-0-1:/root-$ ip -6 addr show dev eth2.10
6: eth2.10@eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500
inet6 fe80::20c:29ff:fec4:aa4a/64 scope link
valid_lft forever preferred_lft forever

Bring up first IP (config named test6):

sl112-0-0-1:/root-$ ifup test6; ip -6 addr show dev eth2.10
RTNETLINK answers: File exists
6: eth2.10@eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500
inet6 1000:1000::1/64 scope global
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fec4:aa4a/64 scope link
valid_lft forever preferred_lft forever

Bring up second IP (config named test6A):

sl112-0-0-1:/root-$ ifup test6A; ip -6 addr show dev eth2.10
RTNETLINK answers: File exists
6: eth2.10@eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500
inet6 1000:1000::7/64 scope global tentative
valid_lft forever preferred_lft forever
inet6 1000:1000::1/64 scope global
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fec4:aa4a/64 scope link
valid_lft forever preferred_lft forever

Bring down second IP (config named test6A):

sl112-0-0-1:/root-$ ifdown test6A; ip -6 addr show dev eth2.10
RTNETLINK answers: Cannot assign requested address
6: eth2.10@eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500
inet6 fe80::20c:29ff:fec4:aa4a/64 scope link
valid_lft forever preferred_lft forever

Result: first IP also torn down - 1000:1000::1/64 is no longer on interface.

deekej avatar Oct 27 '16 09:10 deekej