Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Evergreen:11.1
sysconfig
sysconfig-ifup-dhcp-dhcpcd-config-sync.bnc51821...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File sysconfig-ifup-dhcp-dhcpcd-config-sync.bnc518219.diff of Package sysconfig
From d1693ae2bcff50565fc04455409293e7f42bff9a Mon Sep 17 00:00:00 2001 From: mt <mt@bf393798-0adf-0310-9952-bd479070b6c1> Date: Thu, 10 Dec 2009 16:04:38 +0000 Subject: [PATCH] Synchronized ifup-dhcp and dhcpcd configuration steps to report status after dhcpcd really finished all its steps (bnc#518219). --- scripts/dhcpcd-hook | 27 +++++++++++++++++++---- scripts/ifup-dhcp | 57 ++++++++++++++++++++++++++++++-------------------- 2 files changed, 56 insertions(+), 28 deletions(-) diff --git a/scripts/dhcpcd-hook b/scripts/dhcpcd-hook index c1c468e..9ee5cad 100755 --- a/scripts/dhcpcd-hook +++ b/scripts/dhcpcd-hook @@ -71,6 +71,9 @@ state="$2" debug="$3" action="" +if [ -r /etc/sysconfig/network/scripts/functions ] ; then + . /etc/sysconfig/network/scripts/functions +fi if [ -r /etc/sysconfig/network/config ] ; then . /etc/sysconfig/network/config fi @@ -113,6 +116,9 @@ done < $leaseinfo case $state in up) + write_cached_config_data dhcp4_state up $INTERFACE + commit_cached_config_data $INTERFACE + $debug && $log_dbg "Running ifup $INTERFACE -o dhcp" ifup $INTERFACE -o dhcp @@ -121,10 +127,11 @@ up) -i $INTERFACE $NC_OPTIONS \ -l $leaseinfo 2>&1 | $log_dbg - # reload syslog so it knows the new hostname - /etc/init.d/syslog reload ;; down) + write_cached_config_data dhcp4_state down $INTERFACE + commit_cached_config_data $INTERFACE + # We now call PRE_DOWN_SCRIPT directly from ifdown, because it was called # POST from here (after IP address was removed). Thus we don't need this # $debug && $log_dbg "Running ifdown $INTERFACE -o dhcp" @@ -136,6 +143,9 @@ down) 2>&1 | $log_dbg ;; new) + write_cached_config_data dhcp4_state new $INTERFACE + commit_cached_config_data $INTERFACE + $debug && $log_dbg "new IP address: $IPADDR" $debug && NC_OPTIONS="-v" @@ -143,14 +153,21 @@ new) -i $INTERFACE $NC_OPTIONS \ < $leaseinfo 2>&1 | $log_dbg - # reload syslog so it knows the new hostname - /etc/init.d/syslog reload - $debug && $log_dbg "Running ifdown $INTERFACE -o dhcp" ifdown $INTERFACE -o dhcp $debug && $log_dbg "Running ifup $INTERFACE -o dhcp" ifup $INTERFACE -o dhcp ;; +complete) + # dhcpcd finished all requested configuration steps ... + # reload syslog so it knows the new hostname + /etc/init.d/syslog reload + + $debug && $log_dbg "DHCP4 configuration of $INTERFACE is complete" + + write_cached_config_data dhcp4_state complete $INTERFACE + commit_cached_config_data $INTERFACE + ;; esac diff --git a/scripts/ifup-dhcp b/scripts/ifup-dhcp index 5a4844d..707201d 100755 --- a/scripts/ifup-dhcp +++ b/scripts/ifup-dhcp @@ -47,7 +47,7 @@ test "$DEBUG" = "EXTRA" && . scripts/extradebug # check arguments and how we are called (in case of links) # SCRIPTNAME=${0##*/} -debug $* +debug "$SCRIPTNAME $*" case "${SCRIPTNAME}" in ifup-*) ACTION=start ;; @@ -586,14 +586,19 @@ case "$ACTION" in case "$DHCLIENT" in (dhcpcd) test -n "$DHCP4_STATUS" || { - start_dhcp4_dhcpcd - DHCP4_STARTED="yes" + start_dhcp4_dhcpcd && { + DHCP4_STARTED="yes" + write_cached_config_data dhcp4_client $DHCLIENT $INTERFACE + write_cached_config_data dhcp4_state started $INTERFACE + commit_cached_config_data $INTERFACE + } || DHCP4_STATUS=$? } ;; (dhclient) test -n "$DHCP4_STATUS" || { - start_dhcp4_dhclient - DHCP4_STARTED="yes" + start_dhcp4_dhclient && { + DHCP4_STARTED="yes" + } || DHCP4_STATUS=$? } ;; esac @@ -602,8 +607,9 @@ case "$ACTION" in case "$DHCLIENT6" in (dhcp6c) test -n "$DHCP6_STATUS" || { - start_dhcp6_dhcp6c - DHCP6_STARTED="yes" + start_dhcp6_dhcp6c && { + DHCP6_STARTED="yes" + } || DHCP6_STATUS=$? } ;; #(dhclient) @@ -616,8 +622,6 @@ case "$ACTION" in ;; esac done - # don't hurry too much... - [ "x$DHCP6_STARTED" = xyes -o "x$DHCP4_STARTED" = xyes ] && sleep 1 # # in case we've started at least one client, wait the specified @@ -626,11 +630,10 @@ case "$ACTION" in DHCP4_MESSAGE='' DHCP6_MESSAGE='' - # - # TODO: does one the actual clients still exit on infinite lease?? - # (dhcpcd does not do this any more) - show_dots=true - for ((wab_cnt=0; wab_cnt<=${DHCLIENT_WAIT_AT_BOOT:-15}; wab_cnt++)); do + typeset -i wusleep=100000 + typeset -i wab_max=${DHCLIENT_WAIT_AT_BOOT:-15}; + let wab_max\*=10 + for ((wab_cnt=0; wab_cnt<=wab_max; wab_cnt++)); do for BOOTPROTO in ${BOOTPROTOS[@]} ; do case "$BOOTPROTO" in (dhcp4) @@ -640,14 +643,15 @@ case "$ACTION" in info=/var/lib/dhcpcd/dhcpcd-$INTERFACE.info if ! dhcpc4_on_iface -q ; then - [ $wab_cnt -lt 2 ] && message_n .\ .\ + ((wab_cnt== 0 || wab_cnt==10)) && message_n .\ .\ DHCP4_MESSAGE="DHCP4 client NOT running" DHCP4_STATUS=$R_NOTRUNNING continue fi [ -n "$DHCP4_STATUS" ] && continue - if [ -e $info -a ! $info -ot $stamp ]; then + state=`read_cached_config_data dhcp4_state $INTERFACE` + if [ "x$state" = "xcomplete" -a -e $info -a ! $info -ot $stamp ]; then IP='' ; NM='' ; HN='' while read line ; do case "$line" in @@ -672,7 +676,7 @@ case "$ACTION" in (dhclient) # TODO: parse the lease?! if ! dhcpc4_on_iface -q ; then - [ $wab_cnt -lt 2 ] && message_n .\ .\ + ((wab_cnt== 0 || wab_cnt==10)) && message_n .\ .\ DHCP4_MESSAGE="DHCP4 client NOT running" DHCP4_STATUS=$R_NOTRUNNING continue @@ -697,7 +701,7 @@ case "$ACTION" in ;; (dhcp6) if ! dhcpc6_on_iface -q ; then - [ $wab_cnt -lt 2 ] && message_n .\ .\ + ((wab_cnt== 0 || wab_cnt==10)) && message_n .\ .\ DHCP6_MESSAGE="DHCP6 client NOT running" DHCP6_STATUS=$R_NOTRUNNING continue @@ -724,8 +728,11 @@ case "$ACTION" in esac done if [ -z "$DHCP4_STATUS" -o -z "$DHCP6_STATUS" ] ; then - $show_dots && { show_dots=false ; message_n .\ ; } || show_dots=true - sleep 1 + ((wab_cnt % 20 == 1)) && message_n .\ + usleep $wusleep + else + # ok, we have status from both clients now => done + break fi done message " " @@ -957,8 +964,10 @@ case "$ACTION" in #if [ $STATUS -eq $R_SUCCESS ] ; then # delete primary flag from cache file if needed - delete_from_cached_config_data primary yes $INTERFACE - commit_cached_config_data $INTERFACE + delete_from_cached_config_data primary yes $INTERFACE + delete_from_cached_config_data 'dhcp4_*' '' $INTERFACE + delete_from_cached_config_data 'dhcp6_*' '' $INTERFACE + commit_cached_config_data $INTERFACE # This is useful for pcmcia interfaces... before the modules can be # unloaded, the device must be unused. @@ -991,7 +1000,9 @@ case "$ACTION" in stamp=/var/lib/dhcpcd/dhcpcd-$INTERFACE.timestamp info=/var/lib/dhcpcd/dhcpcd-$INTERFACE.info - if [ \( -e $info -a ! $info -ot $stamp \) -a -n \ + state=`read_cached_config_data dhcp4_state $INTERFACE` + if [ "x$state" = "xcomplete" -a \ + \( -e $info -a ! $info -ot $stamp \) -a -n \ "`ip -o -f inet addr show $INTERFACE`" ]; then while read line ; do case "$line" in -- 1.6.4.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor