Source-Changes-HG archive

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

[src/trunk]: src/sys/net Permit the existence of a route with unlinked ifp an...



details:   https://anonhg.NetBSD.org/src/rev/f8be61837af3
branches:  trunk
changeset: 754517:f8be61837af3
user:      kefren <kefren%NetBSD.org@localhost>
date:      Sun May 02 19:17:56 2010 +0000

description:
Permit the existence of a route with unlinked ifp and ifa,
enabling this way the posibility to send a packet on an interface with
source address from another interface.

diffstat:

 sys/net/route.c  |  14 ++++++++++----
 sys/net/rtsock.c |  14 +++++++++-----
 2 files changed, 19 insertions(+), 9 deletions(-)

diffs (84 lines):

diff -r 3e81a64f55ef -r f8be61837af3 sys/net/route.c
--- a/sys/net/route.c   Sun May 02 18:49:13 2010 +0000
+++ b/sys/net/route.c   Sun May 02 19:17:56 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: route.c,v 1.121 2009/11/03 00:30:11 dyoung Exp $       */
+/*     $NetBSD: route.c,v 1.122 2010/05/02 19:17:56 kefren Exp $       */
 
 /*-
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -93,7 +93,7 @@
 #include "opt_route.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.121 2009/11/03 00:30:11 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.122 2010/05/02 19:17:56 kefren Exp $");
 
 #include <sys/param.h>
 #include <sys/sysctl.h>
@@ -490,6 +490,7 @@
                        if (rt != NULL)
                                rtfree(rt);
                        flags |=  RTF_GATEWAY | RTF_DYNAMIC;
+                       memset(&info, 0, sizeof(info));
                        info.rti_info[RTAX_DST] = dst;
                        info.rti_info[RTAX_GATEWAY] = gateway;
                        info.rti_info[RTAX_NETMASK] = netmask;
@@ -702,7 +703,7 @@
        struct rtentry *rt, *crt;
        struct radix_node *rn;
        struct radix_node_head *rnh;
-       struct ifaddr *ifa;
+       struct ifaddr *ifa, *ifa2;
        struct sockaddr_storage maskeddst;
        const struct sockaddr *dst = info->rti_info[RTAX_DST];
        const struct sockaddr *gateway = info->rti_info[RTAX_GATEWAY];
@@ -804,7 +805,12 @@
                }
                rt_set_ifa(rt, ifa);
                RT_DPRINTF("rt->_rt_key = %p\n", (void *)rt->_rt_key);
-               rt->rt_ifp = ifa->ifa_ifp;
+               if (info->rti_info[RTAX_IFP] != NULL &&
+                   (ifa2 = ifa_ifwithnet(info->rti_info[RTAX_IFP])) != NULL &&
+                   ifa2->ifa_ifp != NULL)
+                       rt->rt_ifp = ifa2->ifa_ifp;
+               else
+                       rt->rt_ifp = ifa->ifa_ifp;
                if (req == RTM_RESOLVE) {
                        rt->rt_rmx = (*ret_nrt)->rt_rmx; /* copy metrics */
                        rt->rt_parent = *ret_nrt;
diff -r 3e81a64f55ef -r f8be61837af3 sys/net/rtsock.c
--- a/sys/net/rtsock.c  Sun May 02 18:49:13 2010 +0000
+++ b/sys/net/rtsock.c  Sun May 02 19:17:56 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtsock.c,v 1.127 2009/09/16 15:23:04 pooka Exp $       */
+/*     $NetBSD: rtsock.c,v 1.128 2010/05/02 19:17:56 kefren Exp $      */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.127 2009/09/16 15:23:04 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.128 2010/05/02 19:17:56 kefren Exp $");
 
 #include "opt_inet.h"
 #ifdef _KERNEL_OPT
@@ -410,9 +410,13 @@
                            (ifa = ifa_ifwithnet(info.rti_info[RTAX_IFP])) &&
                            (ifp = ifa->ifa_ifp) && (info.rti_info[RTAX_IFA] ||
                            info.rti_info[RTAX_GATEWAY])) {
-                               ifa = ifaof_ifpforaddr(info.rti_info[RTAX_IFA] ?
-                                   info.rti_info[RTAX_IFA] :
-                                   info.rti_info[RTAX_GATEWAY], ifp);
+                               if (info.rti_info[RTAX_IFA] == NULL ||
+                                   (ifa = ifa_ifwithaddr(
+                                   info.rti_info[RTAX_IFA])) == NULL)
+                                       ifa = ifaof_ifpforaddr(
+                                           info.rti_info[RTAX_IFA] ?
+                                           info.rti_info[RTAX_IFA] :
+                                           info.rti_info[RTAX_GATEWAY], ifp);
                        } else if ((info.rti_info[RTAX_IFA] &&
                            (ifa = ifa_ifwithaddr(info.rti_info[RTAX_IFA]))) ||
                            (info.rti_info[RTAX_GATEWAY] &&



Home | Main Index | Thread Index | Old Index