Source-Changes-HG archive

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

[src/netbsd-8]: src/sys/netinet Pull up following revision(s) (requested by r...



details:   https://anonhg.NetBSD.org/src/rev/b8ab3c8265a7
branches:  netbsd-8
changeset: 850811:b8ab3c8265a7
user:      martin <martin%NetBSD.org@localhost>
date:      Fri Jul 07 09:23:01 2017 +0000

description:
Pull up following revision(s) (requested by roy in ticket #100):
        sys/netinet/ip_output.c: revision 1.280
        sys/netinet/ip_output.c: revision 1.282
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.
Rename u to udst, .dst to .sa and .dst4 to sin.
Create sockaddr for the source address in usrc so it won't stamp on udst.
This fixes a regression caused in r1.280

diffstat:

 sys/netinet/ip_output.c |  32 +++++++++++++++++---------------
 1 files changed, 17 insertions(+), 15 deletions(-)

diffs (94 lines):

diff -r 972c88b42d1f -r b8ab3c8265a7 sys/netinet/ip_output.c
--- a/sys/netinet/ip_output.c   Thu Jul 06 05:29:43 2017 +0000
+++ b/sys/netinet/ip_output.c   Fri Jul 07 09:23: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.279.2.1 2017/07/07 09:23:01 martin 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.279.2.1 2017/07/07 09:23:01 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -236,18 +236,19 @@
        struct route iproute;
        const struct sockaddr_in *dst;
        struct in_ifaddr *ia = NULL;
+       struct ifaddr *ifa;
        int isbroadcast;
        int sw_csum;
        u_long mtu;
        bool natt_frag = false;
        bool rtmtu_nolock;
        union {
-               struct sockaddr         dst;
-               struct sockaddr_in      dst4;
-       } u;
-       struct sockaddr *rdst = &u.dst; /* real IP destination, as opposed
-                                        * to the nexthop
-                                        */
+               struct sockaddr         sa;
+               struct sockaddr_in      sin;
+       } udst, usrc;
+       struct sockaddr *rdst = &udst.sa;       /* real IP destination, as
+                                                * opposed to the nexthop
+                                                */
        struct psref psref, psref_ia;
        int bound;
        bool bind_need_restore = false;
@@ -288,7 +289,7 @@
                memset(&iproute, 0, sizeof(iproute));
                ro = &iproute;
        }
-       sockaddr_in_init(&u.dst4, &ip->ip_dst, 0);
+       sockaddr_in_init(&udst.sin, &ip->ip_dst, 0);
        dst = satocsin(rtcache_getdst(ro));
 
        /*
@@ -303,8 +304,8 @@
 
        if ((rt = rtcache_validate(ro)) == NULL &&
            (rt = rtcache_update(ro, 1)) == NULL) {
-               dst = &u.dst4;
-               error = rtcache_setdst(ro, &u.dst);
+               dst = &udst.sin;
+               error = rtcache_setdst(ro, &udst.sa);
                if (error != 0)
                        goto bad;
        }
@@ -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);
@@ -448,7 +447,7 @@
                         * on the outgoing interface, and the caller did not
                         * forbid loopback, loop back a copy.
                         */
-                       ip_mloopback(ifp, m, &u.dst4);
+                       ip_mloopback(ifp, m, &udst.sin);
                }
 #ifdef MROUTING
                else {
@@ -612,7 +611,10 @@
         * validity
         */
        KASSERT(ia == NULL);
-       ia = in_get_ia_psref(ip->ip_src, &psref_ia);
+       sockaddr_in_init(&usrc.sin, &ip->ip_src, 0);
+       ifa = ifaof_ifpforaddr_psref(&usrc.sa, ifp, &psref_ia);
+       if (ifa != NULL)
+               ia = ifatoia(ifa);
 
        /*
         * Ensure we only send from a valid address.



Home | Main Index | Thread Index | Old Index