ifconfig.sh down messes up loopback interfaces
Summary
ifconfig.sh up works fine, but ifconfig.sh down doesn't undo things correctly and messes up main loopback interface, leaves 2 test interfaces lying around
BIND version used
This bug has been around for a long time but here is a build with it...
BIND 9.16.16 (Stable Release) <id:0c314d8>
running on SunOS i86pc 5.11 11.4.40.107.3
built by make with '--prefix=/opt/local/bind' '--mandir=/opt/local/man' '--with-python=/opt/local/bin/python3.8' 'CPPFLAGS=-I/usr/include/kerberosv5'
compiled by GCC 7.3.0
compiled with OpenSSL version: OpenSSL 1.1.1k 25 Mar 2021
linked to OpenSSL version: OpenSSL 1.1.1l 24 Aug 2021
compiled with libuv version: 1.40.0
linked to libuv version: 1.40.0
compiled with libxml2 version: 2.9.10
linked to libxml2 version: 20912
compiled with zlib version: 1.2.11
linked to zlib version: 1.2.11
threads support is enabled
default paths:
named configuration: /opt/local/bind/etc/named.conf
rndc configuration: /opt/local/bind/etc/rndc.conf
DNSSEC root key: /opt/local/bind/etc/bind.keys
nsupdate session key: /opt/local/bind/var/run/named/session.key
named PID file: /opt/local/bind/var/run/named/named.pid
named lock file: /opt/local/bind/var/run/named/named.lock
Also present in 9.16.24
Steps to reproduce
as root:
bin/tests/system/ifconfig.sh up
ordinarily a 'make test' would be done here...
bin/tests/system/ifconfig.sh down
What is the current bug behavior?
ifconfig -a
lo0: flags=3001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,FIXEDMTU,VIRTUAL> mtu 1500 index 1
inet 127.0.0.1 netmask ff000000
...
lo0: flags=2002000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv6,VIRTUAL> mtu 8252 index 1
inet6 ::1/128
...
bin/tests/system/ifconfig.sh up
bin/tests/system/ifconfig.sh down
ifconfig: could not create address: Can't assign requested address
ifconfig: cannot unplumb lo0:0: Invalid interface name
ifconfig: cannot unplumb lo0:0: Invalid interface name
ifconfig: could not create address: Can't assign requested address
ifconfig: could not create address: Can't assign requested address
ifconfig: setifaddr: SIOCGLIFNETMASK: lo0:20: no such interface
ifconfig: setifaddr: SIOCGLIFNETMASK: lo0:20: no such interface
ifconfig: setifflags: SIOCGLIFFLAGS: lo0:20: no such interface
ifconfig: cannot unplumb lo0:20: No such interface
ifconfig -a
lo0: flags=3001000848<LOOPBACK,RUNNING,MULTICAST,IPv4,FIXEDMTU,VIRTUAL> mtu 1500 index 1
inet 10.53.0.1 netmask ff000000
lo0:12: flags=3001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,FIXEDMTU,VIRTUAL> mtu 1500 index 1
inet 10.53.1.2 netmask ff000000
lo0:22: flags=3001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,FIXEDMTU,VIRTUAL> mtu 1500 index 1
inet 10.53.2.2 netmask ff000000
...
lo0: flags=2002000848<LOOPBACK,RUNNING,MULTICAST,IPv6,VIRTUAL> mtu 8252 index 1
inet6 ::1/128
lo0:12: flags=2002000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv6,VIRTUAL> mtu 8252 index 1
inet6 fd92:7065:b8e:99ff::2/64
lo0:22: flags=2002000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv6,VIRTUAL> mtu 8252 index 1
inet6 fd92:7065:b8e:ff::2/64
...
Note lo0 is down and lo12, lo22 are lying around still.
Fixed via:
ifconfig lo0 127.0.0.1 up
ifconfig lo0:12 down unplumb
ifconfig lo0:22 down unplumb
ifconfig lo0 inet6 up
ifconfig lo0:12 inet6 down unplumb
ifconfig lo0:22 inet6 down unplumb
What is the expected correct behavior?
ifconfig -a before and after should look the same; lo0 shouldn't be touched
Relevant configuration files
none
Relevant logs and/or screenshots
Possible fixes
Trivial fix; remove "-1" in the down section for int calculation. Also make down do things in same order as up; don't see any advantage to doing it in reverse order.
diff is against 9.16.24 release
*** bin/tests/system/ifconfig.sh.orig Tue Dec 7 12:24:49 2021
--- bin/tests/system/ifconfig.sh Fri Dec 17 03:33:55 2021
***************
*** 160,169 ****
2) ipv6="00" ;;
*) ipv6="" ;;
esac
! for ns in 10 9 8 7 6 5 4 3 2 1
do
[ $i -gt 0 -a $ns -gt 2 ] && continue
! int=`expr $i \* 10 + $ns - 1`
case "$sys" in
*-pc-solaris2.5.1)
ifconfig lo0:$int 0.0.0.0 down
--- 160,169 ----
2) ipv6="00" ;;
*) ipv6="" ;;
esac
! for ns in 1 2 3 4 5 6 7 8 9 10
do
[ $i -gt 0 -a $ns -gt 2 ] && continue
! int=`expr $i \* 10 + $ns`
case "$sys" in
*-pc-solaris2.5.1)
ifconfig lo0:$int 0.0.0.0 down
Edited by Mark Andrews