Bugzilla – Attachment 452941 Details for
Bug 697929
ipv6, rcnetwork returns before dad completed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
IDP Log In
|
Forgot Password
[patch]
Patch to wait for ipv6 dad in rcnetwork
0001-Fixed-wait-for-ipv6-duplicate-address-detection.patch (text/plain), 15.92 KB, created by
Marius Tomaschewski
on 2011-09-26 10:00:38 UTC
(
hide
)
Description:
Patch to wait for ipv6 dad in rcnetwork
Filename:
MIME Type:
Creator:
Marius Tomaschewski
Created:
2011-09-26 10:00:38 UTC
Size:
15.92 KB
patch
obsolete
>From 4e1f2b2dcf7a3df0b60c430185cc41e1aaf9bc94 Mon Sep 17 00:00:00 2001 >From: Marius Tomaschewski <mt@suse.com> >Date: Mon, 26 Sep 2011 11:33:20 +0200 >Subject: [PATCH] Fixed wait for ipv6 duplicate address detection > >Improved to not wait for link ready by default, because this breaks >the status of several interfaces (e.g. host-only bridges) and check >the ipv6 duplicate address detection only. IPv6 dad starts when the >link becomes up & ready, so this includes the link ready status. >The link ready check can be enabled on a per interface basis. >Fixed to not wait for each single interface separately in ifup, but >to wait for all together in /etc/init.d/network instead (bnc#697929). > >Signed-off-by: Marius Tomaschewski <mt@suse.com> >--- > config/ifcfg.template | 22 +++++++ > config/sysconfig.config-network | 15 +++-- > scripts/functions | 43 ++++++++------ > scripts/ifup | 121 +++++++++++++++++++++++++++------------ > scripts/network | 81 +++++++++++++++++++++----- > 5 files changed, 206 insertions(+), 76 deletions(-) > >diff --git a/config/ifcfg.template b/config/ifcfg.template >index d0e1b6d..d938f94 100644 >--- a/config/ifcfg.template >+++ b/config/ifcfg.template >@@ -167,6 +167,28 @@ LLADDR= > # > LINK_OPTIONS= > >+## Type: integer >+## Default: 0 >+# >+# The number of seconds to wait for link to become useable / ready. >+# Default is 0, causing to not wait for a ready link (0), because link >+# detection can't be enabled in all cases (e.g. bridges without ports). >+# Please use per interface settings to enable it. >+# >+LINK_READY_WAIT= >+ >+## Type: integer >+## Default: "" >+# >+# The number of seconds to wait for the end of IPv6 duplicate address >+# detection in ifup. >+# Default is to use WAIT_FOR_INTERFACES/2 seconds in normal ifup runs. >+# When ifup is called by /etc/init.d/network at boot time, the check >+# is done, but /etc/init.d/network waits WAIT_FOR_INTERFACES seconds >+# for all interfaces togerther. Set to 0 to disable it. >+# >+IPV6_DAD_WAIT= >+ > ## Type: string > ## Default: "" > # >diff --git a/config/sysconfig.config-network b/config/sysconfig.config-network >index c39a265..8fbe2a5 100644 >--- a/config/sysconfig.config-network >+++ b/config/sysconfig.config-network >@@ -136,19 +136,24 @@ MANDATORY_DEVICES="" > WAIT_FOR_INTERFACES="30" > > ## Type: integer >-## Default: "" >+## Default: 0 > # > # The number of seconds to wait for link to become useable / ready. >-# Default is to use WAIT_FOR_INTERFACES/2 seconds. Set to 0 to disable. >+# Default is 0, causing to not wait for a ready link (0), because link >+# detection can't be enabled in all cases (e.g. bridges without ports). >+# Please use per interface settings to enable it. > # >-LINK_READY_WAIT="" >+LINK_READY_WAIT=0 > > ## Type: integer > ## Default: "" > # > # The number of seconds to wait for the end of IPv6 duplicate address >-# detection. Default is to use WAIT_FOR_INTERFACES/5 seconds. Set to >-# 0 to disable. >+# detection in ifup. >+# Default is to use WAIT_FOR_INTERFACES/2 seconds in normal ifup runs. >+# When ifup is called by /etc/init.d/network at boot time, the check >+# is done, but /etc/init.d/network waits WAIT_FOR_INTERFACES seconds >+# for all interfaces togerther. Set to 0 to disable it. > # > IPV6_DAD_WAIT="" > >diff --git a/scripts/functions b/scripts/functions >index 5d8c035..0ed67ee 100644 >--- a/scripts/functions >+++ b/scripts/functions >@@ -128,19 +128,6 @@ link_ready_check () { > return 0 > } > >-link_ready_wait () { >- local iface=$1 >- local wsecs=${2:-0} >- local uwait=25000 >- local loops=$(((wsecs * 100000) / $uwait)) >- local loop ret=0 >- for((loop=0; loop < $loops; loop++)) ; do >- link_ready_check "$iface" ; ret=$? >- test $ret -ne 0 && usleep $uwait || break >- done >- return $ret >-} >- > ipv6_addr_dad_check() > { > local iface="$1" word i >@@ -171,16 +158,34 @@ ipv6_addr_dad_check() > return $R_SUCCESS > } > >+link_ready_wait () >+{ >+ local iface=$1 >+ local -i wsecs=${2:-0} >+ local -i uwait=25000 >+ local -i loops=$(((wsecs * 100000) / $uwait)) >+ local -i loop=0 ret=0 >+ >+ link_ready_check "$iface" ; ret=$? >+ while ((ret != 0 && loop++ < loops)) ; do >+ usleep $uwait >+ link_ready_check "$iface" ; ret=$? >+ done >+ return $ret >+} >+ > ipv6_addr_dad_wait() > { > local iface=$1 >- local wsecs=${2:-0} >- local uwait=25000 >- local loops=$(((wsecs * 100000) / $uwait)) >- local loop ret=0 >- for((loop=0; loop < $loops; loop++)) ; do >+ local -i wsecs=${2:-0} >+ local -i uwait=25000 >+ local -i loops=$(((wsecs * 100000) / $uwait)) >+ local -i loop=0 ret=0 >+ >+ ipv6_addr_dad_check "$iface" ; ret=$? >+ while ((ret == 3 && loop++ < loops)) ; do >+ usleep $uwait > ipv6_addr_dad_check "$iface" ; ret=$? >- test $ret -eq 3 && usleep $uwait || break > done > return $ret > } >diff --git a/scripts/ifup b/scripts/ifup >index 85a9251..71d5169 100755 >--- a/scripts/ifup >+++ b/scripts/ifup >@@ -96,6 +96,7 @@ test "$1" = "-o" && shift > OPTIONS=$@ > MODE=manual > HOTPLUG=no >+BOOTING=no > CONTROL_IFPLUGD=yes # Start/Stop ifplugd? > # Don't log messages from ifstatus in syslog by default (Bug 261350). This > # overwrites the config variable /etc/sysconfig/network/config:USE_SYSLOG >@@ -103,7 +104,7 @@ export DONT_USE_SYSLOG=no > test "$SCRIPTNAME" == ifstatus && DONT_USE_SYSLOG=yes > while [ $# -gt 0 ]; do > case $1 in >- boot|onboot) MODE=auto ;; >+ boot|onboot) MODE=auto ; BOOTING=yes ;; > auto) MODE=auto ;; > hotplug) MODE=auto > HOTPLUG=yes ;; >@@ -423,7 +424,7 @@ setexitstate () { > esac > commit_cached_config_data $INTERFACE > commit_cached_config_data $INTERFACE PFX=ifup- >- ;; >+ ;; > ifdown) > test "$HOTPLUG" = yes && RET_STATE=removed > test "$RUN_FROM_RC" = yes && RET_STATE=removed >@@ -447,7 +448,7 @@ setexitstate () { > commit_cached_config_data $INTERFACE > delete_from_cached_config_data '*' '' $INTERFACE PFX=ifup- > commit_cached_config_data $INTERFACE PFX=ifup- >- ;; >+ ;; > esac > } > >@@ -501,6 +502,11 @@ DEVNAME= > if [ -n "$VENDORID$PRODUCTID" -a "$BUSNAME" = pci -a -x /sbin/lspci ] ; then > DEVNAME=`lspci -d $VENDORID:$PRODUCTID 2>/dev/null | sed -n 1p` > DEVNAME=${DEVNAME#*: } >+ if [ "$RUN_FROM_RC" = yes ] ; then >+ DEVNAME=${DEVNAME%%[(\[]*} >+ DEVNAME=${DEVNAME:0:45} >+ NAME=${NAME:0:45} >+ fi > elif [ "$BUSNAME" = pcmcia ] ; then > DEVNAME=`cat /sys/class/net/$INTERFACE/device/prod_id* 2>/dev/null` > fi >@@ -1037,9 +1043,6 @@ case "$BOOTPROTO$SKIP_MAIN_PART" in > # else > # message_n "`printf "IP/Netmask: %s / %s " $IPADDR $NETMASK`" > fi >- if [ "$INTERFACETYPE" == bond ] ; then >- message_n " as bonding master" >- fi > message " " > ;; > esac >@@ -1096,28 +1099,57 @@ case "$BOOTPROTO$SKIP_MAIN_PART" in > ifup-route $CONFIG $INTERFACE ${OPTIONS:+-o $OPTIONS} > > # >- # OK, everything is set up here .. lets check the state >+ # OK, all setup done ... check the state now >+ # >+ # Do not override codes when already set (e.g. $R_DHCP_BG); >+ # it is the final action to check the link / dad status. >+ # >+ # When called from rcnetwork, do not wait as rcnetwork does. > # >+ dad_ret=0 >+ link_ret=0 > >- # - link >- link_ready_wait "$INTERFACE" "${LINK_READY_WAIT:-$((WAIT_FOR_INTERFACES/2))}" >- link_ret=$? >+ # - check the link (carrier, ...) >+ # per interface setting, disabled by default > if [ "$retcode" = "$R_SUCCESS" ] ; then >- # do not override codes when already set (e.g. $R_DHCP_BG) >- case "$link_ret" in >- 1|2|3) retcode=$R_NOTRUNNING ;; >- esac >+ if [ $((LINK_READY_WAIT)) -gt 0 ] ; then >+ if [ "$BOOTING" = yes -a "$RUN_FROM_RC" = yes ] ; then >+ link_ready_check "$INTERFACE" >+ link_ret=$? >+ test "$link_ret" && retcode=$R_DHCP_BG >+ else >+ link_ready_wait "$INTERFACE" "${LINK_READY_WAIT}" >+ link_ret=$? >+ test "$link_ret" && retcode=$R_NOTRUNNING >+ fi >+ fi > fi > >- # - dad >- if [ "$retcode" = "$R_SUCCESS" -a -d /proc/sys/net/ipv6 ] ; then >- IPV6_DAD_WAIT=${IPV6_DAD_WAIT:-$((WAIT_FOR_INTERFACES/5))} >- ipv6_addr_dad_wait "$INTERFACE" "$IPV6_DAD_WAIT" >- dad_ret=$? >- case $dad_ret in >- 1|2) retcode=$R_NOTRUNNING ;; >- 3) retcode=$R_DHCP_BG ;; >- esac >+ # - check ipv6 dad >+ # global (and per interface) setting, enabled by default >+ # when the link isn't ready yet, the addresses are marked tentative >+ # dad starts when the link becomes ready and we wait until success >+ # or dad failure. >+ if [ "$retcode" = "$R_SUCCESS" ] ; then >+ IPV6_DAD_WAIT=${IPV6_DAD_WAIT:-$((WAIT_FOR_INTERFACES/2))} >+ if [ $((IPV6_DAD_WAIT)) -gt 0 ] ; then >+ if [ "$BOOTING" = yes -a "$RUN_FROM_RC" = yes ] ; then >+ ipv6_addr_dad_check "$INTERFACE" >+ dad_ret=$? >+ else >+ ipv6_addr_dad_wait "$INTERFACE" "${IPV6_DAD_WAIT}" >+ dad_ret=$? >+ fi >+ case $dad_ret in >+ 1|2) retcode=$R_NOTRUNNING ;; >+ 3) retcode=$R_DHCP_BG ;; >+ esac >+ fi >+ fi >+ >+ # inform ifstatus to update status connecting flag >+ if [ $retcode -eq $R_DHCP_BG -a \( $link_ret -ne 0 -o $dad_ret -ne 0 \) ] ; then >+ write_cached_config_data verify status $INTERFACE > fi > > ;; >@@ -1154,25 +1186,31 @@ case "$BOOTPROTO$SKIP_MAIN_PART" in > > ifstatus-route $CONFIG $INTERFACE ${OPTIONS:+-o $OPTIONS} > >- retcode=$R_SUCCESS > dad_ret=0 > link_ret=0 >+ retcode=$R_SUCCESS > >- # Check the link >- if [ -n "$LINK_READY_WAIT" -a $((LINK_READY_WAIT)) -gt 0 ] ; then >- # check the link >- link_ready_check "$INTERFACE" || link_ret=$? >- case $link_ret in >- 1|2|3) retcode=$R_NOTRUNNING ;; >- esac >+ # - check the link >+ if [ $((LINK_READY_WAIT)) -gt 0 ] ; then >+ link_ready_check "$INTERFACE" >+ link_ret=$? >+ if [ "$BOOTING" = yes -a "$RUN_FROM_RC" = yes ] ; then >+ test "$link_ret" && retcode=$R_DHCP_BG >+ else >+ test "$link_ret" && retcode=$R_NOTRUNNING >+ fi > fi > >- # Check ipv6 dad >- if [ "$retcode" = "$R_SUCCESS" -a -d /proc/sys/net/ipv6 ] ; then >- IPV6_DAD_WAIT=${IPV6_DAD_WAIT:-$((WAIT_FOR_INTERFACES/5))} >- if [ $((IPV6_DAD_WAIT)) -gt 0 ] ; then >+ # - check ipv6 dad >+ if [ "$retcode" = "$R_SUCCESS" ] ; then >+ IPV6_DAD_WAIT=$((${IPV6_DAD_WAIT:-$((WAIT_FOR_INTERFACES/2))})) >+ if [ $((IPV6_DAD_WAIT)) -ge 0 ] ; then > ipv6_addr_dad_check "$INTERFACE" > dad_ret=$? >+ case $dad_ret in >+ 1|2) retcode=$R_NOTRUNNING ;; >+ 3) retcode=$R_DHCP_BG ;; >+ esac > fi > fi > >@@ -1190,12 +1228,21 @@ case "$BOOTPROTO$SKIP_MAIN_PART" in > 2) message "`printf " %-9s is dormant" "$INTERFACE"`" ;; > 3) message "`printf " %-9s has no carrier" "$INTERFACE"`" ;; > esac >+ >+ if [ "$retcode" = "$R_SUCCESS" ] ; then >+ v=`read_cached_config_data verify $INTERFACE` >+ s=`read_cached_config_data status $INTERFACE` >+ if test "$v" = "status" -a "$s" = "connecting" ; then >+ write_cached_config_data status connected $INTERFACE >+ commit_cached_config_data $INTERFACE >+ fi >+ fi > else > # message_if_not_run_from_rc "$INTERFACE is down" > message "`printf " %-9s is down" $INTERFACE`" > retcode=$R_NOTRUNNING > case "$STARTMODE" in >- manual|off) retcode=$R_INACTIVE ;; >+ manual|off) retcode=$R_INACTIVE ;; > esac > fi > ;; >@@ -1221,7 +1268,7 @@ if [ "$DHCP" != yes ] ; then > test "$CHECK" = yes -a $ret != 0 && retcode=$ret > DEP_IFACES=`get_depending_ifaces $INTERFACE` > if [ "$?" = 0 -a "$NODEPS" != yes ] ; then >- message "`printf " %-9s is still used from interfaces %s" \ >+ message "`printf " %-9s is used from interfaces %s" \ > $INTERFACE "$DEP_IFACES"`" > #for DI in $DEP_IFACES; do > # ifstatus $DI -o $OPTIONS >diff --git a/scripts/network b/scripts/network >index 5d8dc52..f82f4d1 100755 >--- a/scripts/network >+++ b/scripts/network >@@ -674,8 +674,7 @@ status() { > for IFACE in $@; do > $FAKE /sbin/ifstatus $CONFIG $IFACE -o rc $CHECK $MODE > RET=$? >- debug && printf " %-9s returned %s\n" $IFACE $RET || \ >- printf " %-9s\n" $IFACE >+ debug && printf " %-9s returned %s\n" $IFACE $RET > case $RET in > $R_SUCCESS|$R_BUSY) > # : $((R++)) >@@ -745,8 +744,7 @@ case "$ACTION" in > done > $FAKE ifup $CONFIG $IFACE -o rc $MODE > RET=$? >- debug && printf " %-9s returned %s\n" $IFACE $RET || \ >- printf " %-9s\n" $IFACE >+ debug && printf " %-9s returned %s\n" $IFACE $RET > case "$RET" in > $R_SUCCESS) > SUCCESS_IFACES="$SUCCESS_IFACES $IFACE" >@@ -831,7 +829,7 @@ case "$ACTION" in > > debug "Time to wait: $((WAIT_FOR_INTERFACES - TTWAIT))" > if [ "$NEWLINE" != yes ] ; then >- echo "Waiting for mandatory devices: $MANDATORY_DEVICES" >+ echo "Waiting for mandatory devices: ${MANDATORY_DEVICES//__NSC__/}" > fi > echo -n "$((WAIT_FOR_INTERFACES - TTWAIT)) " > NEWLINE=yes >@@ -861,7 +859,7 @@ case "$ACTION" in > debug SUCCESS_IFACES=$SUCCESS_IFACES > debug MANDATORY_DEVICES=$MANDATORY_DEVICES > debug FAILED=$FAILED >- >+ debug TTWAIT=$TTWAIT > > if [ -z "$INTERFACE" ] ; then > for IFACE in $VIRTUAL_IFACES ; do >@@ -870,8 +868,7 @@ case "$ACTION" in > done > $FAKE ifup $CONFIG $IFACE -o rc $MODE > RET=$? >- debug && printf " %-9s returned %s\n" $IFACE $RET || \ >- printf " %-9s\n" $IFACE >+ debug && printf " %-9s returned %s\n" $IFACE $RET > case "$RET" in > $R_SUCCESS) > SUCCESS_IFACES="$SUCCESS_IFACES $IFACE" >@@ -886,7 +883,7 @@ case "$ACTION" in > $R_NOCONFIG) > rc_failed 6 > rc_status -v1 >- : $((FAILED++)) >+ # : $((FAILED++)) > ;; > $R_NOTCONFIGURED|$R_INACTIVE) > SUCCESS_IFACES="$SUCCESS_IFACES $IFACE" >@@ -896,13 +893,69 @@ case "$ACTION" in > *) > rc_failed 7 > rc_status -v1 >- : $((FAILED++)) >+ # : $((FAILED++)) > ;; > esac > rc_reset > done >- fi > >+ LINE="" >+ NEWLINE=no >+ while true; do >+ debug ... still waiting for virtual devices: >+ debug SUCCESS_IFACES=$SUCCESS_IFACES >+ debug VIRTUAL_IFACES=$VIRTUAL_IFACES >+ >+ TMP=$VIRTUAL_IFACES >+ VIRTUAL_IFACES= >+ for IFACE in $TMP ; do >+ for S in $SUCCESS_IFACES; do >+ test "$IFACE" = "$S" && continue 2 >+ done >+ IFACE="`type_filter $IFACE`" >+ test -z "$IFACE" && continue >+ status -m $IFACE &>/dev/null >+ RET=$? >+ if [ $RET = 0 ] ; then >+ SUCCESS_IFACES="$SUCCESS_IFACES $IFACE" >+ if [ "$NEWLINE" = yes ] ; then >+ echo >+ NEWLINE=no >+ fi >+ status $IFACE >+ continue >+ fi >+ VIRTUAL_IFACES="$VIRTUAL_IFACES $IFACE" >+ done >+ >+ IFS=. read a b < /proc/uptime >+ TTWAIT2=$((a - (TTWAIT + `cat $NETWORK_RUNFILE`))) >+ test $TTWAIT2 -gt $((WAIT_FOR_INTERFACES)) \ >+ -o -z "$VIRTUAL_IFACES" && break >+ >+ debug "Time to wait: $((WAIT_FOR_INTERFACES - TTWAIT2))" >+ if [ "$NEWLINE" != yes ] ; then >+ echo "Waiting for virtual interfaces: $VIRTUAL_IFACES" >+ fi >+ echo -n "$((WAIT_FOR_INTERFACES - TTWAIT2)) " >+ NEWLINE=yes >+ sleep 1 >+ done >+ >+ if [ "$NEWLINE" = yes ] ; then >+ echo >+ fi >+ >+ for IFACE in $VIRTUAL_IFACES; do >+ if [ -d /sys/class/net/$IFACE ] ; then >+ status -m $IFACE && continue >+ printf " %-9s interface is not ready until now\n" $IFACE >+ fi >+ rc_failed >+ rc_status -v1 >+ : $((FAILED++)) >+ done >+ fi > > rc_reset > if [ -z "$INTERFACE" ] ; then >@@ -940,8 +993,7 @@ case "$ACTION" in > # printf " %-9s " $IFACE > $FAKE ifdown $CONFIG $IFACE -o rc $MODE > RET=$? >- debug && printf " %-9s returned %s\n" $IFACE $RET || \ >- printf " %-9s\n" $IFACE >+ debug && printf " %-9s returned %s\n" $IFACE $RET > rc_failed $RET > case "$RET" in > $R_NODEV|$R_NOTCONFIGURED|$R_INACTIVE) >@@ -988,8 +1040,7 @@ case "$ACTION" in > fi > $FAKE ifdown $CONFIG $IFACE -o rc $MODE > RET=$? >- debug && printf " %-9s returned %s\n" $IFACE $RET || \ >- printf " %-9s\n" $IFACE >+ debug && printf " %-9s returned %s\n" $IFACE $RET > rc_failed $RET > case "$RET" in > $R_NODEV|$R_NOTCONFIGURED|$R_INACTIVE) >-- >1.7.3.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
Attachments on
bug 697929
:
451318
| 452941 |
452988