bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/2] selftest/bpf: improve bpf tunnel test
@ 2020-11-03  4:29 Hangbin Liu
  2020-11-03  4:29 ` [PATCH bpf-next 1/2] selftest/bpf: add missed ip6ip6 test back Hangbin Liu
                   ` (2 more replies)
  0 siblings, 3 replies; 23+ messages in thread
From: Hangbin Liu @ 2020-11-03  4:29 UTC (permalink / raw)
  To: netdev; +Cc: William Tu, Daniel Borkmann, bpf, Hangbin Liu

In comment 173ca26e9b51 ("samples/bpf: add comprehensive ipip, ipip6,
ip6ip6 test") we added some bpf tunnel tests. In commit 933a741e3b82
("selftests/bpf: bpf tunnel test.") when we moved it to the current
folder, we missed some points:

1. ip6ip6 test is not added
2. forgot to remove test_ipip.sh in sample folder
3. TCP test code is not removed in test_tunnel_kern.c

In this patch set I add back ip6ip6 test and remove unused code.
As I'm not sure if this should be a fixup, I didn't add the Fixes flag.

Here is the test result:
```
  Testing IP6IP6 tunnel...
  PING ::11(::11) 56 data bytes

  --- ::11 ping statistics ---
  3 packets transmitted, 3 received, 0% packet loss, time 47ms
  rtt min/avg/max/mdev = 0.031/1023.035/2044.975/834.846 ms, pipe 2
  PING 1::11(1::11) 56 data bytes

  --- 1::11 ping statistics ---
  3 packets transmitted, 3 received, 0% packet loss, time 47ms
  rtt min/avg/max/mdev = 0.027/0.046/0.058/0.013 ms
  PING 1::22(1::22) 56 data bytes

  --- 1::22 ping statistics ---
  3 packets transmitted, 3 received, 0% packet loss, time 47ms
  rtt min/avg/max/mdev = 0.041/0.056/0.074/0.014 ms
  PASS: ip6ip6tnl
```

Hangbin Liu (2):
  selftest/bpf: add missed ip6ip6 test back
  selftest/bpf: remove unused bpf tunnel testing code

 samples/bpf/test_ipip.sh                      | 179 ------------------
 .../selftests/bpf/progs/test_tunnel_kern.c    |  87 +--------
 tools/testing/selftests/bpf/test_tunnel.sh    |  39 +++-
 3 files changed, 40 insertions(+), 265 deletions(-)
 delete mode 100755 samples/bpf/test_ipip.sh

-- 
2.25.4


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

* [PATCH bpf-next 1/2] selftest/bpf: add missed ip6ip6 test back
  2020-11-03  4:29 [PATCH bpf-next 0/2] selftest/bpf: improve bpf tunnel test Hangbin Liu
@ 2020-11-03  4:29 ` Hangbin Liu
  2020-11-04 18:40   ` Martin KaFai Lau
  2020-11-03  4:29 ` [PATCH bpf-next 2/2] selftest/bpf: remove unused bpf tunnel testing code Hangbin Liu
  2020-11-06  9:01 ` [PATCHv2 net 0/2] Remove unused test_ipip.sh test and add missed ip6ip6 test Hangbin Liu
  2 siblings, 1 reply; 23+ messages in thread
From: Hangbin Liu @ 2020-11-03  4:29 UTC (permalink / raw)
  To: netdev; +Cc: William Tu, Daniel Borkmann, bpf, Hangbin Liu

In comment 173ca26e9b51 ("samples/bpf: add comprehensive ipip, ipip6,
ip6ip6 test") we added ip6ip6 test for bpf tunnel testing. But in commit
933a741e3b82 ("selftests/bpf: bpf tunnel test.") when we moved it to
the current folder, we didn't add it.

This patch add the ip6ip6 test back to bpf tunnel test. Since the
underlay network is the same, we can reuse the ipip6 framework directly.
Iperf test is removed as currect framework simplified it in purpose.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 tools/testing/selftests/bpf/test_tunnel.sh | 39 ++++++++++++++++++++--
 1 file changed, 37 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/bpf/test_tunnel.sh b/tools/testing/selftests/bpf/test_tunnel.sh
index bd12ec97a44d..76a00d2ef988 100755
--- a/tools/testing/selftests/bpf/test_tunnel.sh
+++ b/tools/testing/selftests/bpf/test_tunnel.sh
@@ -24,12 +24,12 @@
 # Root namespace with metadata-mode tunnel + BPF
 # Device names and addresses:
 # 	veth1 IP: 172.16.1.200, IPv6: 00::22 (underlay)
-# 	tunnel dev <type>11, ex: gre11, IPv4: 10.1.1.200 (overlay)
+# 	tunnel dev <type>11, ex: gre11, IPv4: 10.1.1.200, IPv6: 1::22 (overlay)
 #
 # Namespace at_ns0 with native tunnel
 # Device names and addresses:
 # 	veth0 IPv4: 172.16.1.100, IPv6: 00::11 (underlay)
-# 	tunnel dev <type>00, ex: gre00, IPv4: 10.1.1.100 (overlay)
+# 	tunnel dev <type>00, ex: gre00, IPv4: 10.1.1.100, IPv6: 1::11 (overlay)
 #
 #
 # End-to-end ping packet flow
@@ -262,11 +262,13 @@ add_ipip6tnl_tunnel()
 		ip link add dev $DEV_NS type $TYPE \
 		local ::11 remote ::22
 	ip netns exec at_ns0 ip addr add dev $DEV_NS 10.1.1.100/24
+	ip netns exec at_ns0 ip addr add dev $DEV_NS 1::11/96
 	ip netns exec at_ns0 ip link set dev $DEV_NS up
 
 	# root namespace
 	ip link add dev $DEV type $TYPE external
 	ip addr add dev $DEV 10.1.1.200/24
+	ip addr add dev $DEV 1::22/96
 	ip link set dev $DEV up
 }
 
@@ -553,6 +555,34 @@ test_ipip6()
         echo -e ${GREEN}"PASS: $TYPE"${NC}
 }
 
