netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] selftests: forwarding: Fix failing tests with old libnet
@ 2022-08-09 11:33 Ido Schimmel
  2022-08-09 13:10 ` Jiri Pirko
  2022-08-11  5:40 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 5+ messages in thread
From: Ido Schimmel @ 2022-08-09 11:33 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, pabeni, edumazet, amcohen, dsahern, ivecera, mlxsw,
	Ido Schimmel

The custom multipath hash tests use mausezahn in order to test how
changes in various packet fields affect the packet distribution across
the available nexthops.

The tool uses the libnet library for various low-level packet
construction and injection. The library started using the
"SO_BINDTODEVICE" socket option for IPv6 sockets in version 1.1.6 and
for IPv4 sockets in version 1.2.

When the option is not set, packets are not routed according to the
table associated with the VRF master device and tests fail.

Fix this by prefixing the command with "ip vrf exec", which will cause
the route lookup to occur in the VRF routing table. This makes the tests
pass regardless of the libnet library version.

Fixes: 511e8db54036 ("selftests: forwarding: Add test for custom multipath hash")
Fixes: 185b0c190bb6 ("selftests: forwarding: Add test for custom multipath hash with IPv4 GRE")
Fixes: b7715acba4d3 ("selftests: forwarding: Add test for custom multipath hash with IPv6 GRE")
Reported-by: Ivan Vecera <ivecera@redhat.com>
Tested-by: Ivan Vecera <ivecera@redhat.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Amit Cohen <amcohen@nvidia.com>
---
 .../net/forwarding/custom_multipath_hash.sh   | 24 ++++++++++++-------
 .../forwarding/gre_custom_multipath_hash.sh   | 24 ++++++++++++-------
 .../ip6gre_custom_multipath_hash.sh           | 24 ++++++++++++-------
 3 files changed, 48 insertions(+), 24 deletions(-)

diff --git a/tools/testing/selftests/net/forwarding/custom_multipath_hash.sh b/tools/testing/selftests/net/forwarding/custom_multipath_hash.sh
index a15d21dc035a..56eb83d1a3bd 100755
--- a/tools/testing/selftests/net/forwarding/custom_multipath_hash.sh
+++ b/tools/testing/selftests/net/forwarding/custom_multipath_hash.sh
@@ -181,37 +181,43 @@ ping_ipv6()
 
 send_src_ipv4()
 {
-	$MZ $h1 -q -p 64 -A "198.51.100.2-198.51.100.253" -B 203.0.113.2 \
+	ip vrf exec v$h1 $MZ $h1 -q -p 64 \
+		-A "198.51.100.2-198.51.100.253" -B 203.0.113.2 \
 		-d 1msec -c 50 -t udp "sp=20000,dp=30000"
 }
 
 send_dst_ipv4()
 {
-	$MZ $h1 -q -p 64 -A 198.51.100.2 -B "203.0.113.2-203.0.113.253" \
+	ip vrf exec v$h1 $MZ $h1 -q -p 64 \
+		-A 198.51.100.2 -B "203.0.113.2-203.0.113.253" \
 		-d 1msec -c 50 -t udp "sp=20000,dp=30000"
 }
 
 send_src_udp4()
 {
-	$MZ $h1 -q -p 64 -A 198.51.100.2 -B 203.0.113.2 \
+	ip vrf exec v$h1 $MZ $h1 -q -p 64 \
+		-A 198.51.100.2 -B 203.0.113.2 \
 		-d 1msec -t udp "sp=0-32768,dp=30000"
 }
 
 send_dst_udp4()
 {
-	$MZ $h1 -q -p 64 -A 198.51.100.2 -B 203.0.113.2 \
+	ip vrf exec v$h1 $MZ $h1 -q -p 64 \
+		-A 198.51.100.2 -B 203.0.113.2 \
 		-d 1msec -t udp "sp=20000,dp=0-32768"
 }
 
 send_src_ipv6()
 {
-	$MZ -6 $h1 -q -p 64 -A "2001:db8:1::2-2001:db8:1::fd" -B 2001:db8:4::2 \
+	ip vrf exec v$h1 $MZ -6 $h1 -q -p 64 \
+		-A "2001:db8:1::2-2001:db8:1::fd" -B 2001:db8:4::2 \
 		-d 1msec -c 50 -t udp "sp=20000,dp=30000"
 }
 
 send_dst_ipv6()
 {
-	$MZ -6 $h1 -q -p 64 -A 2001:db8:1::2 -B "2001:db8:4::2-2001:db8:4::fd" \
+	ip vrf exec v$h1 $MZ -6 $h1 -q -p 64 \
+		-A 2001:db8:1::2 -B "2001:db8:4::2-2001:db8:4::fd" \
 		-d 1msec -c 50 -t udp "sp=20000,dp=30000"
 }
 
@@ -226,13 +232,15 @@ send_flowlabel()
 
 send_src_udp6()
 {
-	$MZ -6 $h1 -q -p 64 -A 2001:db8:1::2 -B 2001:db8:4::2 \
+	ip vrf exec v$h1 $MZ -6 $h1 -q -p 64 \
+		-A 2001:db8:1::2 -B 2001:db8:4::2 \
 		-d 1msec -t udp "sp=0-32768,dp=30000"
 }
 
 send_dst_udp6()
 {
-	$MZ -6 $h1 -q -p 64 -A 2001:db8:1::2 -B 2001:db8:4::2 \
+	ip vrf exec v$h1 $MZ -6 $h1 -q -p 64 \
+		-A 2001:db8:1::2 -B 2001:db8:4::2 \
 		-d 1msec -t udp "sp=20000,dp=0-32768"
 }
 
diff --git a/tools/testing/selftests/net/forwarding/gre_custom_multipath_hash.sh b/tools/testing/selftests/net/forwarding/gre_custom_multipath_hash.sh
index a73f52efcb6c..0446db9c6f74 100755
--- a/tools/testing/selftests/net/forwarding/gre_custom_multipath_hash.sh
+++ b/tools/testing/selftests/net/forwarding/gre_custom_multipath_hash.sh
@@ -276,37 +276,43 @@ ping_ipv6()
 
 send_src_ipv4()
 {
-	$MZ $h1 -q -p 64 -A "198.51.100.2-198.51.100.253" -B 203.0.113.2 \
+	ip vrf exec v$h1 $MZ $h1 -q -p 64 \
+		-A "198.51.100.2-198.51.100.253" -B 203.0.113.2 \
 		-d 1msec -c 50 -t udp "sp=20000,dp=30000"
 }
 
 send_dst_ipv4()
 {
-	$MZ $h1 -q -p 64 -A 198.51.100.2 -B "203.0.113.2-203.0.113.253" \
+	ip vrf exec v$h1 $MZ $h1 -q -p 64 \
+		-A 198.51.100.2 -B "203.0.113.2-203.0.113.253" \
 		-d 1msec -c 50 -t udp "sp=20000,dp=30000"
 }
 
 send_src_udp4()
 {
-	$MZ $h1 -q -p 64 -A 198.51.100.2 -B 203.0.113.2 \
+	ip vrf exec v$h1 $MZ $h1 -q -p 64 \
+		-A 198.51.100.2 -B 203.0.113.2 \
 		-d 1msec -t udp "sp=0-32768,dp=30000"
 }
 
 send_dst_udp4()
 {
-	$MZ $h1 -q -p 64 -A 198.51.100.2 -B 203.0.113.2 \
+	ip vrf exec v$h1 $MZ $h1 -q -p 64 \
+		-A 198.51.100.2 -B 203.0.113.2 \
 		-d 1msec -t udp "sp=20000,dp=0-32768"
 }
 
 send_src_ipv6()
 {
-	$MZ -6 $h1 -q -p 64 -A "2001:db8:1::2-2001:db8:1::fd" -B 2001:db8:2::2 \
+	ip vrf exec v$h1 $MZ -6 $h1 -q -p 64 \
+		-A "2001:db8:1::2-2001:db8:1::fd" -B 2001:db8:2::2 \
 		-d 1msec -c 50 -t udp "sp=20000,dp=30000"
 }
 
 send_dst_ipv6()
 {
-	$MZ -6 $h1 -q -p 64 -A 2001:db8:1::2 -B "2001:db8:2::2-2001:db8:2::fd" \
+	ip vrf exec v$h1 $MZ -6 $h1 -q -p 64 \
+		-A 2001:db8:1::2 -B "2001:db8:2::2-2001:db8:2::fd" \
 		-d 1msec -c 50 -t udp "sp=20000,dp=30000"
 }
 
@@ -321,13 +327,15 @@ send_flowlabel()
 
 send_src_udp6()
 {
-	$MZ -6 $h1 -q -p 64 -A 2001:db8:1::2 -B 2001:db8:2::2 \
+	ip vrf exec v$h1 $MZ -6 $h1 -q -p 64 \
+		-A 2001:db8:1::2 -B 2001:db8:2::2 \
 		-d 1msec -t udp "sp=0-32768,dp=30000"
 }
 
 send_dst_udp6()
 {
-	$MZ -6 $h1 -q -p 64 -A 2001:db8:1::2 -B 2001:db8:2::2 \
+	ip vrf exec v$h1 $MZ -6 $h1 -q -p 64 \
+		-A 2001:db8:1::2 -B 2001:db8:2::2 \
 		-d 1msec -t udp "sp=20000,dp=0-32768"
 }
 
diff --git a/tools/testing/selftests/net/forwarding/ip6gre_custom_multipath_hash.sh b/tools/testing/selftests/net/forwarding/ip6gre_custom_multipath_hash.sh
index 8fea2c2e0b25..d40183b4eccc 100755
--- a/tools/testing/selftests/net/forwarding/ip6gre_custom_multipath_hash.sh
+++ b/tools/testing/selftests/net/forwarding/ip6gre_custom_multipath_hash.sh
@@ -278,37 +278,43 @@ ping_ipv6()
 
 send_src_ipv4()
 {
-	$MZ $h1 -q -p 64 -A "198.51.100.2-198.51.100.253" -B 203.0.113.2 \
+	ip vrf exec v$h1 $MZ $h1 -q -p 64 \
+		-A "198.51.100.2-198.51.100.253" -B 203.0.113.2 \
 		-d 1msec -c 50 -t udp "sp=20000,dp=30000"
 }
 
 send_dst_ipv4()
 {
-	$MZ $h1 -q -p 64 -A 198.51.100.2 -B "203.0.113.2-203.0.113.253" \
+	ip vrf exec v$h1 $MZ $h1 -q -p 64 \
+		-A 198.51.100.2 -B "203.0.113.2-203.0.113.253" \
 		-d 1msec -c 50 -t udp "sp=20000,dp=30000"
 }
 
 send_src_udp4()
 {
-	$MZ $h1 -q -p 64 -A 198.51.100.2 -B 203.0.113.2 \
+	ip vrf exec v$h1 $MZ $h1 -q -p 64 \
+		-A 198.51.100.2 -B 203.0.113.2 \
 		-d 1msec -t udp "sp=0-32768,dp=30000"
 }
 
 send_dst_udp4()
 {
-	$MZ $h1 -q -p 64 -A 198.51.100.2 -B 203.0.113.2 \
+	ip vrf exec v$h1 $MZ $h1 -q -p 64 \
+		-A 198.51.100.2 -B 203.0.113.2 \
 		-d 1msec -t udp "sp=20000,dp=0-32768"
 }
 
 send_src_ipv6()
 {
-	$MZ -6 $h1 -q -p 64 -A "2001:db8:1::2-2001:db8:1::fd" -B 2001:db8:2::2 \
+	ip vrf exec v$h1 $MZ -6 $h1 -q -p 64 \
+		-A "2001:db8:1::2-2001:db8:1::fd" -B 2001:db8:2::2 \
 		-d 1msec -c 50 -t udp "sp=20000,dp=30000"
 }
 
 send_dst_ipv6()
 {
-	$MZ -6 $h1 -q -p 64 -A 2001:db8:1::2 -B "2001:db8:2::2-2001:db8:2::fd" \
+	ip vrf exec v$h1 $MZ -6 $h1 -q -p 64 \
+		-A 2001:db8:1::2 -B "2001:db8:2::2-2001:db8:2::fd" \
 		-d 1msec -c 50 -t udp "sp=20000,dp=30000"
 }
 
@@ -323,13 +329,15 @@ send_flowlabel()
 
 send_src_udp6()
 {
-	$MZ -6 $h1 -q -p 64 -A 2001:db8:1::2 -B 2001:db8:2::2 \
+	ip vrf exec v$h1 $MZ -6 $h1 -q -p 64 \
+		-A 2001:db8:1::2 -B 2001:db8:2::2 \
 		-d 1msec -t udp "sp=0-32768,dp=30000"
 }
 
 send_dst_udp6()
 {
-	$MZ -6 $h1 -q -p 64 -A 2001:db8:1::2 -B 2001:db8:2::2 \
+	ip vrf exec v$h1 $MZ -6 $h1 -q -p 64 \
+		-A 2001:db8:1::2 -B 2001:db8:2::2 \
 		-d 1msec -t udp "sp=20000,dp=0-32768"
 }
 
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net] selftests: forwarding: Fix failing tests with old libnet
  2022-08-09 11:33 [PATCH net] selftests: forwarding: Fix failing tests with old libnet Ido Schimmel
@ 2022-08-09 13:10 ` Jiri Pirko
  2022-08-09 14:21   ` Petr Machata
  2022-08-09 14:27   ` Ido Schimmel
  2022-08-11  5:40 ` patchwork-bot+netdevbpf
  1 sibling, 2 replies; 5+ messages in thread
From: Jiri Pirko @ 2022-08-09 13:10 UTC (permalink / raw)
  To: Ido Schimmel
  Cc: netdev, davem, kuba, pabeni, edumazet, amcohen, dsahern, ivecera,
	mlxsw

Tue, Aug 09, 2022 at 01:33:20PM CEST, idosch@nvidia.com wrote:
>The custom multipath hash tests use mausezahn in order to test how
>changes in various packet fields affect the packet distribution across
>the available nexthops.
>
>The tool uses the libnet library for various low-level packet
>construction and injection. The library started using the
>"SO_BINDTODEVICE" socket option for IPv6 sockets in version 1.1.6 and
>for IPv4 sockets in version 1.2.
>
>When the option is not set, packets are not routed according to the
>table associated with the VRF master device and tests fail.
>
>Fix this by prefixing the command with "ip vrf exec", which will cause
>the route lookup to occur in the VRF routing table. This makes the tests
>pass regardless of the libnet library version.
>
>Fixes: 511e8db54036 ("selftests: forwarding: Add test for custom multipath hash")
>Fixes: 185b0c190bb6 ("selftests: forwarding: Add test for custom multipath hash with IPv4 GRE")
>Fixes: b7715acba4d3 ("selftests: forwarding: Add test for custom multipath hash with IPv6 GRE")
>Reported-by: Ivan Vecera <ivecera@redhat.com>
>Tested-by: Ivan Vecera <ivecera@redhat.com>
>Signed-off-by: Ido Schimmel <idosch@nvidia.com>
>Reviewed-by: Amit Cohen <amcohen@nvidia.com>
>---
> .../net/forwarding/custom_multipath_hash.sh   | 24 ++++++++++++-------
> .../forwarding/gre_custom_multipath_hash.sh   | 24 ++++++++++++-------
> .../ip6gre_custom_multipath_hash.sh           | 24 ++++++++++++-------
> 3 files changed, 48 insertions(+), 24 deletions(-)
>
>diff --git a/tools/testing/selftests/net/forwarding/custom_multipath_hash.sh b/tools/testing/selftests/net/forwarding/custom_multipath_hash.sh
>index a15d21dc035a..56eb83d1a3bd 100755
>--- a/tools/testing/selftests/net/forwarding/custom_multipath_hash.sh
>+++ b/tools/testing/selftests/net/forwarding/custom_multipath_hash.sh
>@@ -181,37 +181,43 @@ ping_ipv6()
> 
> send_src_ipv4()
> {
>-	$MZ $h1 -q -p 64 -A "198.51.100.2-198.51.100.253" -B 203.0.113.2 \
>+	ip vrf exec v$h1 $MZ $h1 -q -p 64 \

Not directly related to this, but I was wondering, if it would be
possible to use $IP and allow user to replace the system-wide "ip" for
testing purposes...

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] selftests: forwarding: Fix failing tests with old libnet
  2022-08-09 13:10 ` Jiri Pirko
