On Sun, 12 Jul 2009, Qing Li wrote:
Author: qingli
Date: Sun Jul 12 19:20:55 2009
New Revision: 195643
URL: http://svn.freebsd.org/changeset/base/195643
Log:
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.
Thanks a lot for fixing this.
Now I am reviewing another patch and I found that this here used to be
configurable actually by sysctls: nd6_useloopback for v6 and the v4
version from r192011 used to use useloopback; see the lines following
pointing at the 7-STABLE tree to have a tree before new-arp:
http://fxr.watson.org/fxr/source/netinet/if_ether.c?v=FREEBSD7#L259
http://fxr.watson.org/fxr/source/netinet6/nd6.c?v=FREEBSD7#L1320
Not sure if we'll want to restore that behaviour or remove the
sysctls?
/bz
Reviewed by: bz, gnn
Approved by: re
Modified:
head/sys/netinet6/in6.c
Modified: head/sys/netinet6/in6.c
==============================================================================
--- head/sys/netinet6/in6.c Sun Jul 12 17:07:35 2009 (r195642)
+++ head/sys/netinet6/in6.c Sun Jul 12 19:20:55 2009 (r195643)
@@ -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
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;
--
Bjoern A. Zeeb The greatest risk is not taking one.
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"