Changeset 7b2dc2a8 in freewrt for package/fwifupdown/files


Ignore:
Timestamp:
Jun 28, 2007, 6:27:03 PM (18 years ago)
Author:
Thorsten Glaser <tg@…>
Children:
b3aae94e
Parents:
14005bc
Message:

experimental: reduce number of calls to brctl by running only one watchdog
which handles all bridge interfaces at once, sequentially

spaetzle@ said it's okay if I lay hand on this script ☺
will be tested soon

git-svn-id: svn://www.freewrt.org/trunk/freewrt@3006 afb5a338-a214-0410-bd46-81f09a774fd1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • package/fwifupdown/files/ifupdown.sh

    r14005bc r7b2dc2a8  
    66#
    77# Christian Fischer <spaetzle@freewrt.org>
     8# Thorsten Glaser <tg@freewrt.org>
    89#
    910
     
    3536
    3637# cleanup ifstate files
    37 rm -rf /tmp/ifupdown/ifstate/*
     38rm -rf /tmp/ifupdown/ifstate
     39mkdir -p /tmp/ifupdown/ifstate
    3840
    3941eval IFUPDOWN_ENV= $(grep '^FWIFUPDOWN_' /etc/rc.conf |sed "s/#.*//g") \
    4042    busybox $what $@ $redirect
    4143
    42 grep -q initialize /tmp/ifupdown/ifstate/bridge/* 2>&- || exit 0
    43 
    44 mprint -n "Waiting for finishing bridge initialization"
    45 
    46 while grep -rq initialize /tmp/ifupdown/ifstate/bridge/*; do
    47         sleep 1
     44i=0     # did we print the initialisation message?
     45j=0     # timeout in seconds
     46rv=0    # exit status of this script
     47while sleep 1; do
     48        if test $j -gt 15; then
     49                mprint -s "bridge initialisation timed out"
     50                rv=1
     51                break
     52        fi
     53        for x in /tmp/ifupdown/ifstate/bridge/*; do
     54                # any bridges to check?
     55                test -e "$x" || break 2         # no -> out of both loops
     56                # print initialisatio message, but once only
     57                test $i = 1 || mprint -n \
     58                    "Waiting for bridge initialisation to finish"
     59                i=1
     60                # check this bridge for its states
     61                s=ok
     62                for state in $(brctl showstp ${x##*/} | \
     63                    fgrep state | sed "s/^.*state//"); do
     64                        test x"$state" = x"forwarding" && continue
     65                        # if only one is not forwarding, wait
     66                        s=no
     67                        break
     68                done
     69                test $s = ok || break   # not ok? wait one second
     70                rm -f $x                # this bridge done, check next ones
     71        done
     72        j=$(eval $j + 1)
    4873done
    4974
    50 if grep -rq timeout /tmp/ifupdown/ifstate/bridge/*; then
    51         mstate 1
    52         mprint -s "bridge init: timeout"
    53         exit 1
    54 fi
    55 mstate 0
     75mstate $rv
    5676
    57 # vim:ts=4
     77# vim:ts=8
Note: See TracChangeset for help on using the changeset viewer.