Commit 1bd3773a authored by Alexei Starovoitov's avatar Alexei Starovoitov
Browse files

Merge branch 'libbpf-fix-libbpf_sha256-for-github-compatibility'

Andrii Nakryiko says:

====================
libbpf: fix libbpf_sha256() for Github compatibility

Recent reimplementation of libbpf_sha256() introduced issues for libbpf's
Github mirror due to reliance on linux/unaligned.h header. This patch set
fixes those issues to make libbpf source code compatible with Github mirror
setup.

This patch set starts with a bit of organization: we introduce libbpf_utils.c
as a place for generic internal helpers like libbpf_errstr() and
libbpf_sha256(), and move a few existing helpers there. We also clean up
libbpf_strerror_r(), which seems to be a leftover of some previous
refactorings.

And finally, we move libbpf_sha256() from huge libbpf.c into libbpf_utils.c,
following up with fix ups to make its code more Github-friendly.

v1->v2:
- add missed cpu_to_be32() and be32_to_cpu() conversions inside
  {get/put}_unaligned_be32() macros;
- target bpf tree (Alexei);
- applied Eric's libbpf_sha256 selftest locally and verified it works;

v1:
https://lore.kernel.org/bpf/20250930212619.1645410-1-andrii@kernel.org/
====================

Link: https://patch.msgid.link/20251001171326.3883055-1-andrii@kernel.org


Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parents a1aca22d 4a1c9e54
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
libbpf-y := libbpf.o bpf.o nlattr.o btf.o libbpf_errno.o str_error.o \
libbpf-y := libbpf.o bpf.o nlattr.o btf.o libbpf_utils.o \
	    netlink.o bpf_prog_linfo.o libbpf_probes.o hashmap.o \
	    btf_dump.o ringbuf.o strset.o linker.o gen_loader.o relo_core.o \
	    usdt.o zip.o elf.o features.o btf_iter.o btf_relocate.o
+0 −1
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@
#include "libbpf_internal.h"
#include "hashmap.h"
#include "strset.h"
#include "str_error.h"

#define BTF_MAX_NR_TYPES 0x7fffffffU
#define BTF_MAX_STR_OFFSET 0x7fffffffU
+0 −1
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@
#include "hashmap.h"
#include "libbpf.h"
#include "libbpf_internal.h"
#include "str_error.h"

static const char PREFIXES[] = "\t\t\t\t\t\t\t\t\t\t\t\t\t";
static const size_t PREFIX_CNT = sizeof(PREFIXES) - 1;
+0 −1
Original line number Diff line number Diff line
@@ -9,7 +9,6 @@
#include <linux/kernel.h>

#include "libbpf_internal.h"
#include "str_error.h"

/* A SHT_GNU_versym section holds 16-bit words. This bit is set if
 * the symbol is hidden and can only be seen when referenced using an
+0 −1
Original line number Diff line number Diff line
@@ -6,7 +6,6 @@
#include "libbpf.h"
#include "libbpf_common.h"
#include "libbpf_internal.h"
#include "str_error.h"

static inline __u64 ptr_to_u64(const void *ptr)
{
Loading