libbpf: move logging helpers into libbpf_internal.h
authorAndrii Nakryiko <andriin@fb.com>
Thu, 16 May 2019 03:39:27 +0000 (20:39 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 16 May 2019 19:47:47 +0000 (12:47 -0700)
libbpf_util.h header was recently exposed as public as a dependency of
xsk.h. In addition to memory barriers, it contained logging helpers,
which are not supposed to be exposed. This patch moves those into
libbpf_internal.h, which is kept as an internal header.

Cc: Stanislav Fomichev <sdf@google.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Fixes: 7080da890984 ("libbpf: add libbpf_util.h to header install.")
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/lib/bpf/btf.c
tools/lib/bpf/libbpf.c
tools/lib/bpf/libbpf_internal.h
tools/lib/bpf/libbpf_util.h
tools/lib/bpf/xsk.c

index 75eaf10b9e1aa6fd3ceba642013c8a1f1815ae46..03348c4d6bd480f480d137bd45fc2c2302a489f3 100644 (file)
@@ -11,7 +11,7 @@
 #include "btf.h"
 #include "bpf.h"
 #include "libbpf.h"
-#include "libbpf_util.h"
+#include "libbpf_internal.h"
 
 #define max(a, b) ((a) > (b) ? (a) : (b))
 #define min(a, b) ((a) < (b) ? (a) : (b))
index 3562b6ef5fdcbaea58e86926efd229443e844b88..197b574406b3ac6599bb81e395ff88d9c0374661 100644 (file)
@@ -43,7 +43,6 @@
 #include "bpf.h"
 #include "btf.h"
 #include "str_error.h"
-#include "libbpf_util.h"
 #include "libbpf_internal.h"
 
 #ifndef EM_BPF
index 789e435b59004146d2f428160615bef47fc5a15e..f3025b4d90e19806d028485aca99f35796cc8f13 100644 (file)
 #define BTF_PARAM_ENC(name, type) (name), (type)
 #define BTF_VAR_SECINFO_ENC(type, offset, size) (type), (offset), (size)
 
+extern void libbpf_print(enum libbpf_print_level level,
+                        const char *format, ...)
+       __attribute__((format(printf, 2, 3)));
+
+#define __pr(level, fmt, ...)  \
+do {                           \
+       libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__);     \
+} while (0)
+
+#define pr_warning(fmt, ...)   __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
+#define pr_info(fmt, ...)      __pr(LIBBPF_INFO, fmt, ##__VA_ARGS__)
+#define pr_debug(fmt, ...)     __pr(LIBBPF_DEBUG, fmt, ##__VA_ARGS__)
+
 int libbpf__probe_raw_btf(const char *raw_types, size_t types_len,
                          const char *str_sec, size_t str_len);
 
index da94c4cb2e4db5094e9b3e3a91ae05f8b1d9bbf6..59c779c5790c16de5e64fc8be397639ec6356fbd 100644 (file)
 extern "C" {
 #endif
 
-extern void libbpf_print(enum libbpf_print_level level,
-                        const char *format, ...)
-       __attribute__((format(printf, 2, 3)));
-
-#define __pr(level, fmt, ...)  \
-do {                           \
-       libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__);     \
-} while (0)
-
-#define pr_warning(fmt, ...)   __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
-#define pr_info(fmt, ...)      __pr(LIBBPF_INFO, fmt, ##__VA_ARGS__)
-#define pr_debug(fmt, ...)     __pr(LIBBPF_DEBUG, fmt, ##__VA_ARGS__)
-
 /* Use these barrier functions instead of smp_[rw]mb() when they are
  * used in a libbpf header file. That way they can be built into the
  * application that uses libbpf.
index a3d1a302bc9cb36788612c2033bb667737aee455..38667b62f1fe4f9f4c9524cf42b3d1e23e49af51 100644 (file)
@@ -29,7 +29,7 @@
 
 #include "bpf.h"
 #include "libbpf.h"
-#include "libbpf_util.h"
+#include "libbpf_internal.h"
 #include "xsk.h"
 
 #ifndef SOL_XDP