From owner-freebsd-net Sat Jun 8 8:34: 8 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 0E6D537B406 for ; Sat, 8 Jun 2002 08:33:58 -0700 (PDT) Received: from judicator.otel.net ([212.36.9.113]) by mail.otel.net with esmtp (Exim 3.36 #1) id 17GiDo-000ILK-00; Sat, 08 Jun 2002 18:33:44 +0300 Date: Sat, 8 Jun 2002 18:33:44 +0300 (EEST) From: Iasen Kostoff To: Brian Somers Cc: Iasen Kostov , , Subject: Re: host routes for interface addresses In-Reply-To: <20020608145134.07fda923.brian@Awfulhak.org> Message-ID: <20020608171620.S34125-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 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 ? To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message