From nobody@FreeBSD.org  Mon Mar 21 17:37:38 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 9F7481065673
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 21 Mar 2011 17:37:38 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 910F88FC13
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 21 Mar 2011 17:37:38 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p2LHbc8e007115
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 21 Mar 2011 17:37:38 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p2LHbcYX007114;
	Mon, 21 Mar 2011 17:37:38 GMT
	(envelope-from nobody)
Message-Id: <201103211737.p2LHbcYX007114@red.freebsd.org>
Date: Mon, 21 Mar 2011 17:37:38 GMT
From: Vincent Miszczak <vmiszczak@ankama.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: setfib behavior
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         155757
>Category:       bin
>Synopsis:       problems with setfib(1) behavior
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Mar 21 17:40:07 UTC 2011
>Closed-Date:    
>Last-Modified:  Tue Mar 22 00:23:01 UTC 2011
>Originator:     Vincent Miszczak
>Release:        8.2
>Organization:
Ankama
>Environment:
FreeBSD testQOS.ankama.lan 8.2-RELEASE FreeBSD 8.2-RELEASE #0: Mon Mar 21 11:30:16 UTC 2011     root@testQOS.ankama.lan:/usr/src/sys/amd64/compile/QOSRouter  amd64
>Description:
Hi guys,
I'm using the very undocumented command setfib to play with several
routing tables for test purposes before production release.

This command has at least 2 problems :
The kernel I'm running have the followings running settings :
net.my_fibnum: 0
net.add_addr_allfibs: 0
net.fibs: 2

I'm currently testing very simple things :
I boot my machine, and I enter those commands :

#Configure interface em4
testQOS# ifconfig em4 10.10.10.0/24 up
#Delete automatically added route (btw is there any parameter to prevent this behavior?)
testQOS# route delete 10.10.10.0/24
delete net 10.10.10.0
#Populate FIB#1 context. We have net.add_addr_allfibs set to 0, so this is not done automatically
testQOS# setfib 1 route add 10.10.10.0/24 -interface em4
add net 10.10.10.0: gateway em4
#Try a ping to a host(it's alive) in FIB#1 context 
testQOS# setfib 1 ping 10.10.10.11
PING 10.10.10.11 (10.10.10.11): 56 data bytes
ping: sendto: Invalid argument

If I do the following : 
testQOS# ifconfig em4 10.10.10.0/24 up
testQOS# setfib 1 route add 10.10.10.0/24 -interface em4
testQOS# setfib 1 ping 10.10.10.11
PING 10.10.10.11 (10.10.10.11): 56 data bytes
64 bytes from 10.10.10.11: icmp_seq=0 ttl=64 time=1.561 ms

The only difference is that I'm not deleting the route from FIB#0 context.

Second problem :
#Configuring an interface from FIB#1 context then trying to ping 
testQOS# setfib 1 sh
# ifconfig em4 10.10.10.72/24 up
# ping 10.10.10.11
PING 10.10.10.11 (10.10.10.11): 56 data bytes
ping: sendto: Invalid argument

#Doing the same thing in FIB#0 context
testQOS# setfib 0 sh
# ifconfig em4 10.10.10.72/24 up
# ping 10.10.10.11
PING 10.10.10.11 (10.10.10.11): 56 data bytes
64 bytes from 10.10.10.11: icmp_seq=0 ttl=64 time=1.481 ms

So it seems FIB#1 context depends on FIB#0 context. Maybe I've missed
something, but it seems to be a bug.

Thank you
>How-To-Repeat:
Install a FreeBSD 8.2 AMD64, compile kernel with options :
options IPFIREWALL
options IPFIREWALL_FORWARD
options IPFIREWALL_DEFAULT_TO_ACCEPT
options IPFIREWALL_VERBOSE
options IPFIREWALL_VERBOSE_LIMIT=250
options IPDIVERT
options DUMMYNET
options HZ=1000
options ROUTETABLES=2

Boot your machine

Run commands given in "description"
>Fix:


>Release-Note:
>Audit-Trail:
>Unformatted:
