X-Git-Url: https://git.tld-linux.org/?a=blobdiff_plain;f=lib%2Fifup;h=be231ceb5fe4ac7d778775b956506b4bd4b3a3ef;hb=0603354acf21cc77a19b97ae3218ae65cef3d138;hp=c53444235e1b2f49ee6c3cbdc073e686e48afa35;hpb=12e7a5b1a4ca9c8f03ee66db198426770cc84300;p=rc-scripts.git diff --git a/lib/ifup b/lib/ifup index c534442..be231ce 100755 --- a/lib/ifup +++ b/lib/ifup @@ -3,6 +3,8 @@ # PATH=/sbin:/usr/sbin:/bin:/usr/bin +run_pre_up() { :; } + . /etc/sysconfig/network . /etc/rc.d/init.d/functions . /lib/rc-scripts/functions.network @@ -65,6 +67,9 @@ setup_ip_param SYSCTLDEVICE=$(echo ${DEVICE} | sed 's/\./\//g') +# anything you need done first +run_pre_up + OTHERSCRIPT="/lib/rc-scripts/ifup-${DEVICETYPE}" if [ -x "$OTHERSCRIPT" ]; then @@ -80,7 +85,7 @@ fi if [ -n "$MACVLAN_DEV" -a -n "$MACVLAN_MACADDR" ]; then ip link del link ${MACVLAN_DEV} ${DEVICE} type macvlan > /dev/null 2>&1 - ip link add link ${MACVLAN_DEV} address ${MACVLAN_MACADDR} name ${DEVICE} type macvlan + ip link add link ${MACVLAN_DEV} address ${MACVLAN_MACADDR} name ${DEVICE} type macvlan ${MACVLAN_MODE:+mode $MACVLAN_MODE} fi # is this device available? (this catches PCMCIA devices for us) @@ -120,11 +125,14 @@ if [ -n "$ETHTOOL_OPTS" ] ; then fi if is_yes "$SLAVE" && [ -n "$MASTER" ] ; then - nls "Enslaving %s to %s" "$DEVICE" "$MASTER" - ip link set "$DEVICE" master "$MASTER" - ip link set "$DEVICE" up + # create master if it doesn't exist yet + [ ! -d "/sys/class/net/${MASTER}" ] && ip link add "${MASTER}" type bond + + nls "Enslaving %s to %s" "${DEVICE}" "${MASTER}" + ip link set "${DEVICE}" master "${MASTER}" + ip link set "${DEVICE}" up - exit 0 + exit 0 fi if [ "$HANDLING" = "2" ]; then @@ -171,7 +179,8 @@ if [ -n "$BOOTPROTO" -a "$BOOTPROTO" != "none" -a "$BOOTPROTO" != "static" ]; th fi DHCP_ARGS="$DHCP_OPTIONS $DHCP_ARGS" - if check_link_down ${DEVICE}; then + [ -z "$CHECK_LINK_WAIT_TIMEOUT" ] && CHECK_LINK_WAIT_TIMEOUT=5 + if check_link_down ${DEVICE} $(( $CHECK_LINK_WAIT_TIMEOUT * 2 )); then run_cmd "$(nls 'Determining IP information for %s (%s)' "$DEVICE" "${DHCP_CLIENT##*/}")" /bin/false nls '%s: Check cable/radio on-off switch?' "$DEVICE" exit 1 @@ -210,6 +219,19 @@ else # IPv6 in use ? if is_yes "$IPV6_NETWORKING" && [ -n "${IP6ADDR}" ]; then ip addr add ${IP6ADDR} dev ${DEVICE} ${IP6ADDROPT} + timeout=0 + while [ $timeout -le 20 ] && \ + if_state="`ip -o addr list dev ${DEVICE} to ${IP6ADDR}`" && \ + echo "$if_state" | grep -q tentative && \ + ! echo "$if_state" | grep -q dadfailed ; do + usleep 500000 + timeout=$((timeout+1)) + done + if ip -o addr list dev ${DEVICE} to ${IP6ADDR} | grep -q dadfailed ; then + ip addr del ${IP6ADDR} dev ${DEVICE} + nls '%s: Duplicated address detected: %s' "$DEVICE" "$IP6ADDR" + exit 1 + fi if [ -n "${IP6ADDRLABEL}" ]; then ip addrlabel add prefix ${IP6ADDR} dev ${DEVICE} label ${IP6ADDRLABEL} fi