[PATCH bpf 0/2] selftests/bpf: fix false failures

STALE2549d

5 messages, 3 authors, 2019-10-08 · open the first message on its own page

[PATCH bpf 0/2] selftests/bpf: fix false failures

From: Jiri Benc <hidden>
Date: 2019-10-08 13:11:10

The test_flow_dissector and test_lwt_ip_encap selftests were failing for me.
It was caused by the tests not being enough system/distro independent.

Jiri Benc (2):
  selftests/bpf: set rp_filter in test_flow_dissector
  selftests/bpf: more compatible nc options in test_lwt_ip_encap

 tools/testing/selftests/bpf/test_flow_dissector.sh | 3 +++
 tools/testing/selftests/bpf/test_lwt_ip_encap.sh   | 6 +++---
 2 files changed, 6 insertions(+), 3 deletions(-)

-- 
2.18.1

[PATCH bpf 1/2] selftests/bpf: set rp_filter in test_flow_dissector

From: Jiri Benc <hidden>
Date: 2019-10-08 13:11:13

Many distributions enable rp_filter. However, the flow dissector test
generates packets that have 1.1.1.1 set as (inner) source address without
this address being reachable. This causes the selftest to fail.

The selftests should not assume a particular initial configuration. Switch
off rp_filter.

Fixes: 50b3ed57dee9 ("selftests/bpf: test bpf flow dissection")
Cc: Petar Penkov <redacted>
Signed-off-by: Jiri Benc <redacted>
---
 tools/testing/selftests/bpf/test_flow_dissector.sh | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/tools/testing/selftests/bpf/test_flow_dissector.sh b/tools/testing/selftests/bpf/test_flow_dissector.sh
index d23d4da66b83..e2d06191bd35 100755
--- a/tools/testing/selftests/bpf/test_flow_dissector.sh
+++ b/tools/testing/selftests/bpf/test_flow_dissector.sh
@@ -63,6 +63,9 @@ fi
 
 # Setup
 tc qdisc add dev lo ingress
+echo 0 > /proc/sys/net/ipv4/conf/default/rp_filter
+echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter
+echo 0 > /proc/sys/net/ipv4/conf/lo/rp_filter
 
 echo "Testing IPv4..."
 # Drops all IP/UDP packets coming from port 9
-- 
2.18.1

[PATCH bpf 2/2] selftests/bpf: more compatible nc options in test_lwt_ip_encap

From: Jiri Benc <hidden>
Date: 2019-10-08 13:11:14

Out of the three nc implementations widely in use, at least two (BSD netcat
and nmap-ncat) do not support -l combined with -s. Modify the nc invocation
to be accepted by all of them.

Fixes: 17a90a788473 ("selftests/bpf: test that GSO works in lwt_ip_encap")
Cc: Peter Oskolkov <redacted>
Signed-off-by: Jiri Benc <redacted>
---
 tools/testing/selftests/bpf/test_lwt_ip_encap.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/bpf/test_lwt_ip_encap.sh b/tools/testing/selftests/bpf/test_lwt_ip_encap.sh
index acf7a74f97cd..59ea56945e6c 100755
--- a/tools/testing/selftests/bpf/test_lwt_ip_encap.sh
+++ b/tools/testing/selftests/bpf/test_lwt_ip_encap.sh
@@ -314,15 +314,15 @@ test_gso()
 	command -v nc >/dev/null 2>&1 || \
 		{ echo >&2 "nc is not available: skipping TSO tests"; return; }
 
-	# listen on IPv*_DST, capture TCP into $TMPFILE
+	# listen on port 9000, capture TCP into $TMPFILE
 	if [ "${PROTO}" == "IPv4" ] ; then
 		IP_DST=${IPv4_DST}
 		ip netns exec ${NS3} bash -c \
-			"nc -4 -l -s ${IPv4_DST} -p 9000 > ${TMPFILE} &"
+			"nc -4 -l -p 9000 > ${TMPFILE} &"
 	elif [ "${PROTO}" == "IPv6" ] ; then
 		IP_DST=${IPv6_DST}
 		ip netns exec ${NS3} bash -c \
-			"nc -6 -l -s ${IPv6_DST} -p 9000 > ${TMPFILE} &"
+			"nc -6 -l -p 9000 > ${TMPFILE} &"
 		RET=$?
 	else
 		echo "    test_gso: unknown PROTO: ${PROTO}"
-- 
2.18.1

Re: [PATCH bpf 1/2] selftests/bpf: set rp_filter in test_flow_dissector

From: Petar Penkov <hidden>
Date: 2019-10-08 16:45:26

On Tue, Oct 8, 2019 at 6:11 AM Jiri Benc [off-list ref] wrote:
Many distributions enable rp_filter. However, the flow dissector test
generates packets that have 1.1.1.1 set as (inner) source address without
this address being reachable. This causes the selftest to fail.

The selftests should not assume a particular initial configuration. Switch
off rp_filter.

Fixes: 50b3ed57dee9 ("selftests/bpf: test bpf flow dissection")
Cc: Petar Penkov <redacted>
Signed-off-by: Jiri Benc <redacted>
Acked-by: Petar Penkov <redacted>
quoted hunk
---
 tools/testing/selftests/bpf/test_flow_dissector.sh | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/tools/testing/selftests/bpf/test_flow_dissector.sh b/tools/testing/selftests/bpf/test_flow_dissector.sh
index d23d4da66b83..e2d06191bd35 100755
--- a/tools/testing/selftests/bpf/test_flow_dissector.sh
+++ b/tools/testing/selftests/bpf/test_flow_dissector.sh
@@ -63,6 +63,9 @@ fi

 # Setup
 tc qdisc add dev lo ingress
+echo 0 > /proc/sys/net/ipv4/conf/default/rp_filter
+echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter
+echo 0 > /proc/sys/net/ipv4/conf/lo/rp_filter

 echo "Testing IPv4..."
 # Drops all IP/UDP packets coming from port 9
--
2.18.1

Re: [PATCH bpf 0/2] selftests/bpf: fix false failures

From: Daniel Borkmann <daniel@iogearbox.net>
Date: 2019-10-08 22:03:05

On Tue, Oct 08, 2019 at 03:10:43PM +0200, Jiri Benc wrote:
The test_flow_dissector and test_lwt_ip_encap selftests were failing for me.
It was caused by the tests not being enough system/distro independent.

Jiri Benc (2):
  selftests/bpf: set rp_filter in test_flow_dissector
  selftests/bpf: more compatible nc options in test_lwt_ip_encap

 tools/testing/selftests/bpf/test_flow_dissector.sh | 3 +++
 tools/testing/selftests/bpf/test_lwt_ip_encap.sh   | 6 +++---
 2 files changed, 6 insertions(+), 3 deletions(-)
Applied, thanks!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help