View | Details | Raw Unified | Return to bug 196361 | Differences between
and this patch

Collapse All | Expand All

(-)b/tests/sys/netinet/fibs_test.sh (+201 lines)
Lines 166-171 loopback_and_network_routes_on_nondefault_fib_cleanup() Link Here
166
	cleanup_tap
166
	cleanup_tap
167
}
167
}
168
168
169
atf_test_case loopback_and_network_routes_on_nondefault_fib_inet6 cleanup
170
loopback_and_network_routes_on_nondefault_fib_inet6_head()
171
{
172
	atf_set "descr" "When creating and deleting loopback routes, use the interface's fib"
173
	atf_set "require.user" "root"
174
	atf_set "require.config" "fibs"
175
}
176
177
loopback_and_network_routes_on_nondefault_fib_inet6_body()
178
{
179
	# Configure the TAP interface to use an RFC5737 nonrouteable address
180
	# and a non-default fib
181
	ADDR="2001:db8::2"
182
	SUBNET="2001:db8::"
183
	MASK="64"
184
185
	# Check system configuration
186
	if [ 0 != `sysctl -n net.add_addr_allfibs` ]; then
187
		atf_skip "This test requires net.add_addr_allfibs=0"
188
	fi
189
	get_fibs 1
190
191
	# Configure a TAP interface
192
	setup_tap6 ${FIB0} ${ADDR} ${MASK}
193
194
	# Check whether the host route exists in only the correct FIB
195
	setfib ${FIB0} netstat -rn -f inet6 | grep -q "^${ADDR}.*UHS.*lo0"
196
	if [ 0 -ne $? ]; then
197
		setfib ${FIB0} netstat -rn -f inet6
198
		atf_fail "Host route did not appear in the correct FIB"
199
	fi
200
	setfib 0 netstat -rn -f inet6 | grep -q "^${ADDR}.*UHS.*lo0"
201
	if [ 0 -eq $? ]; then
202
		setfib 0 netstat -rn -f inet6
203
		atf_fail "Host route appeared in the wrong FIB"
204
	fi
205
206
	# Check whether the network route exists in only the correct FIB
207
	setfib ${FIB0} netstat -rn -f inet6 | \
208
		grep -q "^${SUBNET}/${MASK}.*${TAPD}"
209
	if [ 0 -ne $? ]; then
210
		setfib ${FIB0} netstat -rn -f inet6
211
		atf_fail "Network route did not appear in the correct FIB"
212
	fi
213
	setfib 0 netstat -rn -f inet6 | \
214
		grep -q "^${SUBNET}/${MASK}.*${TAPD}"
215
	if [ 0 -eq $? ]; then
216
		setfib ${FIB0} netstat -rn -f inet6
217
		atf_fail "Network route appeared in the wrong FIB"
218
	fi
219
}
220
221
loopback_and_network_routes_on_nondefault_fib_inet6_cleanup()
222
{
223
	cleanup_tap
224
}
225
169
226
170
# Regression test for kern/187552
227
# Regression test for kern/187552
171
atf_test_case default_route_with_multiple_fibs_on_same_subnet cleanup
228
atf_test_case default_route_with_multiple_fibs_on_same_subnet cleanup
Lines 215-220 default_route_with_multiple_fibs_on_same_subnet_cleanup() Link Here
215
	cleanup_tap
272
	cleanup_tap
