[PATCH] ip route metric
Bernhard Reutner-Fischer
rep.dot.nop at gmail.com
Tue Oct 7 08:58:18 UTC 2008
On Tue, Oct 07, 2008 at 10:36:30AM +0200, Natanael Copa wrote:
>Hi,
>
>Attatched patch lets you use the "metric" keyword when adding routes.
>Useful for udhcp scripts:
>
>metric=0
>for gw in $router; do
> ip route add default via $gw dev $interface metric $metric
> metric=$(( $metric + 1 ))
>done
sounds good, please resend with updated usage.h, too.
TIA,
>
>-nc
>
>Index: networking/libiproute/iproute.c
>===================================================================
>--- networking/libiproute/iproute.c (revision 23582)
>+++ networking/libiproute/iproute.c (working copy)
>@@ -291,7 +291,7 @@
> {
> static const char keywords[] ALIGN1 =
> "src\0""via\0""mtu\0""lock\0""protocol\0"USE_FEATURE_IP_RULE("table\0")
>- "dev\0""oif\0""to\0";
>+ "dev\0""oif\0""to\0""metric\0";
> enum {
> ARG_src,
> ARG_via,
>@@ -300,7 +300,8 @@
> USE_FEATURE_IP_RULE(ARG_table,)
> ARG_dev,
> ARG_oif,
>- ARG_to
>+ ARG_to,
>+ ARG_metric,
> };
> enum {
> gw_ok = 1 << 0,
>@@ -387,6 +388,12 @@
> } else if (arg == ARG_dev || arg == ARG_oif) {
> NEXT_ARG();
> d = *argv;
>+ } else if (arg == ARG_metric) {
>+ uint32_t metric;
>+ NEXT_ARG();
>+ if (get_u32(&metric, *argv, 0))
>+ invarg(*argv, "metric");
>+ addattr32(&req.n, sizeof(req), RTA_PRIORITY, metric);
> } else {
> int type;
> inet_prefix dst;
>_______________________________________________
>busybox mailing list
>busybox at busybox.net
>http://busybox.net/cgi-bin/mailman/listinfo/busybox
More information about the busybox
mailing list