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

selftests/bpf: Fix compilation failure when CONFIG_NET_FOU!=y

Without CONFIG_NET_FOU bpf selftests are unable to build because of
missing definitions. Add ___local versions of struct bpf_fou_encap and
enum bpf_fou_encap_type to fix the issue.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20240723071031.3389423-1-asavkov@redhat.com

authored by

Artem Savkov and committed by
Andrii Nakryiko
d17f9b37 a5f40d59

+21 -6
+21 -6
tools/testing/selftests/bpf/progs/test_tunnel_kern.c
··· 26 26 */ 27 27 #define ASSIGNED_ADDR_VETH1 0xac1001c8 28 28 29 + struct bpf_fou_encap___local { 30 + __be16 sport; 31 + __be16 dport; 32 + } __attribute__((preserve_access_index)); 33 + 34 + enum bpf_fou_encap_type___local { 35 + FOU_BPF_ENCAP_FOU___local, 36 + FOU_BPF_ENCAP_GUE___local, 37 + }; 38 + 39 + struct bpf_fou_encap; 40 + 29 41 int bpf_skb_set_fou_encap(struct __sk_buff *skb_ctx, 30 42 struct bpf_fou_encap *encap, int type) __ksym; 31 43 int bpf_skb_get_fou_encap(struct __sk_buff *skb_ctx, ··· 757 745 int ipip_gue_set_tunnel(struct __sk_buff *skb) 758 746 { 759 747 struct bpf_tunnel_key key = {}; 760 - struct bpf_fou_encap encap = {}; 748 + struct bpf_fou_encap___local encap = {}; 761 749 void *data = (void *)(long)skb->data; 762 750 struct iphdr *iph = data; 763 751 void *data_end = (void *)(long)skb->data_end; ··· 781 769 encap.sport = 0; 782 770 encap.dport = bpf_htons(5555); 783 771 784 - ret = bpf_skb_set_fou_encap(skb, &encap, FOU_BPF_ENCAP_GUE); 772 + ret = bpf_skb_set_fou_encap(skb, (struct bpf_fou_encap *)&encap, 773 + bpf_core_enum_value(enum bpf_fou_encap_type___local, 774 + FOU_BPF_ENCAP_GUE___local)); 785 775 if (ret < 0) { 786 776 log_err(ret); 787 777 return TC_ACT_SHOT; ··· 796 782 int ipip_fou_set_tunnel(struct __sk_buff *skb) 797 783 { 798 784 struct bpf_tunnel_key key = {}; 799 - struct bpf_fou_encap encap = {}; 785 + struct bpf_fou_encap___local encap = {}; 800 786 void *data = (void *)(long)skb->data; 801 787 struct iphdr *iph = data; 802 788 void *data_end = (void *)(long)skb->data_end; ··· 820 806 encap.sport = 0; 821 807 encap.dport = bpf_htons(5555); 822 808 823 - ret = bpf_skb_set_fou_encap(skb, &encap, FOU_BPF_ENCAP_FOU); 809 + ret = bpf_skb_set_fou_encap(skb, (struct bpf_fou_encap *)&encap, 810 + FOU_BPF_ENCAP_FOU___local); 824 811 if (ret < 0) { 825 812 log_err(ret); 826 813 return TC_ACT_SHOT; ··· 835 820 { 836 821 int ret; 837 822 struct bpf_tunnel_key key = {}; 838 - struct bpf_fou_encap encap = {}; 823 + struct bpf_fou_encap___local encap = {}; 839 824 840 825 ret = bpf_skb_get_tunnel_key(skb, &key, sizeof(key), 0); 841 826 if (ret < 0) { ··· 843 828 return TC_ACT_SHOT; 844 829 } 845 830 846 - ret = bpf_skb_get_fou_encap(skb, &encap); 831 + ret = bpf_skb_get_fou_encap(skb, (struct bpf_fou_encap *)&encap); 847 832 if (ret < 0) { 848 833 log_err(ret); 849 834 return TC_ACT_SHOT;