On Mon, Apr 03, 2023 at 02:12:09PM +0200, Christian Ehrig wrote:
+SEC("tc") +int ipip_encap_get_tunnel(struct __sk_buff *skb) +{
- int ret;
- struct bpf_tunnel_key key = {};
- struct bpf_fou_encap encap = {};
- ret = bpf_skb_get_tunnel_key(skb, &key, sizeof(key), 0);
- if (ret < 0) {
log_err(ret);
return TC_ACT_SHOT;
- }
- ret = bpf_skb_get_fou_encap(skb, &encap);
- if (ret < 0) {
log_err(ret);
return TC_ACT_SHOT;
- }
- if (bpf_ntohs(encap.dport) != 5555)
return TC_ACT_SHOT;
- bpf_printk("%d remote ip 0x%x, sport %d, dport %d\n", ret,
key.remote_ipv4, bpf_ntohs(encap.sport),
bpf_ntohs(encap.dport));
- return TC_ACT_OK;
+}
SEC("tc") int ipip6_set_tunnel(struct __sk_buff *skb) { diff --git a/tools/testing/selftests/bpf/test_tunnel.sh b/tools/testing/selftests/bpf/test_tunnel.sh index 2dec7dbf29a2..f2379414a887 100755 --- a/tools/testing/selftests/bpf/test_tunnel.sh +++ b/tools/testing/selftests/bpf/test_tunnel.sh
All looks good to me, but please integrate the selftest into test_progs. test_tunnel is obsolete. BPF CI doesn't run it and maintainers don't do either.