/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to network-hooks.d/bridge

  • Committer: teddy at recompile
  • Date: 2011-12-27 14:15:40 UTC
  • Revision ID: teddy@recompile.se-20111227141540-ajrabf33q59jfa7t
Reorder TODO entries

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
CONFIG="$MANDOSNETHOOKDIR/bridge.conf"
17
17
 
18
 
addrtoif(){
19
 
    grep -liFe "$1" /sys/class/net/*/address \
20
 
        | sed -e 's,.*/\([^/]*\)/[^/]*,\1,'
21
 
}
22
 
 
23
 
# Read config file, which must set "BRIDGE", "PORT_ADDRESSES", and
24
 
# optionally "IPADDRS" and "ROUTES".
 
18
# Read config file, which must set "BRIDGE", "PORTS", and optionally
 
19
# "IPADDRS" and "ROUTES".
25
20
if [ -e "$CONFIG" ]; then
26
21
    . "$CONFIG"
27
22
fi
28
23
 
29
 
if [ -z "$BRIDGE" -o -z "$PORT_ADDRESSES" ]; then
 
24
if [ -z "$BRIDGE" -o -z "$PORTS" ]; then
30
25
    exit
31
26
fi
32
27
 
44
39
case "$1" in
45
40
    start)
46
41
        "$brctl" addbr "$BRIDGE"
47
 
        for address in $PORT_ADDRESSES; do
48
 
            interface=`addrtoif "$address"`
49
 
            "$brctl" addif "$BRIDGE" "$interface"
50
 
            ip link set dev "$interface" up
 
42
        for port in $PORTS; do
 
43
            "$brctl" addif "$BRIDGE" "$port"
 
44
            ip link set up "$port"
51
45
        done
52
 
        ip link set dev "$BRIDGE" up
 
46
        ip link set up "$BRIDGE"
53
47
        sleep "$DELAY"
54
48
        if [ -n "$IPADDRS" ]; then
55
49
            for ipaddr in $IPADDRS; do
63
57
        fi
64
58
        ;;
65
59
    stop)
66
 
        ip link set dev "$BRIDGE" down
67
 
        for address in $PORT_ADDRESSES; do
68
 
            interface=`addrtoif "$address"`
69
 
            ip link set dev "$interface" down
70
 
            "$brctl" delif "$BRIDGE" "$interface"
 
60
        ip link set down "$BRIDGE"
 
61
        for port in $PORTS; do
 
62
            ip link set down "$port"
 
63
            "$brctl" delif "$BRIDGE" "$port"
71
64
        done
72
65
        "$brctl" delbr "$BRIDGE"
73
66
        ;;