Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Mar 2014 15:03:08 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r263738 - head/tests/sys/netinet
Message-ID:  <201403251503.s2PF38BE043599@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Tue Mar 25 15:03:08 2014
New Revision: 263738
URL: http://svnweb.freebsd.org/changeset/base/263738

Log:
  tests/sys/netinet/Makefile
  tests/sys/netinet/fibs.sh
  	Replace fibs:udp_dontroute with fibs:src_addr_selection_by_subnet.
  	The original test was poorly written; it was actually testing
  	kern/167947 instead of the desired kern/187553.  The root cause of the
  	bug is that ifa_ifwithnet did not have a fib argument.  The new test
  	more directly targets that behavior.
  
  tests/sys/netinet/udp_dontroute.c
  	Delete the auxilliary binary used by the old test
  
  PR:		kern/187553
  MFC after:	3 weeks
  Sponsored by:	Spectra Logic Corporation

Deleted:
  head/tests/sys/netinet/udp_dontroute.c
Modified:
  head/tests/sys/netinet/Makefile
  head/tests/sys/netinet/fibs_test.sh

Modified: head/tests/sys/netinet/Makefile
==============================================================================
--- head/tests/sys/netinet/Makefile	Tue Mar 25 13:41:55 2014	(r263737)
+++ head/tests/sys/netinet/Makefile	Tue Mar 25 15:03:08 2014	(r263738)
@@ -1,12 +1,7 @@
 # $FreeBSD$
 
 TESTSDIR=	${TESTSBASE}/sys/netinet
-BINDIR=		${TESTSDIR}
 
 ATF_TESTS_SH+=	fibs_test
-PROG=	udp_dontroute
-SRCS=	udp_dontroute.c
-NO_MAN=
-WARNS?=	6
 
 .include <bsd.test.mk>

Modified: head/tests/sys/netinet/fibs_test.sh
==============================================================================
--- head/tests/sys/netinet/fibs_test.sh	Tue Mar 25 13:41:55 2014	(r263737)
+++ head/tests/sys/netinet/fibs_test.sh	Tue Mar 25 15:03:08 2014	(r263738)
@@ -255,45 +255,66 @@ subnet_route_with_multiple_fibs_on_same_
 	cleanup_tap
 }
 
-# Test that source address selection works correctly for UDP packets with
-# SO_DONTROUTE set that are sent on non-default FIBs.
+# Regression test for kern/187553 "Source address selection for UDP packets
+# with SO_DONTROUTE uses the default FIB".  The original complaint was that a
+# UDP packet with SO_DONTROUTE set would select a source address from an
+# interface on the default FIB instead of the process FIB.
 # This bug was discovered with "setfib 1 netperf -t UDP_STREAM -H some_host"
 # Regression test for kern/187553
-atf_test_case udp_dontroute cleanup
-udp_dontroute_head()
+
+# The root cause was that ifa_ifwithnet() did not have a fib argument.  It
+# would return an address from an interface on any FIB that had a subnet route
+# for the destination.  If more than one were available, it would choose the
+# most specific.  The root cause is most easily tested by creating two
+# interfaces with overlapping subnet routes, adding a default route to the
+# interface with the less specific subnet route, and looking up a host that
+# requires the default route using the FIB of the interface with the less
+# specific subnet route.  "route get" should provide a route that uses the
+# interface on the chosen FIB.  However, absent the patch for this bug it will
+# instead use the other interface.
+atf_test_case src_addr_selection_by_subnet cleanup
+src_addr_selection_by_subnet_head()
 {
 	atf_set "descr" "Source address selection for UDP packets with SO_DONTROUTE on non-default FIBs works"
 	atf_set "require.user" "root"
 	atf_set "require.config" "fibs"
 }
 
-udp_dontroute_body()
+src_addr_selection_by_subnet_body()
 {
 	atf_expect_fail "kern/187553 Source address selection for UDP packets with SO_DONTROUTE uses the default FIB"
 	# Configure the TAP interface to use an RFC5737 nonrouteable address
 	# and a non-default fib
-	ADDR="192.0.2.2"
+	ADDR0="192.0.2.2"
+	ADDR1="192.0.2.3"
+	GATEWAY0="192.0.2.1"
+	TARGET="192.0.2.128"
 	SUBNET="192.0.2.0"
-	MASK="24"
-	# Use a different IP on the same subnet as the target
-	TARGET="192.0.2.100"
+	MASK0="25"
+	MASK1="26"
 
 	# Check system configuration
 	if [ 0 != `sysctl -n net.add_addr_allfibs` ]; then
 		atf_skip "This test requires net.add_addr_allfibs=0"
 	fi
-	get_fibs 1
+	get_fibs 2
 
 	# Configure a TAP interface
-	setup_tap ${FIB0} ${ADDR} ${MASK}
+	setup_tap ${FIB0} ${ADDR0} ${MASK0}
+	TAP0=${TAP}
+	setup_tap ${FIB1} ${ADDR1} ${MASK1}
+	TAP1=${TAP}
+
+	# Add a gateway to the interface with the less specific subnet route
+	setfib ${FIB0} route add default ${GATEWAY0}
 
-	# Send a UDP packet with SO_DONTROUTE.  In the failure case, it will
-	# return ENETUNREACH
-	SRCDIR=`atf_get_srcdir`
-	atf_check -o ignore setfib ${FIB0} ${SRCDIR}/udp_dontroute ${TARGET}
+	# Lookup a route
+	echo "Looking up route to ${TARGET} with fib ${FIB0}"
+	echo "Expected behavior is to use interface ${TAP0}"
+	atf_check -o match:"interface:.${TAP0}" setfib ${FIB0} route -n get ${TARGET}
 }
 
-udp_dontroute_cleanup()
+src_addr_selection_by_subnet_cleanup()
 {
 	cleanup_tap
 }
@@ -305,7 +326,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 subnet_route_with_multiple_fibs_on_same_subnet 
-	atf_add_test_case udp_dontroute
+	atf_add_test_case src_addr_selection_by_subnet
 }
 
 # Looks up one or more fibs from the configuration data and validates them.



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