Root/package/base-files/files/etc/hotplug.d/net/10-net

1# Copyright (C) 2006 OpenWrt.org
2
3include /lib/network
4
5addif() {
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*|3g-*) return 0;;
15        ath*) return 0;;
16        wlan*) return 0;;
17    esac
18
19    scan_interfaces
20    local cfg="$(find_config "$INTERFACE")"
21
22    # check the autoload setting
23    config_get auto "$cfg" auto
24    case "$auto" in
25        1|on|enabled) setup_interface "$INTERFACE";;
26    esac
27
28
29    # find all vlan configurations for this interface and set them up as well
30    for ifc in $interfaces; do
31        config_get iftype "$ifc" type
32        config_get ifs "$ifc" device
33        for dev in $ifs; do
34            [ "${dev%%\.*}" = "$INTERFACE" -a "$dev" != "$INTERFACE" ] && {
35                add_vlan "$dev"
36            }
37        done
38    done
39}
40
41
42delif() {
43    scan_interfaces
44
45    # find all vlan configurations for this interface and nuke 'em
46    for ifc in $interfaces; do
47        config_get iftype "$ifc" type
48        config_get ifs "$ifc" device
49        confdevs="$(uci_get network.$ifc.ifname)"
50        for dev in $ifs; do
51            [ "${dev%%\.*}" = "$INTERFACE" ] && {
52                list_contains confdevs "$dev" || list_remove ifs "$dev"
53            }
54        done
55        uci_set_state "network" "$ifc" device "$ifs"
56    done
57}
58
59case "$ACTION" in
60    add|register)
61        case "$PHYSDEVDRIVER" in
62            natsemi) sleep 1;;
63        esac
64        addif
65    ;;
66    remove|unregister)
67        delif
68    ;;
69esac
70

Archive Download this file



interactive