summaryrefslogtreecommitdiffstats
path: root/sys/netinet6
diff options
context:
space:
mode:
authorqingli <qingli@FreeBSD.org>2009-09-05 16:43:16 +0000
committerqingli <qingli@FreeBSD.org>2009-09-05 16:43:16 +0000
commit0cca60c70d1c3115577b3e8fa7f015d4d9eb8904 (patch)
treec3085c58ec7f99afbd953e6a54aeb378a9bdc66f /sys/netinet6
parent36333bfcba5bfd937fe1818b3b8ad16d334d48b5 (diff)
downloadFreeBSD-src-0cca60c70d1c3115577b3e8fa7f015d4d9eb8904.zip
FreeBSD-src-0cca60c70d1c3115577b3e8fa7f015d4d9eb8904.tar.gz
This patch fixes the following issues:
- Interface link-local address is not reachable within the node that owns the interface, this is due to the mismatch in address scope as the result of the installed interface address loopback route. Therefore for each interface address loopback route, the rt_gateway field (of AF_LINK type) will be used to track which interface a given address belongs to. This will aid the address source to use the proper interface for address scope/zone validation. - The loopback address is not reachable. The root cause is the same as the above. - Empty nd6 entries are created for the IPv6 loopback addresses only for validation reason. Doing so will eliminate as much of the special case (loopback addresses) handling code as possible, however, these empty nd6 entries should not be returned to the userland applications such as the "ndp" command. Since both of the above issues contain common files, these files are committed together. Reviewed by: bz MFC after: immediately
Diffstat (limited to 'sys/netinet6')
-rw-r--r--sys/netinet6/in6.c11
-rw-r--r--sys/netinet6/in6_src.c30
-rw-r--r--sys/netinet6/ip6_output.c15
3 files changed, 35 insertions, 21 deletions
diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c
index b0b2585..9521e8e 100644
--- a/sys/netinet6/in6.c
+++ b/sys/netinet6/in6.c
@@ -1201,8 +1201,8 @@ in6_purgeaddr(struct ifaddr *ifa)
bzero(&null_sdl, sizeof(null_sdl));
null_sdl.sdl_len = sizeof(null_sdl);
null_sdl.sdl_family = AF_LINK;
- null_sdl.sdl_type = V_loif->if_type;
- null_sdl.sdl_index = V_loif->if_index;
+ null_sdl.sdl_type = ia->ia_ifp->if_type;
+ null_sdl.sdl_index = ia->ia_ifp->if_index;
bzero(&info, sizeof(info));
info.rti_flags = ia->ia_flags | RTF_HOST | RTF_STATIC;
info.rti_info[RTAX_DST] = (struct sockaddr *)&ia->ia_addr;
@@ -1782,9 +1782,9 @@ in6_ifinit(struct ifnet *ifp, struct in6_ifaddr *ia,
if (error == 0 && rt != NULL) {
RT_LOCK(rt);
((struct sockaddr_dl *)rt->rt_gateway)->sdl_type =
- rt->rt_ifp->if_type;
+ ifp->if_type;
((struct sockaddr_dl *)rt->rt_gateway)->sdl_index =
- rt->rt_ifp->if_index;
+ ifp->if_index;
RT_REMREF(rt);
RT_UNLOCK(rt);
} else if (error != 0)
@@ -2495,6 +2495,9 @@ in6_lltable_dump(struct lltable *llt, struct sysctl_req *wr)
} ndpc;
int i, error;
+ if (ifp->if_flags & IFF_LOOPBACK)
+ return 0;
+
LLTABLE_LOCK_ASSERT();
error = 0;
diff --git a/sys/netinet6/in6_src.c b/sys/netinet6/in6_src.c
index f087fae..8e82ef1 100644
--- a/sys/netinet6/in6_src.c
+++ b/sys/netinet6/in6_src.c
@@ -85,6 +85,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sx.h>
#include <net/if.h>
+#include <net/if_dl.h>
#include <net/route.h>
#include <net/if_llatbl.h>
#ifdef RADIX_MPATH
@@ -697,8 +698,25 @@ selectroute(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
if (error == EHOSTUNREACH)
V_ip6stat.ip6s_noroute++;
- if (retifp != NULL)
+ if (retifp != NULL) {
*retifp = ifp;
+
+ /*
+ * Adjust the "outgoing" interface. If we're going to loop
+ * the packet back to ourselves, the ifp would be the loopback
+ * interface. However, we'd rather know the interface associated
+ * to the destination address (which should probably be one of
+ * our own addresses.)
+ */
+ if (rt) {
+ if ((rt->rt_ifp->if_flags & IFF_LOOPBACK) &&
+ (rt->rt_gateway->sa_family == AF_LINK))
+ *retifp =
+ ifnet_byindex(((struct sockaddr_dl *)
+ rt->rt_gateway)->sdl_index);
+ }
+ }
+
if (retrt != NULL)
*retrt = rt; /* rt may be NULL */
@@ -750,16 +768,6 @@ in6_selectif(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
return (flags);
}
- /*
- * Adjust the "outgoing" interface. If we're going to loop the packet
- * back to ourselves, the ifp would be the loopback interface.
- * However, we'd rather know the interface associated to the
- * destination address (which should probably be one of our own
- * addresses.)
- */
- if (rt && rt->rt_ifa && rt->rt_ifa->ifa_ifp)
- *retifp = rt->rt_ifa->ifa_ifp;
-
if (ro == &sro && rt && rt == sro.ro_rt)
RTFREE(rt);
return (0);
diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c
index c48ac7b..9887564 100644
--- a/sys/netinet6/ip6_output.c
+++ b/sys/netinet6/ip6_output.c
@@ -602,15 +602,12 @@ again:
rt->rt_use++;
}
+
/*
* The outgoing interface must be in the zone of source and
- * destination addresses. We should use ia_ifp to support the
- * case of sending packets to an address of our own.
+ * destination addresses.
*/
- if (ia != NULL && ia->ia_ifp)
- origifp = ia->ia_ifp;
- else
- origifp = ifp;
+ origifp = ifp;
src0 = ip6->ip6_src;
if (in6_setscope(&src0, origifp, &zone))
@@ -634,6 +631,12 @@ again:
goto badscope;
}
+ /* We should use ia_ifp to support the case of
+ * sending packets to an address of our own.
+ */
+ if (ia != NULL && ia->ia_ifp)
+ ifp = ia->ia_ifp;
+
/* scope check is done. */
goto routefound;
OpenPOWER on IntegriCloud