Skip to content

Commit

Permalink
selftests/bpf: convert bpf tunnel test to encap modes
Browse files Browse the repository at this point in the history
Make the tests correctly annotate skbs with tunnel metadata.

This makes the gso tests succeed. Enable them.

Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
  • Loading branch information
Willem de Bruijn authored and Alexei Starovoitov committed Mar 22, 2019
1 parent 94f1681 commit 75a1a9f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
19 changes: 15 additions & 4 deletions tools/testing/selftests/bpf/progs/test_tc_tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,13 @@ static __always_inline int encap_ipv4(struct __sk_buff *skb, bool with_gre)
if (tcph.dest != __bpf_constant_htons(cfg_port))
return TC_ACT_OK;

flags = BPF_F_ADJ_ROOM_FIXED_GSO;
olen = with_gre ? sizeof(h_outer) : sizeof(h_outer.ip);
flags = BPF_F_ADJ_ROOM_FIXED_GSO | BPF_F_ADJ_ROOM_ENCAP_L3_IPV4;
if (with_gre) {
flags |= BPF_F_ADJ_ROOM_ENCAP_L4_GRE;
olen = sizeof(h_outer);
} else {
olen = sizeof(h_outer.ip);
}

/* add room between mac and network header */
if (bpf_skb_adjust_room(skb, olen, BPF_ADJ_ROOM_MAC, flags))
Expand Down Expand Up @@ -119,8 +124,14 @@ static __always_inline int encap_ipv6(struct __sk_buff *skb, bool with_gre)
if (tcph.dest != __bpf_constant_htons(cfg_port))
return TC_ACT_OK;

flags = BPF_F_ADJ_ROOM_FIXED_GSO;
olen = with_gre ? sizeof(h_outer) : sizeof(h_outer.ip);
flags = BPF_F_ADJ_ROOM_FIXED_GSO | BPF_F_ADJ_ROOM_ENCAP_L3_IPV6;
if (with_gre) {
flags |= BPF_F_ADJ_ROOM_ENCAP_L4_GRE;
olen = sizeof(h_outer);
} else {
olen = sizeof(h_outer.ip);
}


/* add room between mac and network header */
if (bpf_skb_adjust_room(skb, olen, BPF_ADJ_ROOM_MAC, flags))
Expand Down
10 changes: 4 additions & 6 deletions tools/testing/selftests/bpf/test_tc_tunnel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,11 @@ if [[ "$#" -eq "0" ]]; then
echo "ip6 gre"
$0 ipv6 ip6gre 100

# disabled until passes SKB_GSO_DODGY checks
# echo "ip gre gso"
# $0 ipv4 gre 2000
echo "ip gre gso"
$0 ipv4 gre 2000

# disabled until passes SKB_GSO_DODGY checks
# echo "ip6 gre gso"
# $0 ipv6 ip6gre 2000
echo "ip6 gre gso"
$0 ipv6 ip6gre 2000

echo "OK. All tests passed"
exit 0
Expand Down

0 comments on commit 75a1a9f

Please sign in to comment.