diff options
Diffstat (limited to 'meta-oe/recipes-core/udev/udev/network.sh')
-rw-r--r-- | meta-oe/recipes-core/udev/udev/network.sh | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/meta-oe/recipes-core/udev/udev/network.sh b/meta-oe/recipes-core/udev/udev/network.sh new file mode 100644 index 000000000..182c26d86 --- /dev/null +++ b/meta-oe/recipes-core/udev/udev/network.sh | |||
@@ -0,0 +1,58 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # udevd does clearenv(). Export shell PATH to children. | ||
4 | export PATH | ||
5 | |||
6 | # Do not run when pcmcia-cs is installed | ||
7 | test -x /sbin/cardctl && exit 0 | ||
8 | |||
9 | # We get two "add" events for hostap cards due to wifi0 | ||
10 | echo "$INTERFACE" | grep -q wifi && exit 0 | ||
11 | |||
12 | |||
13 | # Check if /etc/init.d/network has been run yet to see if we are | ||
14 | # called by starting /etc/rcS.d/S03udev and not by hotplugging a device | ||
15 | # | ||
16 | # At this stage, network interfaces should not be brought up | ||
17 | # automatically because: | ||
18 | # a) /etc/init.d/network has not been run yet (security issue) | ||
19 | # b) /var has not been populated yet so /etc/resolv,conf points to | ||
20 | # oblivion, making the network unusable | ||
21 | # | ||
22 | |||
23 | spoofp="`grep ^spoofprotect /etc/network/options`" | ||
24 | if test -z "$spoofp" | ||
25 | then | ||
26 | # This is the default from /etc/init.d/network | ||
27 | spoofp_val=yes | ||
28 | else | ||
29 | spoofp_val=${spoofp#spoofprotect=} | ||
30 | fi | ||
31 | |||
32 | test "$spoofp_val" = yes && spoofp_val=1 || spoofp_val=0 | ||
33 | |||
34 | # I think it is safe to assume that "lo" will always be there ;) | ||
35 | if test "`cat /proc/sys/net/ipv4/conf/lo/rp_filter`" != "$spoofp_val" -a -n "$spoofp_val" | ||
36 | then | ||
37 | echo "$INTERFACE" >> /dev/udev_network_queue | ||
38 | exit 0 | ||
39 | fi | ||
40 | |||
41 | # | ||
42 | # Code taken from pcmcia-cs:/etc/pcmcia/network | ||
43 | # | ||
44 | |||
45 | # if this interface has an entry in /etc/network/interfaces, let ifupdown | ||
46 | # handle it | ||
47 | if grep -q "iface \+$INTERFACE" /etc/network/interfaces; then | ||
48 | case $ACTION in | ||
49 | add) | ||
50 | ifconfig | grep -q "^$INTERFACE" || ifup $INTERFACE | ||
51 | ;; | ||
52 | remove) | ||
53 | ifdown $INTERFACE | ||
54 | ;; | ||
55 | esac | ||
56 | |||
57 | exit 0 | ||
58 | fi | ||