Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet When outputting, search for the sending address ...



details:   https://anonhg.NetBSD.org/src/rev/5cd65f48e62e
branches:  trunk
changeset: 825202:5cd65f48e62e
user:      roy <roy%NetBSD.org@localhost>
date:      Mon Jul 03 16:43:01 2017 +0000

description:
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.

diffstat:

 sys/netinet/ip_output.c |  12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diffs (47 lines):

diff -r e3cb830cb460 -r 5cd65f48e62e sys/netinet/ip_output.c
--- a/sys/netinet/ip_output.c   Mon Jul 03 13:18:31 2017 +0000
+++ b/sys/netinet/ip_output.c   Mon Jul 03 16:43:01 2017 +0000
@@ -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 @@
        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 @@
         * 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 @@
         * 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.



Home | Main Index | Thread Index | Old Index