[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    ip route problem
From:       Jean Wolter <jw5 () os ! inf ! tu-dresden ! de>
Date:       2007-03-30 8:40:37
Message-ID: 864po3qg3e.fsf () erwin ! inf ! tu-dresden ! de
[Download RAW message or body]

Hello,

busybox ip and the original ip utility behave differently when setting
the following route (verified with ip route show using the original ip
utility):

   ip route add 10.0.0.138 dev eth0

Result for busybox ip:

       # ip route add 10.0.0.138 dev eth0
       # /usr/local/bin/ip route show
       10.0.0.138 dev eth0

Result for ip:

       # /usr/local/bin/ip route add 10.0.0.138 dev eth0
       #  /usr/local/bin/ip route show
       10.0.0.138 dev eth0  scope link

A following "ip route add default via 10.0.0.138" fails for busybox
ip, since the kernel can not find a route to 10.0.0.138 (it replies
with Network is unreachable).

The reasons seems to be that the original ip utility explicitly sets
the scope after parsing all parameters. This is missing in busybox,
the attached patch fixes this. I took this from the original iproute
sources and removed some variables, which are not needed for busybox.

regards,
Jean


["busybox-iproute2_scope.patch" (text/x-patch)]

diff -upr busybox-1.5.0.orig/networking/libiproute/iproute.c \
                busybox-1.5.0/networking/libiproute/iproute.c
--- busybox-1.5.0.orig/networking/libiproute/iproute.c	2007-03-22 21:21:22.000000000 \
                +0100
+++ busybox-1.5.0/networking/libiproute/iproute.c	2007-03-30 10:00:40.650195096 +0200
@@ -433,6 +433,21 @@ static int iproute_modify(int cmd, unsig
 		addattr_l(&req.n, sizeof(req), RTA_METRICS, RTA_DATA(mxrta), RTA_PAYLOAD(mxrta));
 	}
 
+	if (req.r.rtm_type == RTN_LOCAL ||
+	    req.r.rtm_type == RTN_NAT)
+		req.r.rtm_scope = RT_SCOPE_HOST;
+	else if (req.r.rtm_type == RTN_BROADCAST ||
+		 req.r.rtm_type == RTN_MULTICAST ||
+		 req.r.rtm_type == RTN_ANYCAST)
+		req.r.rtm_scope = RT_SCOPE_LINK;
+	else if (req.r.rtm_type == RTN_UNICAST ||
+		 req.r.rtm_type == RTN_UNSPEC) {
+		if (cmd == RTM_DELROUTE)
+			req.r.rtm_scope = RT_SCOPE_NOWHERE;
+		else if (!gw_ok)
+			req.r.rtm_scope = RT_SCOPE_LINK;
+	}
+
 	if (req.r.rtm_family == AF_UNSPEC) {
 		req.r.rtm_family = AF_INET;
 	}



_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic