From owner-freebsd-net Sat Jun 8 9:24:49 2002 Delivered-To: freebsd-net@freebsd.org Received: from Awfulhak.org (gw.Awfulhak.org [217.204.245.18]) by hub.freebsd.org (Postfix) with ESMTP id 2469337B40A for ; Sat, 8 Jun 2002 09:24:37 -0700 (PDT) Received: from hak.lan.Awfulhak.org (root@hak.lan.Awfulhak.org [IPv6:fec0::1:12]) by Awfulhak.org (8.12.3/8.12.3) with ESMTP id g58GOZKZ055919; Sat, 8 Jun 2002 17:24:35 +0100 (BST) (envelope-from brian@Awfulhak.org) Received: from hak.lan.Awfulhak.org (brian@localhost [IPv6:::1]) by hak.lan.Awfulhak.org (8.12.3/8.12.3) with SMTP id g58GOX9B050707; Sat, 8 Jun 2002 17:24:33 +0100 (BST) (envelope-from brian@Awfulhak.org) Date: Sat, 8 Jun 2002 17:24:32 +0100 From: Brian Somers To: Iasen Kostoff Cc: ikostov@otel.net, freebsd-net@FreeBSD.ORG, vova@sw.ru Subject: Re: host routes for interface addresses Message-Id: <20020608172432.3f030ceb.brian@Awfulhak.org> In-Reply-To: <20020608171620.S34125-100000@shadowhand.OTEL.net> References: <20020608145134.07fda923.brian@Awfulhak.org> <20020608171620.S34125-100000@shadowhand.OTEL.net> X-Mailer: Sylpheed version 0.7.5claws (GTK+ 1.2.10; i386-portbld-freebsd5.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 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: > > > On Sat, 8 Jun 2002, Brian Somers wrote: > > > On Fri, 7 Jun 2002 17:27:46 +0300 (EEST), Iasen Kostov > > wrote: > > > > > > > > > On Fri, 7 Jun 2002, Iasen Kostov wrote: > > > > > > > > > > > I think it's possible to use SIOCSIFCAP to tell the kernel not > > > > to set > > > > host route via IFCAP_NOROUTE or something similar which will set > > > > IFCAP_NOROUTE in uif_capenable. This flag will be checked in > > > > in_ifinit() and if it is set no host route will be added. And > > > > ofcourse there should be a way to set this by ifconfig ( > > > > -noroute for example). > > > > What you think about this ? > > > > > > > Hum or set an iface flag IFF_NOROUTE in struct ifnet.if_flags by > > > SIOCGIFFLAGS ioctl. > > > What you think ? > > > > The problem is that ifnet::if_flags is a short and all of it's bits > > are already used up :( > > > > -- > > Brian > > > > > > > > Don't _EVER_ lose your sense of humour ! > > > > > 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 ? > -- Brian Don't _EVER_ lose your sense of humour ! To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message