From owner-freebsd-bugs@FreeBSD.ORG Thu Mar 13 17:40:00 2014 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C1E80A10 for ; Thu, 13 Mar 2014 17:40:00 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 9D6CA84C for ; Thu, 13 Mar 2014 17:40:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.8/8.14.8) with ESMTP id s2DHe0Ak095874 for ; Thu, 13 Mar 2014 17:40:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.8/8.14.8/Submit) id s2DHe0PR095873; Thu, 13 Mar 2014 17:40:00 GMT (envelope-from gnats) Resent-Date: Thu, 13 Mar 2014 17:40:00 GMT Resent-Message-Id: <201403131740.s2DHe0PR095873@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Alan Somers 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 7B32C84B for ; Thu, 13 Mar 2014 17:32:18 +0000 (UTC) Received: from cgiserv.freebsd.org (cgiserv.freebsd.org [IPv6:2001:1900:2254:206a::50:4]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 5B3577F2 for ; Thu, 13 Mar 2014 17:32:18 +0000 (UTC) Received: from cgiserv.freebsd.org ([127.0.1.6]) by cgiserv.freebsd.org (8.14.8/8.14.8) with ESMTP id s2DHWIlH014971 for ; Thu, 13 Mar 2014 17:32:18 GMT (envelope-from nobody@cgiserv.freebsd.org) Received: (from nobody@localhost) by cgiserv.freebsd.org (8.14.8/8.14.8/Submit) id s2DHWIVM014965; Thu, 13 Mar 2014 17:32:18 GMT (envelope-from nobody) Message-Id: <201403131732.s2DHWIVM014965@cgiserv.freebsd.org> Date: Thu, 13 Mar 2014 17:32:18 GMT From: Alan Somers To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: kern/187549: Host and network routes for a new interface appear in the wrong FIB X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Mar 2014 17:40:00 -0000 >Number: 187549 >Category: kern >Synopsis: Host and network routes for a new interface appear in the wrong FIB >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Mar 13 17:40:00 UTC 2014 >Closed-Date: >Last-Modified: >Originator: Alan Somers >Release: 11.0-CURRENT r262867 >Organization: SpectraLogic >Environment: FreeBSD alans-fbsd-head 11.0-CURRENT FreeBSD 11.0-CURRENT #38 r262867M: Thu Mar 6 13:50:32 MST 2014 alans@ns1.eng.sldomain.com:/vmpool/obj/usr/home/alans/freebsd/head/sys/GENERIC amd64 >Description: When UPing a new interface, the kernel automatically adds a host route (referred to as a loopback route in some places) and a network route. These routes should be added to the interface's FIB. However, they get added to the default FIB instead. >How-To-Repeat: ifconfig tap0 create setfib 2 ifconfig tap0 192.0.2.2 netmask 255.255.255.0 fib 2 setfib 2 netstat -rn -f inet # This is what you ought to see Routing tables Internet: Destination Gateway Flags Refs Use Netif Expire 192.0.2.0/24 link#9 UP 0 0 tap0 192.0.2.2 link#9 UHS 0 0 lo0 # This is what you actually see Routing tables (fib: 2) Internet: Destination Gateway Flags Netif Expire 192.0.2.0/24 link#3 U tap0 Notice that the host route is missing. >Fix: Patch attached with submission follows: --- //SpectraBSD/stable/sbin/ifconfig/iffib.c 2012-06-29 17:23:35.000000000 -0600 +++ //SpectraBSD/stable/sbin/ifconfig/iffib.c 2013-02-07 01:14:53.000000000 -0700 @@ -76,6 +76,8 @@ strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name)); ifr.ifr_fib = fib; + if (setfib(fib) != 0) + warn("setfib"); if (ioctl(s, SIOCSIFFIB, (caddr_t)&ifr) < 0) warn("ioctl (SIOCSIFFIB)"); } --- //SpectraBSD/stable/sys/net/if.c 2012-08-29 22:35:04.000000000 -0600 +++ //SpectraBSD/stable/sys/net/if.c 2013-02-07 01:14:53.000000000 -0700 @@ -1464,7 +1464,7 @@ 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); @@ -1496,7 +1496,7 @@ 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_INFO, "ifa_del_loopback_route: deletion failed\n"); --- //SpectraBSD/stable/sys/netinet/in.c 2013-01-31 22:00:58.000000000 -0700 +++ //SpectraBSD/stable/sys/netinet/in.c 2013-02-07 01:14:53.000000000 -0700 @@ -1101,10 +1101,12 @@ (target->ia_flags & IFA_RTSELF)) { struct route ia_ro; int freeit = 0; + int fib; bzero(&ia_ro, sizeof(ia_ro)); *((struct sockaddr_in *)(&ia_ro.ro_dst)) = target->ia_addr; - rtalloc_ign_fib(&ia_ro, 0, 0); + fib = target->ia_ifa.ifa_ifp->if_fib; + rtalloc_ign_fib(&ia_ro, 0, fib); if ((ia_ro.ro_rt != NULL) && (ia_ro.ro_rt->rt_ifp != NULL) && (ia_ro.ro_rt->rt_ifp == V_loif)) { RT_LOCK(ia_ro.ro_rt); >Release-Note: >Audit-Trail: >Unformatted: