summaryrefslogtreecommitdiffstats
path: root/sys/netinet6
diff options
context:
space:
mode:
authorqingli <qingli@FreeBSD.org>2009-07-12 19:20:55 +0000
committerqingli <qingli@FreeBSD.org>2009-07-12 19:20:55 +0000
commit1d57d752af3da7674b59d9eb4f4e39ba06c1aea2 (patch)
treec41581b2c275d6235a054e340024726ae5252bb2 /sys/netinet6
parenta3e6ec19e5a1ba4e009853980224b908177a136a (diff)
downloadFreeBSD-src-1d57d752af3da7674b59d9eb4f4e39ba06c1aea2.zip
FreeBSD-src-1d57d752af3da7674b59d9eb4f4e39ba06c1aea2.tar.gz
This patch adds a host route to an interface address (that is assigned
to a non loopback/ppp link type) through the loopback interface. Prior to the new L2/L3 rewrite, this host route was explicitly created when processing the IPv6 address assignment. This loopback host route is deleted when that IPv6 address is removed from the interface. Reviewed by: bz, gnn Approved by: re
Diffstat (limited to 'sys/netinet6')
-rw-r--r--sys/netinet6/in6.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c
index 645e107..40d198a 100644
--- a/sys/netinet6/in6.c
+++ b/sys/netinet6/in6.c
@@ -1194,6 +1194,25 @@ in6_purgeaddr(struct ifaddr *ifa)
ifa_ref(ifa0);
IF_ADDR_UNLOCK(ifp);
+ if (!(ia->ia_ifp->if_flags & (IFF_LOOPBACK | IFF_POINTOPOINT))) {
+ struct rt_addrinfo info;
+ struct sockaddr_dl null_sdl;
+
+ 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;
+ bzero(&info, sizeof(info));
+ info.rti_flags = ia->ia_flags | RTF_HOST | RTF_STATIC;
+ info.rti_info[RTAX_DST] = (struct sockaddr *)&ia->ia_addr;
+ info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&null_sdl;
+ error = rtrequest1_fib(RTM_DELETE, &info, NULL, 0);
+
+ if (error != 0)
+ log(LOG_INFO, "in6_purgeaddr: deletion failed\n");
+ }
+
/* stop DAD processing */
nd6_dad_stop(ifa);
@@ -1755,6 +1774,33 @@ in6_ifinit(struct ifnet *ifp, struct in6_ifaddr *ia,
ia->ia_flags |= IFA_ROUTE;
}
+ /*
+ * add a loopback route to self
+ */
+ if (!(ifp->if_flags & (IFF_LOOPBACK | IFF_POINTOPOINT))) {
+ struct rt_addrinfo info;
+ struct rtentry *rt = NULL;
+ static struct sockaddr_dl null_sdl = {sizeof(null_sdl), AF_LINK};
+
+ bzero(&info, sizeof(info));
+ info.rti_ifp = V_loif;
+ info.rti_flags = ia->ia_flags | RTF_HOST | RTF_STATIC;
+ info.rti_info[RTAX_DST] = (struct sockaddr *)&ia->ia_addr;
+ info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&null_sdl;
+ error = rtrequest1_fib(RTM_ADD, &info, &rt, 0);
+
+ if (error == 0 && rt != NULL) {
+ RT_LOCK(rt);
+ ((struct sockaddr_dl *)rt->rt_gateway)->sdl_type =
+ rt->rt_ifp->if_type;
+ ((struct sockaddr_dl *)rt->rt_gateway)->sdl_index =
+ rt->rt_ifp->if_index;
+ RT_REMREF(rt);
+ RT_UNLOCK(rt);
+ } else if (error != 0)
+ log(LOG_INFO, "in6_ifinit: insertion failed\n");
+ }
+
/* Add ownaddr as loopback rtentry, if necessary (ex. on p2p link). */
if (newhost) {
struct llentry *ln;
OpenPOWER on IntegriCloud