Skip to contentSkip to conversation

selftests/bpf: fix false failures

PATCH Applied Jiri Benc 3 participants 5 messages Oct 8, 2019

Subsystems (5)
lore
Share & tools
lore

Jiri Benc

author
#0 lore raw

cover selftests/bpf: fix false failures

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(-)
Signature · 1 line
2.18.1
author
#1 lore raw

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

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 <[email protected]>
---
 tools/testing/selftests/bpf/test_flow_dissector.sh | 3 +++
 1 file changed, 3 insertions(+)
tools/testing/selftests/bpf/test_flow_dissector.sh +3 -0
index d23d4da66b83..e2d06191bd35 100755
@@ -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
Signature · 1 line
2.18.1
author
#3 lore raw

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

In reply to Jiri Benc

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 <[email protected]>
---
 tools/testing/selftests/bpf/test_lwt_ip_encap.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/bpf/test_lwt_ip_encap.sh +3 -3
index acf7a74f97cd..59ea56945e6c 100755
@@ -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}"
Signature · 1 line
2.18.1
Acked-by on v1 1/2
#2 lore raw

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

In reply to Jiri Benc
Quoted 11 lines · Jiri Benc

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 <[email protected]>
Quoted 21 lines
---
 tools/testing/selftests/bpf/test_flow_dissector.sh | 3 +++
 1 file changed, 3 insertions(+)
tools/testing/selftests/bpf/test_flow_dissector.sh +3 -1
index d23d4da66b83..e2d06191bd35 100755
@@ -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

maintainer Applied
#4 lore raw
In reply to Jiri Benc
Quoted 10 lines · Jiri Benc

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!