216
}
273
}
217
274
275
atf_test_case default_route_with_multiple_fibs_on_same_subnet_inet6 cleanup
276
default_route_with_multiple_fibs_on_same_subnet_inet6_head()
277
{
278
	atf_set "descr" "Multiple interfaces on the same subnet but with different fibs can both have default routes"
279
	atf_set "require.user" "root"
280
	atf_set "require.config" "fibs"
281
}
282
283
default_route_with_multiple_fibs_on_same_subnet_inet6_body()
284
{
285
	# Configure the TAP interfaces to use a RFC5737 nonrouteable addresses
286
	# and a non-default fib
287
	ADDR0="2001:db8::2"
288
	ADDR1="2001:db8::3"
289
	GATEWAY="2001:db8::1"
290
	SUBNET="2001:db8::"
291
	MASK="64"
292
293
	# Check system configuration
294
	if [ 0 != `sysctl -n net.add_addr_allfibs` ]; then
295
		atf_skip "This test requires net.add_addr_allfibs=0"
296
	fi
297
	get_fibs 2
298
299
	# Configure TAP interfaces
300
	setup_tap6 "$FIB0" ${ADDR0} ${MASK}
301
	TAP0=$TAP
302
	setup_tap6 "$FIB1" ${ADDR1} ${MASK}
303
	TAP1=$TAP
304
305
	# Attempt to add default routes
306
	setfib ${FIB0} route -6 add default ${GATEWAY}
307
	setfib ${FIB1} route -6 add default ${GATEWAY}
308
309
	# Verify that the default route exists for both fibs, with their
310
	# respective interfaces.
311
	atf_check -o match:"^default.*${TAP0}$" \
312
		setfib ${FIB0} netstat -rn -f inet6
313
	atf_check -o match:"^default.*${TAP1}$" \
314
		setfib ${FIB1} netstat -rn -f inet6
315
}
316
317
default_route_with_multiple_fibs_on_same_subnet_inet6_cleanup()
318
{
319
	cleanup_tap
320
}
321
218
322
219
# Regression test for PR kern/189089
323
# Regression test for PR kern/189089
220
# Create two tap interfaces and assign them both the same IP address but with
324
# Create two tap interfaces and assign them both the same IP address but with
Lines 308-313 same_ip_multiple_ifaces_cleanup() Link Here
308
	done
412
	done
309
}
413
}
310
414
415
atf_test_case same_ip_multiple_ifaces_inet6 cleanup
416
same_ip_multiple_ifaces_inet6_head()
417
{
418
	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."
419
	atf_set "require.user" "root"
420
	atf_set "require.config" "fibs"
421
}
422
same_ip_multiple_ifaces_inet6_body()
423
{
424
	atf_expect_fail "kern/189088 Assigning the same IP to multiple interfaces in different FIBs creates a host route for only one"
425
	ADDR="2001:db8::2"
426
	MASK0="64"
427
	MASK1="128"
428
429
	# Unlike most of the tests in this file, this is applicable regardless
430
	# of net.add_addr_allfibs
431
	get_fibs 2
432
433
	# Setup the interfaces, then remove one alias.  It should not panic.
434
	setup_tap6 ${FIB0} ${ADDR} ${MASK0}
435
	TAP0=${TAP}
436
	setup_tap6 ${FIB1} ${ADDR} ${MASK1}
437
	TAP1=${TAP}
438
	ifconfig ${TAP1} inet6 -alias ${ADDR}
439
	atf_check -o not-match:"^${ADDR}[[:space:]]" \
440
		setfib ${FIB1} netstat -rn -f inet6
441
442
	# Do it again, in the opposite order.  It should not panic.
443
	setup_tap6 ${FIB0} ${ADDR} ${MASK0}
444
	TAP0=${TAP}
445
	setup_tap6 ${FIB1} ${ADDR} ${MASK1}
446
	TAP1=${TAP}
447
	ifconfig ${TAP0} inet6 -alias ${ADDR}
448
	atf_check -o not-match:"^${ADDR}[[:space:]]" \
449
		setfib ${FIB0} netstat -rn -f inet6
450
}
451
same_ip_multiple_ifaces_inet6_cleanup()
452
{
453
	# Due to PR kern/189088, we must destroy the interfaces in LIFO order
454
	# in order for the routes to be correctly cleaned up.
455
	for TAPD in `tail -r "tap_devices_to_cleanup"`; do
456
		ifconfig ${TAPD} destroy
457
	done
458
}
459
311
# Regression test for kern/187550
460
# Regression test for kern/187550
312
atf_test_case subnet_route_with_multiple_fibs_on_same_subnet cleanup
461
atf_test_case subnet_route_with_multiple_fibs_on_same_subnet cleanup
313
subnet_route_with_multiple_fibs_on_same_subnet_head()
462
subnet_route_with_multiple_fibs_on_same_subnet_head()
Lines 346-351 subnet_route_with_multiple_fibs_on_same_subnet_cleanup() Link Here
346
	cleanup_tap
495
	cleanup_tap
