diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 214085ed9640..b003014bfeed 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -1,4 +1,4 @@ -/* $NetBSD: ip_output.c,v 1.279 2017/05/12 17:53:54 ryo Exp $ */ +/* $NetBSD: ip_output.c,v 1.280 2017/07/03 16:43:01 roy Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.279 2017/05/12 17:53:54 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.280 2017/07/03 16:43:01 roy Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -236,6 +236,7 @@ ip_output(struct mbuf *m0, struct mbuf *opt, struct route *ro, int flags, struct route iproute; const struct sockaddr_in *dst; struct in_ifaddr *ia = NULL; + struct ifaddr *ifa; int isbroadcast; int sw_csum; u_long mtu; @@ -315,8 +316,6 @@ ip_output(struct mbuf *m0, struct mbuf *opt, struct route *ro, int flags, * If routing to interface only, short circuit routing lookup. */ if (flags & IP_ROUTETOIF) { - struct ifaddr *ifa; - ifa = ifa_ifwithladdr_psref(sintocsa(dst), &psref_ia); if (ifa == NULL) { IP_STATINC(IP_STAT_NOROUTE); @@ -612,7 +611,10 @@ sendit: * validity */ KASSERT(ia == NULL); - ia = in_get_ia_psref(ip->ip_src, &psref_ia); + sockaddr_in_init(&u.dst4, &ip->ip_src, 0); + ifa = ifaof_ifpforaddr_psref(&u.dst, ifp, &psref_ia); + if (ifa != NULL) + ia = ifatoia(ifa); /* * Ensure we only send from a valid address.