X-Git-Url: https://git.rohieb.name/openwrt.git/blobdiff_plain/c4f3575368c5aeef4134d82125df2814d688cc2a..00394c57717f28bb3b9860020729cd73036a8cf8:/package/base-files/default/lib/network/config.sh?ds=sidebyside diff --git a/package/base-files/default/lib/network/config.sh b/package/base-files/default/lib/network/config.sh index 59ec84aba..5bc74d128 100755 --- a/package/base-files/default/lib/network/config.sh +++ b/package/base-files/default/lib/network/config.sh @@ -4,16 +4,12 @@ # DEBUG="echo" find_config() { - local type iface ifn + local iftype iface ifn for ifn in $interfaces; do - config_get type "$ifn" type + config_get iftype "$ifn" type config_get iface "$ifn" ifname - case "$type" in - bridge) - config_get iface "$ifn" ifnames - ;; - esac - for ifc in $iface; do + config_get device "$ifn" device + for ifc in ${device:-$iface}; do [ "$ifc" = "$1" ] && { echo "$ifn" return 0 @@ -25,23 +21,23 @@ find_config() { } scan_interfaces() { - local mode type iface + local mode iftype iface ifname device interfaces= config_cb() { - config_get type "$CONFIG_SECTION" TYPE - case "$type" in + config_get iftype "$CONFIG_SECTION" TYPE + case "$iftype" in interface) - config_get type "$CONFIG_SECTION" type - config_get mode "$CONFIG_SECTION" proto - case "$type" in + config_get proto "$CONFIG_SECTION" proto + append interfaces "$CONFIG_SECTION" + config_get iftype "$CONFIG_SECTION" iftype + case "$iftype" in bridge) - config_get iface "$CONFIG_SECTION" ifname - iface="${iface:-br-$CONFIG_SECTION}" - config_set "$CONFIG_SECTION" ifname "$iface" + config_get ifname "$CONFIG_SECTION" ifname + config_set "$CONFIG_SECTION" ifnames "$ifname" + config_set "$CONFIG_SECTION" ifname br-"$CONFIG_SECTION" ;; esac - append interfaces "$CONFIG_SECTION" - ( type "scan_$mode" ) >/dev/null 2>/dev/null && eval "scan_$mode '$CONFIG_SECTION'" + ( type "scan_$proto" ) >/dev/null 2>/dev/null && eval "scan_$proto '$CONFIG_SECTION'" ;; esac } @@ -79,16 +75,15 @@ setup_interface() { # Setup bridging case "$iftype" in bridge) - config_get bridge_ifname "$config" ifname ifconfig "$iface" up 2>/dev/null >/dev/null - ifconfig "$bridge_ifname" 2>/dev/null >/dev/null && { - $DEBUG brctl addif "$bridge_ifname" "$iface" + ifconfig "br-$config" 2>/dev/null >/dev/null && { + $DEBUG brctl addif "br-$config" "$iface" return 0 } || { - $DEBUG brctl addbr "$bridge_ifname" - $DEBUG brctl setfd "$bridge_ifname" 0 - $DEBUG brctl addif "$bridge_ifname" "$iface" - iface="$bridge_ifname" + $DEBUG brctl addbr "br-$config" + $DEBUG brctl setfd "br-$config" 0 + $DEBUG brctl addif "br-$config" "$iface" + iface="br-$config" } ;; esac