提交 a49a761b 编写于 作者: D David Ahern 提交者: Zheng Zengkai

selftests: Fix IPv6 address bind tests

stable inclusion
from stable-v5.10.88
commit dfff1d5e85fff5702f7b28a8a18a26f88d3e6883
bugzilla: 186058 https://gitee.com/openeuler/kernel/issues/I4QW6A

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=dfff1d5e85fff5702f7b28a8a18a26f88d3e6883

--------------------------------

[ Upstream commit 28a2686c ]

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: 34d0302a ("selftests: Add ipv6 address bind tests to fcnal-test")
Reported-by: NLi Zhijian <lizhijian@fujitsu.com>
Signed-off-by: NDavid Ahern <dsahern@kernel.org>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 82e419d3
...@@ -3366,11 +3366,14 @@ ipv6_addr_bind_novrf() ...@@ -3366,11 +3366,14 @@ ipv6_addr_bind_novrf()
run_cmd nettest -6 -s -l ${a} -d ${NSA_DEV} -t1 -b run_cmd nettest -6 -s -l ${a} -d ${NSA_DEV} -t1 -b
log_test_addr ${a} $? 0 "TCP socket bind to local address after device bind" log_test_addr ${a} $? 0 "TCP socket bind to local address after device bind"
# Sadly, the kernel allows binding a socket to a device and then
# binding to an address not on the device. So this test passes
# when it really should not
a=${NSA_LO_IP6} a=${NSA_LO_IP6}
log_start log_start
show_hint "Should fail with 'Cannot assign requested address'" show_hint "Tecnically should fail since address is not on device but kernel allows"
run_cmd nettest -6 -s -l ${a} -d ${NSA_DEV} -t1 -b run_cmd nettest -6 -s -l ${a} -I ${NSA_DEV} -t1 -b
log_test_addr ${a} $? 1 "TCP socket bind to out of scope local address" log_test_addr ${a} $? 0 "TCP socket bind to out of scope local address"
} }
ipv6_addr_bind_vrf() ipv6_addr_bind_vrf()
...@@ -3411,10 +3414,15 @@ ipv6_addr_bind_vrf() ...@@ -3411,10 +3414,15 @@ ipv6_addr_bind_vrf()
run_cmd nettest -6 -s -l ${a} -d ${NSA_DEV} -t1 -b run_cmd nettest -6 -s -l ${a} -d ${NSA_DEV} -t1 -b
log_test_addr ${a} $? 0 "TCP socket bind to local address with device bind" log_test_addr ${a} $? 0 "TCP socket bind to local address with device bind"
# Sadly, the kernel allows binding a socket to a device and then
# binding to an address not on the device. The only restriction
# is that the address is valid in the L3 domain. So this test
# passes when it really should not
a=${VRF_IP6} a=${VRF_IP6}
log_start log_start
run_cmd nettest -6 -s -l ${a} -d ${NSA_DEV} -t1 -b show_hint "Tecnically should fail since address is not on device but kernel allows"
log_test_addr ${a} $? 1 "TCP socket bind to VRF address with device bind" run_cmd nettest -6 -s -l ${a} -I ${NSA_DEV} -t1 -b
log_test_addr ${a} $? 0 "TCP socket bind to VRF address with device bind"
a=${NSA_LO_IP6} a=${NSA_LO_IP6}
log_start log_start
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册