summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandro Colomar <alx.manpages@gmail.com>2021-11-19 19:20:07 +0100
committerAlejandro Colomar <alx.manpages@gmail.com>2021-11-20 14:45:31 +0100
commited5609ed87855708868e7a13ce132fa3726fa398 (patch)
tree24b9a50183e3cbf6b340970193f8fc53d1dd8b35
parent9b568cd21579eff8f037fa0e951e590da0335efe (diff)
samples/bpf/: Don't redefine ARRAY_SIZE()
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
-rw-r--r--samples/bpf/cookie_uid_helper_example.c3
-rw-r--r--samples/bpf/xdp_sample.bpf.h4
-rw-r--r--samples/bpf/xsk_fwd.c3
3 files changed, 7 insertions, 3 deletions
diff --git a/samples/bpf/cookie_uid_helper_example.c b/samples/bpf/cookie_uid_helper_example.c
index 818d4af9803d..764d1658b8e5 100644
--- a/samples/bpf/cookie_uid_helper_example.c
+++ b/samples/bpf/cookie_uid_helper_example.c
@@ -30,12 +30,12 @@
#define _GNU_SOURCE
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
#include <arpa/inet.h>
#include <errno.h>
#include <error.h>
#include <limits.h>
+#include <linux/array_size.h>
#include <linux/bpf.h>
#include <linux/if_ether.h>
#include <linux/offsetof.h>
@@ -53,6 +53,7 @@
#include <bpf/bpf.h>
#include "bpf_insn.h"
+
#define PORT 8888
struct stats {
diff --git a/samples/bpf/xdp_sample.bpf.h b/samples/bpf/xdp_sample.bpf.h
index 25b1dbe9b37b..d5779a68d9b7 100644
--- a/samples/bpf/xdp_sample.bpf.h
+++ b/samples/bpf/xdp_sample.bpf.h
@@ -2,13 +2,16 @@
#ifndef _XDP_SAMPLE_BPF_H
#define _XDP_SAMPLE_BPF_H
+
#include "vmlinux.h"
#include <bpf/bpf_tracing.h>
#include <bpf/bpf_core_read.h>
#include <bpf/bpf_helpers.h>
+#include <linux/array_size.h>
#include "xdp_sample_shared.h"
+
#define ETH_ALEN 6
#define ETH_P_802_3_MIN 0x0600
#define ETH_P_8021Q 0x8100
@@ -136,6 +139,5 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
#define NO_TEAR_ADD(x, val) WRITE_ONCE((x), READ_ONCE(x) + (val))
#define NO_TEAR_INC(x) NO_TEAR_ADD((x), 1)
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#endif
diff --git a/samples/bpf/xsk_fwd.c b/samples/bpf/xsk_fwd.c
index 1cd97c84c337..b0da6c477390 100644
--- a/samples/bpf/xsk_fwd.c
+++ b/samples/bpf/xsk_fwd.c
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
/* Copyright(c) 2020 Intel Corporation. */
+
#define _GNU_SOURCE
#include <poll.h>
#include <pthread.h>
@@ -19,6 +20,7 @@
#include <netinet/ether.h>
#include <net/if.h>
+#include <linux/array_size.h>
#include <linux/bpf.h>
#include <linux/if_link.h>
#include <linux/if_xdp.h>
@@ -27,7 +29,6 @@
#include <bpf/xsk.h>
#include <bpf/bpf.h>
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
typedef __u64 u64;
typedef __u32 u32;