From owner-freebsd-net Sat Jun 8 11:54:41 2002 Delivered-To: freebsd-net@freebsd.org Received: from mail.otel.net (gw3.OTEL.net [212.36.8.151]) by hub.freebsd.org (Postfix) with ESMTP id BFE6637B405 for ; Sat, 8 Jun 2002 11:54:09 -0700 (PDT) Received: from judicator.otel.net ([212.36.9.113]) by mail.otel.net with esmtp (Exim 3.36 #1) id 17GlLb-000LvG-00; Sat, 08 Jun 2002 21:53:59 +0300 Date: Sat, 8 Jun 2002 21:53:59 +0300 (EEST) From: Iasen Kostov To: Brian Somers Cc: freebsd-net@FreeBSD.ORG Subject: Re: host routes for interface addresses In-Reply-To: <20020608172432.3f030ceb.brian@Awfulhak.org> Message-ID: <20020608214357.Q9095-100000@shadowhand.OTEL.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org 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 > 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