@ 2022-08-09 14:21   ` Petr Machata
  2022-08-09 14:27   ` Ido Schimmel
  1 sibling, 0 replies; 5+ messages in thread
From: Petr Machata @ 2022-08-09 14:21 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: Ido Schimmel, netdev, davem, kuba, pabeni, edumazet, amcohen,
	dsahern, ivecera, mlxsw


Jiri Pirko <jiri@nvidia.com> writes:

> Tue, Aug 09, 2022 at 01:33:20PM CEST, idosch@nvidia.com wrote:
>>diff --git a/tools/testing/selftests/net/forwarding/custom_multipath_hash.sh b/tools/testing/selftests/net/forwarding/custom_multipath_hash.sh
>>index a15d21dc035a..56eb83d1a3bd 100755
>>--- a/tools/testing/selftests/net/forwarding/custom_multipath_hash.sh
>>+++ b/tools/testing/selftests/net/forwarding/custom_multipath_hash.sh
>>@@ -181,37 +181,43 @@ ping_ipv6()
>> 
>> send_src_ipv4()
>> {
>>-	$MZ $h1 -q -p 64 -A "198.51.100.2-198.51.100.253" -B 203.0.113.2 \
>>+	ip vrf exec v$h1 $MZ $h1 -q -p 64 \
>
> Not directly related to this, but I was wondering, if it would be
> possible to use $IP and allow user to replace the system-wide "ip" for
> testing purposes...

A typical forwarding test builds a whole topology with a number of IP
addresses and assumptions about them. E.g. routes need network address
derived from address of the remote endpoint, directly attached hosts
need addresses from the same network, flower rules etc. might match
pieces of endpoint addresses, the above code fragment actually walks a
range of IPs... So it's not just $IP. At the minimum it's a map of IPs
plus some helpers to derive the rest, and conversion of the selftests to
correctly use the helpers. Doable, sure, but I suspect a fairly messy
deal.

That's why the selftests use reserved ranges: 192.0.2.0/24,
198.51.100.0/24 etc. and 2001:db8::/32. They are not supposed to
conflict with whatever addresses the user uses.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] selftests: forwarding: Fix failing tests with old libnet
  2022-08-09 13:10 ` Jiri Pirko
  2022-08-09 14:21   ` Petr Machata
