Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Mar 2014 17:32:18 GMT
From:      Alan Somers <asomers@freebsd.org>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   kern/187549: Host and network routes for a new interface appear in the wrong FIB
Message-ID:  <201403131732.s2DHWIVM014965@cgiserv.freebsd.org>
Resent-Message-ID: <201403131740.s2DHe0PR095873@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201403131732.s2DHWIVM014965>