Skip to content

Commit 28a2686

Browse files
dsaherndavem330
authored andcommitted
selftests: Fix IPv6 address bind tests
IPv6 allows binding a socket to a device then binding to an address not on the device (__inet6_bind -> ipv6_chk_addr with strict flag not set). Update the bind tests to reflect legacy behavior. Fixes: 34d0302 ("selftests: Add ipv6 address bind tests to fcnal-test") Reported-by: Li Zhijian <lizhijian@fujitsu.com> Signed-off-by: David Ahern <dsahern@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 0f108ae commit 28a2686

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

tools/testing/selftests/net/fcnal-test.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3429,11 +3429,14 @@ ipv6_addr_bind_novrf()
34293429
run_cmd nettest -6 -s -l ${a} -I ${NSA_DEV} -t1 -b
34303430
log_test_addr ${a} $? 0 "TCP socket bind to local address after device bind"
34313431

3432+
# Sadly, the kernel allows binding a socket to a device and then
3433+
# binding to an address not on the device. So this test passes
3434+
# when it really should not
34323435
a=${NSA_LO_IP6}
34333436
log_start
3434-
show_hint "Should fail with 'Cannot assign requested address'"
3437+
show_hint "Tecnically should fail since address is not on device but kernel allows"
34353438
run_cmd nettest -6 -s -l ${a} -I ${NSA_DEV} -t1 -b
3436-
log_test_addr ${a} $? 1 "TCP socket bind to out of scope local address"
3439+
log_test_addr ${a} $? 0 "TCP socket bind to out of scope local address"
34373440
}
34383441

34393442
ipv6_addr_bind_vrf()
@@ -3474,10 +3477,15 @@ ipv6_addr_bind_vrf()
34743477
run_cmd nettest -6 -s -l ${a} -I ${NSA_DEV} -t1 -b
34753478
log_test_addr ${a} $? 0 "TCP socket bind to local address with device bind"
34763479

3480+
# Sadly, the kernel allows binding a socket to a device and then
3481+
# binding to an address not on the device. The only restriction
3482+
# is that the address is valid in the L3 domain. So this test
3483+
# passes when it really should not
34773484
a=${VRF_IP6}
34783485
log_start
3486+
show_hint "Tecnically should fail since address is not on device but kernel allows"
34793487
run_cmd nettest -6 -s -l ${a} -I ${NSA_DEV} -t1 -b
3480-
log_test_addr ${a} $? 1 "TCP socket bind to VRF address with device bind"
3488+
log_test_addr ${a} $? 0 "TCP socket bind to VRF address with device bind"
34813489

34823490
a=${NSA_LO_IP6}
34833491
log_start

0 commit comments

Comments
 (0)