@ 2022-08-09 14:27   ` Ido Schimmel
  1 sibling, 0 replies; 5+ messages in thread
From: Ido Schimmel @ 2022-08-09 14:27 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: netdev, davem, kuba, pabeni, edumazet, amcohen, dsahern, ivecera,
	mlxsw

On Tue, Aug 09, 2022 at 03:10:02PM +0200, Jiri Pirko wrote:
> Not directly related to this, but I was wondering, if it would be
> possible to use $IP and allow user to replace the system-wide "ip" for
> testing purposes...

When testing iproute2 patches (mine or from the ML) I usually do:

export PATH=/home/idosch/code/iproute2/ip/:/home/idosch/code/iproute2/devlink/:/home/idosch/code/iproute2/bridge:$PATH

As part of regression we just compile and install iproute2 from git

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] selftests: forwarding: Fix failing tests with old libnet
  2022-08-09 11:33 [PATCH net] selftests: forwarding: Fix failing tests with old libnet Ido Schimmel
  2022-08-09 13:10 ` Jiri Pirko
@ 2022-08-11  5:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-08-11  5:40 UTC (permalink / raw)
  To: Ido Schimmel
  Cc: netdev, davem, kuba, pabeni, edumazet, amcohen, dsahern, ivecera,
	mlxsw

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Tue,  9 Aug 2022 14:33:20 +0300 you wrote:
> The custom multipath hash tests use mausezahn in order to test how
> changes in various packet fields affect the packet distribution across
> the available nexthops.
> 
> The tool uses the libnet library for various low-level packet
> construction and injection. The library started using the
> "SO_BINDTODEVICE" socket option for IPv6 sockets in version 1.1.6 and
> for IPv4 sockets in version 1.2.
> 
> [...]

Here is the summary with links:
  - [net] selftests: forwarding: Fix failing tests with old libnet
    https://git.kernel.org/netdev/net/c/8bcfb4ae4d97

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-08-11  5:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-09 11:33 [PATCH net] selftests: forwarding: Fix failing tests with old libnet Ido Schimmel
2022-08-09 13:10 ` Jiri Pirko
2022-08-09 14:21   ` Petr Machata
2022-08-09 14:27   ` Ido Schimmel
2022-08-11  5:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).