Commit d0248dc2 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by Ma Wupeng
Browse files

selftests: net: move amt to socat for better compatibility

stable inclusion
from stable-v6.6.33
commit 1ebaa96f97cd5f90563b7decd0e7c07c27b2d4f0
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IAD6H2

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



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

[ Upstream commit 4c639b6a7b9db236c0907aca8e92d1537076f2cd ]

The test seems to expect that nc will exit after the first
received message. This is not the case with Ncat 7.94.
There are multiple versions of nc out there, switch
to socat for better compatibility.

Tell socat to exit after 128 bytes and pad the message.

Since the test sets -e make sure we don't set exit code
(|| true) and print the pass / fail rather then silently
moving over the test and just setting non-zero exit code
with no output indicating what failed.

Fixes: c08e8bae ("selftests: add amt interface selftest script")
Acked-by: default avatarPaolo <Abeni&lt;pabeni@redhat.com>
Tested-by: default avatarTaehee Yoo <ap420073@gmail.com>
Link: https://lore.kernel.org/r/20240509161952.3940476-1-kuba@kernel.org


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarWang Hai <wanghai38@huawei.com>
parent ee08fbf5
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -210,8 +210,8 @@ check_features()

test_ipv4_forward()
{
	RESULT4=$(ip netns exec "${LISTENER}" nc -w 1 -l -u 239.0.0.1 4000)
	if [ "$RESULT4" == "172.17.0.2" ]; then
	RESULT4=$(ip netns exec "${LISTENER}" timeout 15 socat - UDP4-LISTEN:4000,readbytes=128 || true)
	if echo "$RESULT4" | grep -q "172.17.0.2"; then
		printf "TEST: %-60s  [ OK ]\n" "IPv4 amt multicast forwarding"
		exit 0
	else
@@ -222,8 +222,8 @@ test_ipv4_forward()

test_ipv6_forward()
{
	RESULT6=$(ip netns exec "${LISTENER}" nc -w 1 -l -u ff0e::5:6 6000)
	if [ "$RESULT6" == "2001:db8:3::2" ]; then
	RESULT6=$(ip netns exec "${LISTENER}" timeout 15 socat - UDP6-LISTEN:6000,readbytes=128 || true)
	if echo "$RESULT6" | grep -q "2001:db8:3::2"; then
		printf "TEST: %-60s  [ OK ]\n" "IPv6 amt multicast forwarding"
		exit 0
	else
@@ -236,14 +236,14 @@ send_mcast4()
{
	sleep 2
	ip netns exec "${SOURCE}" bash -c \
		'echo 172.17.0.2 | nc -w 1 -u 239.0.0.1 4000' &
		'printf "%s %128s" 172.17.0.2 | nc -w 1 -u 239.0.0.1 4000' &
}

send_mcast6()
{
	sleep 2
	ip netns exec "${SOURCE}" bash -c \
		'echo 2001:db8:3::2 | nc -w 1 -u ff0e::5:6 6000' &
		'printf "%s %128s" 2001:db8:3::2 | nc -w 1 -u ff0e::5:6 6000' &
}

check_features