Bug 9621

Summary: udhcpc deletes IPv6 addresses when getting an IPv4 lease
Product: Busybox Reporter: corentinhenry
Component: NetworkingAssignee: unassigned
Status: RESOLVED INVALID    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: 1.24.x   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:
Attachments: alpine linux default.script

Description corentinhenry 2017-01-27 01:51:34 UTC
We start with eth0 being down

localhost:~# ip addr show
1: lo: <LOOPBACK> mtu 65536 qdisc noqueue state DOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether ce:f6:d7:0c:78:00 brd ff:ff:ff:ff:ff:ff
3: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
4: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1
    link/sit 0.0.0.0 brd 0.0.0.0

We set eth0up, and it gets an IPv6 link local address

localhost:~# ip link set dev eth0 up && ip addr show
1: lo: <LOOPBACK> mtu 65536 qdisc noqueue state DOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether ce:f6:d7:0c:78:00 brd ff:ff:ff:ff:ff:ff
3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::5054:ff:fe12:3456/64 scope link
       valid_lft forever preferred_lft forever
4: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1
    link/sit 0.0.0.0 brd 0.0.0.0


Now if we get an IPv4 via udhcp, the IPv6 link local address gets deleted:

localhost:~# udhcpc -i eth0
udhcpc (v1.24.2) started
Sending discover...
Sending discover...
Sending select for 192.168.10.76...
Lease of 192.168.10.76 obtained, lease time 43200

localhost:~# ip addr show
1: lo: <LOOPBACK> mtu 65536 qdisc noqueue state DOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether ce:f6:d7:0c:78:00 brd ff:ff:ff:ff:ff:ff
3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.76/24 brd 192.168.10.255 scope global eth0
       valid_lft forever preferred_lft forever
Comment 1 Denys Vlasenko 2017-01-30 18:29:12 UTC
udhcpc itself does not change network configuration. Changes, if any, are done by *udhcpc script*

Usage: udhcpc [-fbqvaRB] [-t N] [-T SEC] [-A SEC/-n]
	[-i IFACE] [-s PROG] [-p PIDFILE]
	[-oC] [-r IP] [-V VENDOR] [-F NAME] [-x OPT:VAL]... [-O OPT]...

	-i,--interface IFACE	Interface to use (default eth0)
	-s,--script PROG	Run PROG at DHCP events (default /usr/share/udhcpc/default.script)

See that -s PROG option? That's the script name. If you run "udhcpc -i eth0" as you show (without -s), then it uses default script. What happens depends on what is in that default script. Show it.
Comment 2 corentinhenry 2017-01-30 19:34:43 UTC
Sorry for having missed this...

The issue lies in /usr/share/udhcpc/default.script indeed which calls this function:

    deconfig() {
        ip addr flush dev $interface
    }


That script if from Alpine Linux so I'll close this ticket.
Comment 3 corentinhenry 2017-01-30 19:37:21 UTC
Created attachment 6876 [details]
alpine linux default.script

Attaching the faulty script in case anyone is interested in the future.