Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/bpf: Amend test_tunnel to exercise BPF_F_TUNINFO_FLAGS

Get the tunnel flags in {ipv6}vxlan_get_tunnel_src and ensure they are
aligned with tunnel params set at {ipv6}vxlan_set_tunnel_dst.

Signed-off-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20220831144010.174110-2-shmulik.ladkani@gmail.com

authored by

Shmulik Ladkani and committed by
Daniel Borkmann
8cc61b7a 44c51472

+16 -8
+16 -8
tools/testing/selftests/bpf/progs/test_tunnel_kern.c
··· 12 12 #include <linux/bpf.h> 13 13 #include <linux/if_ether.h> 14 14 #include <linux/if_packet.h> 15 + #include <linux/if_tunnel.h> 15 16 #include <linux/ip.h> 16 17 #include <linux/ipv6.h> 17 18 #include <linux/icmp.h> ··· 387 386 __u32 orig_daddr; 388 387 __u32 index = 0; 389 388 390 - ret = bpf_skb_get_tunnel_key(skb, &key, sizeof(key), 0); 389 + ret = bpf_skb_get_tunnel_key(skb, &key, sizeof(key), 390 + BPF_F_TUNINFO_FLAGS); 391 391 if (ret < 0) { 392 392 log_err(ret); 393 393 return TC_ACT_SHOT; ··· 400 398 return TC_ACT_SHOT; 401 399 } 402 400 403 - if (key.local_ipv4 != ASSIGNED_ADDR_VETH1 || md.gbp != 0x800FF) { 404 - bpf_printk("vxlan key %d local ip 0x%x remote ip 0x%x gbp 0x%x\n", 401 + if (key.local_ipv4 != ASSIGNED_ADDR_VETH1 || md.gbp != 0x800FF || 402 + !(key.tunnel_flags & TUNNEL_KEY) || 403 + (key.tunnel_flags & TUNNEL_CSUM)) { 404 + bpf_printk("vxlan key %d local ip 0x%x remote ip 0x%x gbp 0x%x flags 0x%x\n", 405 405 key.tunnel_id, key.local_ipv4, 406 - key.remote_ipv4, md.gbp); 406 + key.remote_ipv4, md.gbp, 407 + bpf_ntohs(key.tunnel_flags)); 407 408 log_err(ret); 408 409 return TC_ACT_SHOT; 409 410 } ··· 546 541 } 547 542 548 543 ret = bpf_skb_get_tunnel_key(skb, &key, sizeof(key), 549 - BPF_F_TUNINFO_IPV6); 544 + BPF_F_TUNINFO_IPV6 | BPF_F_TUNINFO_FLAGS); 550 545 if (ret < 0) { 551 546 log_err(ret); 552 547 return TC_ACT_SHOT; 553 548 } 554 549 555 - if (bpf_ntohl(key.local_ipv6[3]) != *local_ip) { 556 - bpf_printk("ip6vxlan key %d local ip6 ::%x remote ip6 ::%x label 0x%x\n", 550 + if (bpf_ntohl(key.local_ipv6[3]) != *local_ip || 551 + !(key.tunnel_flags & TUNNEL_KEY) || 552 + !(key.tunnel_flags & TUNNEL_CSUM)) { 553 + bpf_printk("ip6vxlan key %d local ip6 ::%x remote ip6 ::%x label 0x%x flags 0x%x\n", 557 554 key.tunnel_id, bpf_ntohl(key.local_ipv6[3]), 558 - bpf_ntohl(key.remote_ipv6[3]), key.tunnel_label); 555 + bpf_ntohl(key.remote_ipv6[3]), key.tunnel_label, 556 + bpf_ntohs(key.tunnel_flags)); 559 557 bpf_printk("local_ip 0x%x\n", *local_ip); 560 558 log_err(ret); 561 559 return TC_ACT_SHOT;