X-Git-Url: https://git.rohieb.name/openwrt.git/blobdiff_plain/ada8f6b917ea6848cae6c0df5860f2d4f4eb8409..02e3b0f5531da86339e8da86b1f78a9b6aba7f50:/package/base-files/files/lib/network/config.sh?ds=sidebyside diff --git a/package/base-files/files/lib/network/config.sh b/package/base-files/files/lib/network/config.sh index a194ab8e2..cf5b197b5 100755 --- a/package/base-files/files/lib/network/config.sh +++ b/package/base-files/files/lib/network/config.sh @@ -9,6 +9,23 @@ do_sysctl() { sysctl -n -e "$1" } +map_sysctls() { + local cfg="$1" + local ifn="$2" + + local fam + for fam in ipv4 ipv6; do + if [ -d /proc/sys/net/$fam ]; then + local key + for key in /proc/sys/net/$fam/*/$ifn/*; do + local val + config_get val "$cfg" "${fam}_${key##*/}" + [ -n "$val" ] && echo -n "$val" > "$key" + done + fi + done +} + find_config() { local iftype device iface ifaces ifn for ifn in $interfaces; do @@ -96,8 +113,8 @@ add_dns() { done [ -n "$cfg" ] && { - uci_set_state network "$cfg" dns "$add" - uci_set_state network "$cfg" resolv_dns "$add" + uci_toggle_state network "$cfg" dns "$add" + uci_toggle_state network "$cfg" resolv_dns "$add" } } @@ -156,6 +173,9 @@ prepare_interface() { ifconfig "$iface" down ifconfig "$iface" hw ether "$vifmac" up } + + # Apply sysctl settings + map_sysctls "$config" "$iface" } # Setup VLAN interfaces @@ -176,7 +196,7 @@ prepare_interface() { for dev in $(sort_list "$devices" "$iface"); do append newdevs "$dev" done - uci_set_state network "$config" device "$newdevs" + uci_toggle_state network "$config" device "$newdevs" $DEBUG ifconfig "$iface" 0.0.0.0 $DEBUG do_sysctl "net.ipv6.conf.$iface.disable_ipv6" 1 $DEBUG brctl addif "br-$config" "$iface" @@ -210,8 +230,8 @@ set_interface_ifname() { local device config_get device "$1" device - uci_set_state network "$config" ifname "$ifname" - uci_set_state network "$config" device "$device" + uci_toggle_state network "$config" ifname "$ifname" + uci_toggle_state network "$config" device "$device" } setup_interface_none() {