Date: Sat, 8 Jun 2002 21:53:59 +0300 (EEST) From: Iasen Kostov <ikostov@otel.net> To: Brian Somers <brian@Awfulhak.org> Cc: freebsd-net@FreeBSD.ORG Subject: Re: host routes for interface addresses Message-ID: <20020608214357.Q9095-100000@shadowhand.OTEL.net> In-Reply-To: <20020608172432.3f030ceb.brian@Awfulhak.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Here is the patch. I'm now looking in the code to see where kernel replays to the interface table requests. I hope there are not a lot of places where it sets ifm_flags. > This certainly seems to make sense. Could you generate a patch and send > it to me ? I can test & commit it, and then maybe look at removing that > horrible BOOTP hack :) > > I haven't looked at it yet, but it'll be worth testing that ifm_flags is > populated correctly in routing socket messages... > > Thanks. > > On Sat, 8 Jun 2002 18:33:44 +0300 (EEST), Iasen Kostoff <tbyte@otel.net> > wrote: > > > The problem is that ifnet::if_flags is a short and all of it's bits > > > are already used up :( > > > > > Yep but I think I solve the problem. > > > > I found this in net/if.h : > > > > /* > > * The following flag(s) ought to go in if_flags, but we cannot change > > * struct ifnet because of binary compatibility, so we store them in > > * if_ipending, which is not used so far. > > * If possible, make sure the value is not conflicting with other > > * IFF flags, so we have an easier time when we want to merge them. > > */ > > > > and decide to use if_ipending utill extend of if_flags. > > > > Just add to the ifr_ifru union of the ifreq struct: > > int ifru_flagslong; > > and this: > > #define ifr_flagslong ifr_ifru.ifru_flagslong /* long flags (int) */ > > > > than in net/if.c I've changed SIOCGIFFLAGS and SIOCSIFFLAGS handling > > in ifioctl() function like this: > > > > case SIOCGIFFLAGS: > > flagslong = ifp->if_flags & 0x0000ffff; > > ifr->ifr_flagslong = flagslong | ifp->if_ipending; > > break; > > > > case SIOCSIFFLAGS: > > error = suser(p); > > if (error) > > return (error); > > -> ifp->if_ipending = ifr->ifr_flagslong & 0xffff0000; > > ... > > > > than ofcourse I fixed and ifconfig's function setifflags() to use > > ifr_flagslong value instead of ifr_flags. It's a partial solution. > > Sysctl that returns iface table should do the same thing as > > SIOCGIFFLAGS handler. I saw that ifm_flags is int that means there > > will not be a problem when sysctl is returning the new flags. And I > > think this doesn't break anything in binary compatibility. > > > > To test all this I add this 2 lines to cmds[] declaration in > > ifconfig.c : > > > > { "noroute", IFF_NOROUTE, setifflags }, > > { "-noroute", -IFF_NOROUTE, setifflags }, > > > > and this line to net/if.h : > > > > #define IFF_NOROUTE 0x20000 /* Interface doesn't need host > > #route. */ > > > > Than a fixed in.c and add a IFF_NOROUTE check in in_ifinit() : > > > > ... > > if (!(ifp->if_ipending & IFF_NOROUTE)) > > if (ia->ia_addr.sin_addr.s_addr != INADDR_ANY || > > ... > > > > And everything work perfect for me on the test machine : > > > > root@test:/sys/netinet on ttyp1 > > #:> ifconfig ed0 10.0.0.0 netmask 255.255.0.0 noroute > > root@test:/sys/netinet on ttyp1 > > #:> netstat -rn > > Routing tables > > Internet: > > Destination Gateway Flags Refs Use Netif > > Expire default 212.36.8.137 UGSc 0 4 > > ed1 127.0.0.1 127.0.0.1 UH 1 10 > > lo0 212.36.8/23 link#2 UC 4 0 > > ed1 > > > > root@test:/sys/netinet on ttyp1 > > #:> ifconfig ed0 10.0.0.0 netmask 255.255.0.0 -noroute > > root@test:/sys/netinet on ttyp1 > > #:> netstat -rn > > Routing tables > > Internet: > > Destination Gateway Flags Refs Use Netif > > Expire default 212.36.8.137 UGSc 0 4 > > ed1 10/16 link#1 UC 0 0 > > ed0 127.0.0.1 127.0.0.1 UH 1 10 > > lo0 212.36.8/23 link#2 UC 3 0 > > ed1 > > > > Could it be done that way, what You think ? > > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020608214357.Q9095-100000>