On 20/06/16(Mon) 00:32, Alexander Bluhm wrote: > On Tue, Jun 14, 2016 at 12:02:34PM +0200, Martin Pieuchot wrote: > > --- netinet/in_pcb.c 19 Apr 2016 22:16:25 -0000 1.206 > > +++ netinet/in_pcb.c 14 Jun 2016 09:57:25 -0000 > > @@ -924,8 +924,10 @@ in_selectsrc(struct in_addr **insrc, str > > * If we found a route, use the address > > * corresponding to the outgoing interface. > > */ > > - if (ro->ro_rt != NULL) > > - ia = ifatoia(ro->ro_rt->rt_ifa); > > + if (ro->ro_rt != NULL) { > > + *insrc = &satosin(ro->ro_rt->rt_addr)->sin_addr; > > + return (0); > > + } > > > > if (ia == NULL) > > return (EADDRNOTAVAIL); > > A ia is never set, the code below this line is dead. Perhaps change > the logic to > if (ro->ro_rt == NULL) > return (EADDRNOTAVAIL);
Or like that? Index: netinet/in_pcb.c =================================================================== RCS file: /cvs/src/sys/netinet/in_pcb.c,v retrieving revision 1.207 diff -u -p -r1.207 in_pcb.c --- netinet/in_pcb.c 18 Jun 2016 10:36:13 -0000 1.207 +++ netinet/in_pcb.c 29 Jun 2016 10:15:51 -0000 @@ -879,7 +879,6 @@ in_selectsrc(struct in_addr **insrc, str u_int rtableid) { struct sockaddr_in *sin2; - struct in_ifaddr *ia = NULL; /* * If the socket(if any) is already bound, use that bound address @@ -901,6 +900,8 @@ in_selectsrc(struct in_addr **insrc, str ifp = if_get(mopts->imo_ifidx); if (ifp != NULL) { + struct in_ifaddr *ia = NULL; + if (ifp->if_rdomain == rtable_l2(rtableid)) IFP_TO_IA(ifp, ia); if (ia == NULL) { @@ -941,14 +942,12 @@ in_selectsrc(struct in_addr **insrc, str * If we found a route, use the address * corresponding to the outgoing interface. */ - if (ro->ro_rt != NULL) - ia = ifatoia(ro->ro_rt->rt_ifa); - - if (ia == NULL) - return (EADDRNOTAVAIL); + if (ro->ro_rt != NULL) { + *insrc = &satosin(ro->ro_rt->rt_addr)->sin_addr; + return (0); + } - *insrc = &ia->ia_addr.sin_addr; - return (0); + return (EADDRNOTAVAIL); } void Index: netinet6/in6_src.c =================================================================== RCS file: /cvs/src/sys/netinet6/in6_src.c,v retrieving revision 1.73 diff -u -p -r1.73 in6_src.c --- netinet6/in6_src.c 27 Jun 2016 16:36:08 -0000 1.73 +++ netinet6/in6_src.c 28 Jun 2016 14:17:09 -0000 @@ -257,8 +257,11 @@ in6_selectsrc(struct in6_addr **in6src, 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) { /* xxx scope error ?*/ + *in6src = + &satosin6(ro->ro_rt->rt_addr)->sin6_addr; + return (0); + } } if (ia6 == NULL) return (EHOSTUNREACH); /* no route */