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

selftests/bpf: Remove SEC("version") from test progs

Since commit 6c4fc209fcf9d ("bpf: remove useless version check for prog
load") these "version" sections, which result in bpf_attr.kern_version
being set, have been unnecessary.

Remove them so that it's obvious to folks using selftests as a guide that
"modern" BPF progs don't need this section.

Signed-off-by: Dave Marchevsky <davemarchevsky@fb.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211007231234.2223081-1-davemarchevsky@fb.com

authored by

Dave Marchevsky and committed by
Andrii Nakryiko
dd65acf7 aa67fdb4

-61
-1
tools/testing/selftests/bpf/progs/cgroup_skb_sk_lookup_kern.c
··· 14 14 #include <sys/types.h> 15 15 #include <sys/socket.h> 16 16 17 - int _version SEC("version") = 1; 18 17 char _license[] SEC("license") = "GPL"; 19 18 20 19 __u16 g_serv_port = 0;
-2
tools/testing/selftests/bpf/progs/connect4_prog.c
··· 31 31 #define IFNAMSIZ 16 32 32 #endif 33 33 34 - int _version SEC("version") = 1; 35 - 36 34 __attribute__ ((noinline)) 37 35 int do_bind(struct bpf_sock_addr *ctx) 38 36 {
-2
tools/testing/selftests/bpf/progs/connect6_prog.c
··· 24 24 25 25 #define DST_REWRITE_PORT6 6666 26 26 27 - int _version SEC("version") = 1; 28 - 29 27 SEC("cgroup/connect6") 30 28 int connect_v6_prog(struct bpf_sock_addr *ctx) 31 29 {
-1
tools/testing/selftests/bpf/progs/connect_force_port4.c
··· 13 13 #include <bpf_sockopt_helpers.h> 14 14 15 15 char _license[] SEC("license") = "GPL"; 16 - int _version SEC("version") = 1; 17 16 18 17 struct svc_addr { 19 18 __be32 addr;
-1
tools/testing/selftests/bpf/progs/connect_force_port6.c
··· 12 12 #include <bpf_sockopt_helpers.h> 13 13 14 14 char _license[] SEC("license") = "GPL"; 15 - int _version SEC("version") = 1; 16 15 17 16 struct svc_addr { 18 17 __be32 addr[4];
-1
tools/testing/selftests/bpf/progs/dev_cgroup.c
··· 57 57 } 58 58 59 59 char _license[] SEC("license") = "GPL"; 60 - __u32 _version SEC("version") = LINUX_VERSION_CODE;
-1
tools/testing/selftests/bpf/progs/get_cgroup_id_kern.c
··· 37 37 } 38 38 39 39 char _license[] SEC("license") = "GPL"; 40 - __u32 _version SEC("version") = 1; /* ignored by tracepoints, required by libbpf.a */
-1
tools/testing/selftests/bpf/progs/map_ptr_kern.c
··· 683 683 return 1; 684 684 } 685 685 686 - __u32 _version SEC("version") = 1; 687 686 char _license[] SEC("license") = "GPL";
-1
tools/testing/selftests/bpf/progs/netcnt_prog.c
··· 68 68 } 69 69 70 70 char _license[] SEC("license") = "GPL"; 71 - __u32 _version SEC("version") = LINUX_VERSION_CODE;
-2
tools/testing/selftests/bpf/progs/sendmsg4_prog.c
··· 18 18 #define DST_PORT 4040 19 19 #define DST_REWRITE_PORT4 4444 20 20 21 - int _version SEC("version") = 1; 22 - 23 21 SEC("cgroup/sendmsg4") 24 22 int sendmsg_v4_prog(struct bpf_sock_addr *ctx) 25 23 {
-2
tools/testing/selftests/bpf/progs/sendmsg6_prog.c
··· 22 22 23 23 #define DST_REWRITE_PORT6 6666 24 24 25 - int _version SEC("version") = 1; 26 - 27 25 SEC("cgroup/sendmsg6") 28 26 int sendmsg_v6_prog(struct bpf_sock_addr *ctx) 29 27 {
-2
tools/testing/selftests/bpf/progs/sockmap_parse_prog.c
··· 2 2 #include <bpf/bpf_helpers.h> 3 3 #include <bpf/bpf_endian.h> 4 4 5 - int _version SEC("version") = 1; 6 - 7 5 SEC("sk_skb1") 8 6 int bpf_prog1(struct __sk_buff *skb) 9 7 {
-2
tools/testing/selftests/bpf/progs/sockmap_tcp_msg_prog.c
··· 3 3 #include <bpf/bpf_helpers.h> 4 4 #include <bpf/bpf_endian.h> 5 5 6 - int _version SEC("version") = 1; 7 - 8 6 SEC("sk_msg1") 9 7 int bpf_prog1(struct sk_msg_md *msg) 10 8 {
-2
tools/testing/selftests/bpf/progs/sockmap_verdict_prog.c
··· 2 2 #include <bpf/bpf_helpers.h> 3 3 #include <bpf/bpf_endian.h> 4 4 5 - int _version SEC("version") = 1; 6 - 7 5 struct { 8 6 __uint(type, BPF_MAP_TYPE_SOCKMAP); 9 7 __uint(max_entries, 20);
-1
tools/testing/selftests/bpf/progs/sockopt_inherit.c
··· 3 3 #include <bpf/bpf_helpers.h> 4 4 5 5 char _license[] SEC("license") = "GPL"; 6 - __u32 _version SEC("version") = 1; 7 6 8 7 #define SOL_CUSTOM 0xdeadbeef 9 8 #define CUSTOM_INHERIT1 0
-1
tools/testing/selftests/bpf/progs/tcp_rtt.c
··· 3 3 #include <bpf/bpf_helpers.h> 4 4 5 5 char _license[] SEC("license") = "GPL"; 6 - __u32 _version SEC("version") = 1; 7 6 8 7 struct tcp_rtt_storage { 9 8 __u32 invoked;
-2
tools/testing/selftests/bpf/progs/test_btf_haskv.c
··· 4 4 #include <bpf/bpf_helpers.h> 5 5 #include "bpf_legacy.h" 6 6 7 - int _version SEC("version") = 1; 8 - 9 7 struct ipv_counts { 10 8 unsigned int v4; 11 9 unsigned int v6;
-2
tools/testing/selftests/bpf/progs/test_btf_newkv.c
··· 4 4 #include <bpf/bpf_helpers.h> 5 5 #include "bpf_legacy.h" 6 6 7 - int _version SEC("version") = 1; 8 - 9 7 struct ipv_counts { 10 8 unsigned int v4; 11 9 unsigned int v6;
-2
tools/testing/selftests/bpf/progs/test_btf_nokv.c
··· 3 3 #include <linux/bpf.h> 4 4 #include <bpf/bpf_helpers.h> 5 5 6 - int _version SEC("version") = 1; 7 - 8 6 struct ipv_counts { 9 7 unsigned int v4; 10 8 unsigned int v6;
-2
tools/testing/selftests/bpf/progs/test_l4lb.c
··· 21 21 #include "test_iptunnel_common.h" 22 22 #include <bpf/bpf_endian.h> 23 23 24 - int _version SEC("version") = 1; 25 - 26 24 static inline __u32 rol32(__u32 word, unsigned int shift) 27 25 { 28 26 return (word << shift) | (word >> ((-shift) & 31));
-1
tools/testing/selftests/bpf/progs/test_map_in_map.c
··· 47 47 return XDP_PASS; 48 48 } 49 49 50 - int _version SEC("version") = 1; 51 50 char _license[] SEC("license") = "GPL";
-2
tools/testing/selftests/bpf/progs/test_pinning.c
··· 3 3 #include <linux/bpf.h> 4 4 #include <bpf/bpf_helpers.h> 5 5 6 - int _version SEC("version") = 1; 7 - 8 6 struct { 9 7 __uint(type, BPF_MAP_TYPE_ARRAY); 10 8 __uint(max_entries, 1);
-2
tools/testing/selftests/bpf/progs/test_pinning_invalid.c
··· 3 3 #include <linux/bpf.h> 4 4 #include <bpf/bpf_helpers.h> 5 5 6 - int _version SEC("version") = 1; 7 - 8 6 struct { 9 7 __uint(type, BPF_MAP_TYPE_ARRAY); 10 8 __uint(max_entries, 1);
-1
tools/testing/selftests/bpf/progs/test_pkt_access.c
··· 15 15 #include <bpf/bpf_endian.h> 16 16 17 17 #define barrier() __asm__ __volatile__("": : :"memory") 18 - int _version SEC("version") = 1; 19 18 20 19 /* llvm will optimize both subprograms into exactly the same BPF assembly 21 20 *
-2
tools/testing/selftests/bpf/progs/test_queue_stack_map.h
··· 8 8 #include <linux/pkt_cls.h> 9 9 #include <bpf/bpf_helpers.h> 10 10 11 - int _version SEC("version") = 1; 12 - 13 11 struct { 14 12 __uint(type, MAP_TYPE); 15 13 __uint(max_entries, 32);
-2
tools/testing/selftests/bpf/progs/test_select_reuseport_kern.c
··· 15 15 #include <bpf/bpf_helpers.h> 16 16 #include "test_select_reuseport_common.h" 17 17 18 - int _version SEC("version") = 1; 19 - 20 18 #ifndef offsetof 21 19 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) 22 20 #endif
-1
tools/testing/selftests/bpf/progs/test_sk_lookup.c
··· 644 644 } 645 645 646 646 char _license[] SEC("license") = "Dual BSD/GPL"; 647 - __u32 _version SEC("version") = 1;
-2
tools/testing/selftests/bpf/progs/test_skb_cgroup_id_kern.c
··· 42 42 return TC_ACT_OK; 43 43 } 44 44 45 - int _version SEC("version") = 1; 46 - 47 45 char _license[] SEC("license") = "GPL";
-1
tools/testing/selftests/bpf/progs/test_skb_ctx.c
··· 3 3 #include <linux/bpf.h> 4 4 #include <bpf/bpf_helpers.h> 5 5 6 - int _version SEC("version") = 1; 7 6 char _license[] SEC("license") = "GPL"; 8 7 9 8 SEC("skb_ctx")
-1
tools/testing/selftests/bpf/progs/test_sockmap_kern.h
··· 361 361 return SK_DROP; 362 362 } 363 363 364 - int _version SEC("version") = 1; 365 364 char _license[] SEC("license") = "GPL";
-1
tools/testing/selftests/bpf/progs/test_sockmap_listen.c
··· 116 116 return verdict; 117 117 } 118 118 119 - int _version SEC("version") = 1; 120 119 char _license[] SEC("license") = "GPL";
-1
tools/testing/selftests/bpf/progs/test_stacktrace_build_id.c
··· 73 73 } 74 74 75 75 char _license[] SEC("license") = "GPL"; 76 - __u32 _version SEC("version") = 1; /* ignored by tracepoints, required by libbpf.a */
-1
tools/testing/selftests/bpf/progs/test_tcp_estats.c
··· 255 255 } 256 256 257 257 char _license[] SEC("license") = "GPL"; 258 - __u32 _version SEC("version") = 1; /* ignored by tracepoints, required by libbpf.a */
-1
tools/testing/selftests/bpf/progs/test_tcpbpf_kern.c
··· 16 16 #include "test_tcpbpf.h" 17 17 18 18 struct tcpbpf_globals global = {}; 19 - int _version SEC("version") = 1; 20 19 21 20 /** 22 21 * SOL_TCP is defined in <netinet/tcp.h> while
-2
tools/testing/selftests/bpf/progs/test_tcpnotify_kern.c
··· 28 28 __type(value, __u32); 29 29 } perf_event_map SEC(".maps"); 30 30 31 - int _version SEC("version") = 1; 32 - 33 31 SEC("sockops") 34 32 int bpf_testcb(struct bpf_sock_ops *skops) 35 33 {
-1
tools/testing/selftests/bpf/progs/test_tracepoint.c
··· 23 23 } 24 24 25 25 char _license[] SEC("license") = "GPL"; 26 - __u32 _version SEC("version") = 1; /* ignored by tracepoints, required by libbpf.a */
-2
tools/testing/selftests/bpf/progs/test_tunnel_kern.c
··· 26 26 bpf_trace_printk(fmt, sizeof(fmt), __LINE__, ret); \ 27 27 } while (0) 28 28 29 - int _version SEC("version") = 1; 30 - 31 29 struct geneve_opt { 32 30 __be16 opt_class; 33 31 __u8 type;
-2
tools/testing/selftests/bpf/progs/test_xdp.c
··· 20 20 #include <bpf/bpf_endian.h> 21 21 #include "test_iptunnel_common.h" 22 22 23 - int _version SEC("version") = 1; 24 - 25 23 struct { 26 24 __uint(type, BPF_MAP_TYPE_PERCPU_ARRAY); 27 25 __uint(max_entries, 256);
-2
tools/testing/selftests/bpf/progs/test_xdp_loop.c
··· 16 16 #include <bpf/bpf_endian.h> 17 17 #include "test_iptunnel_common.h" 18 18 19 - int _version SEC("version") = 1; 20 - 21 19 struct { 22 20 __uint(type, BPF_MAP_TYPE_PERCPU_ARRAY); 23 21 __uint(max_entries, 256);
-2
tools/testing/selftests/bpf/progs/test_xdp_redirect.c
··· 12 12 #include <linux/bpf.h> 13 13 #include <bpf/bpf_helpers.h> 14 14 15 - int _version SEC("version") = 1; 16 - 17 15 SEC("redirect_to_111") 18 16 int xdp_redirect_to_111(struct xdp_md *xdp) 19 17 {