summaryrefslogtreecommitdiff
path: root/sys/netinet/in_pcb.c
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2016-06-30 12:36:28 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2016-06-30 12:36:28 +0000
commit80c467c6c65914f49732d82d9759954c6fdab7b0 (patch)
treee1c48ce2d3499a4e578d7bb7d6e3154c60d47471 /sys/netinet/in_pcb.c
parent56c60705f239c978d6ff8cc5d017ad881bbd89e6 (diff)
Use ``rt_addr'' rather than ``rt_ifa'' to get the source address
corresponding to a route. ok florian@ on a previous version, input and ok bluhm@
Diffstat (limited to 'sys/netinet/in_pcb.c')
-rw-r--r--sys/netinet/in_pcb.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index 5cf54ac7550..24526a9e6bd 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in_pcb.c,v 1.207 2016/06/18 10:36:13 vgross Exp $ */
+/* $OpenBSD: in_pcb.c,v 1.208 2016/06/30 12:36:27 mpi Exp $ */
/* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */
/*
@@ -879,7 +879,6 @@ in_selectsrc(struct in_addr **insrc, struct sockaddr_in *sin,
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, struct sockaddr_in *sin,
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, struct sockaddr_in *sin,
* 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