Commit 50d51cef authored by David Yang's avatar David Yang Committed by Jakub Kicinski
Browse files

selftests: forwarding: Reorder (ar)ping arguments to obey POSIX getopt



Quoted from musl wiki:

  GNU getopt permutes argv to pull options to the front, ahead of
  non-option arguments. musl and the POSIX standard getopt stop
  processing options at the first non-option argument with no
  permutation.

Thus these scripts stop working on musl since non-option arguments for
tools using getopt() (in this case, (ar)ping) do not always come last.
Fix it by reordering arguments.

Signed-off-by: default avatarDavid Yang <mmyangfl@gmail.com>
Reviewed-by: default avatarPetr Machata <petrm@nvidia.com>
Reviewed-by: default avatarIdo Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20250919053538.1106753-1-mmyangfl@gmail.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 312e6f76
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -226,7 +226,7 @@ send_flowlabel()
	# Generate 16384 echo requests, each with a random flow label.
	ip vrf exec v$h1 sh -c \
		"for _ in {1..16384}; do \
			$PING6 2001:db8:4::2 -F 0 -c 1 -q >/dev/null 2>&1; \
			$PING6 -F 0 -c 1 -q 2001:db8:4::2 >/dev/null 2>&1; \
		done"
}

+1 −1
Original line number Diff line number Diff line
@@ -321,7 +321,7 @@ send_flowlabel()
	# Generate 16384 echo requests, each with a random flow label.
	ip vrf exec v$h1 sh -c \
		"for _ in {1..16384}; do \
			$PING6 2001:db8:2::2 -F 0 -c 1 -q >/dev/null 2>&1; \
			$PING6 -F 0 -c 1 -q 2001:db8:2::2 >/dev/null 2>&1; \
		done"
}

+3 −3
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ ipv6_in_too_big_err()

	# Send too big packets
	ip vrf exec $vrf_name \
		$PING6 -s 1300 2001:1:2::2 -c 1 -w $PING_TIMEOUT &> /dev/null
		$PING6 -s 1300 -c 1 -w $PING_TIMEOUT 2001:1:2::2 &> /dev/null

	local t1=$(ipv6_stats_get $rtr1 Ip6InTooBigErrors)
	test "$((t1 - t0))" -ne 0
@@ -131,7 +131,7 @@ ipv6_in_addr_err()
	# Disable forwarding temporary while sending the packet
	sysctl -qw net.ipv6.conf.all.forwarding=0
	ip vrf exec $vrf_name \
		$PING6 2001:1:2::2 -c 1 -w $PING_TIMEOUT &> /dev/null
		$PING6 -c 1 -w $PING_TIMEOUT 2001:1:2::2 &> /dev/null
	sysctl -qw net.ipv6.conf.all.forwarding=1

	local t1=$(ipv6_stats_get $rtr1 Ip6InAddrErrors)
@@ -150,7 +150,7 @@ ipv6_in_discard()
	# Add a policy to discard
	ip xfrm policy add dst 2001:1:2::2/128 dir fwd action block
	ip vrf exec $vrf_name \
		$PING6 2001:1:2::2 -c 1 -w $PING_TIMEOUT &> /dev/null
		$PING6 -c 1 -w $PING_TIMEOUT 2001:1:2::2 &> /dev/null
	ip xfrm policy del dst 2001:1:2::2/128 dir fwd

	local t1=$(ipv6_stats_get $rtr1 Ip6InDiscards)
+1 −1
Original line number Diff line number Diff line
@@ -323,7 +323,7 @@ send_flowlabel()
	# Generate 16384 echo requests, each with a random flow label.
	ip vrf exec v$h1 sh -c \
		"for _ in {1..16384}; do \
			$PING6 2001:db8:2::2 -F 0 -c 1 -q >/dev/null 2>&1; \
			$PING6 -F 0 -c 1 -q 2001:db8:2::2 >/dev/null 2>&1; \
		done"
}

+4 −4
Original line number Diff line number Diff line
@@ -1267,8 +1267,8 @@ ping_do()

	vrf_name=$(master_name_get $if_name)
	ip vrf exec $vrf_name \
		$PING $args $dip -c $PING_COUNT -i 0.1 \
		-w $PING_TIMEOUT &> /dev/null
		$PING $args -c $PING_COUNT -i 0.1 \
		-w $PING_TIMEOUT $dip &> /dev/null
}

ping_test()
@@ -1298,8 +1298,8 @@ ping6_do()

	vrf_name=$(master_name_get $if_name)
	ip vrf exec $vrf_name \
		$PING6 $args $dip -c $PING_COUNT -i 0.1 \
		-w $PING_TIMEOUT &> /dev/null
		$PING6 $args -c $PING_COUNT -i 0.1 \
		-w $PING_TIMEOUT $dip &> /dev/null
}

ping6_test()
Loading