fix a race condition with dynamic interfaces and firewalling
[openwrt/openwrt.git] / package / base-files / files / lib / network / config.sh
index c08fd69bc8f615dc2040919a6fb6816eb86ee21f..3ff65ff8f564b559ae8159638bffced43abd65d4 100755 (executable)
@@ -91,7 +91,6 @@ prepare_interface() {
        case "$iftype" in
                bridge)
                        [ -x /usr/sbin/brctl ] && {
-                               ifconfig "$iface" up 2>/dev/null >/dev/null
                                ifconfig "br-$config" 2>/dev/null >/dev/null && {
                                        $DEBUG brctl addif "br-$config" "$iface"
                                        # Bridge existed already. No further processing necesary
@@ -104,6 +103,7 @@ prepare_interface() {
                                        # result in another setup_interface() call, so we simply stop processing
                                        # the current event at this point.
                                }
+                               ifconfig "$iface" up 2>/dev/null >/dev/null
                                return 1
                        }
                ;;
@@ -137,6 +137,7 @@ setup_interface() {
        config_get mtu "$config" mtu
        config_get macaddr "$config" macaddr
        $DEBUG ifconfig "$iface" ${macaddr:+hw ether "$macaddr"} ${mtu:+mtu $mtu} up
+       uci set "/var/state/network.$config.ifname=$iface"
 
        pidfile="/var/run/$iface.pid"
        case "$proto" in