From owner-svn-src-head@FreeBSD.ORG Fri Nov 11 23:22:38 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B7538106566C; Fri, 11 Nov 2011 23:22:38 +0000 (UTC) (envelope-from qingli@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A6AD88FC0A; Fri, 11 Nov 2011 23:22:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pABNMc1p013264; Fri, 11 Nov 2011 23:22:38 GMT (envelope-from qingli@svn.freebsd.org) Received: (from qingli@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pABNMc8S013259; Fri, 11 Nov 2011 23:22:38 GMT (envelope-from qingli@svn.freebsd.org) Message-Id: <201111112322.pABNMc8S013259@svn.freebsd.org> From: Qing Li Date: Fri, 11 Nov 2011 23:22:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227460 - head/sys/netinet6 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Nov 2011 23:22:38 -0000 Author: qingli Date: Fri Nov 11 23:22:38 2011 New Revision: 227460 URL: http://svn.freebsd.org/changeset/base/227460 Log: A default route learned from the RAs could be deleted manually after its installation. This removal may be accidental and can prevent the default route from being installed in the future if the associated default router has the best preference. The cause is the lack of status update in the default router on the state of its route installation in the kernel FIB. This patch fixes the described problem. Reviewed by: hrs, discussed with hrs MFC after: 5 days Modified: head/sys/netinet6/in6.c head/sys/netinet6/nd6.c head/sys/netinet6/nd6.h head/sys/netinet6/nd6_rtr.c Modified: head/sys/netinet6/in6.c ============================================================================== --- head/sys/netinet6/in6.c Fri Nov 11 22:57:52 2011 (r227459) +++ head/sys/netinet6/in6.c Fri Nov 11 23:22:38 2011 (r227460) @@ -152,7 +152,7 @@ in6_ifaddloop(struct ifaddr *ifa) ia = ifa2ia6(ifa); ifp = ifa->ifa_ifp; IF_AFDATA_LOCK(ifp); - ifa->ifa_rtrequest = NULL; + ifa->ifa_rtrequest = nd6_rtrequest; /* XXX QL * we need to report rt_newaddrmsg Modified: head/sys/netinet6/nd6.c ============================================================================== --- head/sys/netinet6/nd6.c Fri Nov 11 22:57:52 2011 (r227459) +++ head/sys/netinet6/nd6.c Fri Nov 11 23:22:38 2011 (r227460) @@ -1174,6 +1174,46 @@ done: } +/* + * Rejuvenate this function for routing operations related + * processing. + */ +void +nd6_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info) +{ + struct sockaddr_in6 *gateway = (struct sockaddr_in6 *)rt->rt_gateway; + struct nd_defrouter *dr; + struct ifnet *ifp = rt->rt_ifp; + + RT_LOCK_ASSERT(rt); + + switch (req) { + case RTM_ADD: + break; + + case RTM_DELETE: + if (!ifp) + return; + /* + * Only indirect routes are interesting. + */ + if ((rt->rt_flags & RTF_GATEWAY) == 0) + return; + /* + * check for default route + */ + if (IN6_ARE_ADDR_EQUAL(&in6addr_any, + &SIN6(rt_key(rt))->sin6_addr)) { + + dr = defrouter_lookup(&gateway->sin6_addr, ifp); + if (dr != NULL) + dr->installed = 0; + } + break; + } +} + + int nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp) { Modified: head/sys/netinet6/nd6.h ============================================================================== --- head/sys/netinet6/nd6.h Fri Nov 11 22:57:52 2011 (r227459) +++ head/sys/netinet6/nd6.h Fri Nov 11 23:22:38 2011 (r227460) @@ -406,6 +406,7 @@ void nd6_purge __P((struct ifnet *)); void nd6_nud_hint __P((struct rtentry *, struct in6_addr *, int)); int nd6_resolve __P((struct ifnet *, struct rtentry *, struct mbuf *, struct sockaddr *, u_char *)); +void nd6_rtrequest __P((int, struct rtentry *, struct rt_addrinfo *)); int nd6_ioctl __P((u_long, caddr_t, struct ifnet *)); struct llentry *nd6_cache_lladdr __P((struct ifnet *, struct in6_addr *, char *, int, int, int)); Modified: head/sys/netinet6/nd6_rtr.c ============================================================================== --- head/sys/netinet6/nd6_rtr.c Fri Nov 11 22:57:52 2011 (r227459) +++ head/sys/netinet6/nd6_rtr.c Fri Nov 11 23:22:38 2011 (r227460) @@ -751,9 +751,10 @@ defrtrlist_update(struct nd_defrouter *n /* * If the preference does not change, there's no need - * to sort the entries. + * to sort the entries. Also make sure the selected + * router is still installed in the kernel. */ - if (rtpref(new) == oldpref) { + if (dr->installed && rtpref(new) == oldpref) { splx(s); return (dr); }