diff options
| author | Daniel T. Lee <danieltimlee@gmail.com> | 2023-01-15 16:16:11 +0900 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2023-01-15 13:32:45 -0800 |
| commit | c2f4f5593e6ae8014b277b46f5f9a8227f11d69c (patch) | |
| tree | b0783fde4891a16ecaae27c6e6f3a561bdb234bb /samples/bpf/test_cgrp2_tc_kern.c | |
| parent | e69fe8459552f112d7327dff87953d40202c61f1 (diff) | |
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/test_cgrp2_tc_kern.c')
| -rw-r--r-- | samples/bpf/test_cgrp2_tc_kern.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/samples/bpf/test_cgrp2_tc_kern.c b/samples/bpf/test_cgrp2_tc_kern.c index 737ce3eb8944..45a2f01d2029 100644 --- a/samples/bpf/test_cgrp2_tc_kern.c +++ b/samples/bpf/test_cgrp2_tc_kern.c @@ -5,10 +5,8 @@ * License as published by the Free Software Foundation. */ #define KBUILD_MODNAME "foo" -#include <uapi/linux/if_ether.h> -#include <uapi/linux/in6.h> +#include "net_shared.h" #include <uapi/linux/ipv6.h> -#include <uapi/linux/pkt_cls.h> #include <uapi/linux/bpf.h> #include <bpf/bpf_helpers.h> @@ -42,7 +40,7 @@ int handle_egress(struct __sk_buff *skb) if (data + sizeof(*eth) + sizeof(*ip6h) > data_end) return TC_ACT_OK; - if (eth->h_proto != htons(ETH_P_IPV6) || + if (eth->h_proto != bpf_htons(ETH_P_IPV6) || ip6h->nexthdr != IPPROTO_ICMPV6) { bpf_trace_printk(dont_care_msg, sizeof(dont_care_msg), eth->h_proto, ip6h->nexthdr); |
