aboutsummaryrefslogtreecommitdiffstats
path: root/main/busybox-initscripts/default.script
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2012-03-15 20:36:23 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2012-03-15 21:04:08 +0000
commit01e62c2fa4fdc836d340ee47cd079c4d611763a2 (patch)
tree22e81f0165aae37ccdaa9693abe94744183f282d /main/busybox-initscripts/default.script
parentd2b7964762199998966a0473e65b72624d54411e (diff)
downloadaports-01e62c2fa4fdc836d340ee47cd079c4d611763a2.tar.bz2
aports-01e62c2fa4fdc836d340ee47cd079c4d611763a2.tar.xz
main/busybox-initscripts: support multiple dhcp interfaces
We set the metric to 300 + ifindex for wifi and 200 + ifindex for others. This is basically what dhcpcd does. Also allow overriding the metric in interfaces file. This makes multi isp setups easier.
Diffstat (limited to 'main/busybox-initscripts/default.script')
-rw-r--r--main/busybox-initscripts/default.script27
1 files changed, 23 insertions, 4 deletions
diff --git a/main/busybox-initscripts/default.script b/main/busybox-initscripts/default.script
index c6cfbc5be1..5447080ec9 100644
--- a/main/busybox-initscripts/default.script
+++ b/main/busybox-initscripts/default.script
@@ -34,16 +34,35 @@ deconfig() {
ip addr flush dev $interface
}
+is_wifi() {
+ test -e /sys/class/net/$interface/phy80211
+}
+
+if_index() {
+ cat /sys/class/net/$interface/ifindex
+}
+
+calc_metric() {
+ local base=
+ if is_wifi; then
+ base=300
+ else
+ base=200
+ fi
+ echo $(( $base + $(if_index) ))
+}
+
routes() {
[ -z "$router" ] && return
- local gw metric
+ local gw= num=
while ip route del default via dev $interface 2>/dev/null; do
:
done
- metric=0
+ num=0
for gw in $router; do
- route add default gw $gw dev $interface metric $metric
- metric=$(( $metric + 1 ))
+ ip route add 0.0.0.0/0 via $gw dev $interface \
+ metric $(( $num + ${IF_METRIC:-$(calc_metric)} ))
+ num=$(( $num + 1 ))
done
}