aboutsummaryrefslogtreecommitdiff
path: root/samples/bpf/net_shared.h
diff options
context:
space:
mode:
authorGravatar Daniel T. Lee <danieltimlee@gmail.com> 2023-01-15 16:16:11 +0900
committerGravatar Alexei Starovoitov <ast@kernel.org> 2023-01-15 13:32:45 -0800
commitc2f4f5593e6ae8014b277b46f5f9a8227f11d69c (patch)
treeb0783fde4891a16ecaae27c6e6f3a561bdb234bb /samples/bpf/net_shared.h
parentsamples/bpf: split common macros to net_shared.h (diff)
downloadlinux-c2f4f5593e6ae8014b277b46f5f9a8227f11d69c.tar.gz
linux-c2f4f5593e6ae8014b277b46f5f9a8227f11d69c.tar.bz2
linux-c2f4f5593e6ae8014b277b46f5f9a8227f11d69c.zip
samples/bpf: replace BPF programs header with net_shared.h
This commit applies "net_shared.h" to BPF programs to remove existing network related header dependencies. Also, this commit removes unnecessary headers before applying "vmlinux.h" to the BPF programs. Mostly, endianness conversion function has been applied to the source. In addition, several macros have been defined to fulfill the INET, TC-related constants. Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com> Link: https://lore.kernel.org/r/20230115071613.125791-9-danieltimlee@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'samples/bpf/net_shared.h')
-rw-r--r--samples/bpf/net_shared.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/samples/bpf/net_shared.h b/samples/bpf/net_shared.h
index 04b29b217d25..e9429af9aa44 100644
--- a/samples/bpf/net_shared.h
+++ b/samples/bpf/net_shared.h
@@ -2,6 +2,9 @@
#ifndef _NET_SHARED_H
#define _NET_SHARED_H
+#define AF_INET 2
+#define AF_INET6 10
+
#define ETH_ALEN 6
#define ETH_P_802_3_MIN 0x0600
#define ETH_P_8021Q 0x8100
@@ -11,6 +14,9 @@
#define ETH_P_ARP 0x0806
#define IPPROTO_ICMPV6 58
+#define TC_ACT_OK 0
+#define TC_ACT_SHOT 2
+
#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define bpf_ntohs(x) __builtin_bswap16(x)