For those who cramp on the one IP per interface thinking.
The renaming of the variable names must be done, because of a bug
in /etc/functions.sh which doesn't allow local variables.
Index: package/base-files/files/lib/network/config.sh
===================================================================
--- package/base-files/files/lib/network/config.sh (Revision 18843)
+++ package/base-files/files/lib/network/config.sh (Arbeitskopie)
@@ -233,48 +233,50 @@
}
setup_interface() {
- local iface="$1"
+ local iface0="$1"
local config="$2"
local proto="$3"
local vifmac="$4"
+ local ip6addr0=
[ -n "$config" ] || {
- config=$(find_config "$iface")
+ config=$(find_config "$iface0")
[ "$?" = 0 ] || return 1
}
- prepare_interface "$iface" "$config" "$vifmac" || return 0
+ prepare_interface "$iface0" "$config" "$vifmac" || return 0
- [ "$iface" = "br-$config" ] && {
+ [ "$iface0" = "br-$config" ] && {
# need to bring up the bridge and wait a second for
# it to switch to the 'forwarding' state, otherwise
# it will lose its routes...
- ifconfig "$iface" up
+ ifconfig "$iface0" up
sleep 1
}
# Interface settings
- grep "$iface:" /proc/net/dev > /dev/null && {
+ grep "$iface0:" /proc/net/dev > /dev/null && {
local mtu macaddr
config_get mtu "$config" mtu
config_get macaddr "$config" macaddr
- [ -n "$macaddr" ] && $DEBUG ifconfig "$iface" down
- $DEBUG ifconfig "$iface" ${macaddr:+hw ether "$macaddr"} ${mtu:+mtu $mtu} up
+ [ -n "$macaddr" ] && $DEBUG ifconfig "$iface0" down
+ $DEBUG ifconfig "$iface0" ${macaddr:+hw ether "$macaddr"} ${mtu:+mtu $mtu} up
}
- set_interface_ifname "$config" "$iface"
+ set_interface_ifname "$config" "$iface0"
- pidfile="/var/run/$iface.pid"
+ pidfile="/var/run/$iface0.pid"
[ -n "$proto" ] || config_get proto "$config" proto
case "$proto" in
static)
- setup_interface_static "$iface" "$config"
+ config_get ip6addr0 "$config" ip6addr
+ setup_interface_static "$iface0" "$config"
;;
dhcp)
# prevent udhcpc from starting more than once
- lock "/var/lock/dhcp-$iface"
+ lock "/var/lock/dhcp-$iface0"
local pid="$(cat "$pidfile" 2>/dev/null)"
if [ -d "/proc/$pid" ] && grep udhcpc "/proc/${pid}/cmdline" >/dev/null 2>/dev/null; then
- lock -u "/var/lock/dhcp-$iface"
+ lock -u "/var/lock/dhcp-$iface0"
else
local ipaddr netmask hostname proto1 clientid
config_get ipaddr "$config" ipaddr
@@ -284,21 +286,21 @@
config_get clientid "$config" clientid
[ -z "$ipaddr" ] || \
- $DEBUG ifconfig "$iface" "$ipaddr" ${netmask:+netmask "$netmask"}
+ $DEBUG ifconfig "$iface0" "$ipaddr" ${netmask:+netmask "$netmask"}
# don't stay running in background if dhcp is not the main proto on the interface (e.g. when using pptp)
local dhcpopts
[ ."$proto1" != ."$proto" ] && dhcpopts="-n -q"
- $DEBUG eval udhcpc -t 0 -i "$iface" ${ipaddr:+-r $ipaddr} ${hostname:+-H $hostname} ${clientid:+-c $clientid} -b -p "$pidfile" ${dhcpopts:- -R &}
- lock -u "/var/lock/dhcp-$iface"
+ $DEBUG eval udhcpc -t 0 -i "$iface0" ${ipaddr:+-r $ipaddr} ${hostname:+-H $hostname} ${clientid:+-c $clientid} -b -p "$pidfile" ${dhcpopts:- -R &}
+ lock -u "/var/lock/dhcp-$iface0"
fi
;;
none)
- setup_interface_none "$iface" "$config"
+ setup_interface_none "$iface0" "$config"
;;
*)
if ( eval "type setup_interface_$proto" ) >/dev/null 2>/dev/null; then
- eval "setup_interface_$proto '$iface' '$config' '$proto'"
+ eval "setup_interface_$proto '$iface0' '$config' '$proto'"
else
echo "Interface type $proto not supported."
return 1
@@ -306,7 +308,7 @@
;;
esac
[ "$proto" = none ] || {
- for ifn in `ifconfig | grep "^$iface:" | awk '{print $1}'`; do
+ for ifn in `ifconfig | grep "^$iface0:" | awk '{print $1}'`; do
ifconfig "$ifn" down
done
}
@@ -314,9 +316,15 @@
local aliases
config_set "$config" aliases ""
config_set "$config" alias_count 0
- config_foreach setup_interface_alias alias "$config" "$iface"
+ config_foreach setup_interface_alias alias "$config" "$iface0"
config_get aliases "$config" aliases
[ -z "$aliases" ] || uci_set_state network "$config" aliases "$aliases"
+
+ # put the ip6addr back to the beginning to become the main ip again
+ [ -z "$ip6addr0" ] || {
+ $DEBUG ifconfig "$iface0" del "$ip6addr0"
+ $DEBUG ifconfig "$iface0" add "$ip6addr0"
+ }
}
unbridge() {
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel