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. 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 */