diff options
author | jow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2010-11-17 19:11:50 +0000 |
---|---|---|
committer | jow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2010-11-17 19:11:50 +0000 |
commit | b71062831ca43cdf7be948640f13288b469eed9f (patch) | |
tree | 18df62e3f760aac318a0d1bf6ce01b12683a5820 /package | |
parent | 93b487b3a576416e0e80e697a8c890ba1ceaf24f (diff) |
[package] base-file: add metric option for static and dhcp protos, this simplifies the management of multiple default routes
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@24020 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package')
-rw-r--r-- | package/base-files/Makefile | 2 | ||||
-rwxr-xr-x | package/base-files/files/lib/network/config.sh | 7 | ||||
-rwxr-xr-x | package/base-files/files/usr/share/udhcpc/default.script | 4 |
3 files changed, 8 insertions, 5 deletions
diff --git a/package/base-files/Makefile b/package/base-files/Makefile index 67d1d76223..9ed6d9939b 100644 --- a/package/base-files/Makefile +++ b/package/base-files/Makefile @@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=base-files -PKG_RELEASE:=60 +PKG_RELEASE:=61 PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/ PKG_BUILD_DEPENDS:=opkg/host diff --git a/package/base-files/files/lib/network/config.sh b/package/base-files/files/lib/network/config.sh index d285da23ad..358e610f62 100755 --- a/package/base-files/files/lib/network/config.sh +++ b/package/base-files/files/lib/network/config.sh @@ -228,16 +228,17 @@ setup_interface_static() { config_get ip6addr "$config" ip6addr [ -z "$ipaddr" -o -z "$netmask" ] && [ -z "$ip6addr" ] && return 1 - local gateway ip6gw dns bcast + local gateway ip6gw dns bcast metric config_get gateway "$config" gateway config_get ip6gw "$config" ip6gw config_get dns "$config" dns config_get bcast "$config" broadcast + config_get metric "$config" metric [ -z "$ipaddr" ] || $DEBUG ifconfig "$iface" "$ipaddr" netmask "$netmask" broadcast "${bcast:-+}" [ -z "$ip6addr" ] || $DEBUG ifconfig "$iface" add "$ip6addr" - [ -z "$gateway" ] || $DEBUG route add default gw "$gateway" dev "$iface" - [ -z "$ip6gw" ] || $DEBUG route -A inet6 add default gw "$ip6gw" dev "$iface" + [ -z "$gateway" ] || $DEBUG route add default gw "$gateway" ${metric:+metric $metric} dev "$iface" + [ -z "$ip6gw" ] || $DEBUG route -A inet6 add default gw "$ip6gw" ${metric:+metric $metric} dev "$iface" [ -z "$dns" ] || add_dns "$config" $dns config_get type "$config" TYPE diff --git a/package/base-files/files/usr/share/udhcpc/default.script b/package/base-files/files/usr/share/udhcpc/default.script index 708f847839..9acde829d0 100755 --- a/package/base-files/files/usr/share/udhcpc/default.script +++ b/package/base-files/files/usr/share/udhcpc/default.script @@ -19,6 +19,7 @@ setup_interface () { local old_dns local user_dns local user_router + local user_metric [ -n "$ifc" ] && { old_ip="$(uci_get_state network "$ifc" ipaddr)" @@ -43,6 +44,7 @@ setup_interface () { change_state network "$ifc" lease_gateway "$router" old_router="$(uci_get_state network "$ifc" gateway)" user_router="$(uci_get network "$ifc" gateway)" + user_metric="$(uci_get network "$ifc" metric)" [ -n "$user_router" ] && router="$user_router" } @@ -51,7 +53,7 @@ setup_interface () { local valid_gw="" for i in $router ; do - route add default gw $i dev $interface + route add default gw $i ${user_metric:+metric $user_metric} dev $interface valid_gw="${valid_gw:+$valid_gw|}$i" done |