Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 8 Jun 2002 17:24:32 +0100
From:      Brian Somers <brian@Awfulhak.org>
To:        Iasen Kostoff <tbyte@otel.net>
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>

next in thread | previous in thread | raw e-mail | index | archive | help
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:
> 
> 
> On Sat, 8 Jun 2002, Brian Somers wrote:
> 
> > On Fri, 7 Jun 2002 17:27:46 +0300 (EEST), Iasen Kostov
> > <ikostov@otel.net> 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 <brian@Awfulhak.org>                      
> > <brian.somers@sun.com>
> >       <http://www.Awfulhak.org>;               
> >       <brian@[uk.]FreeBSD.org>
> > Don't _EVER_ lose your sense of humour !      
> > <brian@[uk.]OpenBSD.org>
> >
>   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 <brian@Awfulhak.org>                       <brian.somers@sun.com>
      <http://www.Awfulhak.org>;                <brian@[uk.]FreeBSD.org>
Don't _EVER_ lose your sense of humour !       <brian@[uk.]OpenBSD.org>

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?20020608172432.3f030ceb.brian>