base-files: implement a generic mechanism to map per-interface sysctls to uci. -...
authorJo-Philipp Wich <jow@openwrt.org>
Sun, 17 Jul 2011 17:10:30 +0000 (17:10 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sun, 17 Jul 2011 17:10:30 +0000 (17:10 +0000)
SVN-Revision: 27653

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

index d537ed3c170ea8974d064ccca9d43c36254051df..9cac1f058b93c4e21e4d284e1a3ec8ff0b9697df 100644 (file)
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/kernel.mk
 
 PKG_NAME:=base-files
-PKG_RELEASE:=75
+PKG_RELEASE:=76
 
 PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
 PKG_BUILD_DEPENDS:=opkg/host
index 03d7ca1f7a523925a59039268176533e23d51b0d..cf5b197b59a0f92e6eede74d5fdfd0f52a0e2917 100755 (executable)
@@ -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
@@ -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