347
}
496
}
348
497
498
atf_test_case subnet_route_with_multiple_fibs_on_same_subnet_inet6 cleanup
499
subnet_route_with_multiple_fibs_on_same_subnet_inet6_head()
500
{
501
	atf_set "descr" "Multiple FIBs can have subnet routes for the same subnet"
502
	atf_set "require.user" "root"
503
	atf_set "require.config" "fibs"
504
}
505
506
subnet_route_with_multiple_fibs_on_same_subnet_inet6_body()
507
{
508
	# Configure the TAP interfaces to use a RFC5737 nonrouteable addresses
509
	# and a non-default fib
510
	ADDR0="2001:db8::2"
511
	ADDR1="2001:db8::3"
512
	SUBNET="2001:db8::"
513
	MASK="64"
514
515
	# Check system configuration
516
	if [ 0 != `sysctl -n net.add_addr_allfibs` ]; then
517
		atf_skip "This test requires net.add_addr_allfibs=0"
518
	fi
519
	get_fibs 2
520
521
	# Configure TAP interfaces
522
	setup_tap6 "$FIB0" ${ADDR0} ${MASK}
523
	setup_tap6 "$FIB1" ${ADDR1} ${MASK}
524
525
	# Check that a subnet route exists on both fibs
526
	atf_check -o ignore setfib "$FIB0" route -6 get $ADDR1
527
	atf_check -o ignore setfib "$FIB1" route -6 get $ADDR0
528
}
529
530
subnet_route_with_multiple_fibs_on_same_subnet_inet6_cleanup()
531
{
532
	cleanup_tap
533
}
534
349
# Test that source address selection works correctly for UDP packets with
535
# Test that source address selection works correctly for UDP packets with
350
# SO_DONTROUTE set that are sent on non-default FIBs.
536
# SO_DONTROUTE set that are sent on non-default FIBs.
351
# This bug was discovered with "setfib 1 netperf -t UDP_STREAM -H some_host"
537
# This bug was discovered with "setfib 1 netperf -t UDP_STREAM -H some_host"
Lines 415-424 atf_init_test_cases() Link Here
415
{
601
{
416
	atf_add_test_case arpresolve_checks_interface_fib
602
	atf_add_test_case arpresolve_checks_interface_fib
417
	atf_add_test_case loopback_and_network_routes_on_nondefault_fib
603
	atf_add_test_case loopback_and_network_routes_on_nondefault_fib
604
	atf_add_test_case loopback_and_network_routes_on_nondefault_fib_inet6
418
	atf_add_test_case default_route_with_multiple_fibs_on_same_subnet
605
	atf_add_test_case default_route_with_multiple_fibs_on_same_subnet
606
	atf_add_test_case default_route_with_multiple_fibs_on_same_subnet_inet6
419
	atf_add_test_case same_ip_multiple_ifaces_fib0
607
	atf_add_test_case same_ip_multiple_ifaces_fib0
420
	atf_add_test_case same_ip_multiple_ifaces
608
	atf_add_test_case same_ip_multiple_ifaces
609
	atf_add_test_case same_ip_multiple_ifaces_inet6
421
	atf_add_test_case subnet_route_with_multiple_fibs_on_same_subnet
610
	atf_add_test_case subnet_route_with_multiple_fibs_on_same_subnet
611
	atf_add_test_case subnet_route_with_multiple_fibs_on_same_subnet_inet6
422
	atf_add_test_case udp_dontroute
612
	atf_add_test_case udp_dontroute
423
}
613
}
424
614
Lines 477-486 setup_tap() Link Here
477
	setfib ${FIB} ifconfig $TAP ${ADDR}/${MASK} fib $FIB
667
	setfib ${FIB} ifconfig $TAP ${ADDR}/${MASK} fib $FIB
478
}
668
}
479
669
670
setup_tap6()
671
{
672
	local FIB=$1
673
	local ADDR=$2
674
	local MASK=$3
675
	get_tap
676
	echo setfib ${FIB} ifconfig $TAP inet6 ${ADDR}/${MASK} fib $FIB
677
	setfib ${FIB} ifconfig $TAP inet6 ${ADDR}/${MASK} fib $FIB
678
}
679
480
cleanup_tap()
680
cleanup_tap()
481
{
681
{
482
	if [ -f tap_devices_to_cleanup ]; then
682
	if [ -f tap_devices_to_cleanup ]; then
483
		for tap_device in $(cat tap_devices_to_cleanup); do
683
		for tap_device in $(cat tap_devices_to_cleanup); do
684
			echo ifconfig "${tap_device}" destroy
484
			ifconfig "${tap_device}" destroy
685
			ifconfig "${tap_device}" destroy
485
		done
686
		done
486
		rm -f tap_devices_to_cleanup
687
		rm -f tap_devices_to_cleanup

Return to bug 196361