mbox series

[bpf-next,0/2] selftest/bpf: improve bpf tunnel test

Message ID 20201103042908.2825734-1-liuhangbin@gmail.com
Headers show
Series selftest/bpf: improve bpf tunnel test | expand

Message

Hangbin Liu Nov. 3, 2020, 4:29 a.m. UTC
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

Comments

Martin KaFai Lau Nov. 4, 2020, 6:40 p.m. UTC | #1
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}

> +}
Hangbin Liu Nov. 5, 2020, 3:20 a.m. UTC | #2
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
Jakub Kicinski Nov. 6, 2020, 6:56 p.m. UTC | #3
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.
Alexei Starovoitov Nov. 6, 2020, 6:58 p.m. UTC | #4
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.
Hangbin Liu Nov. 7, 2020, 1:20 a.m. UTC | #5
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
Martin KaFai Lau Nov. 7, 2020, 2:16 a.m. UTC | #6
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>