On 24/01/17(Tue) 04:55, Peter Hessler wrote:
> On 2017 Jan 24 (Tue) at 02:38:54 +0100 (+0100), Peter Hessler wrote:
> :When an interface loses link, we delete all directly connected and
> :cloned routes.  However, this means we also lose any BFD configuration
> :on those routes.
> :
> :Surviving link-down is pretty much mandatory for BFD to work.
> :
> :So instead, I bypass the route deletion, and clean up the link-local
> :gateway information.
> :
> :$ arp -n | grep 203.0.113.9
> :203.0.113.9                          (incomplete)          em1 expired   
> :
> :$ netstat -rnf inet | grep 203.0.113.9
> :203.0.113.9        link#2             HLcF       2       53     -     3 em1  
> :
> :OK?
> :
> 
> Even nicer, now I only expire the route, instead of poking at some of
> the internals.

There's no need to expire it, bringing the route down is enough.
Expiration means you assume the route represents a L2 entry.  Plus
rt_expire should be only modified by ARP/NDP code.

Just change:

        !ISSET(rt->rt_flags, RTF_CACHED)

into
        !ISSET(rt->rt_flags, RTF_CACHED|RTF_BFD)


But this really show that BFD data structure don't need to be linked to
rtentries.

> Index: sys/net/route.c
> ===================================================================
> RCS file: /cvs/src/sys/net/route.c,v
> retrieving revision 1.347
> diff -u -p -u -p -r1.347 route.c
> --- sys/net/route.c   20 Jan 2017 08:10:54 -0000      1.347
> +++ sys/net/route.c   24 Jan 2017 03:55:01 -0000
> @@ -1760,13 +1760,27 @@ rt_if_linkstate_change(struct rtentry *r
>                        * new routes from a better source.
>                        */
>                       if (ISSET(rt->rt_flags, RTF_CLONED|RTF_DYNAMIC) &&
> -                         !ISSET(rt->rt_flags, RTF_CACHED)) {
> +                         !ISSET(rt->rt_flags, RTF_CACHED)
> +#ifdef BFD
> +                         && !ISSET(rt->rt_flags, RTF_BFD)
> +#endif
> +                         ) {
>                               int error;
>  
>                               if ((error = rtdeletemsg(rt, ifp, id)))
>                                       return (error);
>                               return (EAGAIN);
>                       }
> +#ifdef BFD
> +                     /*
> +                      * in the BFD case, expire the route
> +                      */
> +                     if (ISSET(rt->rt_flags, RTF_BFD) &&
> +                         ISSET(rt->rt_flags, RTF_CLONED) &&
> +                         (rt->rt_gateway->sa_family == AF_LINK)) {
> +                             rt->rt_expire = time_uptime;
> +                     }
> +#endif
>                       /* take route down */
>                       rt->rt_flags &= ~RTF_UP;
>                       rtable_mpath_reprio(id, rt_key(rt),
> 
> 
> -- 
> Only presidents, editors, and people with tapeworms have the right to
> use the editorial "we."
> 

Reply via email to