Skip to contentSkip to conversation

selftests/bpf: delete xfrm tunnel when test exits.

PATCH In review William Tu 4 participants 7 messages Jun 14, 2018 – Jun 15, 2018

Subsystems (5)
lore
Share & tools
lore

William Tu

author
#0 lore raw

PATCH 1/1 selftests/bpf: delete xfrm tunnel when test exits.

Make the printting of bpf xfrm tunnel better and cleanup xfrm state and policy when xfrm test finishes.

---
 tools/testing/selftests/bpf/test_tunnel.sh | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)
tools/testing/selftests/bpf/test_tunnel.sh +13 -11
index aeb2901f21f4..7b1946b340be 100755
@@ -608,28 +608,26 @@ setup_xfrm_tunnel()
 test_xfrm_tunnel()
 {
 	config_device
-        #tcpdump -nei veth1 ip &
-	output=$(mktemp)
-	cat /sys/kernel/debug/tracing/trace_pipe | tee $output &
-        setup_xfrm_tunnel
+	> /sys/kernel/debug/tracing/trace
+	setup_xfrm_tunnel
 	tc qdisc add dev veth1 clsact
 	tc filter add dev veth1 proto ip ingress bpf da obj test_tunnel_kern.o \
 		sec xfrm_get_state
 	ip netns exec at_ns0 ping $PING_ARG 10.1.1.200
 	sleep 1
-	grep "reqid 1" $output
+	grep "reqid 1" /sys/kernel/debug/tracing/trace
 	check_err $?
-	grep "spi 0x1" $output
+	grep "spi 0x1" /sys/kernel/debug/tracing/trace
 	check_err $?
-	grep "remote ip 0xac100164" $output
+	grep "remote ip 0xac100164" /sys/kernel/debug/tracing/trace
 	check_err $?
 	cleanup
 
 	if [ $ret -ne 0 ]; then
-                echo -e ${RED}"FAIL: xfrm tunnel"${NC}
-                return 1
-        fi
-        echo -e ${GREEN}"PASS: xfrm tunnel"${NC}
+		echo -e ${RED}"FAIL: xfrm tunnel"${NC}
+		return 1
+	fi
+	echo -e ${GREEN}"PASS: xfrm tunnel"${NC}
 }
 
 attach_bpf()
@@ -657,6 +655,10 @@ cleanup()
 	ip link del ip6geneve11 2> /dev/null
 	ip link del erspan11 2> /dev/null
 	ip link del ip6erspan11 2> /dev/null
+	ip xfrm policy delete dir out src 10.1.1.200/32 dst 10.1.1.100/32 2> /dev/null
+	ip xfrm policy delete dir in src 10.1.1.100/32 dst 10.1.1.200/32 2> /dev/null
+	ip xfrm state delete src 172.16.1.100 dst 172.16.1.200 proto esp spi 0x1 2> /dev/null
+	ip xfrm state delete src 172.16.1.200 dst 172.16.1.100 proto esp spi 0x2 2> /dev/null
 }
 
 cleanup_exit()
Signature · 1 line
2.7.4
#1 lore raw
Quoted 2 lines · William Tu

Make the printting of bpf xfrm tunnel better and cleanup xfrm state and policy when xfrm test finishes.

LGTM. The subject tag actually meant s/bpf-net/bpf-next/?

It makes sense to be in bpf-next but I think bpf-next is still closed. Please repost later.

Quoted 62 lines
---
 tools/testing/selftests/bpf/test_tunnel.sh | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)
tools/testing/selftests/bpf/test_tunnel.sh +13 -11
index aeb2901f21f4..7b1946b340be 100755
@@ -608,28 +608,26 @@ setup_xfrm_tunnel()
 test_xfrm_tunnel()
 {
 	config_device
-        #tcpdump -nei veth1 ip &
-	output=$(mktemp)
-	cat /sys/kernel/debug/tracing/trace_pipe | tee $output &
-        setup_xfrm_tunnel
+	> /sys/kernel/debug/tracing/trace
+	setup_xfrm_tunnel
 	tc qdisc add dev veth1 clsact
 	tc filter add dev veth1 proto ip ingress bpf da obj test_tunnel_kern.o \
 		sec xfrm_get_state
 	ip netns exec at_ns0 ping $PING_ARG 10.1.1.200
 	sleep 1
-	grep "reqid 1" $output
+	grep "reqid 1" /sys/kernel/debug/tracing/trace
 	check_err $?
-	grep "spi 0x1" $output
+	grep "spi 0x1" /sys/kernel/debug/tracing/trace
 	check_err $?
-	grep "remote ip 0xac100164" $output
+	grep "remote ip 0xac100164" /sys/kernel/debug/tracing/trace
 	check_err $?
 	cleanup
 
 	if [ $ret -ne 0 ]; then
-                echo -e ${RED}"FAIL: xfrm tunnel"${NC}
-                return 1
-        fi
-        echo -e ${GREEN}"PASS: xfrm tunnel"${NC}
+		echo -e ${RED}"FAIL: xfrm tunnel"${NC}
+		return 1
+	fi
+	echo -e ${GREEN}"PASS: xfrm tunnel"${NC}
 }
 
 attach_bpf()
