[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#646961: patch



On 05.04.2012 15:27, Robert Millan wrote:
> El 5 d’abril de 2012 11:37, Michael Tokarev <mjt@tls.msk.ru> ha escrit:
>> I also wonder if we can just test for /lib/freebsd/route
>> existance instead of checking $(uname -r) ?
>>
>> Somehow I'm not comfortable with the uname check...
> 
> It doesn't make a difference now.  But what will you do when we remove
> the wrapper and move /lib/freebsd/route back to /sbin?  Then you will
> need uname.

Oh. I didn't know /sbin/route wrapper is going away.  Ok, that makes
sense.

[]
> You can't archieve compatible CLI among net-tools/Linux route and
> FreeBSD route.  They were never meant to be compatible.  All existing
> portable DHCP clients adapt to this and ship separate setup scripts
> for each platform.

And this is a pity really, because the difference is actually
very small, at least in the basic syntax.  It is merely the
"gw" keyword which is required by linux route and not accepted
by freebsd route.  Fixing _both_ of them should be trivial, so
_both_ will understand either form...

>> Besides, I'm not really sure why/when/how several routes can
>> be present.
> 
> You mean because interfaces are not specified?  The kernel associates
> routes with interfaces automatically, try "netstat -nr" and check the
> output.

I know a route is assotiated with an interface.

What I'm unsure about is why dhcpc script is ready to
see "$route" being several words.  It makes very little
sense even on linux, since only lowest-metric route will
be used anyway, and the rest will be ignored.  But I've
no idea if "$route" variable from dhcpc can have >1 word.

This is unrelated to this freebsd/linux difference, but
since the changes are in the same area I just tried to
understand where this multiple-routes code in the script
comes from.  Digging further... ;)


Here's what I'm after currently:

--- a/debian/tree/udhcpc/etc/udhcpc/default.script
+++ b/debian/tree/udhcpc/etc/udhcpc/default.script
@@ -15,13 +15,23 @@ case $1 in

        if [ -n "$router" ]; then
            echo "$0: Resetting default routes"
-           while /sbin/route del default gw 0.0.0.0 dev $interface; do :; done
-
-           metric=0
-           for i in $router; do
-               /sbin/route add default gw $i dev $interface metric $metric
-               metric=$(($metric + 1))
-           done
+           case $(uname) in
+               *FreeBSD*) # kFreeBSD route uses different location & syntax
+                   /lib/freebsd/route del default
+                   set -- $route #XXX can we have >1 route?
+                   /lib/freebsd/route add default $1
+                   ;;
+               *)
+                   #XXX should we delete any route or only device-specific?
+                   while /sbin/route del default dev $interface
+                   do :; done
+                   m=0
+                   for i in $router; do #XXX can we have >1 route?
+                       /sbin/route add default gw $i dev $interface metric $m
+                       m=$(($m+1))
+                   done
+                   ;;
+           esac
        fi


Thanks,

/mjt



Reply to: