blob: 19b23047db69898f32dc6356dc953602f0adea6a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
--- rc.inet1.orig 2009-08-26 16:25:44.000000000 +0200
+++ rc.inet1 2010-09-01 21:38:52.161516124 +0200
@@ -72,6 +72,29 @@
# INTERFACE FUNCTIONS #
#######################
+# Function to assemble a bridge interface.
+br_open() {
+ # argument is 'i' - the position of this interface in the IFNAME array.
+ /sbin/brctl addbr ${IFNAME[$1]}
+ for BRIF in $(echo ${BRNICS[$1]}); do
+ /sbin/ifconfig $BRIF down
+ /sbin/ifconfig $BRIF 0.0.0.0 promisc up
+ /sbin/brctl addif ${IFNAME[$1]} $BRIF
+ done
+}
+
+# Function to disassemble a bridge interface.
+br_close() {
+ # argument is 'i' - the position of this interface in the IFNAME array.
+ #for BRIF in $(echo ${BRNICS[$1]}); do
+ for BRIF in $(ls --indicator-style=none /sys/class/net/${IFNAME[$1]}/brif/)
+ do
+ /sbin/brctl delif ${IFNAME[$1]} $BRIF
+ done
+ /sbin/ifconfig ${IFNAME[$1]} down
+ /sbin/brctl delbr ${IFNAME[$1]}
+}
+
# Function to bring up a network interface. If the interface is
# already up or does not yet exist (perhaps because the kernel driver
# is not loaded yet), do nothing.
@@ -82,6 +105,8 @@
[ "${IFNAME[$i]}" = "${1}" ] && break
i=$(($i+1))
done
+ # If the interface is a bridge, then create it first:
+ [ -n "${BRNICS[$i]}" ] && br_open $i
# If the interface isn't in the kernel yet (but there's an alias for it in
# modules.conf), then it should be loaded first:
if ! grep `echo ${1}: | cut -f 1 -d :`: /proc/net/dev 1> /dev/null ; then # no interface yet
@@ -179,6 +204,8 @@
if [ -x /etc/rc.d/rc.wireless ]; then
. /etc/rc.d/rc.wireless ${1} stop # Kill wireless daemons if any.
fi
+ # If the interface is a bridge, then destroy it now:
+ [ -n "${BRNICS[$i]}" ] && br_close $i
fi
}
|