Commit dd65acf7 authored by Dave Marchevsky's avatar Dave Marchevsky Committed by Andrii Nakryiko

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

Since commit 6c4fc209 ("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: default avatarDave Marchevsky <davemarchevsky@fb.com>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211007231234.2223081-1-davemarchevsky@fb.com
parent aa67fdb4
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
int _version SEC("version") = 1;
char _license[] SEC("license") = "GPL"; char _license[] SEC("license") = "GPL";
__u16 g_serv_port = 0; __u16 g_serv_port = 0;
......
...@@ -31,8 +31,6 @@ ...@@ -31,8 +31,6 @@
#define IFNAMSIZ 16 #define IFNAMSIZ 16
#endif #endif
int _version SEC("version") = 1;
__attribute__ ((noinline)) __attribute__ ((noinline))
int do_bind(struct bpf_sock_addr *ctx) int do_bind(struct bpf_sock_addr *ctx)
{ {
......
...@@ -24,8 +24,6 @@ ...@@ -24,8 +24,6 @@
#define DST_REWRITE_PORT6 6666 #define DST_REWRITE_PORT6 6666
int _version SEC("version") = 1;
SEC("cgroup/connect6") SEC("cgroup/connect6")
int connect_v6_prog(struct bpf_sock_addr *ctx) int connect_v6_prog(struct bpf_sock_addr *ctx)
{ {
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include <bpf_sockopt_helpers.h> #include <bpf_sockopt_helpers.h>
char _license[] SEC("license") = "GPL"; char _license[] SEC("license") = "GPL";
int _version SEC("version") = 1;
struct svc_addr { struct svc_addr {
__be32 addr; __be32 addr;
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include <bpf_sockopt_helpers.h> #include <bpf_sockopt_helpers.h>
char _license[] SEC("license") = "GPL"; char _license[] SEC("license") = "GPL";
int _version SEC("version") = 1;
struct svc_addr { struct svc_addr {
__be32 addr[4]; __be32 addr[4];
......
...@@ -57,4 +57,3 @@ int bpf_prog1(struct bpf_cgroup_dev_ctx *ctx) ...@@ -57,4 +57,3 @@ int bpf_prog1(struct bpf_cgroup_dev_ctx *ctx)
} }
char _license[] SEC("license") = "GPL"; char _license[] SEC("license") = "GPL";
__u32 _version SEC("version") = LINUX_VERSION_CODE;
...@@ -37,4 +37,3 @@ int trace(void *ctx) ...@@ -37,4 +37,3 @@ int trace(void *ctx)
} }
char _license[] SEC("license") = "GPL"; char _license[] SEC("license") = "GPL";
__u32 _version SEC("version") = 1; /* ignored by tracepoints, required by libbpf.a */
...@@ -683,5 +683,4 @@ int cg_skb(void *ctx) ...@@ -683,5 +683,4 @@ int cg_skb(void *ctx)
return 1; return 1;
} }
__u32 _version SEC("version") = 1;
char _license[] SEC("license") = "GPL"; char _license[] SEC("license") = "GPL";
...@@ -68,4 +68,3 @@ int bpf_nextcnt(struct __sk_buff *skb) ...@@ -68,4 +68,3 @@ int bpf_nextcnt(struct __sk_buff *skb)
} }
char _license[] SEC("license") = "GPL"; char _license[] SEC("license") = "GPL";
__u32 _version SEC("version") = LINUX_VERSION_CODE;
...@@ -18,8 +18,6 @@ ...@@ -18,8 +18,6 @@
#define DST_PORT 4040 #define DST_PORT 4040
#define DST_REWRITE_PORT4 4444 #define DST_REWRITE_PORT4 4444
int _version SEC("version") = 1;
SEC("cgroup/sendmsg4") SEC("cgroup/sendmsg4")
int sendmsg_v4_prog(struct bpf_sock_addr *ctx) int sendmsg_v4_prog(struct bpf_sock_addr *ctx)
{ {
......
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
#define DST_REWRITE_PORT6 6666 #define DST_REWRITE_PORT6 6666
int _version SEC("version") = 1;
SEC("cgroup/sendmsg6") SEC("cgroup/sendmsg6")
int sendmsg_v6_prog(struct bpf_sock_addr *ctx) int sendmsg_v6_prog(struct bpf_sock_addr *ctx)
{ {
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
#include <bpf/bpf_helpers.h> #include <bpf/bpf_helpers.h>
#include <bpf/bpf_endian.h> #include <bpf/bpf_endian.h>
int _version SEC("version") = 1;
SEC("sk_skb1") SEC("sk_skb1")
int bpf_prog1(struct __sk_buff *skb) int bpf_prog1(struct __sk_buff *skb)
{ {
......
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
#include <bpf/bpf_helpers.h> #include <bpf/bpf_helpers.h>
#include <bpf/bpf_endian.h> #include <bpf/bpf_endian.h>
int _version SEC("version") = 1;
SEC("sk_msg1") SEC("sk_msg1")
int bpf_prog1(struct sk_msg_md *msg) int bpf_prog1(struct sk_msg_md *msg)
{ {
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
#include <bpf/bpf_helpers.h> #include <bpf/bpf_helpers.h>
#include <bpf/bpf_endian.h> #include <bpf/bpf_endian.h>
int _version SEC("version") = 1;
struct { struct {
__uint(type, BPF_MAP_TYPE_SOCKMAP); __uint(type, BPF_MAP_TYPE_SOCKMAP);
__uint(max_entries, 20); __uint(max_entries, 20);
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include <bpf/bpf_helpers.h> #include <bpf/bpf_helpers.h>
char _license[] SEC("license") = "GPL"; char _license[] SEC("license") = "GPL";
__u32 _version SEC("version") = 1;
#define SOL_CUSTOM 0xdeadbeef #define SOL_CUSTOM 0xdeadbeef
#define CUSTOM_INHERIT1 0 #define CUSTOM_INHERIT1 0
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include <bpf/bpf_helpers.h> #include <bpf/bpf_helpers.h>
char _license[] SEC("license") = "GPL"; char _license[] SEC("license") = "GPL";
__u32 _version SEC("version") = 1;
struct tcp_rtt_storage { struct tcp_rtt_storage {
__u32 invoked; __u32 invoked;
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
#include <bpf/bpf_helpers.h> #include <bpf/bpf_helpers.h>
#include "bpf_legacy.h" #include "bpf_legacy.h"
int _version SEC("version") = 1;
struct ipv_counts { struct ipv_counts {
unsigned int v4; unsigned int v4;
unsigned int v6; unsigned int v6;
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
#include <bpf/bpf_helpers.h> #include <bpf/bpf_helpers.h>
#include "bpf_legacy.h" #include "bpf_legacy.h"
int _version SEC("version") = 1;
struct ipv_counts { struct ipv_counts {
unsigned int v4; unsigned int v4;
unsigned int v6; unsigned int v6;
......
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
#include <linux/bpf.h> #include <linux/bpf.h>
#include <bpf/bpf_helpers.h> #include <bpf/bpf_helpers.h>
int _version SEC("version") = 1;
struct ipv_counts { struct ipv_counts {
unsigned int v4; unsigned int v4;
unsigned int v6; unsigned int v6;
......
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
#include "test_iptunnel_common.h" #include "test_iptunnel_common.h"
#include <bpf/bpf_endian.h> #include <bpf/bpf_endian.h>
int _version SEC("version") = 1;
static inline __u32 rol32(__u32 word, unsigned int shift) static inline __u32 rol32(__u32 word, unsigned int shift)
{ {
return (word << shift) | (word >> ((-shift) & 31)); return (word << shift) | (word >> ((-shift) & 31));
......
...@@ -47,5 +47,4 @@ int xdp_mimtest0(struct xdp_md *ctx) ...@@ -47,5 +47,4 @@ int xdp_mimtest0(struct xdp_md *ctx)
return XDP_PASS; return XDP_PASS;
} }
int _version SEC("version") = 1;
char _license[] SEC("license") = "GPL"; char _license[] SEC("license") = "GPL";
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
#include <linux/bpf.h> #include <linux/bpf.h>
#include <bpf/bpf_helpers.h> #include <bpf/bpf_helpers.h>
int _version SEC("version") = 1;
struct { struct {
__uint(type, BPF_MAP_TYPE_ARRAY); __uint(type, BPF_MAP_TYPE_ARRAY);
__uint(max_entries, 1); __uint(max_entries, 1);
......
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
#include <linux/bpf.h> #include <linux/bpf.h>
#include <bpf/bpf_helpers.h> #include <bpf/bpf_helpers.h>
int _version SEC("version") = 1;
struct { struct {
__uint(type, BPF_MAP_TYPE_ARRAY); __uint(type, BPF_MAP_TYPE_ARRAY);
__uint(max_entries, 1); __uint(max_entries, 1);
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include <bpf/bpf_endian.h> #include <bpf/bpf_endian.h>
#define barrier() __asm__ __volatile__("": : :"memory") #define barrier() __asm__ __volatile__("": : :"memory")
int _version SEC("version") = 1;
/* llvm will optimize both subprograms into exactly the same BPF assembly /* llvm will optimize both subprograms into exactly the same BPF assembly
* *
......
...@@ -8,8 +8,6 @@ ...@@ -8,8 +8,6 @@
#include <linux/pkt_cls.h> #include <linux/pkt_cls.h>
#include <bpf/bpf_helpers.h> #include <bpf/bpf_helpers.h>
int _version SEC("version") = 1;
struct { struct {
__uint(type, MAP_TYPE); __uint(type, MAP_TYPE);
__uint(max_entries, 32); __uint(max_entries, 32);
......
...@@ -15,8 +15,6 @@ ...@@ -15,8 +15,6 @@
#include <bpf/bpf_helpers.h> #include <bpf/bpf_helpers.h>
#include "test_select_reuseport_common.h" #include "test_select_reuseport_common.h"
int _version SEC("version") = 1;
#ifndef offsetof #ifndef offsetof
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif #endif
......
...@@ -644,4 +644,3 @@ int multi_prog_redir2(struct bpf_sk_lookup *ctx) ...@@ -644,4 +644,3 @@ int multi_prog_redir2(struct bpf_sk_lookup *ctx)
} }
char _license[] SEC("license") = "Dual BSD/GPL"; char _license[] SEC("license") = "Dual BSD/GPL";
__u32 _version SEC("version") = 1;
...@@ -42,6 +42,4 @@ int log_cgroup_id(struct __sk_buff *skb) ...@@ -42,6 +42,4 @@ int log_cgroup_id(struct __sk_buff *skb)
return TC_ACT_OK; return TC_ACT_OK;
} }
int _version SEC("version") = 1;
char _license[] SEC("license") = "GPL"; char _license[] SEC("license") = "GPL";
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include <linux/bpf.h> #include <linux/bpf.h>
#include <bpf/bpf_helpers.h> #include <bpf/bpf_helpers.h>
int _version SEC("version") = 1;
char _license[] SEC("license") = "GPL"; char _license[] SEC("license") = "GPL";
SEC("skb_ctx") SEC("skb_ctx")
......
...@@ -361,5 +361,4 @@ int bpf_prog10(struct sk_msg_md *msg) ...@@ -361,5 +361,4 @@ int bpf_prog10(struct sk_msg_md *msg)
return SK_DROP; return SK_DROP;
} }
int _version SEC("version") = 1;
char _license[] SEC("license") = "GPL"; char _license[] SEC("license") = "GPL";
...@@ -116,5 +116,4 @@ int prog_reuseport(struct sk_reuseport_md *reuse) ...@@ -116,5 +116,4 @@ int prog_reuseport(struct sk_reuseport_md *reuse)
return verdict; return verdict;
} }
int _version SEC("version") = 1;
char _license[] SEC("license") = "GPL"; char _license[] SEC("license") = "GPL";
...@@ -73,4 +73,3 @@ int oncpu(struct random_urandom_args *args) ...@@ -73,4 +73,3 @@ int oncpu(struct random_urandom_args *args)
} }
char _license[] SEC("license") = "GPL"; char _license[] SEC("license") = "GPL";
__u32 _version SEC("version") = 1; /* ignored by tracepoints, required by libbpf.a */
...@@ -255,4 +255,3 @@ int _dummy_tracepoint(struct dummy_tracepoint_args *arg) ...@@ -255,4 +255,3 @@ int _dummy_tracepoint(struct dummy_tracepoint_args *arg)
} }
char _license[] SEC("license") = "GPL"; char _license[] SEC("license") = "GPL";
__u32 _version SEC("version") = 1; /* ignored by tracepoints, required by libbpf.a */
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "test_tcpbpf.h" #include "test_tcpbpf.h"
struct tcpbpf_globals global = {}; struct tcpbpf_globals global = {};
int _version SEC("version") = 1;
/** /**
* SOL_TCP is defined in <netinet/tcp.h> while * SOL_TCP is defined in <netinet/tcp.h> while
......
...@@ -28,8 +28,6 @@ struct { ...@@ -28,8 +28,6 @@ struct {
__type(value, __u32); __type(value, __u32);
} perf_event_map SEC(".maps"); } perf_event_map SEC(".maps");
int _version SEC("version") = 1;
SEC("sockops") SEC("sockops")
int bpf_testcb(struct bpf_sock_ops *skops) int bpf_testcb(struct bpf_sock_ops *skops)
{ {
......
...@@ -23,4 +23,3 @@ int oncpu(struct sched_switch_args *ctx) ...@@ -23,4 +23,3 @@ int oncpu(struct sched_switch_args *ctx)
} }
char _license[] SEC("license") = "GPL"; char _license[] SEC("license") = "GPL";
__u32 _version SEC("version") = 1; /* ignored by tracepoints, required by libbpf.a */
...@@ -26,8 +26,6 @@ ...@@ -26,8 +26,6 @@
bpf_trace_printk(fmt, sizeof(fmt), __LINE__, ret); \ bpf_trace_printk(fmt, sizeof(fmt), __LINE__, ret); \
} while (0) } while (0)
int _version SEC("version") = 1;
struct geneve_opt { struct geneve_opt {
__be16 opt_class; __be16 opt_class;
__u8 type; __u8 type;
......
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
#include <bpf/bpf_endian.h> #include <bpf/bpf_endian.h>
#include "test_iptunnel_common.h" #include "test_iptunnel_common.h"
int _version SEC("version") = 1;
struct { struct {
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY); __uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
__uint(max_entries, 256); __uint(max_entries, 256);
......
...@@ -16,8 +16,6 @@ ...@@ -16,8 +16,6 @@
#include <bpf/bpf_endian.h> #include <bpf/bpf_endian.h>
#include "test_iptunnel_common.h" #include "test_iptunnel_common.h"
int _version SEC("version") = 1;
struct { struct {
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY); __uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
__uint(max_entries, 256); __uint(max_entries, 256);
......
...@@ -12,8 +12,6 @@ ...@@ -12,8 +12,6 @@
#include <linux/bpf.h> #include <linux/bpf.h>
#include <bpf/bpf_helpers.h> #include <bpf/bpf_helpers.h>
int _version SEC("version") = 1;
SEC("redirect_to_111") SEC("redirect_to_111")
int xdp_redirect_to_111(struct xdp_md *xdp) int xdp_redirect_to_111(struct xdp_md *xdp)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment