From nobody@FreeBSD.org  Mon Apr 28 22:24:31 2014
Return-Path: <nobody@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 BBEDF94B
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 28 Apr 2014 22:24:31 +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))
	(Client did not present a certificate)
	by mx1.freebsd.org (Postfix) with ESMTPS id A87D8193F
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 28 Apr 2014 22:24:31 +0000 (UTC)
Received: from cgiserv.freebsd.org ([127.0.1.6])
	by cgiserv.freebsd.org (8.14.8/8.14.8) with ESMTP id s3SMOVcv021046
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 28 Apr 2014 22:24:31 GMT
	(envelope-from nobody@cgiserv.freebsd.org)
Received: (from nobody@localhost)
	by cgiserv.freebsd.org (8.14.8/8.14.8/Submit) id s3SMOVCV021040;
	Mon, 28 Apr 2014 22:24:31 GMT
	(envelope-from nobody)
Message-Id: <201404282224.s3SMOVCV021040@cgiserv.freebsd.org>
Date: Mon, 28 Apr 2014 22:24:31 GMT
From: Alan Somers <asomers@freebsd.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Assigning the same IP to multiple interfaces in different FIBs creates a host route for only one.
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         189088
>Category:       kern
>Synopsis:       Assigning the same IP to multiple interfaces in different FIBs creates a host route for only one.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    asomers
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Apr 28 22:30:00 UTC 2014
>Closed-Date:    
>Last-Modified:  Tue Apr 29 15:20:00 UTC 2014
>Originator:     Alan Somers
>Release:        11.0 CURRENT
>Organization:
Spectra Logic
>Environment:
FreeBSD alans-fbsd-head 11.0-CURRENT FreeBSD 11.0-CURRENT #55 r265061M: Mon Apr 28 15:08:01 MDT 2014     alans@ns1.eng.sldomain.com:/vmpool/obj/usr/home/alans/freebsd/head/sys/GENERIC  amd64
>Description:
Assigning the same IP to multiple interfaces simultaneously sounds insane, but some people do it.  However, if you assign them to separate FIBs as well as separate interfaces, bad stuff happens.  For one thing, only the first FIB used will get a host route.  For another, if you delete the addresses in FIFO order the host route will never get deleted (though it will if you delete them in LIFO order).
>How-To-Repeat:
On a system with net.add_addr_allfibs=0 and net.fibs=4, Run the following commands:

# ifconfig tap0 create
# ifconfig tap1 create
# ifconfig tap0 192.0.2.2/32 fib 2
# ifconfig tap1 192.0.2.2/32 fib 3
# setfib 2 netstat -rn -f inet
Routing tables (fib: 2)

Internet:
Destination        Gateway            Flags    Netif Expire
192.0.2.2          link#3             UHS       lo0
192.0.2.2/32       link#3             U        tap0
# setfib 3 netstat -rn -f inet
Routing tables (fib: 3)

Internet:
Destination        Gateway            Flags    Netif Expire
192.0.2.2/32       link#4             U        tap1


Notice that FIB 3 does not get a 192.0.2.2 host route.  Now try deleting the addresses in FIFO order:


# ifconfig tap0 -alias 192.0.2.2
# ifconfig tap1 -alias 192.0.2.2
# setfib 2 netstat -rn -f inet
Routing tables (fib: 2)

