bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btf_encoder: Make BTF_KIND_TAG conditional
@ 2021-10-14 21:20 Ian Rogers
  2021-10-15 12:51 ` Arnaldo Carvalho de Melo
  2021-10-20 21:11 ` Andrii Nakryiko
  0 siblings, 2 replies; 10+ messages in thread
From: Ian Rogers @ 2021-10-14 21:20 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Yonghong Song, Alexei Starovoitov,
	Andrii Nakryiko, bpf, Daniel Borkmann, Petar Penkov
  Cc: Ian Rogers

BTF_KIND_TAG is present in libbtf 6.0 but not libbtf in 5.15rc4. Make
the code requiring it conditionally compiled in.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 btf_encoder.c | 7 +++++++
 lib/bpf       | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/btf_encoder.c b/btf_encoder.c
index c341f95..400d64b 100644
--- a/btf_encoder.c
+++ b/btf_encoder.c
@@ -141,7 +141,9 @@ static const char * const btf_kind_str[NR_BTF_KINDS] = {
 	[BTF_KIND_VAR]          = "VAR",
 	[BTF_KIND_DATASEC]      = "DATASEC",
 	[BTF_KIND_FLOAT]        = "FLOAT",
+#ifdef BTF_KIND_TAG /* BTF_KIND_TAG was added in 6.0 */
 	[BTF_KIND_TAG]          = "TAG",
+#endif
 };
 
 static const char *btf__printable_name(const struct btf *btf, uint32_t offset)
@@ -648,6 +650,7 @@ static int32_t btf_encoder__add_datasec(struct btf_encoder *encoder, const char
 static int32_t btf_encoder__add_tag(struct btf_encoder *encoder, const char *value, uint32_t type,
 				    int component_idx)
 {
+#ifdef BTF_KIND_TAG /* Proxy for libbtf 6.0 */
 	struct btf *btf = encoder->btf;
 	const struct btf_type *t;
 	int32_t id;
@@ -663,6 +666,10 @@ static int32_t btf_encoder__add_tag(struct btf_encoder *encoder, const char *val
 	}
 
 	return id;
+#else
+        fprintf(stderr, "error: unable to encode BTF_KIND_TAG due to old libbtf\n");
+        return -ENOTSUP;
+#endif
 }
 
 /*
diff --git a/lib/bpf b/lib/bpf
index 980777c..986962f 160000
--- a/lib/bpf
+++ b/lib/bpf
@@ -1 +1 @@
-Subproject commit 980777cc16db75d5628a537c892aefc2640bb242
+Subproject commit 986962fade5dfa89c2890f3854eb040d2a64ab38
-- 
2.33.0.1079.g6e70778dc9-goog


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-10-21 12:59 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-14 21:20 [PATCH] btf_encoder: Make BTF_KIND_TAG conditional Ian Rogers
2021-10-15 12:51 ` Arnaldo Carvalho de Melo
2021-10-20 21:11 ` Andrii Nakryiko
2021-10-20 21:22   ` Ian Rogers
2021-10-20 21:27     ` Andrii Nakryiko
2021-10-20 21:49       ` Ian Rogers
2021-10-20 22:30         ` Andrii Nakryiko
2021-10-20 23:46           ` Ian Rogers
2021-10-21  1:55             ` Andrii Nakryiko
2021-10-21 12:59       ` Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).