X-Git-Url: https://git.rohieb.name/openwrt.git/blobdiff_plain/d802b2e8f350a00aa9e2c1c116df22943cab1ead..77ec3b2de9bb1880b258ec6aaf4949f146f6fd8d:/package/netifd/files/lib/network/config.sh diff --git a/package/netifd/files/lib/network/config.sh b/package/netifd/files/lib/network/config.sh index 4ce362eb1..8b91f96a6 100755 --- a/package/netifd/files/lib/network/config.sh +++ b/package/netifd/files/lib/network/config.sh @@ -4,7 +4,20 @@ . /usr/share/libubox/jshn.sh find_config() { - return + local device="$1" + for ifobj in `ubus list network.interface.\*`; do + interface="${ifobj##network.interface.}" + ( + json_load "$(ifstatus $interface)" + json_get_var ifdev device + if [[ "$device" = "$ifdev" ]]; then + echo "$interface" + exit 0 + else + exit 1 + fi + ) && return + done } unbridge() { @@ -26,6 +39,7 @@ fixup_interface() { config_get type "$config" type config_get ifname "$config" ifname + config_get device "$config" device "$ifname" [ "bridge" = "$type" ] && ifname="br-$config" config_set "$config" device "$ifname" ubus_call "network.interface.$config" status @@ -33,6 +47,7 @@ fixup_interface() { [ -n "$l3dev" ] && ifname="$l3dev" json_init config_set "$config" ifname "$ifname" + config_set "$config" device "$device" } scan_interfaces() { @@ -55,3 +70,8 @@ setup_interface() { ubus call network.interface."$config" add_device "{ \"name\": \"$iface\" }" } +do_sysctl() { + [ -n "$2" ] && \ + sysctl -n -e -w "$1=$2" >/dev/null || \ + sysctl -n -e "$1" +}