base-files: apply network interface settings such as macaddr, mtu and txqueuelen...
authorFelix Fietkau <nbd@openwrt.org>
Sat, 24 Sep 2011 20:34:17 +0000 (20:34 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Sat, 24 Sep 2011 20:34:17 +0000 (20:34 +0000)
SVN-Revision: 28297

package/base-files/files/lib/network/config.sh

index 00e372a1f3a0c8052e529da237fc5b4fe4665e0c..ce8ec89eae213dea980f38d2c31d31d3fb2b6774 100755 (executable)
@@ -152,7 +152,7 @@ sort_list() {
 prepare_interface() {
        local iface="$1"
        local config="$2"
 prepare_interface() {
        local iface="$1"
        local config="$2"
-       local vifmac="$3"
+       local macaddr="$3"
 
        # if we're called for the bridge interface itself, don't bother trying
        # to create any interfaces here. The scripts have already done that, otherwise
 
        # if we're called for the bridge interface itself, don't bother trying
        # to create any interfaces here. The scripts have already done that, otherwise
@@ -166,13 +166,15 @@ prepare_interface() {
                # make sure the interface is removed from any existing bridge and deconfigured,
                # (deconfigured only if the interface is not set to proto=none)
                unbridge "$iface"
                # make sure the interface is removed from any existing bridge and deconfigured,
                # (deconfigured only if the interface is not set to proto=none)
                unbridge "$iface"
-               [ "$proto" = none ] || ifconfig "$iface" 0.0.0.0
 
 
-               # Change interface MAC address if requested
-               [ -n "$vifmac" ] && {
-                       ifconfig "$iface" down
-                       ifconfig "$iface" hw ether "$vifmac" up
-               }
+               local mtu macaddr txqueuelen
+               config_get mtu "$config" mtu
+               [ -n "$macaddr" ] || config_get macaddr "$config" macaddr
+               config_get txqueuelen "$config" txqueuelen
+               [ -n "$macaddr" ] && $DEBUG ifconfig "$iface" down
+               $DEBUG ifconfig "$iface" ${macaddr:+hw ether "$macaddr"} ${mtu:+mtu $mtu} ${txqueuelen:+txqueuelen $txqueuelen} up
+
+               [ "$proto" = none ] || ifconfig "$iface" 0.0.0.0
 
                # Apply sysctl settings
                map_sysctls "$config" "$iface"
 
                # Apply sysctl settings
                map_sysctls "$config" "$iface"
@@ -350,14 +352,6 @@ setup_interface() {
        }
 
        # Interface settings
        }
 
        # Interface settings
-       grep -qE "^ *$iface:" /proc/net/dev && {
-               local mtu macaddr txqueuelen
-               config_get mtu "$config" mtu
-               config_get macaddr "$config" macaddr
-               config_get txqueuelen "$config" txqueuelen
-               [ -n "$macaddr" ] && $DEBUG ifconfig "$iface" down
-               $DEBUG ifconfig "$iface" ${macaddr:+hw ether "$macaddr"} ${mtu:+mtu $mtu} ${txqueuelen:+txqueuelen $txqueuelen} up
-       }
        set_interface_ifname "$config" "$iface"
 
        [ -n "$proto" ] || config_get proto "$config" proto
        set_interface_ifname "$config" "$iface"
 
        [ -n "$proto" ] || config_get proto "$config" proto