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

Since commit 6c4fc209fc ("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
This commit is contained in:
Dave Marchevsky
2021-10-07 16:12:34 -07:00
committed by Andrii Nakryiko
parent aa67fdb464
commit dd65acf72d
40 changed files with 0 additions and 61 deletions

View File

@@ -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;

View File

@@ -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)
{ {

View File

@@ -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)
{ {

View File

@@ -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;

View File

@@ -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];

View File

@@ -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;

View File

@@ -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 */

View File

@@ -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";

View File

@@ -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;

View File

@@ -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)
{ {

View File

@@ -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)
{ {

View File

@@ -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)
{ {

View File

@@ -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)
{ {

View File

@@ -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);

View File

@@ -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

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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));

View File

@@ -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";

View File

@@ -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);

View File

@@ -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);

View File

@@ -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
* *

View File

@@ -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);

View File

@@ -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

View File

@@ -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;

View File

@@ -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";

View File

@@ -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")

View File

@@ -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";

View File

@@ -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";

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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

View File

@@ -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)
{ {

View File

@@ -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 */

View File

@@ -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;

View File

@@ -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);

View File

@@ -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);

View File

@@ -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)
{ {