busybox: Update udhcpc.script for stateful DHCPv6
PATCH v5 1/2 busybox: Update udhcpc.script for stateful DHCPv6
udhcpc6 will call the default script with the address set in the "ipv6" variable. Set "ip" to this address if present.
---
v5: Split into two patches and added comment about stateful DHCPv6
package/busybox/udhcpc.script | 2 ++ 1 file changed, 2 insertions(+)
package/busybox/udhcpc.script +2 -0
@@ -8,6 +8,8 @@ RESOLV_CONF="/etc/resolv.conf" [ -e $RESOLV_CONF ] || touch $RESOLV_CONF [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" [ -n "$subnet" ] && NETMASK="netmask $subnet" +# Busybox's udhcpc only supports stateful DHCPv6 for now +[ -n "$ipv6" ] && ip="$ipv6/128" case "$1" in deconfig)
Signature · 1 line
2.21.0
PATCH v5 2/2 busybox: wait for ipv6 default route in udhcpc6
udhcpc6 implements "stateful" DHCPv6 for explicitly requesting an address and other configuration information. A major difference between DHCPv4 and DHCPv6 is that DHCPv6 does *not* advertise a default route; this is determined by normal IPv6 autoconfiguration.
Included is a change from Rob, which if handling a DHCPv6 address waits a moment for the IPv6 route to be configured; as above this doesn't come from DHCPv6 but rather the IPv6 Router Advertisement (RA) which happens independently from udhcpc6. The intent here is to try and ensure that the interface is route-able upon the script's completion as it would be if called from udhcpc.
---
v5: Split into two patches, modify the wait_for_ipv6_default_route loop to resemble the loop in package/ifupdown-scripts/network/if-pre-up.d/wait_iface
v4: Expand description of stateful DHCPv6 in commit message
v3: Point out 'stateful' DHCPv6 in commit, send to the correct list...
v2: Avoid bashisms
package/busybox/udhcpc.script | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
package/busybox/udhcpc.script +20 -0
@@ -11,6 +11,23 @@ RESOLV_CONF="/etc/resolv.conf" # Busybox's udhcpc only supports stateful DHCPv6 for now [ -n "$ipv6" ] && ip="$ipv6/128" +if [ -z "${IF_WAIT_DELAY}" ]; then + IF_WAIT_DELAY=10 +fi +wait_for_ipv6_default_route() { + printf "Waiting for IPv6 default route to appear" + while [ $IF_WAIT_DELAY -gt 0 ]; do + if [ -z "$(ip -6 route list | grep default)" ]; then + printf "\n" + return + fi + sleep 1 + printf "." + : $((IF_WAIT_DELAY -= 1)) + done + printf " timeout!\n" +} + case "$1" in deconfig) /sbin/ifconfig $interface up
@@ -39,6 +56,9 @@ case "$1" in /usr/sbin/avahi-autoipd -k $interface fi /sbin/ifconfig $interface $ip $BROADCAST $NETMASK + if [ -n "$ipv6" ] ; then + wait_for_ipv6_default_route + fi if [ -n "$router" ] ; then echo "deleting routers"
Signature · 1 line
2.21.0
PATCH v5 2/2 busybox: wait for ipv6 default route in udhcpc6
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Samuel" == Samuel Mendoza-Jonas <[email protected]> writes:
udhcpc6 implements "stateful" DHCPv6 for explicitly requesting an address and other configuration information. A major difference between DHCPv4 and DHCPv6 is that DHCPv6 does *not* advertise a default route; this is determined by normal IPv6 autoconfiguration.
Included is a change from Rob, which if handling a DHCPv6 address waits
Who is Rob?
Quoted 6 lines
a moment for the IPv6 route to be configured; as above this doesn't come from DHCPv6 but rather the IPv6 Router Advertisement (RA) which happens independently from udhcpc6. The intent here is to try and ensure that the interface is route-able upon the script's completion as it would be if called from udhcpc.
Quoted 7 lines
Signed-off-by Samuel Mendoza-Jonas <[email protected]>---
v5: Split into two patches, modify thewait_for_ipv6_default_routeloop to resemble the loop in package/ifupdown-scripts/network/if-pre-up.d/wait_iface
v4: Expand description of stateful DHCPv6 in commit message
v3: Point out 'stateful' DHCPv6 in commit, send to the correct list...
v2: Avoid bashisms
Committed after extending/rewording the commit message a bit, including mentioning IF_WAIT_DELAY - thanks.
Signature · 1 line
Bye, Peter Korsgaard
PATCH v5 1/2 busybox: Update udhcpc.script for stateful DHCPv6
In reply to Samuel Mendoza-JonasQuoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Samuel" == Samuel Mendoza-Jonas <[email protected]> writes:
First of all, sorry for the slow response.
Quoted 15 lines
udhcpc6 will call the default script with the address set in the "ipv6" variable. Set "ip" to this address if present.
Signed-off-by Samuel Mendoza-Jonas <[email protected]>---
v5: Split into two patches and added comment about stateful DHCPv6package/busybox/udhcpc.script | 2 ++ 1 file changed, 2 insertions(+)package/busybox/udhcpc.script +0
-0
package/busybox/udhcpc.script RESOLV_CONF="/etc/resolv.conf" · line 12
Quoted 5 lines
package/busybox/udhcpc.script +2
-0@@ -8,6 +8,8 @@ RESOLV_CONF="/etc/resolv.conf" [ -e $RESOLV_CONF ] || touch $RESOLV_CONF [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" [ -n "$subnet" ] && NETMASK="netmask $subnet" +# Busybox's udhcpc only supports stateful DHCPv6 for now +[ -n "$ipv6" ] && ip="$ipv6/128"
busybox git actually has stateless support (which will then not set $ipv6), so I changed the comment to state:
# Handle stateful DHCPv6 like DHCPv4
And extended the commit message to explain that the /128 comes from the stateful DHCPv6 spec, and how we can reuse the existing DHCPv4 renew/bound logic with this.
And committed, thanks.
Signature · 1 line
Bye, Peter Korsgaard