@@ -657,6 +655,10 @@ cleanup()
 	ip link del ip6geneve11 2> /dev/null
 	ip link del erspan11 2> /dev/null
 	ip link del ip6erspan11 2> /dev/null
+	ip xfrm policy delete dir out src 10.1.1.200/32 dst 10.1.1.100/32 2> /dev/null
+	ip xfrm policy delete dir in src 10.1.1.100/32 dst 10.1.1.200/32 2> /dev/null
+	ip xfrm state delete src 172.16.1.100 dst 172.16.1.200 proto esp spi 0x1 2> /dev/null
+	ip xfrm state delete src 172.16.1.200 dst 172.16.1.100 proto esp spi 0x2 2> /dev/null
 }
 
 cleanup_exit()
Signature · 1 line
2.7.4
maintainer
#2 lore raw
Quoted 7 lines · Martin KaFai Lau
Quoted 2 lines · William Tu

Make the printting of bpf xfrm tunnel better and cleanup xfrm state and policy when xfrm test finishes.

LGTM. The subject tag actually meant s/bpf-net/bpf-next/?

It makes sense to be in bpf-next but I think bpf-next is still closed. Please repost later.

But given this fixes up missing cleanup of xfrm policy/state that was added earlier as part of the test, I think bpf would be fine. (Subject is a bit confusing indeed either bpf resp. net tree or bpf-next was meant.)

Thanks,
Daniel

maintainer
#3 lore raw
Quoted 6 lines · Daniel Borkmann
Quoted 5 lines · Martin KaFai Lau
Quoted 2 lines · William Tu

Make the printting of bpf xfrm tunnel better and cleanup xfrm state and policy when xfrm test finishes.

LGTM. The subject tag actually meant s/bpf-net/bpf-next/?

Quoted 7 lines
Quoted 2 lines

It makes sense to be in bpf-next but I think bpf-next is still closed. Please repost later.

But given this fixes up missing cleanup of xfrm policy/state that was added earlier as part of the test, I think bpf would be fine. (Subject is a bit confusing indeed either bpf resp. net tree or bpf-next was meant.)

Ok, took it in, thanks William!

#4 lore raw
In reply to William Tu
Quoted 6 lines · William Tu

Make the printting of bpf xfrm tunnel better and cleanup xfrm state and policy when xfrm test finishes.

Yeah the ‘tee’ was useful when developing the test - I could see what’s going on :)

Now that it’s in ‘selftests’ it’s definitely better without it.

Thanks for the cleanup!
Eyal.

author
#5 lore raw
Quoted 7 lines · Eyal Birger
Quoted 6 lines · William Tu

Make the printting of bpf xfrm tunnel better and cleanup xfrm state and policy when xfrm test finishes.

Quoted 6 lines

Yeah the ‘tee’ was useful when developing the test - I could see what’s going on :)

Now that it’s in ‘selftests’ it’s definitely better without it.

Thanks for the cleanup!
Eyal.

Hi Eyal,
Thanks for double check!

Hi Daniel and Martin,
Sorry for the confusing "bpf-net". It should be "net"

Thanks
William

maintainer
#6 lore raw
Quoted 12 lines · William Tu
Quoted 11 lines · Eyal Birger
Quoted 6 lines · William Tu

Make the printting of bpf xfrm tunnel better and cleanup xfrm state and policy when xfrm test finishes.

Yeah the ‘tee’ was useful when developing the test - I could see what’s going on :)

Now that it’s in ‘selftests’ it’s definitely better without it.

Quoted 8 lines
Quoted 2 lines

Thanks for the cleanup!
Eyal.

Hi Eyal,
Thanks for double check!

Hi Daniel and Martin,
Sorry for the confusing "bpf-net". It should be "net"

Yep, took it into bpf, PR to David will come later today.

Thanks,
Daniel