libbpf: Make bpf_endian co-exist with vmlinux.h
authorAndrii Nakryiko <andriin@fb.com>
Tue, 30 Jun 2020 15:21:24 +0000 (08:21 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 1 Jul 2020 07:06:12 +0000 (09:06 +0200)
commit30ad688094bcfe8721bfd4003f6a20c9b6ddf964
tree6695f0791ec2dd7d0ecbd5aa3ea60a25d847dd67
parentca4db6389d611eee2eb7c1dfe710b62d8ea06772
libbpf: Make bpf_endian co-exist with vmlinux.h

Make bpf_endian.h compatible with vmlinux.h. It is a frequent request from
users wanting to use bpf_endian.h in their BPF applications using CO-RE and
vmlinux.h.

To achieve that, re-implement byte swap macros and drop all the header
includes. This way it can be used both with linux header includes, as well as
with a vmlinux.h.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20200630152125.3631920-2-andriin@fb.com
tools/lib/bpf/bpf_endian.h