Module Name: src Committed By: roy Date: Mon Jul 3 16:43:01 UTC 2017
Modified Files: src/sys/netinet: ip_output.c Log Message: When outputting, search for the sending address on the sending interface rather than blindly picking the first matcing address from any interface when testing source address validity. This allows another interface to have the same address, but be detached. To generate a diff of this commit: cvs rdiff -u -r1.279 -r1.280 src/sys/netinet/ip_output.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/netinet/ip_output.c diff -u src/sys/netinet/ip_output.c:1.279 src/sys/netinet/ip_output.c:1.280 --- src/sys/netinet/ip_output.c:1.279 Fri May 12 17:53:54 2017 +++ src/sys/netinet/ip_output.c Mon Jul 3 16:43:01 2017 @@ -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 <sys/cdefs.h> -__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 * 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 * * 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.