Skip to content

Commit

Permalink
samples/bpf: add gre sequence number test.
Browse files Browse the repository at this point in the history
The patch adds tests for GRE sequence number
support for metadata mode tunnel.

Signed-off-by: William Tu <[email protected]>
Acked-by: Daniel Borkmann <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
williamtu authored and davem330 committed Mar 4, 2018
1 parent 77a5196 commit 5f280b6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions samples/bpf/tcbpf2_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ int _gre_set_tunnel(struct __sk_buff *skb)
key.tunnel_tos = 0;
key.tunnel_ttl = 64;

ret = bpf_skb_set_tunnel_key(skb, &key, sizeof(key), BPF_F_ZERO_CSUM_TX);
ret = bpf_skb_set_tunnel_key(skb, &key, sizeof(key),
BPF_F_ZERO_CSUM_TX | BPF_F_SEQ_NUMBER);
if (ret < 0) {
ERROR(ret);
return TC_ACT_SHOT;
Expand Down Expand Up @@ -92,7 +93,8 @@ int _ip6gretap_set_tunnel(struct __sk_buff *skb)
key.tunnel_label = 0xabcde;

ret = bpf_skb_set_tunnel_key(skb, &key, sizeof(key),
BPF_F_TUNINFO_IPV6 | BPF_F_ZERO_CSUM_TX);
BPF_F_TUNINFO_IPV6 | BPF_F_ZERO_CSUM_TX |
BPF_F_SEQ_NUMBER);
if (ret < 0) {
ERROR(ret);
return TC_ACT_SHOT;
Expand Down
5 changes: 3 additions & 2 deletions samples/bpf/test_tunnel_bpf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ function config_device {
function add_gre_tunnel {
# in namespace
ip netns exec at_ns0 \
ip link add dev $DEV_NS type $TYPE key 2 local 172.16.1.100 remote 172.16.1.200
ip link add dev $DEV_NS type $TYPE seq key 2 \
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

Expand All @@ -43,7 +44,7 @@ function add_ip6gretap_tunnel {

# in namespace
ip netns exec at_ns0 \
ip link add dev $DEV_NS type $TYPE flowlabel 0xbcdef key 2 \
ip link add dev $DEV_NS type $TYPE seq flowlabel 0xbcdef key 2 \
local ::11 remote ::22

ip netns exec at_ns0 ip addr add dev $DEV_NS 10.1.1.100/24
Expand Down

0 comments on commit 5f280b6

Please sign in to comment.