source: trunk/package/base-files/files/etc/hotplug.d/net/10-net @ 17217

Last change on this file since 17217 was 17217, checked in by jow, 7 years ago

[package] base-files: move ipv6 module loading from setup_interface() to addif() in the hotplug call, this ensures that ipv6 is loaded before any interfaces or aliases with ip6addr option are configured (#5356)

  • Property svn:eol-style set to native
File size: 1.4 KB
Line 
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*) 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
40delif() {
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
57case "$ACTION" in
58        add|register)
59                case "$PHYSDEVDRIVER" in
60                        natsemi) sleep 1;;
61                esac
62                addif
63        ;;
64        remove|unregister)
65                delif
66        ;;
67esac
Note: See TracBrowser for help on using the repository browser.