+test_ip6ip6()
+{
+	TYPE=ip6tnl
+	DEV_NS=ip6ip6tnl00
+	DEV=ip6ip6tnl11
+	ret=0
+
+	check $TYPE
+	config_device
+	add_ipip6tnl_tunnel
+	ip link set dev veth1 mtu 1500
+	attach_bpf $DEV ipip6_set_tunnel ipip6_get_tunnel
+	# underlay
+	ping6 $PING_ARG ::11
+	# ip6 over ip6
+	ping6 $PING_ARG 1::11
+	check_err $?
+	ip netns exec at_ns0 ping6 $PING_ARG 1::22
+	check_err $?
+	cleanup
+
+	if [ $ret -ne 0 ]; then
+                echo -e ${RED}"FAIL: ip6$TYPE"${NC}
+                return 1
+        fi
+        echo -e ${GREEN}"PASS: ip6$TYPE"${NC}
+}
+
 setup_xfrm_tunnel()
 {
 	auth=0x$(printf '1%.0s' {1..40})
@@ -646,6 +676,7 @@ cleanup()
 	ip link del veth1 2> /dev/null
 	ip link del ipip11 2> /dev/null
 	ip link del ipip6tnl11 2> /dev/null
+	ip link del ip6ip6tnl11 2> /dev/null
 	ip link del gretap11 2> /dev/null
 	ip link del ip6gre11 2> /dev/null
 	ip link del ip6gretap11 2> /dev/null
@@ -742,6 +773,10 @@ bpf_tunnel_test()
 	test_ipip6
 	errors=$(( $errors + $? ))
 
+	echo "Testing IP6IP6 tunnel..."
+	test_ip6ip6
+	errors=$(( $errors + $? ))
+
 	echo "Testing IPSec tunnel..."
 	test_xfrm_tunnel
 	errors=$(( $errors + $? ))
-- 
2.25.4


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

* [PATCH bpf-next 2/2] selftest/bpf: remove unused bpf tunnel testing code
  2020-11-03  4:29 [PATCH bpf-next 0/2] selftest/bpf: improve bpf tunnel test Hangbin Liu
  2020-11-03  4:29 ` [PATCH bpf-next 1/2] selftest/bpf: add missed ip6ip6 test back Hangbin Liu
@ 2020-11-03  4:29 ` Hangbin Liu
  2020-11-06  7:30   ` Martin KaFai Lau
  2020-11-06  9:01 ` [PATCHv2 net 0/2] Remove unused test_ipip.sh test and add missed ip6ip6 test Hangbin Liu
  2 siblings, 1 reply; 23+ messages in thread
From: Hangbin Liu @ 2020-11-03  4:29 UTC (permalink / raw)
  To: netdev; +Cc: William Tu, Daniel Borkmann, bpf, Hangbin Liu

In comment 173ca26e9b51 ("samples/bpf: add comprehensive ipip, ipip6,
ip6ip6 test") we added some bpf tunnel tests. In commit 933a741e3b82
("selftests/bpf: bpf tunnel test.") when we moved it to the current
folder, we forgot to remove test_ipip.sh in sample folder.

Since we simplify the original ipip tests and removed iperf tests, there
is not need for TCP checks. ip6ip6 and ipip6 are using the same underlay
network, we can remove ip6ip6 section too.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 samples/bpf/test_ipip.sh                      | 179 ------------------
 .../selftests/bpf/progs/test_tunnel_kern.c    |  87 +--------
 2 files changed, 3 insertions(+), 263 deletions(-)
 delete mode 100755 samples/bpf/test_ipip.sh

diff --git a/samples/bpf/test_ipip.sh b/samples/bpf/test_ipip.sh
deleted file mode 100755
index 9e507c305c6e..000000000000
--- a/samples/bpf/test_ipip.sh
+++ /dev/null
@@ -1,179 +0,0 @@
-#!/bin/bash
-# SPDX-License-Identifier: GPL-2.0
-
-function config_device {
-	ip netns add at_ns0
-	ip netns add at_ns1
-	ip netns add at_ns2
-	ip link add veth0 type veth peer name veth0b
-	ip link add veth1 type veth peer name veth1b
-	ip link add veth2 type veth peer name veth2b
-	ip link set veth0b up
-	ip link set veth1b up
-	ip link set veth2b up
-	ip link set dev veth0b mtu 1500
-	ip link set dev veth1b mtu 1500
-	ip link set dev veth2b mtu 1500
-	ip link set veth0 netns at_ns0
-	ip link set veth1 netns at_ns1
-	ip link set veth2 netns at_ns2
-	ip netns exec at_ns0 ip addr add 172.16.1.100/24 dev veth0
-	ip netns exec at_ns0 ip addr add 2401:db00::1/64 dev veth0 nodad
-	ip netns exec at_ns0 ip link set dev veth0 up
-	ip netns exec at_ns1 ip addr add 172.16.1.101/24 dev veth1
-	ip netns exec at_ns1 ip addr add 2401:db00::2/64 dev veth1 nodad
-	ip netns exec at_ns1 ip link set dev veth1 up
-	ip netns exec at_ns2 ip addr add 172.16.1.200/24 dev veth2
-	ip netns exec at_ns2 ip addr add 2401:db00::3/64 dev veth2 nodad
-	ip netns exec at_ns2 ip link set dev veth2 up
-	ip link add br0 type bridge
-	ip link set br0 up
-	ip link set dev br0 mtu 1500
-	ip link set veth0b master br0
-	ip link set veth1b master br0
-	ip link set veth2b master br0
-}
-
-function add_ipip_tunnel {
-	ip netns exec at_ns0 \
-		ip link add dev $DEV_NS type ipip local 172.16.1.100 remote 172.16.1.200
-	ip netns exec at_ns0 ip link set dev $DEV_NS up
-	ip netns exec at_ns0 ip addr add dev $DEV_NS 10.1.1.100/24
-	ip netns exec at_ns1 \
-		ip link add dev $DEV_NS type ipip local 172.16.1.101 remote 172.16.1.200
-	ip netns exec at_ns1 ip link set dev $DEV_NS up
-	# same inner IP address in at_ns0 and at_ns1
-	ip netns exec at_ns1 ip addr add dev $DEV_NS 10.1.1.100/24
-
-	ip netns exec at_ns2 ip link add dev $DEV type ipip external
-	ip netns exec at_ns2 ip link set dev $DEV up
-	ip netns exec at_ns2 ip addr add dev $DEV 10.1.1.200/24
-}
-
-function add_ipip6_tunnel {
-	ip netns exec at_ns0 \
-		ip link add dev $DEV_NS type ip6tnl mode ipip6 local 2401:db00::1/64 remote 2401:db00::3/64
-	ip netns exec at_ns0 ip link set dev $DEV_NS up
-	ip netns exec at_ns0 ip addr add dev $DEV_NS 10.1.1.100/24
-	ip netns exec at_ns1 \
-		ip link add dev $DEV_NS type ip6tnl mode ipip6 local 2401:db00::2/64 remote 2401:db00::3/64
-	ip netns exec at_ns1 ip link set dev $DEV_NS up
-	# same inner IP address in at_ns0 and at_ns1
-	ip netns exec at_ns1 ip addr add dev $DEV_NS 10.1.1.100/24
-
-	ip netns exec at_ns2 ip link add dev $DEV type ip6tnl mode ipip6 external
-	ip netns exec at_ns2 ip link set dev $DEV up
-	ip netns exec at_ns2 ip addr add dev $DEV 10.1.1.200/24
-}
-
-function add_ip6ip6_tunnel {
-	ip netns exec at_ns0 \
-		ip link add dev $DEV_NS type ip6tnl mode ip6ip6 local 2401:db00::1/64 remote 2401:db00::3/64
-	ip netns exec at_ns0 ip link set dev $DEV_NS up
-	ip netns exec at_ns0 ip addr add dev $DEV_NS 2601:646::1/64
-	ip netns exec at_ns1 \
-		ip link add dev $DEV_NS type ip6tnl mode ip6ip6 local 2401:db00::2/64 remote 2401:db00::3/64
-	ip netns exec at_ns1 ip link set dev $DEV_NS up
-	# same inner IP address in at_ns0 and at_ns1
-	ip netns exec at_ns1 ip addr add dev $DEV_NS 2601:646::1/64
-
-	ip netns exec at_ns2 ip link add dev $DEV type ip6tnl mode ip6ip6 external
-	ip netns exec at_ns2 ip link set dev $DEV up
-	ip netns exec at_ns2 ip addr add dev $DEV 2601:646::2/64
-}
-
-function attach_bpf {
-	DEV=$1
-	SET_TUNNEL=$2
-	GET_TUNNEL=$3
-	ip netns exec at_ns2 tc qdisc add dev $DEV clsact
-	ip netns exec at_ns2 tc filter add dev $DEV egress bpf da obj tcbpf2_kern.o sec $SET_TUNNEL
-	ip netns exec at_ns2 tc filter add dev $DEV ingress bpf da obj tcbpf2_kern.o sec $GET_TUNNEL
-}
-
-function test_ipip {
-	DEV_NS=ipip_std
-	DEV=ipip_bpf
-	config_device
-#	tcpdump -nei br0 &
-	cat /sys/kernel/debug/tracing/trace_pipe &
-
-	add_ipip_tunnel
-	attach_bpf $DEV ipip_set_tunnel ipip_get_tunnel
-
-	ip netns exec at_ns0 ping -c 1 10.1.1.200
-	ip netns exec at_ns2 ping -c 1 10.1.1.100
-	ip netns exec at_ns0 iperf -sD -p 5200 > /dev/null
-	ip netns exec at_ns1 iperf -sD -p 5201 > /dev/null
-	sleep 0.2
-	# tcp check _same_ IP over different tunnels
-	ip netns exec at_ns2 iperf -c 10.1.1.100 -n 5k -p 5200
-	ip netns exec at_ns2 iperf -c 10.1.1.100 -n 5k -p 5201
-	cleanup
-}
-
-# IPv4 over IPv6 tunnel
-function test_ipip6 {
-	DEV_NS=ipip_std
-	DEV=ipip_bpf
-	config_device
-#	tcpdump -nei br0 &
-	cat /sys/kernel/debug/tracing/trace_pipe &
-
-	add_ipip6_tunnel
-	attach_bpf $DEV ipip6_set_tunnel ipip6_get_tunnel
-
-	ip netns exec at_ns0 ping -c 1 10.1.1.200
-	ip netns exec at_ns2 ping -c 1 10.1.1.100
-	ip netns exec at_ns0 iperf -sD -p 5200 > /dev/null
-	ip netns exec at_ns1 iperf -sD -p 5201 > /dev/null
-	sleep 0.2
-	# tcp check _same_ IP over different tunnels
-	ip netns exec at_ns2 iperf -c 10.1.1.100 -n 5k -p 5200
-	ip netns exec at_ns2 iperf -c 10.1.1.100 -n 5k -p 5201
-	cleanup
-}
-
-# IPv6 over IPv6 tunnel
-function test_ip6ip6 {
-	DEV_NS=ipip_std
-	DEV=ipip_bpf
-	config_device
-#	tcpdump -nei br0 &
-	cat /sys/kernel/debug/tracing/trace_pipe &
-
-	add_ip6ip6_tunnel
-	attach_bpf $DEV ip6ip6_set_tunnel ip6ip6_get_tunnel
-
-	ip netns exec at_ns0 ping -6 -c 1 2601:646::2
-	ip netns exec at_ns2 ping -6 -c 1 2601:646::1
-	ip netns exec at_ns0 iperf -6sD -p 5200 > /dev/null
-	ip netns exec at_ns1 iperf -6sD -p 5201 > /dev/null
-	sleep 0.2
-	# tcp check _same_ IP over different tunnels
-	ip netns exec at_ns2 iperf -6c 2601:646::1 -n 5k -p 5200
-	ip netns exec at_ns2 iperf -6c 2601:646::1 -n 5k -p 5201
-	cleanup
-}
-
-function cleanup {
-	set +ex
-	pkill iperf
-	ip netns delete at_ns0
-	ip netns delete at_ns1
-	ip netns delete at_ns2
-	ip link del veth0
-	ip link del veth1
-	ip link del veth2
-	ip link del br0
-	pkill tcpdump
-	pkill cat
-	set -ex
-}
-
-cleanup
-echo "Testing IP tunnels..."
-test_ipip
-test_ipip6
-test_ip6ip6
-echo "*** PASS ***"
diff --git a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c
index f48dbfe24ddc..ef033ba1e81c 100644
--- a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c
+++ b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c
@@ -15,7 +15,6 @@
 #include <linux/ip.h>
 #include <linux/ipv6.h>
 #include <linux/types.h>
-#include <linux/tcp.h>
 #include <linux/socket.h>
 #include <linux/pkt_cls.h>
 #include <linux/erspan.h>
@@ -528,30 +527,17 @@ int _ipip_set_tunnel(struct __sk_buff *skb)
 	struct bpf_tunnel_key key = {};
 	void *data = (void *)(long)skb->data;
 	struct iphdr *iph = data;
-	struct tcphdr *tcp = data + sizeof(*iph);
 	void *data_end = (void *)(long)skb->data_end;
 	int ret;
 
 	/* single length check */
-	if (data + sizeof(*iph) + sizeof(*tcp) > data_end) {
+	if (data + sizeof(*iph) > data_end) {
 		ERROR(1);
 		return TC_ACT_SHOT;
 	}
 
+	key.remote_ipv4 = 0xac100164; /* 172.16.1.100 */
 	key.tunnel_ttl = 64;
-	if (iph->protocol == IPPROTO_ICMP) {
-		key.remote_ipv4 = 0xac100164; /* 172.16.1.100 */
-	} else {
-		if (iph->protocol != IPPROTO_TCP || iph->ihl != 5)
-			return TC_ACT_SHOT;
-
-		if (tcp->dest == bpf_htons(5200))
-			key.remote_ipv4 = 0xac100164; /* 172.16.1.100 */
-		else if (tcp->dest == bpf_htons(5201))
-			key.remote_ipv4 = 0xac100165; /* 172.16.1.101 */
-		else
-			return TC_ACT_SHOT;
-	}
 
 	ret = bpf_skb_set_tunnel_key(skb, &key, sizeof(key), 0);
 	if (ret < 0) {
@@ -585,12 +571,11 @@ int _ipip6_set_tunnel(struct __sk_buff *skb)
 	struct bpf_tunnel_key key = {};
 	void *data = (void *)(long)skb->data;
 	struct iphdr *iph = data;
-	struct tcphdr *tcp = data + sizeof(*iph);
 	void *data_end = (void *)(long)skb->data_end;
 	int ret;
 
 	/* single length check */
-	if (data + sizeof(*iph) + sizeof(*tcp) > data_end) {
+	if (data + sizeof(*iph) > data_end) {
 		ERROR(1);
 		return TC_ACT_SHOT;
 	}
@@ -628,72 +613,6 @@ int _ipip6_get_tunnel(struct __sk_buff *skb)
 	return TC_ACT_OK;
 }
 
-SEC("ip6ip6_set_tunnel")
-int _ip6ip6_set_tunnel(struct __sk_buff *skb)
-{
-	struct bpf_tunnel_key key = {};
-	void *data = (void *)(long)skb->data;
-	struct ipv6hdr *iph = data;
-	struct tcphdr *tcp = data + sizeof(*iph);
-	void *data_end = (void *)(long)skb->data_end;
-	int ret;
-
-	/* single length check */
-	if (data + sizeof(*iph) + sizeof(*tcp) > data_end) {
-		ERROR(1);
-		return TC_ACT_SHOT;
-	}
-
-	key.remote_ipv6[0] = bpf_htonl(0x2401db00);
-	key.tunnel_ttl = 64;
-
-	if (iph->nexthdr == 58 /* NEXTHDR_ICMP */) {
-		key.remote_ipv6[3] = bpf_htonl(1);
-	} else {
-		if (iph->nexthdr != 6 /* NEXTHDR_TCP */) {
-			ERROR(iph->nexthdr);
-			return TC_ACT_SHOT;
-		}
-
-		if (tcp->dest == bpf_htons(5200)) {
-			key.remote_ipv6[3] = bpf_htonl(1);
-		} else if (tcp->dest == bpf_htons(5201)) {
-			key.remote_ipv6[3] = bpf_htonl(2);
-		} else {
-			ERROR(tcp->dest);
-			return TC_ACT_SHOT;
-		}
-	}
-
-	ret = bpf_skb_set_tunnel_key(skb, &key, sizeof(key),
-				     BPF_F_TUNINFO_IPV6);
-	if (ret < 0) {
-		ERROR(ret);
-		return TC_ACT_SHOT;
-	}
-
-	return TC_ACT_OK;
-}
-
-SEC("ip6ip6_get_tunnel")
-int _ip6ip6_get_tunnel(struct __sk_buff *skb)
-{
-	int ret;
-	struct bpf_tunnel_key key;
-	char fmt[] = "remote ip6 %x::%x\n";
-
-	ret = bpf_skb_get_tunnel_key(skb, &key, sizeof(key),
-				     BPF_F_TUNINFO_IPV6);
-	if (ret < 0) {
-		ERROR(ret);
-		return TC_ACT_SHOT;
-	}
-
-	bpf_trace_printk(fmt, sizeof(fmt), bpf_htonl(key.remote_ipv6[0]),
-			 bpf_htonl(key.remote_ipv6[3]));
-	return TC_ACT_OK;
-}
-
 SEC("xfrm_get_state")
 int _xfrm_get_state(struct __sk_buff *skb)
 {
-- 
2.25.4


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

* Re: [PATCH bpf-next 1/2] selftest/bpf: add missed ip6ip6 test back
  2020-11-03  4:29 ` [PATCH bpf-next 1/2] selftest/bpf: add missed ip6ip6 test back Hangbin Liu
@ 2020-11-04 18:40   ` Martin KaFai Lau
  2020-11-05  3:20     ` Hangbin Liu
  0 siblings, 1 reply; 23+ messages in thread
From: Martin KaFai Lau @ 2020-11-04 18:40 UTC (permalink / raw)
  To: Hangbin Liu; +Cc: netdev, William Tu, Daniel Borkmann, bpf

On Tue, Nov 03, 2020 at 12:29:07PM +0800, Hangbin Liu wrote:
> In comment 173ca26e9b51 ("samples/bpf: add comprehensive ipip, ipip6,
> ip6ip6 test") we added ip6ip6 test for bpf tunnel testing. But in commit
> 933a741e3b82 ("selftests/bpf: bpf tunnel test.") when we moved it to
> the current folder, we didn't add it.
> 
> This patch add the ip6ip6 test back to bpf tunnel test. Since the
> underlay network is the same, we can reuse the ipip6 framework directly.
> Iperf test is removed as currect framework simplified it in purpose.
> 
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
> ---
>  tools/testing/selftests/bpf/test_tunnel.sh | 39 ++++++++++++++++++++--
>  1 file changed, 37 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/bpf/test_tunnel.sh b/tools/testing/selftests/bpf/test_tunnel.sh
> index bd12ec97a44d..76a00d2ef988 100755
> --- a/tools/testing/selftests/bpf/test_tunnel.sh
> +++ b/tools/testing/selftests/bpf/test_tunnel.sh
> @@ -24,12 +24,12 @@
>  # Root namespace with metadata-mode tunnel + BPF
>  # Device names and addresses:
>  # 	veth1 IP: 172.16.1.200, IPv6: 00::22 (underlay)
> -# 	tunnel dev <type>11, ex: gre11, IPv4: 10.1.1.200 (overlay)
> +# 	tunnel dev <type>11, ex: gre11, IPv4: 10.1.1.200, IPv6: 1::22 (overlay)
>  #
>  # Namespace at_ns0 with native tunnel
>  # Device names and addresses:
>  # 	veth0 IPv4: 172.16.1.100, IPv6: 00::11 (underlay)
> -# 	tunnel dev <type>00, ex: gre00, IPv4: 10.1.1.100 (overlay)
> +# 	tunnel dev <type>00, ex: gre00, IPv4: 10.1.1.100, IPv6: 1::11 (overlay)
>  #
>  #
>  # End-to-end ping packet flow
> @@ -262,11 +262,13 @@ add_ipip6tnl_tunnel()
>  		ip link add dev $DEV_NS type $TYPE \
>  		local ::11 remote ::22
>  	ip netns exec at_ns0 ip addr add dev $DEV_NS 10.1.1.100/24
> +	ip netns exec at_ns0 ip addr add dev $DEV_NS 1::11/96
>  	ip netns exec at_ns0 ip link set dev $DEV_NS up
>  
>  	# root namespace
>  	ip link add dev $DEV type $TYPE external
>  	ip addr add dev $DEV 10.1.1.200/24
> +	ip addr add dev $DEV 1::22/96
>  	ip link set dev $DEV up
>  }
>  
> @@ -553,6 +555,34 @@ test_ipip6()
>          echo -e ${GREEN}"PASS: $TYPE"${NC}
>  }
>  
> +test_ip6ip6()
> +{
> +	TYPE=ip6tnl
> +	DEV_NS=ip6ip6tnl00
> +	DEV=ip6ip6tnl11
> +	ret=0
> +
> +	check $TYPE
> +	config_device
> +	add_ipip6tnl_tunnel
> +	ip link set dev veth1 mtu 1500
> +	attach_bpf $DEV ipip6_set_tunnel ipip6_get_tunnel
From looking at the ipip6_set_tunnel in test_tunnel_kern.c.
I don't think they are testing an ip6ip6 packet.
If the intention is to test ip6ip6, why the existing
ip6ip6_set_tunnel does not need to be exercised?

> +	# underlay
> +	ping6 $PING_ARG ::11
> +	# ip6 over ip6
> +	ping6 $PING_ARG 1::11
> +	check_err $?
> +	ip netns exec at_ns0 ping6 $PING_ARG 1::22
> +	check_err $?
> +	cleanup
> +
> +	if [ $ret -ne 0 ]; then
> +                echo -e ${RED}"FAIL: ip6$TYPE"${NC}
> +                return 1
> +        fi
> +        echo -e ${GREEN}"PASS: ip6$TYPE"${NC}
> +}

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

* Re: [PATCH bpf-next 1/2] selftest/bpf: add missed ip6ip6 test back
  2020-11-04 18:40   ` Martin KaFai Lau
@ 2020-11-05  3:20     ` Hangbin Liu
  0 siblings, 0 replies; 23+ messages in thread
From: Hangbin Liu @ 2020-11-05  3:20 UTC (permalink / raw)
  To: Martin KaFai Lau; +Cc: netdev, William Tu, Daniel Borkmann, bpf

On Wed, Nov 04, 2020 at 10:40:34AM -0800, Martin KaFai Lau wrote:
> > +	check $TYPE
> > +	config_device
> > +	add_ipip6tnl_tunnel
> > +	ip link set dev veth1 mtu 1500
> > +	attach_bpf $DEV ipip6_set_tunnel ipip6_get_tunnel
> From looking at the ipip6_set_tunnel in test_tunnel_kern.c.
> I don't think they are testing an ip6ip6 packet.
> If the intention is to test ip6ip6, why the existing
> ip6ip6_set_tunnel does not need to be exercised?

Hi Martin,

Maybe I missed something. But I saw both ipip6_set_tunnel and
ip6ip6_set_tunnel in test_tunnel_kern.c. only set remote IPv6 address.
They didn't do anything else. The only difference between
ipip6 and ip6ip6 are in overlay network, using IPv4 or IPv6.


Thanks
Hangbin

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

* Re: [PATCH bpf-next 2/2] selftest/bpf: remove unused bpf tunnel testing code
  2020-11-03  4:29 ` [PATCH bpf-next 2/2] selftest/bpf: remove unused bpf tunnel testing code Hangbin Liu
@ 2020-11-06  7:30   ` Martin KaFai Lau
  2020-11-06  7:55     ` Hangbin Liu
  0 siblings, 1 reply; 23+ messages in thread
From: Martin KaFai Lau @ 2020-11-06  7:30 UTC (permalink / raw)
  To: Hangbin Liu; +Cc: netdev, William Tu, Daniel Borkmann, bpf

On Tue, Nov 03, 2020 at 12:29:08PM +0800, Hangbin Liu wrote:
> In comment 173ca26e9b51 ("samples/bpf: add comprehensive ipip, ipip6,
> ip6ip6 test") we added some bpf tunnel tests. In commit 933a741e3b82
> ("selftests/bpf: bpf tunnel test.") when we moved it to the current
> folder, we forgot to remove test_ipip.sh in sample folder.
> 
> Since we simplify the original ipip tests and removed iperf tests, there
> is not need for TCP checks. ip6ip6 and ipip6 are using the same underlay
> network, we can remove ip6ip6 section too.
> 
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
[ ... ]

> @@ -585,12 +571,11 @@ int _ipip6_set_tunnel(struct __sk_buff *skb)
>  	struct bpf_tunnel_key key = {};
>  	void *data = (void *)(long)skb->data;
>  	struct iphdr *iph = data;
v4 hdr here.

> -	struct tcphdr *tcp = data + sizeof(*iph);
>  	void *data_end = (void *)(long)skb->data_end;
>  	int ret;
>  
>  	/* single length check */
> -	if (data + sizeof(*iph) + sizeof(*tcp) > data_end) {
> +	if (data + sizeof(*iph) > data_end) {
>  		ERROR(1);
>  		return TC_ACT_SHOT;
>  	}
> @@ -628,72 +613,6 @@ int _ipip6_get_tunnel(struct __sk_buff *skb)
>  	return TC_ACT_OK;
>  }
>  
> -SEC("ip6ip6_set_tunnel")
> -int _ip6ip6_set_tunnel(struct __sk_buff *skb)
> -{
> -	struct bpf_tunnel_key key = {};
> -	void *data = (void *)(long)skb->data;
> -	struct ipv6hdr *iph = data;
IIUC, the patch is to replace _ip6ip6_set_tunnel with _ipip6_set_tunnel.

Are they testing the same thing?  At least, _ip6ip6_set_tunnel()
is expecting a v6 hdr here.

> -	struct tcphdr *tcp = data + sizeof(*iph);
> -	void *data_end = (void *)(long)skb->data_end;
> -	int ret;
> -
> -	/* single length check */
> -	if (data + sizeof(*iph) + sizeof(*tcp) > data_end) {
> -		ERROR(1);
> -		return TC_ACT_SHOT;
> -	}
> -
> -	key.remote_ipv6[0] = bpf_htonl(0x2401db00);
> -	key.tunnel_ttl = 64;
> -
> -	if (iph->nexthdr == 58 /* NEXTHDR_ICMP */) {
> -		key.remote_ipv6[3] = bpf_htonl(1);
> -	} else {
> -		if (iph->nexthdr != 6 /* NEXTHDR_TCP */) {
> -			ERROR(iph->nexthdr);
> -			return TC_ACT_SHOT;
> -		}
> -
> -		if (tcp->dest == bpf_htons(5200)) {
> -			key.remote_ipv6[3] = bpf_htonl(1);
> -		} else if (tcp->dest == bpf_htons(5201)) {
> -			key.remote_ipv6[3] = bpf_htonl(2);
> -		} else {
> -			ERROR(tcp->dest);
> -			return TC_ACT_SHOT;
> -		}
> -	}
> -
> -	ret = bpf_skb_set_tunnel_key(skb, &key, sizeof(key),
> -				     BPF_F_TUNINFO_IPV6);
> -	if (ret < 0) {
> -		ERROR(ret);
> -		return TC_ACT_SHOT;
> -	}
> -
> -	return TC_ACT_OK;
> -}

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

* Re: [PATCH bpf-next 2/2] selftest/bpf: remove unused bpf tunnel testing code
  2020-11-06  7:30   ` Martin KaFai Lau
@ 2020-11-06  7:55     ` Hangbin Liu
  2020-11-06  8:04       ` Hangbin Liu
  0 siblings, 1 reply; 23+ messages in thread
From: Hangbin Liu @ 2020-11-06  7:55 UTC (permalink / raw)
  To: Martin KaFai Lau; +Cc: netdev, William Tu, Daniel Borkmann, bpf

On Thu, Nov 05, 2020 at 11:30:35PM -0800, Martin KaFai Lau wrote:
> [ ... ]
> 
> > @@ -585,12 +571,11 @@ int _ipip6_set_tunnel(struct __sk_buff *skb)
> >  	struct bpf_tunnel_key key = {};
> >  	void *data = (void *)(long)skb->data;
> >  	struct iphdr *iph = data;
> v4 hdr here.

Ah, right, I didn't notice this. I will fix it, maybe by checking
skb->family and use different IPv4,v6 hdr.

> > -SEC("ip6ip6_set_tunnel")
> > -int _ip6ip6_set_tunnel(struct __sk_buff *skb)
> > -{
> > -	struct bpf_tunnel_key key = {};
> > -	void *data = (void *)(long)skb->data;
> > -	struct ipv6hdr *iph = data;
> IIUC, the patch is to replace _ip6ip6_set_tunnel with _ipip6_set_tunnel.
> 
> Are they testing the same thing?  At least, _ip6ip6_set_tunnel()
> is expecting a v6 hdr here.

Yes, the v4/v6 hdr here is just to check the data length.

> 
> > -	struct tcphdr *tcp = data + sizeof(*iph);
> > -	void *data_end = (void *)(long)skb->data_end;
> > -	int ret;
> > -
> > -	/* single length check */
> > -	if (data + sizeof(*iph) + sizeof(*tcp) > data_end) {
> > -		ERROR(1);
> > -		return TC_ACT_SHOT;
> > -	}

^^ here

> > -
> > -	key.remote_ipv6[0] = bpf_htonl(0x2401db00);
> > -	key.tunnel_ttl = 64;

The code logic is same. It set tunnel remote addr to dst IPv6 address, as
they are both testing IP(v4 or v6) over IPv6 tunnel.

Thanks
Hangbin

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

* Re: [PATCH bpf-next 2/2] selftest/bpf: remove unused bpf tunnel testing code
  2020-11-06  7:55     ` Hangbin Liu
@ 2020-11-06  8:04       ` Hangbin Liu
  0 siblings, 0 replies; 23+ messages in thread
From: Hangbin Liu @ 2020-11-06  8:04 UTC (permalink / raw)
  To: Martin KaFai Lau; +Cc: netdev, William Tu, Daniel Borkmann, bpf

On Fri, Nov 06, 2020 at 03:55:47PM +0800, Hangbin Liu wrote:
> > > -	key.remote_ipv6[0] = bpf_htonl(0x2401db00);
> > > -	key.tunnel_ttl = 64;
> 
> The code logic is same. It set tunnel remote addr to dst IPv6 address, as
> they are both testing IP(v4 or v6) over IPv6 tunnel.

OK, I decide to keep the kernel ip6ip6 code as using ipip6_set_tunnel obj in
ip6ip6 testing may cause user confused.

Thanks
Hangbin

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

* [PATCHv2 net 0/2] Remove unused test_ipip.sh test and add missed ip6ip6 test
  2020-11-03  4:29 [PATCH bpf-next 0/2] selftest/bpf: improve bpf tunnel test Hangbin Liu
  2020-11-03  4:29 ` [PATCH bpf-next 1/2] selftest/bpf: add missed ip6ip6 test back Hangbin Liu
  2020-11-03  4:29 ` [PATCH bpf-next 2/2] selftest/bpf: remove unused bpf tunnel testing code Hangbin Liu
@ 2020-11-06  9:01 ` Hangbin Liu
  2020-11-06  9:01   ` [PATCHv2 net 1/2] selftest/bpf: add missed ip6ip6 test back Hangbin Liu
                     ` (3 more replies)
  2 siblings, 4 replies; 23+ messages in thread
From: Hangbin Liu @ 2020-11-06  9:01 UTC (permalink / raw)
  To: netdev; +Cc: William Tu, Daniel Borkmann, bpf, Martin KaFai Lau, Hangbin Liu

In comment 173ca26e9b51 ("samples/bpf: add comprehensive ipip, ipip6,
ip6ip6 test") we added some bpf tunnel tests. In commit 933a741e3b82
("selftests/bpf: bpf tunnel test.") when we moved it to the current
folder, we missed some points:

1. ip6ip6 test is not added
2. forgot to remove test_ipip.sh in sample folder
3. TCP test code is not removed in test_tunnel_kern.c

In this patch set I add back ip6ip6 test and remove unused code. I'm not sure
if this should be net or net-next, so just set to net.

Here is the test result:
```
Testing IP6IP6 tunnel...
PING ::11(::11) 56 data bytes

--- ::11 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 63ms
rtt min/avg/max/mdev = 0.014/1028.308/2060.906/841.361 ms, pipe 2
PING 1::11(1::11) 56 data bytes

--- 1::11 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 48ms
rtt min/avg/max/mdev = 0.026/0.029/0.036/0.006 ms
PING 1::22(1::22) 56 data bytes

--- 1::22 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 47ms
rtt min/avg/max/mdev = 0.030/0.048/0.067/0.016 ms
PASS: ip6ip6tnl
```

v2: Keep ip6ip6 section in test_tunnel_kern.c.

Hangbin Liu (2):
  selftest/bpf: add missed ip6ip6 test back
  samples/bpf: remove unused test_ipip.sh

 samples/bpf/test_ipip.sh                      | 179 ------------------
 .../selftests/bpf/progs/test_tunnel_kern.c    |  44 +----
 tools/testing/selftests/bpf/test_tunnel.sh    |  43 ++++-
 3 files changed, 44 insertions(+), 222 deletions(-)
 delete mode 100755 samples/bpf/test_ipip.sh

-- 
2.25.4


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

* [PATCHv2 net 1/2] selftest/bpf: add missed ip6ip6 test back
  2020-11-06  9:01 ` [PATCHv2 net 0/2] Remove unused test_ipip.sh test and add missed ip6ip6 test Hangbin Liu
@ 2020-11-06  9:01   ` Hangbin Liu
  2020-11-07  2:15     ` Martin KaFai Lau
  2020-11-06  9:01   ` [PATCHv2 net 2/2] samples/bpf: remove unused test_ipip.sh Hangbin Liu
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 23+ messages in thread
From: Hangbin Liu @ 2020-11-06  9:01 UTC (permalink / raw)
  To: netdev; +Cc: William Tu, Daniel Borkmann, bpf, Martin KaFai Lau, Hangbin Liu

In comment 173ca26e9b51 ("samples/bpf: add comprehensive ipip, ipip6,
ip6ip6 test") we added ip6ip6 test for bpf tunnel testing. But in commit
933a741e3b82 ("selftests/bpf: bpf tunnel test.") when we moved it to
the current folder, we didn't add it.

This patch add the ip6ip6 test back to bpf tunnel test. Update the ipip6's
topology for both IPv4 and IPv6 testing. Since iperf test is removed as
currect framework simplified it in purpose, I also removed unused tcp
checkings in test_tunnel_kern.c.

Fixes: 933a741e3b82 ("selftests/bpf: bpf tunnel test.")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---

v2:
update add_ipip6tnl_tunnel() to add_ip6tnl_tunnel()
keep the _ip6ip6_set_tunnel() section.
---
 .../selftests/bpf/progs/test_tunnel_kern.c    | 44 +++----------------
 tools/testing/selftests/bpf/test_tunnel.sh    | 43 ++++++++++++++++--
 2 files changed, 44 insertions(+), 43 deletions(-)

diff --git a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c
index f48dbfe24ddc..7fd95befef56 100644
--- a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c
+++ b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c
@@ -15,7 +15,6 @@
 #include <linux/ip.h>
 #include <linux/ipv6.h>
 #include <linux/types.h>
-#include <linux/tcp.h>
 #include <linux/socket.h>
 #include <linux/pkt_cls.h>
 #include <linux/erspan.h>
@@ -528,30 +527,17 @@ int _ipip_set_tunnel(struct __sk_buff *skb)
 	struct bpf_tunnel_key key = {};
 	void *data = (void *)(long)skb->data;
 	struct iphdr *iph = data;
-	struct tcphdr *tcp = data + sizeof(*iph);
 	void *data_end = (void *)(long)skb->data_end;
 	int ret;
 
 	/* single length check */
-	if (data + sizeof(*iph) + sizeof(*tcp) > data_end) {
+	if (data + sizeof(*iph) > data_end) {
 		ERROR(1);
 		return TC_ACT_SHOT;
 	}
 
+	key.remote_ipv4 = 0xac100164; /* 172.16.1.100 */
 	key.tunnel_ttl = 64;
-	if (iph->protocol == IPPROTO_ICMP) {
-		key.remote_ipv4 = 0xac100164; /* 172.16.1.100 */
-	} else {
-		if (iph->protocol != IPPROTO_TCP || iph->ihl != 5)
-			return TC_ACT_SHOT;
-
-		if (tcp->dest == bpf_htons(5200))
-			key.remote_ipv4 = 0xac100164; /* 172.16.1.100 */
-		else if (tcp->dest == bpf_htons(5201))
-			key.remote_ipv4 = 0xac100165; /* 172.16.1.101 */
-		else
-			return TC_ACT_SHOT;
-	}
 
 	ret = bpf_skb_set_tunnel_key(skb, &key, sizeof(key), 0);
 	if (ret < 0) {
@@ -585,12 +571,11 @@ int _ipip6_set_tunnel(struct __sk_buff *skb)
 	struct bpf_tunnel_key key = {};
 	void *data = (void *)(long)skb->data;
 	struct iphdr *iph = data;
-	struct tcphdr *tcp = data + sizeof(*iph);
 	void *data_end = (void *)(long)skb->data_end;
 	int ret;
 
 	/* single length check */
-	if (data + sizeof(*iph) + sizeof(*tcp) > data_end) {
+	if (data + sizeof(*iph) > data_end) {
 		ERROR(1);
 		return TC_ACT_SHOT;
 	}
@@ -634,37 +619,18 @@ int _ip6ip6_set_tunnel(struct __sk_buff *skb)
 	struct bpf_tunnel_key key = {};
 	void *data = (void *)(long)skb->data;
 	struct ipv6hdr *iph = data;
-	struct tcphdr *tcp = data + sizeof(*iph);
 	void *data_end = (void *)(long)skb->data_end;
 	int ret;
 
 	/* single length check */
-	if (data + sizeof(*iph) + sizeof(*tcp) > data_end) {
+	if (data + sizeof(*iph) > data_end) {
 		ERROR(1);
 		return TC_ACT_SHOT;
 	}
 
-	key.remote_ipv6[0] = bpf_htonl(0x2401db00);
+	key.remote_ipv6[3] = bpf_htonl(0x11); /* ::11 */
 	key.tunnel_ttl = 64;
 
-	if (iph->nexthdr == 58 /* NEXTHDR_ICMP */) {
-		key.remote_ipv6[3] = bpf_htonl(1);
-	} else {
-		if (iph->nexthdr != 6 /* NEXTHDR_TCP */) {
-			ERROR(iph->nexthdr);
-			return TC_ACT_SHOT;
-		}
-
-		if (tcp->dest == bpf_htons(5200)) {
-			key.remote_ipv6[3] = bpf_htonl(1);
-		} else if (tcp->dest == bpf_htons(5201)) {
-			key.remote_ipv6[3] = bpf_htonl(2);
-		} else {
-			ERROR(tcp->dest);
-			return TC_ACT_SHOT;
-		}
-	}
-
 	ret = bpf_skb_set_tunnel_key(skb, &key, sizeof(key),
 				     BPF_F_TUNINFO_IPV6);
 	if (ret < 0) {
diff --git a/tools/testing/selftests/bpf/test_tunnel.sh b/tools/testing/selftests/bpf/test_tunnel.sh
index bd12ec97a44d..1ccbe804e8e1 100755
--- a/tools/testing/selftests/bpf/test_tunnel.sh
+++ b/tools/testing/selftests/bpf/test_tunnel.sh
@@ -24,12 +24,12 @@
 # Root namespace with metadata-mode tunnel + BPF
 # Device names and addresses:
 # 	veth1 IP: 172.16.1.200, IPv6: 00::22 (underlay)
-# 	tunnel dev <type>11, ex: gre11, IPv4: 10.1.1.200 (overlay)
+# 	tunnel dev <type>11, ex: gre11, IPv4: 10.1.1.200, IPv6: 1::22 (overlay)
 #
 # Namespace at_ns0 with native tunnel
 # Device names and addresses:
 # 	veth0 IPv4: 172.16.1.100, IPv6: 00::11 (underlay)
-# 	tunnel dev <type>00, ex: gre00, IPv4: 10.1.1.100 (overlay)
+# 	tunnel dev <type>00, ex: gre00, IPv4: 10.1.1.100, IPv6: 1::11 (overlay)
 #
 #
 # End-to-end ping packet flow
@@ -250,7 +250,7 @@ add_ipip_tunnel()
 	ip addr add dev $DEV 10.1.1.200/24
 }
 
-add_ipip6tnl_tunnel()
+add_ip6tnl_tunnel()
 {
 	ip netns exec at_ns0 ip addr add ::11/96 dev veth0
 	ip netns exec at_ns0 ip link set dev veth0 up
@@ -262,11 +262,13 @@ add_ipip6tnl_tunnel()
 		ip link add dev $DEV_NS type $TYPE \
 		local ::11 remote ::22
 	ip netns exec at_ns0 ip addr add dev $DEV_NS 10.1.1.100/24
+	ip netns exec at_ns0 ip addr add dev $DEV_NS 1::11/96
 	ip netns exec at_ns0 ip link set dev $DEV_NS up
 
 	# root namespace
 	ip link add dev $DEV type $TYPE external
 	ip addr add dev $DEV 10.1.1.200/24
+	ip addr add dev $DEV 1::22/96
 	ip link set dev $DEV up
 }
 
@@ -534,7 +536,7 @@ test_ipip6()
 
 	check $TYPE
 	config_device
-	add_ipip6tnl_tunnel
+	add_ip6tnl_tunnel
 	ip link set dev veth1 mtu 1500
 	attach_bpf $DEV ipip6_set_tunnel ipip6_get_tunnel
 	# underlay
@@ -553,6 +555,34 @@ test_ipip6()
         echo -e ${GREEN}"PASS: $TYPE"${NC}
 }
 
+test_ip6ip6()
+{
+	TYPE=ip6tnl
+	DEV_NS=ip6ip6tnl00
+	DEV=ip6ip6tnl11
+	ret=0
+
+	check $TYPE
+	config_device
+	add_ip6tnl_tunnel
+	ip link set dev veth1 mtu 1500
+	attach_bpf $DEV ip6ip6_set_tunnel ip6ip6_get_tunnel
+	# underlay
+	ping6 $PING_ARG ::11
+	# ip6 over ip6
+	ping6 $PING_ARG 1::11
+	check_err $?
+	ip netns exec at_ns0 ping6 $PING_ARG 1::22
+	check_err $?
+	cleanup
+
+	if [ $ret -ne 0 ]; then
+                echo -e ${RED}"FAIL: ip6$TYPE"${NC}
+                return 1
+        fi
+        echo -e ${GREEN}"PASS: ip6$TYPE"${NC}
+}
+
 setup_xfrm_tunnel()
 {
 	auth=0x$(printf '1%.0s' {1..40})
@@ -646,6 +676,7 @@ cleanup()
 	ip link del veth1 2> /dev/null
 	ip link del ipip11 2> /dev/null
 	ip link del ipip6tnl11 2> /dev/null
+	ip link del ip6ip6tnl11 2> /dev/null
 	ip link del gretap11 2> /dev/null
 	ip link del ip6gre11 2> /dev/null
 	ip link del ip6gretap11 2> /dev/null
@@ -742,6 +773,10 @@ bpf_tunnel_test()
 	test_ipip6
 	errors=$(( $errors + $? ))
 
+	echo "Testing IP6IP6 tunnel..."
+	test_ip6ip6
+	errors=$(( $errors + $? ))
+
 	echo "Testing IPSec tunnel..."
 	test_xfrm_tunnel
 	errors=$(( $errors + $? ))
-- 
2.25.4


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

* [PATCHv2 net 2/2] samples/bpf: remove unused test_ipip.sh
  2020-11-06  9:01 ` [PATCHv2 net 0/2] Remove unused test_ipip.sh test and add missed ip6ip6 test Hangbin Liu
  2020-11-06  9:01   ` [PATCHv2 net 1/2] selftest/bpf: add missed ip6ip6 test back Hangbin Liu
@ 2020-11-06  9:01   ` Hangbin Liu
  2020-11-07  2:16     ` Martin KaFai Lau
  2020-11-06 18:56   ` [PATCHv2 net 0/2] Remove unused test_ipip.sh test and add missed ip6ip6 test Jakub Kicinski
  2020-11-10  1:50   ` [PATCHv3 bpf " Hangbin Liu
  3 siblings, 1 reply; 23+ messages in thread
From: Hangbin Liu @ 2020-11-06  9:01 UTC (permalink / raw)
  To: netdev; +Cc: William Tu, Daniel Borkmann, bpf, Martin KaFai Lau, Hangbin Liu

The tcbpf2_kern.o and related kernel sections are moved to bpf
selftest folder since b05cd7404323 ("samples/bpf: remove the bpf tunnel
testsuite."). Remove this one as well.

Fixes: b05cd7404323 ("samples/bpf: remove the bpf tunnel testsuite.")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---

v2: move test_tunnel_kern.c changes to patch 01
---
 samples/bpf/test_ipip.sh | 179 ---------------------------------------
 1 file changed, 179 deletions(-)
 delete mode 100755 samples/bpf/test_ipip.sh

diff --git a/samples/bpf/test_ipip.sh b/samples/bpf/test_ipip.sh
deleted file mode 100755
index 9e507c305c6e..000000000000
--- a/samples/bpf/test_ipip.sh
+++ /dev/null
@@ -1,179 +0,0 @@
-#!/bin/bash
-# SPDX-License-Identifier: GPL-2.0
-
-function config_device {
-	ip netns add at_ns0
-	ip netns add at_ns1
-	ip netns add at_ns2
-	ip link add veth0 type veth peer name veth0b
-	ip link add veth1 type veth peer name veth1b
-	ip link add veth2 type veth peer name veth2b
-	ip link set veth0b up
-	ip link set veth1b up
-	ip link set veth2b up
-	ip link set dev veth0b mtu 1500
-	ip link set dev veth1b mtu 1500
-	ip link set dev veth2b mtu 1500
-	ip link set veth0 netns at_ns0
-	ip link set veth1 netns at_ns1
-	ip link set veth2 netns at_ns2
-	ip netns exec at_ns0 ip addr add 172.16.1.100/24 dev veth0
-	ip netns exec at_ns0 ip addr add 2401:db00::1/64 dev veth0 nodad
-	ip netns exec at_ns0 ip link set dev veth0 up
-	ip netns exec at_ns1 ip addr add 172.16.1.101/24 dev veth1
-	ip netns exec at_ns1 ip addr add 2401:db00::2/64 dev veth1 nodad
-	ip netns exec at_ns1 ip link set dev veth1 up
-	ip netns exec at_ns2 ip addr add 172.16.1.200/24 dev veth2
-	ip netns exec at_ns2 ip addr add 2401:db00::3/64 dev veth2 nodad
-	ip netns exec at_ns2 ip link set dev veth2 up
-	ip link add br0 type bridge
-	ip link set br0 up
-	ip link set dev br0 mtu 1500
-	ip link set veth0b master br0
-	ip link set veth1b master br0
-	ip link set veth2b master br0
-}
-
-function add_ipip_tunnel {
-	ip netns exec at_ns0 \
-		ip link add dev $DEV_NS type ipip local 172.16.1.100 remote 172.16.1.200
-	ip netns exec at_ns0 ip link set dev $DEV_NS up
-	ip netns exec at_ns0 ip addr add dev $DEV_NS 10.1.1.100/24
-	ip netns exec at_ns1 \
-		ip link add dev $DEV_NS type ipip local 172.16.1.101 remote 172.16.1.200
-	ip netns exec at_ns1 ip link set dev $DEV_NS up
-	# same inner IP address in at_ns0 and at_ns1
-	ip netns exec at_ns1 ip addr add dev $DEV_NS 10.1.1.100/24
-
-	ip netns exec at_ns2 ip link add dev $DEV type ipip external
-	ip netns exec at_ns2 ip link set dev $DEV up
-	ip netns exec at_ns2 ip addr add dev $DEV 10.1.1.200/24
-}
-
-function add_ipip6_tunnel {
-	ip netns exec at_ns0 \
-		ip link add dev $DEV_NS type ip6tnl mode ipip6 local 2401:db00::1/64 remote 2401:db00::3/64
-	ip netns exec at_ns0 ip link set dev $DEV_NS up
-	ip netns exec at_ns0 ip addr add dev $DEV_NS 10.1.1.100/24
-	ip netns exec at_ns1 \
-		ip link add dev $DEV_NS type ip6tnl mode ipip6 local 2401:db00::2/64 remote 2401:db00::3/64
-	ip netns exec at_ns1 ip link set dev $DEV_NS up
-	# same inner IP address in at_ns0 and at_ns1
-	ip netns exec at_ns1 ip addr add dev $DEV_NS 10.1.1.100/24
-
-	ip netns exec at_ns2 ip link add dev $DEV type ip6tnl mode ipip6 external
-	ip netns exec at_ns2 ip link set dev $DEV up
-	ip netns exec at_ns2 ip addr add dev $DEV 10.1.1.200/24
-}
-
-function add_ip6ip6_tunnel {
-	ip netns exec at_ns0 \
-		ip link add dev $DEV_NS type ip6tnl mode ip6ip6 local 2401:db00::1/64 remote 2401:db00::3/64
-	ip netns exec at_ns0 ip link set dev $DEV_NS up
-	ip netns exec at_ns0 ip addr add dev $DEV_NS 2601:646::1/64
-	ip netns exec at_ns1 \
-		ip link add dev $DEV_NS type ip6tnl mode ip6ip6 local 2401:db00::2/64 remote 2401:db00::3/64
-	ip netns exec at_ns1 ip link set dev $DEV_NS up
-	# same inner IP address in at_ns0 and at_ns1
-	ip netns exec at_ns1 ip addr add dev $DEV_NS 2601:646::1/64
-
-	ip netns exec at_ns2 ip link add dev $DEV type ip6tnl mode ip6ip6 external
-	ip netns exec at_ns2 ip link set dev $DEV up
-	ip netns exec at_ns2 ip addr add dev $DEV 2601:646::2/64
-}
-
-function attach_bpf {
-	DEV=$1
-	SET_TUNNEL=$2
-	GET_TUNNEL=$3
-	ip netns exec at_ns2 tc qdisc add dev $DEV clsact
-	ip netns exec at_ns2 tc filter add dev $DEV egress bpf da obj tcbpf2_kern.o sec $SET_TUNNEL
-	ip netns exec at_ns2 tc filter add dev $DEV ingress bpf da obj tcbpf2_kern.o sec $GET_TUNNEL
-}
-
-function test_ipip {
-	DEV_NS=ipip_std
-	DEV=ipip_bpf
-	config_device
-#	tcpdump -nei br0 &
-	cat /sys/kernel/debug/tracing/trace_pipe &
-
-	add_ipip_tunnel
-	attach_bpf $DEV ipip_set_tunnel ipip_get_tunnel
-
-	ip netns exec at_ns0 ping -c 1 10.1.1.200
-	ip netns exec at_ns2 ping -c 1 10.1.1.100
-	ip netns exec at_ns0 iperf -sD -p 5200 > /dev/null
-	ip netns exec at_ns1 iperf -sD -p 5201 > /dev/null
-	sleep 0.2
-	# tcp check _same_ IP over different tunnels
-	ip netns exec at_ns2 iperf -c 10.1.1.100 -n 5k -p 5200
-	ip netns exec at_ns2 iperf -c 10.1.1.100 -n 5k -p 5201
-	cleanup
-}
-
-# IPv4 over IPv6 tunnel
-function test_ipip6 {
-	DEV_NS=ipip_std
-	DEV=ipip_bpf
-	config_device
-#	tcpdump -nei br0 &
-	cat /sys/kernel/debug/tracing/trace_pipe &
-
-	add_ipip6_tunnel
-	attach_bpf $DEV ipip6_set_tunnel ipip6_get_tunnel
-
-	ip netns exec at_ns0 ping -c 1 10.1.1.200
-	ip netns exec at_ns2 ping -c 1 10.1.1.100
-	ip netns exec at_ns0 iperf -sD -p 5200 > /dev/null
-	ip netns exec at_ns1 iperf -sD -p 5201 > /dev/null
-	sleep 0.2
-	# tcp check _same_ IP over different tunnels
-	ip netns exec at_ns2 iperf -c 10.1.1.100 -n 5k -p 5200
-	ip netns exec at_ns2 iperf -c 10.1.1.100 -n 5k -p 5201
-	cleanup
-}
-
-# IPv6 over IPv6 tunnel
-function test_ip6ip6 {
-	DEV_NS=ipip_std
-	DEV=ipip_bpf
-	config_device
-#	tcpdump -nei br0 &
-	cat /sys/kernel/debug/tracing/trace_pipe &
-
-	add_ip6ip6_tunnel
-	attach_bpf $DEV ip6ip6_set_tunnel ip6ip6_get_tunnel
-
-	ip netns exec at_ns0 ping -6 -c 1 2601:646::2
-	ip netns exec at_ns2 ping -6 -c 1 2601:646::1
-	ip netns exec at_ns0 iperf -6sD -p 5200 > /dev/null
-	ip netns exec at_ns1 iperf -6sD -p 5201 > /dev/null
-	sleep 0.2
-	# tcp check _same_ IP over different tunnels
-	ip netns exec at_ns2 iperf -6c 2601:646::1 -n 5k -p 5200
-	ip netns exec at_ns2 iperf -6c 2601:646::1 -n 5k -p 5201
-	cleanup
-}
-
-function cleanup {
-	set +ex
-	pkill iperf
-	ip netns delete at_ns0
-	ip netns delete at_ns1
-	ip netns delete at_ns2
-	ip link del veth0
-	ip link del veth1
-	ip link del veth2
-	ip link del br0
-	pkill tcpdump
-	pkill cat
-	set -ex
-}
-
-cleanup
-echo "Testing IP tunnels..."
-test_ipip
-test_ipip6
-test_ip6ip6
-echo "*** PASS ***"
-- 
2.25.4


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

* Re: [PATCHv2 net 0/2] Remove unused test_ipip.sh test and add missed ip6ip6 test
  2020-11-06  9:01 ` [PATCHv2 net 0/2] Remove unused test_ipip.sh test and add missed ip6ip6 test Hangbin Liu
  2020-11-06  9:01   ` [PATCHv2 net 1/2] selftest/bpf: add missed ip6ip6 test back Hangbin Liu
  2020-11-06  9:01   ` [PATCHv2 net 2/2] samples/bpf: remove unused test_ipip.sh Hangbin Liu
@ 2020-11-06 18:56   ` Jakub Kicinski
  2020-11-06 18:58     ` Alexei Starovoitov
  2020-11-07  1:20     ` Hangbin Liu
  2020-11-10  1:50   ` [PATCHv3 bpf " Hangbin Liu
  3 siblings, 2 replies; 23+ messages in thread
From: Jakub Kicinski @ 2020-11-06 18:56 UTC (permalink / raw)
  To: Hangbin Liu; +Cc: netdev, William Tu, Daniel Borkmann, bpf, Martin KaFai Lau

On Fri,  6 Nov 2020 17:01:15 +0800 Hangbin Liu wrote:
> In comment 173ca26e9b51 ("samples/bpf: add comprehensive ipip, ipip6,
> ip6ip6 test") we added some bpf tunnel tests. In commit 933a741e3b82
> ("selftests/bpf: bpf tunnel test.") when we moved it to the current
> folder, we missed some points:
> 
> 1. ip6ip6 test is not added
> 2. forgot to remove test_ipip.sh in sample folder
> 3. TCP test code is not removed in test_tunnel_kern.c
> 
> In this patch set I add back ip6ip6 test and remove unused code. I'm not sure
> if this should be net or net-next, so just set to net.

I'm assuming you meant to tag this with the bpf tree.

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

* Re: [PATCHv2 net 0/2] Remove unused test_ipip.sh test and add missed ip6ip6 test
  2020-11-06 18:56   ` [PATCHv2 net 0/2] Remove unused test_ipip.sh test and add missed ip6ip6 test Jakub Kicinski
@ 2020-11-06 18:58     ` Alexei Starovoitov
  2020-11-07  1:20     ` Hangbin Liu
  1 sibling, 0 replies; 23+ messages in thread
From: Alexei Starovoitov @ 2020-11-06 18:58 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Hangbin Liu, Network Development, William Tu, Daniel Borkmann,
	bpf, Martin KaFai Lau

On Fri, Nov 6, 2020 at 10:56 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Fri,  6 Nov 2020 17:01:15 +0800 Hangbin Liu wrote:
> > In comment 173ca26e9b51 ("samples/bpf: add comprehensive ipip, ipip6,
> > ip6ip6 test") we added some bpf tunnel tests. In commit 933a741e3b82
> > ("selftests/bpf: bpf tunnel test.") when we moved it to the current
> > folder, we missed some points:
> >
> > 1. ip6ip6 test is not added
> > 2. forgot to remove test_ipip.sh in sample folder
> > 3. TCP test code is not removed in test_tunnel_kern.c
> >
> > In this patch set I add back ip6ip6 test and remove unused code. I'm not sure
> > if this should be net or net-next, so just set to net.
>
> I'm assuming you meant to tag this with the bpf tree.

Right. Thanks for headsup.

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

* Re: [PATCHv2 net 0/2] Remove unused test_ipip.sh test and add missed ip6ip6 test
  2020-11-06 18:56   ` [PATCHv2 net 0/2] Remove unused test_ipip.sh test and add missed ip6ip6 test Jakub Kicinski
  2020-11-06 18:58     ` Alexei Starovoitov
@ 2020-11-07  1:20     ` Hangbin Liu
  1 sibling, 0 replies; 23+ messages in thread
From: Hangbin Liu @ 2020-11-07  1:20 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: netdev, William Tu, Daniel Borkmann, bpf, Martin KaFai Lau

On Fri, Nov 06, 2020 at 10:56:00AM -0800, Jakub Kicinski wrote:
> On Fri,  6 Nov 2020 17:01:15 +0800 Hangbin Liu wrote:
> > In comment 173ca26e9b51 ("samples/bpf: add comprehensive ipip, ipip6,
> > ip6ip6 test") we added some bpf tunnel tests. In commit 933a741e3b82
> > ("selftests/bpf: bpf tunnel test.") when we moved it to the current
> > folder, we missed some points:
> > 
> > 1. ip6ip6 test is not added
> > 2. forgot to remove test_ipip.sh in sample folder
> > 3. TCP test code is not removed in test_tunnel_kern.c
> > 
> > In this patch set I add back ip6ip6 test and remove unused code. I'm not sure
> > if this should be net or net-next, so just set to net.
> 
> I'm assuming you meant to tag this with the bpf tree.

Ah, yes, I mean to bpf tree. Sorry for the mistake.

Regards
Hangbin

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

* Re: [PATCHv2 net 1/2] selftest/bpf: add missed ip6ip6 test back
  2020-11-06  9:01   ` [PATCHv2 net 1/2] selftest/bpf: add missed ip6ip6 test back Hangbin Liu
@ 2020-11-07  2:15     ` Martin KaFai Lau
  2020-11-09  3:00       ` Hangbin Liu
  0 siblings, 1 reply; 23+ messages in thread
From: Martin KaFai Lau @ 2020-11-07  2:15 UTC (permalink / raw)
  To: Hangbin Liu; +Cc: netdev, William Tu, Daniel Borkmann, bpf

On Fri, Nov 06, 2020 at 05:01:16PM +0800, Hangbin Liu wrote:
> In comment 173ca26e9b51 ("samples/bpf: add comprehensive ipip, ipip6,
> ip6ip6 test") we added ip6ip6 test for bpf tunnel testing. But in commit
> 933a741e3b82 ("selftests/bpf: bpf tunnel test.") when we moved it to
> the current folder, we didn't add it.
> 
> This patch add the ip6ip6 test back to bpf tunnel test. Update the ipip6's
> topology for both IPv4 and IPv6 testing. Since iperf test is removed as
> currect framework simplified it in purpose, I also removed unused tcp
> checkings in test_tunnel_kern.c.
> 
> Fixes: 933a741e3b82 ("selftests/bpf: bpf tunnel test.")
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
> ---
> 
> v2:
> update add_ipip6tnl_tunnel() to add_ip6tnl_tunnel()
> keep the _ip6ip6_set_tunnel() section.
> ---
>  .../selftests/bpf/progs/test_tunnel_kern.c    | 44 +++----------------
>  tools/testing/selftests/bpf/test_tunnel.sh    | 43 ++++++++++++++++--
>  2 files changed, 44 insertions(+), 43 deletions(-)
> 
> diff --git a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c
> index f48dbfe24ddc..7fd95befef56 100644
> --- a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c
> +++ b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c
> @@ -15,7 +15,6 @@
>  #include <linux/ip.h>
>  #include <linux/ipv6.h>
>  #include <linux/types.h>
> -#include <linux/tcp.h>
>  #include <linux/socket.h>
>  #include <linux/pkt_cls.h>
>  #include <linux/erspan.h>
> @@ -528,30 +527,17 @@ int _ipip_set_tunnel(struct __sk_buff *skb)
>  	struct bpf_tunnel_key key = {};
>  	void *data = (void *)(long)skb->data;
>  	struct iphdr *iph = data;
> -	struct tcphdr *tcp = data + sizeof(*iph);
>  	void *data_end = (void *)(long)skb->data_end;
>  	int ret;
>  
>  	/* single length check */
> -	if (data + sizeof(*iph) + sizeof(*tcp) > data_end) {
> +	if (data + sizeof(*iph) > data_end) {
>  		ERROR(1);
>  		return TC_ACT_SHOT;
>  	}
>  
> +	key.remote_ipv4 = 0xac100164; /* 172.16.1.100 */
>  	key.tunnel_ttl = 64;
> -	if (iph->protocol == IPPROTO_ICMP) {
> -		key.remote_ipv4 = 0xac100164; /* 172.16.1.100 */
I think it is still good to check IPPROTO_ICMP
even ping is the only test.

> -	} else {
> -		if (iph->protocol != IPPROTO_TCP || iph->ihl != 5)
> -			return TC_ACT_SHOT;
> -
> -		if (tcp->dest == bpf_htons(5200))
> -			key.remote_ipv4 = 0xac100164; /* 172.16.1.100 */
> -		else if (tcp->dest == bpf_htons(5201))
> -			key.remote_ipv4 = 0xac100165; /* 172.16.1.101 */
> -		else
> -			return TC_ACT_SHOT;
> -	}
>  
>  	ret = bpf_skb_set_tunnel_key(skb, &key, sizeof(key), 0);
>  	if (ret < 0) {
> @@ -585,12 +571,11 @@ int _ipip6_set_tunnel(struct __sk_buff *skb)
>  	struct bpf_tunnel_key key = {};
>  	void *data = (void *)(long)skb->data;
>  	struct iphdr *iph = data;
> -	struct tcphdr *tcp = data + sizeof(*iph);
>  	void *data_end = (void *)(long)skb->data_end;
>  	int ret;
>  
>  	/* single length check */
> -	if (data + sizeof(*iph) + sizeof(*tcp) > data_end) {
> +	if (data + sizeof(*iph) > data_end) {
>  		ERROR(1);
>  		return TC_ACT_SHOT;
>  	}
> @@ -634,37 +619,18 @@ int _ip6ip6_set_tunnel(struct __sk_buff *skb)
>  	struct bpf_tunnel_key key = {};
>  	void *data = (void *)(long)skb->data;
>  	struct ipv6hdr *iph = data;
> -	struct tcphdr *tcp = data + sizeof(*iph);
>  	void *data_end = (void *)(long)skb->data_end;
>  	int ret;
>  
>  	/* single length check */
> -	if (data + sizeof(*iph) + sizeof(*tcp) > data_end) {
> +	if (data + sizeof(*iph) > data_end) {
>  		ERROR(1);
>  		return TC_ACT_SHOT;
>  	}
>  
> -	key.remote_ipv6[0] = bpf_htonl(0x2401db00);
> +	key.remote_ipv6[3] = bpf_htonl(0x11); /* ::11 */
>  	key.tunnel_ttl = 64;
>  
> -	if (iph->nexthdr == 58 /* NEXTHDR_ICMP */) {
Same here. Can this check be kept?

Others LGTM.

> -		key.remote_ipv6[3] = bpf_htonl(1);
> -	} else {
> -		if (iph->nexthdr != 6 /* NEXTHDR_TCP */) {
> -			ERROR(iph->nexthdr);
> -			return TC_ACT_SHOT;
> -		}
> -
> -		if (tcp->dest == bpf_htons(5200)) {
> -			key.remote_ipv6[3] = bpf_htonl(1);
> -		} else if (tcp->dest == bpf_htons(5201)) {
> -			key.remote_ipv6[3] = bpf_htonl(2);
> -		} else {
> -			ERROR(tcp->dest);
> -			return TC_ACT_SHOT;
> -		}
> -	}
> -
>  	ret = bpf_skb_set_tunnel_key(skb, &key, sizeof(key),
>  				     BPF_F_TUNINFO_IPV6);
>  	if (ret < 0) {

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

* Re: [PATCHv2 net 2/2] samples/bpf: remove unused test_ipip.sh
  2020-11-06  9:01   ` [PATCHv2 net 2/2] samples/bpf: remove unused test_ipip.sh Hangbin Liu
@ 2020-11-07  2:16     ` Martin KaFai Lau
  0 siblings, 0 replies; 23+ messages in thread
From: Martin KaFai Lau @ 2020-11-07  2:16 UTC (permalink / raw)
  To: Hangbin Liu; +Cc: netdev, William Tu, Daniel Borkmann, bpf

On Fri, Nov 06, 2020 at 05:01:17PM +0800, Hangbin Liu wrote:
> The tcbpf2_kern.o and related kernel sections are moved to bpf
> selftest folder since b05cd7404323 ("samples/bpf: remove the bpf tunnel
> testsuite."). Remove this one as well.
> 
> Fixes: b05cd7404323 ("samples/bpf: remove the bpf tunnel testsuite.")
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Acked-by: Martin KaFai Lau <kafai@fb.com>

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

* Re: [PATCHv2 net 1/2] selftest/bpf: add missed ip6ip6 test back
  2020-11-07  2:15     ` Martin KaFai Lau
@ 2020-11-09  3:00       ` Hangbin Liu
  2020-11-09 22:25         ` Martin KaFai Lau
  0 siblings, 1 reply; 23+ messages in thread
From: Hangbin Liu @ 2020-11-09  3:00 UTC (permalink / raw)
  To: Martin KaFai Lau; +Cc: netdev, William Tu, Daniel Borkmann, bpf

On Fri, Nov 06, 2020 at 06:15:44PM -0800, Martin KaFai Lau wrote:
> > -	if (iph->nexthdr == 58 /* NEXTHDR_ICMP */) {
> Same here. Can this check be kept?

Hi Martin,

I'm OK to keep the checking, then what about _ipip6_set_tunnel()? It also
doesn't have the ICMP checking.

Thanks
Hangbin

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

* Re: [PATCHv2 net 1/2] selftest/bpf: add missed ip6ip6 test back
  2020-11-09  3:00       ` Hangbin Liu
@ 2020-11-09 22:25         ` Martin KaFai Lau
  0 siblings, 0 replies; 23+ messages in thread
From: Martin KaFai Lau @ 2020-11-09 22:25 UTC (permalink / raw)
  To: Hangbin Liu; +Cc: netdev, William Tu, Daniel Borkmann, bpf

On Mon, Nov 09, 2020 at 11:00:15AM +0800, Hangbin Liu wrote:
> On Fri, Nov 06, 2020 at 06:15:44PM -0800, Martin KaFai Lau wrote:
> > > -	if (iph->nexthdr == 58 /* NEXTHDR_ICMP */) {
> > Same here. Can this check be kept?
> 
> Hi Martin,
> 
> I'm OK to keep the checking, then what about _ipip6_set_tunnel()? It also
> doesn't have the ICMP checking.
It should.  Otherwise, what is the point on testing
"data + sizeof(*iph) > data_end" without checking anything from iph?

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

* [PATCHv3 bpf 0/2] Remove unused test_ipip.sh test and add missed ip6ip6 test
  2020-11-06  9:01 ` [PATCHv2 net 0/2] Remove unused test_ipip.sh test and add missed ip6ip6 test Hangbin Liu
                     ` (2 preceding siblings ...)
  2020-11-06 18:56   ` [PATCHv2 net 0/2] Remove unused test_ipip.sh test and add missed ip6ip6 test Jakub Kicinski
@ 2020-11-10  1:50   ` Hangbin Liu
  2020-11-10  1:50     ` [PATCHv3 bpf 1/2] selftest/bpf: add missed ip6ip6 test back Hangbin Liu
                       ` (2 more replies)
  3 siblings, 3 replies; 23+ messages in thread
From: Hangbin Liu @ 2020-11-10  1:50 UTC (permalink / raw)
  To: bpf; +Cc: William Tu, Daniel Borkmann, Martin KaFai Lau, netdev, Hangbin Liu

In comment 173ca26e9b51 ("samples/bpf: add comprehensive ipip, ipip6,
ip6ip6 test") we added some bpf tunnel tests. In commit 933a741e3b82
("selftests/bpf: bpf tunnel test.") when we moved it to the current
folder, we missed some points:

1. ip6ip6 test is not added
2. forgot to remove test_ipip.sh in sample folder
3. TCP test code is not removed in test_tunnel_kern.c

In this patch set I add back ip6ip6 test and remove unused code. I'm not sure
if this should be net or net-next, so just set to net.

Here is the test result:
```
Testing IP6IP6 tunnel...
PING ::11(::11) 56 data bytes

--- ::11 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 63ms
rtt min/avg/max/mdev = 0.014/1028.308/2060.906/841.361 ms, pipe 2
PING 1::11(1::11) 56 data bytes

--- 1::11 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 48ms
rtt min/avg/max/mdev = 0.026/0.029/0.036/0.006 ms
PING 1::22(1::22) 56 data bytes

--- 1::22 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 47ms
rtt min/avg/max/mdev = 0.030/0.048/0.067/0.016 ms
PASS: ip6ip6tnl
```

v3:
Add back ICMP check as Martin suggested.

v2: Keep ip6ip6 section in test_tunnel_kern.c.

Hangbin Liu (2):
  selftest/bpf: add missed ip6ip6 test back
  samples/bpf: remove unused test_ipip.sh

 samples/bpf/test_ipip.sh                      | 179 ------------------
 .../selftests/bpf/progs/test_tunnel_kern.c    |  42 +---
 tools/testing/selftests/bpf/test_tunnel.sh    |  43 ++++-
 3 files changed, 46 insertions(+), 218 deletions(-)
 delete mode 100755 samples/bpf/test_ipip.sh

-- 
2.25.4


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

* [PATCHv3 bpf 1/2] selftest/bpf: add missed ip6ip6 test back
  2020-11-10  1:50   ` [PATCHv3 bpf " Hangbin Liu
@ 2020-11-10  1:50     ` Hangbin Liu
  2020-11-10  1:50     ` [PATCHv3 bpf 2/2] samples/bpf: remove unused test_ipip.sh Hangbin Liu
  2020-11-10 17:35     ` [PATCHv3 bpf 0/2] Remove unused test_ipip.sh test and add missed ip6ip6 test Martin KaFai Lau
  2 siblings, 0 replies; 23+ messages in thread
From: Hangbin Liu @ 2020-11-10  1:50 UTC (permalink / raw)
  To: bpf; +Cc: William Tu, Daniel Borkmann, Martin KaFai Lau, netdev, Hangbin Liu

In comment 173ca26e9b51 ("samples/bpf: add comprehensive ipip, ipip6,
ip6ip6 test") we added ip6ip6 test for bpf tunnel testing. But in commit
933a741e3b82 ("selftests/bpf: bpf tunnel test.") when we moved it to
the current folder, we didn't add it.

This patch add the ip6ip6 test back to bpf tunnel test. Update the ipip6's
topology for both IPv4 and IPv6 testing. Since iperf test is removed as
currect framework simplified it in purpose, I also removed unused tcp
checkings in test_tunnel_kern.c.

Fixes: 933a741e3b82 ("selftests/bpf: bpf tunnel test.")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---

v3:
Add back ICMP check as Martin suggested.

v2:
update add_ipip6tnl_tunnel() to add_ip6tnl_tunnel()
keep the _ip6ip6_set_tunnel() section.
---
 .../selftests/bpf/progs/test_tunnel_kern.c    | 42 +++---------------
 tools/testing/selftests/bpf/test_tunnel.sh    | 43 +++++++++++++++++--
 2 files changed, 46 insertions(+), 39 deletions(-)

diff --git a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c
index f48dbfe24ddc..a621b58ab079 100644
--- a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c
+++ b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c
@@ -15,7 +15,6 @@
 #include <linux/ip.h>
 #include <linux/ipv6.h>
 #include <linux/types.h>
-#include <linux/tcp.h>
 #include <linux/socket.h>
 #include <linux/pkt_cls.h>
 #include <linux/erspan.h>
@@ -528,12 +527,11 @@ int _ipip_set_tunnel(struct __sk_buff *skb)
 	struct bpf_tunnel_key key = {};
 	void *data = (void *)(long)skb->data;
 	struct iphdr *iph = data;
-	struct tcphdr *tcp = data + sizeof(*iph);
 	void *data_end = (void *)(long)skb->data_end;
 	int ret;
 
 	/* single length check */
-	if (data + sizeof(*iph) + sizeof(*tcp) > data_end) {
+	if (data + sizeof(*iph) > data_end) {
 		ERROR(1);
 		return TC_ACT_SHOT;
 	}
@@ -541,16 +539,6 @@ int _ipip_set_tunnel(struct __sk_buff *skb)
 	key.tunnel_ttl = 64;
 	if (iph->protocol == IPPROTO_ICMP) {
 		key.remote_ipv4 = 0xac100164; /* 172.16.1.100 */
-	} else {
-		if (iph->protocol != IPPROTO_TCP || iph->ihl != 5)
-			return TC_ACT_SHOT;
-
-		if (tcp->dest == bpf_htons(5200))
-			key.remote_ipv4 = 0xac100164; /* 172.16.1.100 */
-		else if (tcp->dest == bpf_htons(5201))
-			key.remote_ipv4 = 0xac100165; /* 172.16.1.101 */
-		else
-			return TC_ACT_SHOT;
 	}
 
 	ret = bpf_skb_set_tunnel_key(skb, &key, sizeof(key), 0);
@@ -585,19 +573,20 @@ int _ipip6_set_tunnel(struct __sk_buff *skb)
 	struct bpf_tunnel_key key = {};
 	void *data = (void *)(long)skb->data;
 	struct iphdr *iph = data;
-	struct tcphdr *tcp = data + sizeof(*iph);
 	void *data_end = (void *)(long)skb->data_end;
 	int ret;
 
 	/* single length check */
-	if (data + sizeof(*iph) + sizeof(*tcp) > data_end) {
+	if (data + sizeof(*iph) > data_end) {
 		ERROR(1);
 		return TC_ACT_SHOT;
 	}
 
 	__builtin_memset(&key, 0x0, sizeof(key));
-	key.remote_ipv6[3] = bpf_htonl(0x11); /* ::11 */
 	key.tunnel_ttl = 64;
+	if (iph->protocol == IPPROTO_ICMP) {
+		key.remote_ipv6[3] = bpf_htonl(0x11); /* ::11 */
+	}
 
 	ret = bpf_skb_set_tunnel_key(skb, &key, sizeof(key),
 				     BPF_F_TUNINFO_IPV6);
@@ -634,35 +623,18 @@ int _ip6ip6_set_tunnel(struct __sk_buff *skb)
 	struct bpf_tunnel_key key = {};
 	void *data = (void *)(long)skb->data;
 	struct ipv6hdr *iph = data;
-	struct tcphdr *tcp = data + sizeof(*iph);
 	void *data_end = (void *)(long)skb->data_end;
 	int ret;
 
 	/* single length check */
-	if (data + sizeof(*iph) + sizeof(*tcp) > data_end) {
+	if (data + sizeof(*iph) > data_end) {
 		ERROR(1);
 		return TC_ACT_SHOT;
 	}
 
-	key.remote_ipv6[0] = bpf_htonl(0x2401db00);
 	key.tunnel_ttl = 64;
-
 	if (iph->nexthdr == 58 /* NEXTHDR_ICMP */) {
-		key.remote_ipv6[3] = bpf_htonl(1);
-	} else {
-		if (iph->nexthdr != 6 /* NEXTHDR_TCP */) {
-			ERROR(iph->nexthdr);
-			return TC_ACT_SHOT;
-		}
-
-		if (tcp->dest == bpf_htons(5200)) {
-			key.remote_ipv6[3] = bpf_htonl(1);
-		} else if (tcp->dest == bpf_htons(5201)) {
-			key.remote_ipv6[3] = bpf_htonl(2);
-		} else {
-			ERROR(tcp->dest);
-			return TC_ACT_SHOT;
-		}
+		key.remote_ipv6[3] = bpf_htonl(0x11); /* ::11 */
 	}
 
 	ret = bpf_skb_set_tunnel_key(skb, &key, sizeof(key),
diff --git a/tools/testing/selftests/bpf/test_tunnel.sh b/tools/testing/selftests/bpf/test_tunnel.sh
index bd12ec97a44d..1ccbe804e8e1 100755
--- a/tools/testing/selftests/bpf/test_tunnel.sh
+++ b/tools/testing/selftests/bpf/test_tunnel.sh
@@ -24,12 +24,12 @@
 # Root namespace with metadata-mode tunnel + BPF
 # Device names and addresses:
 # 	veth1 IP: 172.16.1.200, IPv6: 00::22 (underlay)
-# 	tunnel dev <type>11, ex: gre11, IPv4: 10.1.1.200 (overlay)
+# 	tunnel dev <type>11, ex: gre11, IPv4: 10.1.1.200, IPv6: 1::22 (overlay)
 #
 # Namespace at_ns0 with native tunnel
 # Device names and addresses:
 # 	veth0 IPv4: 172.16.1.100, IPv6: 00::11 (underlay)
-# 	tunnel dev <type>00, ex: gre00, IPv4: 10.1.1.100 (overlay)
+# 	tunnel dev <type>00, ex: gre00, IPv4: 10.1.1.100, IPv6: 1::11 (overlay)
 #
 #
 # End-to-end ping packet flow
@@ -250,7 +250,7 @@ add_ipip_tunnel()
 	ip addr add dev $DEV 10.1.1.200/24
 }
 
-add_ipip6tnl_tunnel()
+add_ip6tnl_tunnel()
 {
 	ip netns exec at_ns0 ip addr add ::11/96 dev veth0
 	ip netns exec at_ns0 ip link set dev veth0 up
@@ -262,11 +262,13 @@ add_ipip6tnl_tunnel()
 		ip link add dev $DEV_NS type $TYPE \
 		local ::11 remote ::22
 	ip netns exec at_ns0 ip addr add dev $DEV_NS 10.1.1.100/24
+	ip netns exec at_ns0 ip addr add dev $DEV_NS 1::11/96
 	ip netns exec at_ns0 ip link set dev $DEV_NS up
 
 	# root namespace
 	ip link add dev $DEV type $TYPE external
 	ip addr add dev $DEV 10.1.1.200/24
+	ip addr add dev $DEV 1::22/96
 	ip link set dev $DEV up
 }
 
@@ -534,7 +536,7 @@ test_ipip6()
 
 	check $TYPE
 	config_device
-	add_ipip6tnl_tunnel
+	add_ip6tnl_tunnel
 	ip link set dev veth1 mtu 1500
 	attach_bpf $DEV ipip6_set_tunnel ipip6_get_tunnel
 	# underlay
@@ -553,6 +555,34 @@ test_ipip6()
         echo -e ${GREEN}"PASS: $TYPE"${NC}
 }
 
+test_ip6ip6()
+{
+	TYPE=ip6tnl
+	DEV_NS=ip6ip6tnl00
+	DEV=ip6ip6tnl11
+	ret=0
+
+	check $TYPE
+	config_device
+	add_ip6tnl_tunnel
+	ip link set dev veth1 mtu 1500
+	attach_bpf $DEV ip6ip6_set_tunnel ip6ip6_get_tunnel
+	# underlay
+	ping6 $PING_ARG ::11
+	# ip6 over ip6
+	ping6 $PING_ARG 1::11
+	check_err $?
+	ip netns exec at_ns0 ping6 $PING_ARG 1::22
+	check_err $?
+	cleanup
+
+	if [ $ret -ne 0 ]; then
+                echo -e ${RED}"FAIL: ip6$TYPE"${NC}
+                return 1
+        fi
+        echo -e ${GREEN}"PASS: ip6$TYPE"${NC}
+}
+
 setup_xfrm_tunnel()
 {
 	auth=0x$(printf '1%.0s' {1..40})
@@ -646,6 +676,7 @@ cleanup()
 	ip link del veth1 2> /dev/null
 	ip link del ipip11 2> /dev/null
 	ip link del ipip6tnl11 2> /dev/null
+	ip link del ip6ip6tnl11 2> /dev/null
 	ip link del gretap11 2> /dev/null
 	ip link del ip6gre11 2> /dev/null
 	ip link del ip6gretap11 2> /dev/null
@@ -742,6 +773,10 @@ bpf_tunnel_test()
 	test_ipip6
 	errors=$(( $errors + $? ))
 
+	echo "Testing IP6IP6 tunnel..."
+	test_ip6ip6
+	errors=$(( $errors + $? ))
+
 	echo "Testing IPSec tunnel..."
 	test_xfrm_tunnel
 	errors=$(( $errors + $? ))
-- 
2.25.4


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

* [PATCHv3 bpf 2/2] samples/bpf: remove unused test_ipip.sh
  2020-11-10  1:50   ` [PATCHv3 bpf " Hangbin Liu
  2020-11-10  1:50     ` [PATCHv3 bpf 1/2] selftest/bpf: add missed ip6ip6 test back Hangbin Liu
@ 2020-11-10  1:50     ` Hangbin Liu
  2020-11-10 17:35     ` [PATCHv3 bpf 0/2] Remove unused test_ipip.sh test and add missed ip6ip6 test Martin KaFai Lau
  2 siblings, 0 replies; 23+ messages in thread
From: Hangbin Liu @ 2020-11-10  1:50 UTC (permalink / raw)
  To: bpf; +Cc: William Tu, Daniel Borkmann, Martin KaFai Lau, netdev, Hangbin Liu

The tcbpf2_kern.o and related kernel sections are moved to bpf
selftest folder since b05cd7404323 ("samples/bpf: remove the bpf tunnel
testsuite."). Remove this one as well.

Fixes: b05cd7404323 ("samples/bpf: remove the bpf tunnel testsuite.")
Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---

v2: move test_tunnel_kern.c changes to patch 01
---
 samples/bpf/test_ipip.sh | 179 ---------------------------------------
 1 file changed, 179 deletions(-)
 delete mode 100755 samples/bpf/test_ipip.sh

diff --git a/samples/bpf/test_ipip.sh b/samples/bpf/test_ipip.sh
deleted file mode 100755
index 9e507c305c6e..000000000000
--- a/samples/bpf/test_ipip.sh
+++ /dev/null
@@ -1,179 +0,0 @@
-#!/bin/bash
-# SPDX-License-Identifier: GPL-2.0
-
-function config_device {
-	ip netns add at_ns0
-	ip netns add at_ns1
-	ip netns add at_ns2
-	ip link add veth0 type veth peer name veth0b
-	ip link add veth1 type veth peer name veth1b
-	ip link add veth2 type veth peer name veth2b
-	ip link set veth0b up
-	ip link set veth1b up
-	ip link set veth2b up
-	ip link set dev veth0b mtu 1500
-	ip link set dev veth1b mtu 1500
-	ip link set dev veth2b mtu 1500
-	ip link set veth0 netns at_ns0
-	ip link set veth1 netns at_ns1
-	ip link set veth2 netns at_ns2
-	ip netns exec at_ns0 ip addr add 172.16.1.100/24 dev veth0
-	ip netns exec at_ns0 ip addr add 2401:db00::1/64 dev veth0 nodad
-	ip netns exec at_ns0 ip link set dev veth0 up
-	ip netns exec at_ns1 ip addr add 172.16.1.101/24 dev veth1
-	ip netns exec at_ns1 ip addr add 2401:db00::2/64 dev veth1 nodad
-	ip netns exec at_ns1 ip link set dev veth1 up
-	ip netns exec at_ns2 ip addr add 172.16.1.200/24 dev veth2
-	ip netns exec at_ns2 ip addr add 2401:db00::3/64 dev veth2 nodad
-	ip netns exec at_ns2 ip link set dev veth2 up
-	ip link add br0 type bridge
-	ip link set br0 up
-	ip link set dev br0 mtu 1500
-	ip link set veth0b master br0
-	ip link set veth1b master br0
-	ip link set veth2b master br0
-}
-
-function add_ipip_tunnel {
-	ip netns exec at_ns0 \
-		ip link add dev $DEV_NS type ipip local 172.16.1.100 remote 172.16.1.200
-	ip netns exec at_ns0 ip link set dev $DEV_NS up
-	ip netns exec at_ns0 ip addr add dev $DEV_NS 10.1.1.100/24
-	ip netns exec at_ns1 \
-		ip link add dev $DEV_NS type ipip local 172.16.1.101 remote 172.16.1.200
-	ip netns exec at_ns1 ip link set dev $DEV_NS up
-	# same inner IP address in at_ns0 and at_ns1
-	ip netns exec at_ns1 ip addr add dev $DEV_NS 10.1.1.100/24
-
-	ip netns exec at_ns2 ip link add dev $DEV type ipip external
-	ip netns exec at_ns2 ip link set dev $DEV up
-	ip netns exec at_ns2 ip addr add dev $DEV 10.1.1.200/24
-}
-
-function add_ipip6_tunnel {
-	ip netns exec at_ns0 \
-		ip link add dev $DEV_NS type ip6tnl mode ipip6 local 2401:db00::1/64 remote 2401:db00::3/64
-	ip netns exec at_ns0 ip link set dev $DEV_NS up
-	ip netns exec at_ns0 ip addr add dev $DEV_NS 10.1.1.100/24
-	ip netns exec at_ns1 \
-		ip link add dev $DEV_NS type ip6tnl mode ipip6 local 2401:db00::2/64 remote 2401:db00::3/64
-	ip netns exec at_ns1 ip link set dev $DEV_NS up
-	# same inner IP address in at_ns0 and at_ns1
-	ip netns exec at_ns1 ip addr add dev $DEV_NS 10.1.1.100/24
-
-	ip netns exec at_ns2 ip link add dev $DEV type ip6tnl mode ipip6 external
-	ip netns exec at_ns2 ip link set dev $DEV up
-	ip netns exec at_ns2 ip addr add dev $DEV 10.1.1.200/24
-}
-
-function add_ip6ip6_tunnel {
-	ip netns exec at_ns0 \
-		ip link add dev $DEV_NS type ip6tnl mode ip6ip6 local 2401:db00::1/64 remote 2401:db00::3/64
-	ip netns exec at_ns0 ip link set dev $DEV_NS up
-	ip netns exec at_ns0 ip addr add dev $DEV_NS 2601:646::1/64
-	ip netns exec at_ns1 \
-		ip link add dev $DEV_NS type ip6tnl mode ip6ip6 local 2401:db00::2/64 remote 2401:db00::3/64
-	ip netns exec at_ns1 ip link set dev $DEV_NS up
-	# same inner IP address in at_ns0 and at_ns1
-	ip netns exec at_ns1 ip addr add dev $DEV_NS 2601:646::1/64
-
-	ip netns exec at_ns2 ip link add dev $DEV type ip6tnl mode ip6ip6 external
-	ip netns exec at_ns2 ip link set dev $DEV up
-	ip netns exec at_ns2 ip addr add dev $DEV 2601:646::2/64
-}
-
-function attach_bpf {
-	DEV=$1
-	SET_TUNNEL=$2
-	GET_TUNNEL=$3
-	ip netns exec at_ns2 tc qdisc add dev $DEV clsact
-	ip netns exec at_ns2 tc filter add dev $DEV egress bpf da obj tcbpf2_kern.o sec $SET_TUNNEL
-	ip netns exec at_ns2 tc filter add dev $DEV ingress bpf da obj tcbpf2_kern.o sec $GET_TUNNEL
-}
-
-function test_ipip {
-	DEV_NS=ipip_std
-	DEV=ipip_bpf
-	config_device
-#	tcpdump -nei br0 &
-	cat /sys/kernel/debug/tracing/trace_pipe &
-
-	add_ipip_tunnel
-	attach_bpf $DEV ipip_set_tunnel ipip_get_tunnel
-
-	ip netns exec at_ns0 ping -c 1 10.1.1.200
-	ip netns exec at_ns2 ping -c 1 10.1.1.100
-	ip netns exec at_ns0 iperf -sD -p 5200 > /dev/null
-	ip netns exec at_ns1 iperf -sD -p 5201 > /dev/null
-	sleep 0.2
-	# tcp check _same_ IP over different tunnels
-	ip netns exec at_ns2 iperf -c 10.1.1.100 -n 5k -p 5200
-	ip netns exec at_ns2 iperf -c 10.1.1.100 -n 5k -p 5201
-	cleanup
-}
-
-# IPv4 over IPv6 tunnel
-function test_ipip6 {
-	DEV_NS=ipip_std
-	DEV=ipip_bpf
-	config_device
-#	tcpdump -nei br0 &
-	cat /sys/kernel/debug/tracing/trace_pipe &
-
-	add_ipip6_tunnel
-	attach_bpf $DEV ipip6_set_tunnel ipip6_get_tunnel
-
-	ip netns exec at_ns0 ping -c 1 10.1.1.200
-	ip netns exec at_ns2 ping -c 1 10.1.1.100
-	ip netns exec at_ns0 iperf -sD -p 5200 > /dev/null
-	ip netns exec at_ns1 iperf -sD -p 5201 > /dev/null
-	sleep 0.2
-	# tcp check _same_ IP over different tunnels
-	ip netns exec at_ns2 iperf -c 10.1.1.100 -n 5k -p 5200
-	ip netns exec at_ns2 iperf -c 10.1.1.100 -n 5k -p 5201
-	cleanup
-}
-
-# IPv6 over IPv6 tunnel
-function test_ip6ip6 {
-	DEV_NS=ipip_std
-	DEV=ipip_bpf
-	config_device
-#	tcpdump -nei br0 &
-	cat /sys/kernel/debug/tracing/trace_pipe &
-
-	add_ip6ip6_tunnel
-	attach_bpf $DEV ip6ip6_set_tunnel ip6ip6_get_tunnel
-
-	ip netns exec at_ns0 ping -6 -c 1 2601:646::2
-	ip netns exec at_ns2 ping -6 -c 1 2601:646::1
-	ip netns exec at_ns0 iperf -6sD -p 5200 > /dev/null
-	ip netns exec at_ns1 iperf -6sD -p 5201 > /dev/null
-	sleep 0.2
-	# tcp check _same_ IP over different tunnels
-	ip netns exec at_ns2 iperf -6c 2601:646::1 -n 5k -p 5200
-	ip netns exec at_ns2 iperf -6c 2601:646::1 -n 5k -p 5201
-	cleanup
-}
-
-function cleanup {
-	set +ex
-	pkill iperf
-	ip netns delete at_ns0
-	ip netns delete at_ns1
-	ip netns delete at_ns2
-	ip link del veth0
-	ip link del veth1
-	ip link del veth2
-	ip link del br0
-	pkill tcpdump
-	pkill cat
-	set -ex
-}
-
-cleanup
-echo "Testing IP tunnels..."
-test_ipip
-test_ipip6
-test_ip6ip6
-echo "*** PASS ***"
-- 
2.25.4


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

* Re: [PATCHv3 bpf 0/2] Remove unused test_ipip.sh test and add missed ip6ip6 test
  2020-11-10  1:50   ` [PATCHv3 bpf " Hangbin Liu
  2020-11-10  1:50     ` [PATCHv3 bpf 1/2] selftest/bpf: add missed ip6ip6 test back Hangbin Liu
  2020-11-10  1:50     ` [PATCHv3 bpf 2/2] samples/bpf: remove unused test_ipip.sh Hangbin Liu
@ 2020-11-10 17:35     ` Martin KaFai Lau
  2020-11-11  0:56       ` Alexei Starovoitov
  2 siblings, 1 reply; 23+ messages in thread
From: Martin KaFai Lau @ 2020-11-10 17:35 UTC (permalink / raw)
  To: Hangbin Liu; +Cc: bpf, William Tu, Daniel Borkmann, netdev

On Tue, Nov 10, 2020 at 09:50:11AM +0800, Hangbin Liu wrote:
> In comment 173ca26e9b51 ("samples/bpf: add comprehensive ipip, ipip6,
> ip6ip6 test") we added some bpf tunnel tests. In commit 933a741e3b82
> ("selftests/bpf: bpf tunnel test.") when we moved it to the current
> folder, we missed some points:
> 
> 1. ip6ip6 test is not added
> 2. forgot to remove test_ipip.sh in sample folder
> 3. TCP test code is not removed in test_tunnel_kern.c
> 
> In this patch set I add back ip6ip6 test and remove unused code. I'm not sure
> if this should be net or net-next, so just set to net.
> 
> Here is the test result:
> ```
> Testing IP6IP6 tunnel...
> PING ::11(::11) 56 data bytes
> 
> --- ::11 ping statistics ---
> 3 packets transmitted, 3 received, 0% packet loss, time 63ms
> rtt min/avg/max/mdev = 0.014/1028.308/2060.906/841.361 ms, pipe 2
> PING 1::11(1::11) 56 data bytes
> 
> --- 1::11 ping statistics ---
> 3 packets transmitted, 3 received, 0% packet loss, time 48ms
> rtt min/avg/max/mdev = 0.026/0.029/0.036/0.006 ms
> PING 1::22(1::22) 56 data bytes
> 
> --- 1::22 ping statistics ---
> 3 packets transmitted, 3 received, 0% packet loss, time 47ms
> rtt min/avg/max/mdev = 0.030/0.048/0.067/0.016 ms
> PASS: ip6ip6tnl
> ```
> 
> v3:
> Add back ICMP check as Martin suggested.
> 
> v2: Keep ip6ip6 section in test_tunnel_kern.c.
This should be for bpf-next.

Acked-by: Martin KaFai Lau <kafai@fb.com>

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

* Re: [PATCHv3 bpf 0/2] Remove unused test_ipip.sh test and add missed ip6ip6 test
  2020-11-10 17:35     ` [PATCHv3 bpf 0/2] Remove unused test_ipip.sh test and add missed ip6ip6 test Martin KaFai Lau
@ 2020-11-11  0:56       ` Alexei Starovoitov
  0 siblings, 0 replies; 23+ messages in thread
From: Alexei Starovoitov @ 2020-11-11  0:56 UTC (permalink / raw)
  To: Martin KaFai Lau
  Cc: Hangbin Liu, bpf, William Tu, Daniel Borkmann, Network Development

On Tue, Nov 10, 2020 at 9:39 AM Martin KaFai Lau <kafai@fb.com> wrote:
>
> On Tue, Nov 10, 2020 at 09:50:11AM +0800, Hangbin Liu wrote:
> > In comment 173ca26e9b51 ("samples/bpf: add comprehensive ipip, ipip6,
> > ip6ip6 test") we added some bpf tunnel tests. In commit 933a741e3b82
> > ("selftests/bpf: bpf tunnel test.") when we moved it to the current
> > folder, we missed some points:
> >
> > 1. ip6ip6 test is not added
> > 2. forgot to remove test_ipip.sh in sample folder
> > 3. TCP test code is not removed in test_tunnel_kern.c
> >
> > In this patch set I add back ip6ip6 test and remove unused code. I'm not sure
> > if this should be net or net-next, so just set to net.
> >
> > Here is the test result:
> > ```
> > Testing IP6IP6 tunnel...
> > PING ::11(::11) 56 data bytes
> >
> > --- ::11 ping statistics ---
> > 3 packets transmitted, 3 received, 0% packet loss, time 63ms
> > rtt min/avg/max/mdev = 0.014/1028.308/2060.906/841.361 ms, pipe 2
> > PING 1::11(1::11) 56 data bytes
> >
> > --- 1::11 ping statistics ---
> > 3 packets transmitted, 3 received, 0% packet loss, time 48ms
> > rtt min/avg/max/mdev = 0.026/0.029/0.036/0.006 ms
> > PING 1::22(1::22) 56 data bytes
> >
> > --- 1::22 ping statistics ---
> > 3 packets transmitted, 3 received, 0% packet loss, time 47ms
> > rtt min/avg/max/mdev = 0.030/0.048/0.067/0.016 ms
> > PASS: ip6ip6tnl
> > ```
> >
> > v3:
> > Add back ICMP check as Martin suggested.
> >
> > v2: Keep ip6ip6 section in test_tunnel_kern.c.
> This should be for bpf-next.
>
> Acked-by: Martin KaFai Lau <kafai@fb.com>

git bot got lost.
the patches were applied.

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

end of thread, other threads:[~2020-11-11  0:56 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-03  4:29 [PATCH bpf-next 0/2] selftest/bpf: improve bpf tunnel test Hangbin Liu
2020-11-03  4:29 ` [PATCH bpf-next 1/2] selftest/bpf: add missed ip6ip6 test back Hangbin Liu
2020-11-04 18:40   ` Martin KaFai Lau
2020-11-05  3:20     ` Hangbin Liu
2020-11-03  4:29 ` [PATCH bpf-next 2/2] selftest/bpf: remove unused bpf tunnel testing code Hangbin Liu
2020-11-06  7:30   ` Martin KaFai Lau
2020-11-06  7:55     ` Hangbin Liu
2020-11-06  8:04       ` Hangbin Liu
2020-11-06  9:01 ` [PATCHv2 net 0/2] Remove unused test_ipip.sh test and add missed ip6ip6 test Hangbin Liu
2020-11-06  9:01   ` [PATCHv2 net 1/2] selftest/bpf: add missed ip6ip6 test back Hangbin Liu
2020-11-07  2:15     ` Martin KaFai Lau
2020-11-09  3:00       ` Hangbin Liu
2020-11-09 22:25         ` Martin KaFai Lau
2020-11-06  9:01   ` [PATCHv2 net 2/2] samples/bpf: remove unused test_ipip.sh Hangbin Liu
2020-11-07  2:16     ` Martin KaFai Lau
2020-11-06 18:56   ` [PATCHv2 net 0/2] Remove unused test_ipip.sh test and add missed ip6ip6 test Jakub Kicinski
2020-11-06 18:58     ` Alexei Starovoitov
2020-11-07  1:20     ` Hangbin Liu
2020-11-10  1:50   ` [PATCHv3 bpf " Hangbin Liu
2020-11-10  1:50     ` [PATCHv3 bpf 1/2] selftest/bpf: add missed ip6ip6 test back Hangbin Liu
2020-11-10  1:50     ` [PATCHv3 bpf 2/2] samples/bpf: remove unused test_ipip.sh Hangbin Liu
2020-11-10 17:35     ` [PATCHv3 bpf 0/2] Remove unused test_ipip.sh test and add missed ip6ip6 test Martin KaFai Lau
2020-11-11  0:56       ` Alexei Starovoitov

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).