[package] base-files: move ipv6 module loading from setup_interface() to addif()...
[openwrt.git] / package / base-files / files / etc / hotplug.d / net / 10-net
1 # Copyright (C) 2006 OpenWrt.org
2
3 include /lib/network
4
5 addif() {
6 # Ensure that ipv6 is loaded, autoloading happens later but ipv6 might be
7 # required now for interface setup.
8 [ -d /proc/sys/net/ipv6 ] || {
9 grep -q '^ipv6' /etc/modules.d/* && insmod ipv6
10 }
11
12 # PPP devices are configured by pppd, no need to run setup_interface here
13 case "$INTERFACE" in
14 ppp*) return 0;;
15 esac
16
17 scan_interfaces
18 local cfg="$(find_config "$INTERFACE")"
19
20 # check the autoload setting
21 config_get auto "$cfg" auto
22 case "$auto" in
23 1|on|enabled) setup_interface "$INTERFACE";;
24 esac
25
26
27 # find all vlan configurations for this interface and set them up as well
28 for ifc in $interfaces; do
29 config_get iftype "$ifc" type
30 config_get ifs "$ifc" device
31 for dev in $ifs; do
32 [ "${dev%%\.*}" = "$INTERFACE" -a "$dev" != "$INTERFACE" ] && {
33 add_vlan "$dev"
34 }
35 done
36 done
37 }
38
39
40 delif() {
41 scan_interfaces
42
43 # find all vlan configurations for this interface and nuke 'em
44 for ifc in $interfaces; do
45 config_get iftype "$ifc" type
46 config_get ifs "$ifc" device
47 confdevs="$(uci get network.$ifc.ifname)"
48 for dev in $ifs; do
49 [ "${dev%%\.*}" = "$INTERFACE" ] && {
50 list_contains confdevs "$dev" || list_remove ifs "$dev"
51 }
52 done
53 uci_set_state "network" "$ifc" device "$ifs"
54 done
55 }
56
57 case "$ACTION" in
58 add|register)
59 case "$PHYSDEVDRIVER" in
60 natsemi) sleep 1;;
61 esac
62 addif
63 ;;
64 remove|unregister)
65 delif
66 ;;
67 esac
This page took 0.042297 seconds and 5 git commands to generate.