Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 37739d1b authored by Michal Rostecki's avatar Michal Rostecki Committed by Alexei Starovoitov
Browse files

selftests: bpf: Move bpf_printk to bpf_helpers.h



bpf_printk is a macro which is commonly used to print out debug messages
in BPF programs and it was copied in many selftests and samples. Since
all of them include bpf_helpers.h, this change moves the macro there.

Signed-off-by: default avatarMichal Rostecki <mrostecki@opensuse.org>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 5762a20b
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -8,6 +8,14 @@
 */
#define SEC(NAME) __attribute__((section(NAME), used))

/* helper macro to print out debug messages */
#define bpf_printk(fmt, ...)				\
({							\
	char ____fmt[] = fmt;				\
	bpf_trace_printk(____fmt, sizeof(____fmt),	\
			 ##__VA_ARGS__);		\
})

/* helper functions called from eBPF programs written in C */
static void *(*bpf_map_lookup_elem)(void *map, const void *key) =
	(void *) BPF_FUNC_map_lookup_elem;
+0 −7
Original line number Diff line number Diff line
@@ -5,13 +5,6 @@

int _version SEC("version") = 1;

#define bpf_printk(fmt, ...)					\
({								\
	       char ____fmt[] = fmt;				\
	       bpf_trace_printk(____fmt, sizeof(____fmt),	\
				##__VA_ARGS__);			\
})

SEC("sk_skb1")
int bpf_prog1(struct __sk_buff *skb)
{
+0 −7
Original line number Diff line number Diff line
@@ -5,13 +5,6 @@

int _version SEC("version") = 1;

#define bpf_printk(fmt, ...)					\
({								\
	       char ____fmt[] = fmt;				\
	       bpf_trace_printk(____fmt, sizeof(____fmt),	\
				##__VA_ARGS__);			\
})

SEC("sk_msg1")
int bpf_prog1(struct sk_msg_md *msg)
{
+0 −7
Original line number Diff line number Diff line
@@ -5,13 +5,6 @@

int _version SEC("version") = 1;

#define bpf_printk(fmt, ...)					\
({								\
	       char ____fmt[] = fmt;				\
	       bpf_trace_printk(____fmt, sizeof(____fmt),	\
				##__VA_ARGS__);			\
})

struct bpf_map_def SEC("maps") sock_map_rx = {
	.type = BPF_MAP_TYPE_SOCKMAP,
	.key_size = sizeof(int),
+0 −7
Original line number Diff line number Diff line
@@ -6,13 +6,6 @@
#include "bpf_helpers.h"
#include "bpf_endian.h"

#define bpf_printk(fmt, ...)				\
({							\
	char ____fmt[] = fmt;				\
	bpf_trace_printk(____fmt, sizeof(____fmt),	\
			##__VA_ARGS__);			\
})

/* Packet parsing state machine helpers. */
#define cursor_advance(_cursor, _len) \
	({ void *_tmp = _cursor; _cursor += _len; _tmp; })
Loading