Internet:
Destination        Gateway            Flags    Netif Expire
192.0.2.2          link#4             UHS       lo0
>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->asomers 
Responsible-Changed-By: asomers 
Responsible-Changed-When: Tue Apr 29 15:08:24 UTC 2014 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=189088 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/189088: commit references a PR
Date: Tue, 29 Apr 2014 15:12:27 +0000 (UTC)

 Author: asomers
 Date: Tue Apr 29 15:12:23 2014
 New Revision: 265094
 URL: http://svnweb.freebsd.org/changeset/base/265094
 
 Log:
   Add regression test for PR kern/189088.
   
   PR:		kern/189088
   MFC after:	3 weeks
   Sponsored by:	Spectra Logic
 
 Modified:
   head/tests/sys/netinet/fibs_test.sh
 
 Modified: head/tests/sys/netinet/fibs_test.sh
 ==============================================================================
 --- head/tests/sys/netinet/fibs_test.sh	Tue Apr 29 14:52:39 2014	(r265093)
 +++ head/tests/sys/netinet/fibs_test.sh	Tue Apr 29 15:12:23 2014	(r265094)
 @@ -252,6 +252,59 @@ same_ip_multiple_ifaces_fib0_cleanup()
  	cleanup_tap
  }
  
 +# Regression test for PR kern/189088
 +# Test that removing an IP address works even if the same IP is assigned to a
 +# different interface, on a different FIB.  Tests the same code that whose
 +# panic was regressed by same_ip_multiple_ifaces_fib0.  
 +# Create two tap interfaces and assign them both the same IP address but with
 +# different netmasks, and on different FIBs.  Then remove one's IP
 +# address.  Hopefully the machine won't panic.  Also, the IP's hostroute should
 +# dissappear from the correct fib.
 +atf_test_case same_ip_multiple_ifaces cleanup
 +same_ip_multiple_ifaces_head()
 +{
 +	atf_set "descr" "Can remove an IP alias from an interface when the same IP is also assigned to another interface, on non-default FIBs."
 +	atf_set "require.user" "root"
 +	atf_set "require.config" "fibs"
 +}
 +same_ip_multiple_ifaces_body()
 +{
 +	atf_expect_fail "kern/189088 Assigning the same IP to multiple interfaces in different FIBs creates a host route for only one"
 +	ADDR="192.0.2.2"
 +	MASK0="24"
 +	MASK1="32"
 +
 +	# Unlike most of the tests in this file, this is applicable regardless
 +	# of net.add_addr_allfibs
 +	get_fibs 2
 +
 +	# Setup the interfaces, then remove one alias.  It should not panic.
 +	setup_tap ${FIB0} ${ADDR} ${MASK0}
 +	TAP0=${TAP}
 +	setup_tap ${FIB1} ${ADDR} ${MASK1}
 +	TAP1=${TAP}
 +	ifconfig ${TAP1} -alias ${ADDR}
 +	atf_check -o not-match:"^${ADDR}[[:space:]]" \
 +		setfib ${FIB1} netstat -rn -f inet
 +
 +	# Do it again, in the opposite order.  It should not panic.
 +	setup_tap ${FIB0} ${ADDR} ${MASK0}
 +	TAP0=${TAP}
 +	setup_tap ${FIB1} ${ADDR} ${MASK1}
 +	TAP1=${TAP}
 +	ifconfig ${TAP0} -alias ${ADDR}
 +	atf_check -o not-match:"^${ADDR}[[:space:]]" \
 +		setfib ${FIB0} netstat -rn -f inet
 +}
 +same_ip_multiple_ifaces_cleanup()
 +{
 +	# Due to PR kern/189088, we must destroy the interfaces in LIFO order
 +	# in order for the routes to be correctly cleaned up.
 +	for TAPD in `tail -r "tap_devices_to_cleanup"`; do
 +		ifconfig ${TAPD} destroy
 +	done
 +}
 +
  # Regression test for kern/187550
  atf_test_case subnet_route_with_multiple_fibs_on_same_subnet cleanup
  subnet_route_with_multiple_fibs_on_same_subnet_head()
 @@ -349,6 +402,7 @@ atf_init_test_cases()
  	atf_add_test_case loopback_and_network_routes_on_nondefault_fib
  	atf_add_test_case default_route_with_multiple_fibs_on_same_subnet
  	atf_add_test_case same_ip_multiple_ifaces_fib0
 +	atf_add_test_case same_ip_multiple_ifaces
  	atf_add_test_case subnet_route_with_multiple_fibs_on_same_subnet
  	atf_add_test_case udp_dontroute
  }
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
