On Mon, Aug 24, 2020 at 05:34:09PM +0200, Denis Fondras wrote:
> While working on source selection, I noticed the IPv6 source was not honored
> when set from route(8) with -ifa.
> 
> After discussing with florian@, here is a proposed change. It chooses the 
> source
> address associated with the route (hence honoring -ifa) instead of the first
> address of the output interface which becomes the source address of last
> resort.

To clarify, this is independent of my recent work in
in6_ifawithscope(), -ifa did not work with the old code, either.

Turns out this is not correct. I seems to always bypass
in6_ifawithscope(), so on a system with slaac where default is on a
link local address this will pick a link local address as the source.
That's not going to work.

> 
> Index: netinet6/in6_src.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet6/in6_src.c,v
> retrieving revision 1.81
> diff -u -p -r1.81 in6_src.c
> --- netinet6/in6_src.c        2 Dec 2016 11:16:04 -0000       1.81
> +++ netinet6/in6_src.c        24 Aug 2020 15:14:53 -0000
> @@ -207,13 +207,14 @@ in6_pcbselsrc(struct in6_addr **in6src, 
>        */
>  
>       if (ro->ro_rt) {
> -             ifp = if_get(ro->ro_rt->rt_ifidx);
> -             if (ifp != NULL) {
> -                     ia6 = in6_ifawithscope(ifp, dst, rtableid);
> -                     if_put(ifp);
> +             ia6 = ifatoia6(ro->ro_rt->rt_ifa);
> +             if (ia6 == NULL) {
> +                     ifp = if_get(ro->ro_rt->rt_ifidx);
> +                     if (ifp != NULL) {
> +                             ia6 = in6_ifawithscope(ifp, dst, rtableid);
> +                             if_put(ifp);
> +                     }
>               }
> -             if (ia6 == NULL) /* xxx scope error ?*/
> -                     ia6 = ifatoia6(ro->ro_rt->rt_ifa);
>       }
>       if (ia6 == NULL)
>               return (EHOSTUNREACH);  /* no route */
> 

-- 
I'm not entirely sure you are real.

Reply via email to