From owner-svn-src-head@FreeBSD.ORG Thu Apr 24 17:23:17 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 99809AC; Thu, 24 Apr 2014 17:23:17 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7948E1680; Thu, 24 Apr 2014 17:23:17 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s3OHNH3r044289; Thu, 24 Apr 2014 17:23:17 GMT (envelope-from asomers@svn.freebsd.org) Received: (from asomers@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s3OHNGFQ044284; Thu, 24 Apr 2014 17:23:16 GMT (envelope-from asomers@svn.freebsd.org) Message-Id: <201404241723.s3OHNGFQ044284@svn.freebsd.org> From: Alan Somers Date: Thu, 24 Apr 2014 17:23:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r264887 - in head: sys/net sys/netinet tests/sys/netinet X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 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: Thu, 24 Apr 2014 17:23:17 -0000 Author: asomers Date: Thu Apr 24 17:23:16 2014 New Revision: 264887 URL: http://svnweb.freebsd.org/changeset/base/264887 Log: Fix host and network routes for new interfaces when net.add_addr_allfibs=0 sys/net/route.c In rtinit1, use the interface fib instead of the process fib. The latter wasn't very useful because ifconfig(8) is usually invoked with the default process fib. Changing ifconfig(8) to use setfib(2) would be redundant, because it already sets the interface fib. tests/sys/netinet/fibs_test.sh Clear the expected ATF failure sys/net/if.c Pass the interface fib in calls to rtrequest1_fib and rtalloc1_fib sys/netinet/in.c sys/net/if_var.h Add a fibnum argument to ifa_switch_loopback_route, a subroutine of in_scrubprefix. Pass it the interface fib. PR: kern/187549 Reviewed by: melifaro MFC after: 3 weeks Sponsored by: Spectra Logic Corporation Modified: head/sys/net/if.c head/sys/net/if_var.h head/sys/net/route.c head/sys/netinet/in.c head/tests/sys/netinet/fibs_test.sh Modified: head/sys/net/if.c ============================================================================== --- head/sys/net/if.c Thu Apr 24 16:19:49 2014 (r264886) +++ head/sys/net/if.c Thu Apr 24 17:23:16 2014 (r264887) @@ -1485,7 +1485,7 @@ ifa_add_loopback_route(struct ifaddr *if info.rti_flags = ifa->ifa_flags | RTF_HOST | RTF_STATIC; info.rti_info[RTAX_DST] = ia; info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&null_sdl; - error = rtrequest1_fib(RTM_ADD, &info, &rt, 0); + error = rtrequest1_fib(RTM_ADD, &info, &rt, ifa->ifa_ifp->if_fib); if (error == 0 && rt != NULL) { RT_LOCK(rt); @@ -1517,7 +1517,7 @@ ifa_del_loopback_route(struct ifaddr *if info.rti_flags = ifa->ifa_flags | RTF_HOST | RTF_STATIC; info.rti_info[RTAX_DST] = ia; info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&null_sdl; - error = rtrequest1_fib(RTM_DELETE, &info, NULL, 0); + error = rtrequest1_fib(RTM_DELETE, &info, NULL, ifa->ifa_ifp->if_fib); if (error != 0) log(LOG_DEBUG, "%s: deletion failed: %u\n", __func__, error); @@ -1526,11 +1526,11 @@ ifa_del_loopback_route(struct ifaddr *if } int -ifa_switch_loopback_route(struct ifaddr *ifa, struct sockaddr *sa) +ifa_switch_loopback_route(struct ifaddr *ifa, struct sockaddr *sa, int fib) { struct rtentry *rt; - rt = rtalloc1_fib(sa, 0, 0, 0); + rt = rtalloc1_fib(sa, 0, 0, fib); if (rt == NULL) { log(LOG_DEBUG, "%s: fail", __func__); return (EHOSTUNREACH); Modified: head/sys/net/if_var.h ============================================================================== --- head/sys/net/if_var.h Thu Apr 24 16:19:49 2014 (r264886) +++ head/sys/net/if_var.h Thu Apr 24 17:23:16 2014 (r264887) @@ -490,7 +490,7 @@ struct ifnet *ifunit_ref(const char *); int ifa_add_loopback_route(struct ifaddr *, struct sockaddr *); int ifa_del_loopback_route(struct ifaddr *, struct sockaddr *); -int ifa_switch_loopback_route(struct ifaddr *, struct sockaddr *); +int ifa_switch_loopback_route(struct ifaddr *, struct sockaddr *, int fib); struct ifaddr *ifa_ifwithaddr(struct sockaddr *); int ifa_ifwithaddr_check(struct sockaddr *); Modified: head/sys/net/route.c ============================================================================== --- head/sys/net/route.c Thu Apr 24 16:19:49 2014 (r264886) +++ head/sys/net/route.c Thu Apr 24 17:23:16 2014 (r264887) @@ -1536,7 +1536,7 @@ rtinit1(struct ifaddr *ifa, int cmd, int } if (fibnum == RT_ALL_FIBS) { if (rt_add_addr_allfibs == 0 && cmd == (int)RTM_ADD) { - startfib = endfib = curthread->td_proc->p_fibnum; + startfib = endfib = ifa->ifa_ifp->if_fib; } else { startfib = 0; endfib = rt_numfibs - 1; Modified: head/sys/netinet/in.c ============================================================================== --- head/sys/netinet/in.c Thu Apr 24 16:19:49 2014 (r264886) +++ head/sys/netinet/in.c Thu Apr 24 17:23:16 2014 (r264887) @@ -708,7 +708,7 @@ in_scrubprefix(struct in_ifaddr *target, if (eia != NULL) { error = ifa_switch_loopback_route((struct ifaddr *)eia, - (struct sockaddr *)&target->ia_addr); + (struct sockaddr *)&target->ia_addr, fibnum); ifa_free(&eia->ia_ifa); } else { error = ifa_del_loopback_route((struct ifaddr *)target, Modified: head/tests/sys/netinet/fibs_test.sh ============================================================================== --- head/tests/sys/netinet/fibs_test.sh Thu Apr 24 16:19:49 2014 (r264886) +++ head/tests/sys/netinet/fibs_test.sh Thu Apr 24 17:23:16 2014 (r264887) @@ -116,7 +116,6 @@ loopback_and_network_routes_on_nondefaul loopback_and_network_routes_on_nondefault_fib_body() { - atf_expect_fail "kern/187549 Host and network routes for a new interface appear in the wrong FIB" # Configure the TAP interface to use an RFC5737 nonrouteable address # and a non-default fib ADDR="192.0.2.2"