On Thu, Oct 02, 2014 at 10:31:04AM +0200, Martin Pieuchot wrote:
> Most of the local routes added on a system contain the link-layer
> address of the interface they are attached too.  It is like that
> because these routes must be compatible with the cloned routes for
> ARP or ND.
> 
> But for loopback or point-to-point interfaces it is different since
> the 'gateway' of such routes contain 127.0.0.1.  So there's no reason
> to flag such route with RTF_LLINFO.  Diff below does that, as a result
> you won't see an incomplete entry in arp(8) for loopback addresses.
> 
> -127.0.0.1          127.0.0.1          UHLl       1        0 32768     1 lo0
> +127.0.0.1          127.0.0.1          UHl        1        0 32768     1 lo0
> 
> ok?

Yes please I was wondering about the 'L' on those routes. OK.
 
> Index: net/route.c
> ===================================================================
> RCS file: /cvs/src/sys/net/route.c,v
> retrieving revision 1.184
> diff -u -p -r1.184 route.c
> --- net/route.c       1 Oct 2014 08:38:29 -0000       1.184
> +++ net/route.c       2 Oct 2014 08:09:58 -0000
> @@ -1202,6 +1202,7 @@ void
>  rt_ifa_addloop(struct ifaddr *ifa)
>  {
>       struct rtentry *rt;
> +     u_int flags = RTF_HOST|RTF_LOCAL;
>  
>       /*
>        * If the configured address correspond to the magical "any"
> @@ -1225,11 +1226,13 @@ rt_ifa_addloop(struct ifaddr *ifa)
>               break;
>       }
>  
> +     if (!ISSET(ifa->ifa_ifp->if_flags, (IFF_LOOPBACK|IFF_POINTOPOINT)))
> +             flags |= RTF_LLINFO;
> +
>       /* If there is no loopback entry, allocate one. */
>       rt = rtalloc1(ifa->ifa_addr, 0, ifa->ifa_ifp->if_rdomain);
> -     if (rt == NULL || (rt->rt_flags & (RTF_HOST|RTF_LLINFO|RTF_LOCAL)) == 0)
> -             rt_ifa_add(ifa, RTF_UP| RTF_HOST | RTF_LLINFO | RTF_LOCAL,
> -                 ifa->ifa_addr);
> +     if (rt == NULL || !ISSET(rt->rt_flags, flags));
> +             rt_ifa_add(ifa, RTF_UP | flags, ifa->ifa_addr);
>       if (rt)
>               rt->rt_refcnt--;
>  }
> @@ -1241,6 +1244,7 @@ void
>  rt_ifa_delloop(struct ifaddr *ifa)
>  {
>       struct rtentry *rt;
> +     u_int flags = RTF_HOST|RTF_LOCAL;
>  
>       /*
>        * We do not add local routes for such address, so do not bother
> @@ -1262,6 +1266,9 @@ rt_ifa_delloop(struct ifaddr *ifa)
>               break;
>       }
>  
> +     if (!ISSET(ifa->ifa_ifp->if_flags, (IFF_LOOPBACK|IFF_POINTOPOINT)))
> +             flags |= RTF_LLINFO;
> +
>       /*
>        * Before deleting, check if a corresponding local host
>        * route surely exists.  With this check, we can avoid to
> @@ -1271,9 +1278,8 @@ rt_ifa_delloop(struct ifaddr *ifa)
>        * to a shared medium.
>        */
>       rt = rtalloc1(ifa->ifa_addr, 0, ifa->ifa_ifp->if_rdomain);
> -     if (rt != NULL && (rt->rt_flags & (RTF_HOST|RTF_LLINFO|RTF_LOCAL)) != 0)
> -             rt_ifa_del(ifa,  RTF_HOST | RTF_LLINFO | RTF_LOCAL,
> -                 ifa->ifa_addr);
> +     if (rt != NULL && ISSET(rt->rt_flags, flags))
> +             rt_ifa_del(ifa, flags, ifa->ifa_addr);
>       if (rt)
>               rt->rt_refcnt--;
>  }
> 

-- 
:wq Claudio

Reply via email to