package/base-files: add get_magic_long() to common upgrade script
[openwrt.git] / package / base-files / files / lib / network / config.sh
index 358e610..449d252 100755 (executable)
@@ -3,6 +3,12 @@
 
 # DEBUG="echo"
 
+do_sysctl() {
+       [ -n "$2" ] && \
+               sysctl -n -e -w "$1=$2" >/dev/null || \
+               sysctl -n -e "$1"
+}
+
 find_config() {
        local iftype device iface ifaces ifn
        for ifn in $interfaces; do
@@ -164,14 +170,10 @@ prepare_interface() {
                        local macaddr
                        config_get macaddr "$config" macaddr
                        [ -x /usr/sbin/brctl ] && {
-                               # Remove IPv6 link local addr before adding the iface to the bridge
-                               local llv6="$(ifconfig "$iface")"
-                               case "$llv6" in
-                                       *fe80:*/64*)
-                                               llv6="${llv6#* fe80:}"
-                                               ifconfig "$iface" del "fe80:${llv6%% *}"
-                                       ;;
-                               esac
+                               # Disable IPv6 for bridge ports
+                               do_sysctl net.ipv6.conf.$iface.disable_ipv6 1
+                               [ "${iface##wlan}" != "$iface" ] && \
+                                       do_sysctl net.ipv6.conf.mon.$iface.disable_ipv6 1
 
                                ifconfig "br-$config" 2>/dev/null >/dev/null && {
                                        local newdevs devices
@@ -345,7 +347,7 @@ setup_interface() {
                        local pidfile="/var/run/dhcp-${iface}.pid"
                        service_kill udhcpc "$pidfile"
 
-                       local ipaddr netmask hostname proto1 clientid vendorid broadcast
+                       local ipaddr netmask hostname proto1 clientid vendorid broadcast reqopts
                        config_get ipaddr "$config" ipaddr
                        config_get netmask "$config" netmask
                        config_get hostname "$config" hostname
@@ -353,6 +355,7 @@ setup_interface() {
                        config_get clientid "$config" clientid
                        config_get vendorid "$config" vendorid
                        config_get_bool broadcast "$config" broadcast 0
+                       config_get reqopts "$config" reqopts
 
                        [ -z "$ipaddr" ] || \
                                $DEBUG ifconfig "$iface" "$ipaddr" ${netmask:+netmask "$netmask"}
@@ -368,6 +371,7 @@ setup_interface() {
                                ${clientid:+-c $clientid} \
                                ${vendorid:+-V $vendorid} \
                                -b -p "$pidfile" $broadcast \
+                               ${reqopts:+-O $reqopts} \
                                ${dhcpopts:- -O rootpath -R &}
                ;;
                none)
@@ -411,6 +415,9 @@ unbridge() {
 
                for brdev in $(brctl show | awk '$2 ~ /^[0-9].*\./ { print $1 }'); do
                        brctl delif "$brdev" "$dev" 2>/dev/null >/dev/null
+                       do_sysctl net.ipv6.conf.$dev.disable_ipv6 0
+                       [ "${dev##wlan}" != "$dev" ] && \
+                               do_sysctl net.ipv6.conf.mon.$dev.disable_ipv6 0
                done
        }
 }
This page took 0.023922 seconds and 4 git commands to generate.