libbpf: Improve debug message when the base BTF cannot be found
PATCH 1/1 libbpf: Improve debug message when the base BTF cannot be found
When running bpftool on a kernel module installed in /lib/modules..., this error is encountered if the user does not specify --base-btf to point to a valid base BTF (e.g. usually in /sys/kernel/btf/vmlinux). However, looking at the debug output to determine the cause of the error simply says Invalid BTF string section, which does not point to the actual source of the error. This just improves that debug message to tell users what happened.
--- tools/lib/bpf/btf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/btf.c +1 -1
@@ -283,7 +283,7 @@ static int btf_parse_str_sec(struct btf *btf)return -EINVAL ; }if (!btf->base_btf && start[0 ]) { -pr_debug ("Invalid BTF string section\n" ); +pr_debug ("Cannot find base BTF\n" );return -EINVAL ; }return 0 ;
Signature · 1 line
2.47.0
Quoted 19 lines · Ben Olson
When running
bpftoolon a kernel module installed in/lib/modules..., this error is encountered if the user does not specify--base-btfto point to a valid base BTF (e.g. usually in/sys/kernel/btf/vmlinux). However, looking at the debug output to determine the cause of the error simply saysInvalid BTF string section, which does not point to the actual source of the error. This just improves that debug message to tell users what happened.Signed-off-by Ben Olson <[email protected]>--- tools/lib/bpf/btf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/lib/bpf/btf.c +0
-0
tools/lib/bpf/btf.c static int btf_parse_str_sec(struct btf *btf) · line 286
Quoted 5 lines
tools/lib/bpf/btf.c +1
-1@@ -283,7 +283,7 @@ static int btf_parse_str_sec(struct btf *btf)return -EINVAL ; }if (!btf->base_btf && start[0 ]) { -pr_debug ("Invalid BTF string section\n" ); +pr_debug ("Cannot find base BTF\n" );
Well, the check indeed checks the well-formedness of the BTF string section. It is specified that the first byte has to be zero ("empty string"), unless it's a split BTF.
Base BTF being missing is just one possible reason for this condition, so I'm not sure if it's completely accurate to specialize this error message so much. Perhaps maybe emitting "Malformed BTF string section, did you forget to provide base BTF?" would be a bit better.
pw-bot: cr
Quoted 5 lines
tools/lib/bpf/btf.c +0
-1return -EINVAL ; }return 0 ; --2.47.0
Quoted 30 lines · Andrii Nakryiko
Quoted 19 lines · Ben Olson
When running
bpftoolon a kernel module installed in/lib/modules..., this error is encountered if the user does not specify--base-btfto point to a valid base BTF (e.g. usually in/sys/kernel/btf/vmlinux). However, looking at the debug output to determine the cause of the error simply saysInvalid BTF string section, which does not point to the actual source of the error. This just improves that debug message to tell users what happened.Signed-off-by Ben Olson <[email protected]>--- tools/lib/bpf/btf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/lib/bpf/btf.c +0
-0tools/lib/bpf/btf.c static int btf_parse_str_sec(struct btf *btf) · line 286
Quoted 5 lines
tools/lib/bpf/btf.c +1
-1@@ -283,7 +283,7 @@ static int btf_parse_str_sec(struct btf *btf)return -EINVAL ; }if (!btf->base_btf && start[0 ]) { -pr_debug ("Invalid BTF string section\n" ); +pr_debug ("Cannot find base BTF\n" );Well, the check indeed checks the well-formedness of the BTF string section. It is specified that the first byte has to be zero ("empty string"), unless it's a split BTF.
Quoted 4 lines
Base BTF being missing is just one possible reason for this condition, so I'm not sure if it's completely accurate to specialize this error message so much. Perhaps maybe emitting "Malformed BTF string section, did you forget to provide base BTF?" would be a bit better.
That sounds much better; as long as it hints that the user should check if they specified a base BTF or not, it's good with me! Thanks.
Quoted 9 lines
pw-bot: cr
Quoted 5 lines
tools/lib/bpf/btf.c +0
-1return -EINVAL ; }return 0 ; --2.47.0
From 22ed11ee2153fc921987eac7de24f564da9f9230 Mon Sep 17 00:00:00 2001
From: Ben Olson <[email protected]>
Date: Thu, 21 Nov 2024 11:26:35 -0600
Subject: [PATCH v2 bpf-next] libbpf: Improve debug message when the base BTF
cannot be found
When running bpftool on a kernel module installed in /lib/modules..., this error is encountered if the user does not specify --base-btf to point to a valid base BTF (e.g. usually in /sys/kernel/btf/vmlinux). However, looking at the debug output to determine the cause of the error simply says Invalid BTF string section, which does not point to the actual source of the error. This just improves that debug message to tell users what happened.
---
Changed in v2:
* Made error message better reflect the condition
tools/lib/bpf/btf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/btf.c +1 -1
@@ -283,7 +283,7 @@ static int btf_parse_str_sec(struct btf *btf)return -EINVAL ; }if (!btf->base_btf && start[0 ]) { -pr_debug ("Invalid BTF string section\n" ); +pr_debug ("Malformed BTF string section, did you forget to provide base BTF?\n" );return -EINVAL ; }return 0 ;
--
2.47.0
John Fastabend
Acked-byQuoted 14 lines · Matthew
From
22ed11ee2153fc921987eac7de24f564da9f9230Mon Sep 17 00:00:00 2001
From: Ben Olson <[email protected]>
Date: Thu, 21 Nov 2024 11:26:35 -0600
Subject: [PATCH v2 bpf-next] libbpf: Improve debug message when the base BTF
cannot be foundWhen running
bpftoolon a kernel module installed in/lib/modules..., this error is encountered if the user does not specify--base-btfto point to a valid base BTF (e.g. usually in/sys/kernel/btf/vmlinux). However, looking at the debug output to determine the cause of the error simply saysInvalid BTF string section, which does not point to the actual source of the error. This just improves that debug message to tell users what happened.
Quoted 2 lines
Signed-off-by Ben Olson <[email protected]>---
LGTM
Quoted 22 lines
Changed in v2:
* Made error message better reflect the conditiontools/lib/bpf/btf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/lib/bpf/btf.c +1
-2@@ -283,7 +283,7 @@ static int btf_parse_str_sec(struct btf *btf)return -EINVAL ; }if (!btf->base_btf && start[0 ]) { -pr_debug ("Invalid BTF string section\n" ); +pr_debug ("Malformed BTF string section, did you forget to provide base BTF?\n" );return -EINVAL ; }return 0 ; --2.47.0
Quoted 29 lines · Matthew
From
22ed11ee2153fc921987eac7de24f564da9f9230Mon Sep 17 00:00:00 2001
From: Ben Olson <[email protected]>
Date: Thu, 21 Nov 2024 11:26:35 -0600
Subject: [PATCH v2 bpf-next] libbpf: Improve debug message when the base BTF
cannot be foundWhen running
bpftoolon a kernel module installed in/lib/modules..., this error is encountered if the user does not specify--base-btfto point to a valid base BTF (e.g. usually in/sys/kernel/btf/vmlinux). However, looking at the debug output to determine the cause of the error simply saysInvalid BTF string section, which does not point to the actual source of the error. This just improves that debug message to tell users what happened.Signed-off-by Ben Olson <[email protected]>---
Changed in v2:
* Made error message better reflect the conditiontools/lib/bpf/btf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/lib/bpf/btf.c +0
-0
tools/lib/bpf/btf.c static int btf_parse_str_sec(struct btf *btf) · line 286
Quoted 5 lines
tools/lib/bpf/btf.c +1
-1@@ -283,7 +283,7 @@ static int btf_parse_str_sec(struct btf *btf)return -EINVAL ; }if (!btf->base_btf && start[0 ]) { -pr_debug ("Invalid BTF string section\n" ); +pr_debug ("Malformed BTF string section, did you forget to provide base BTF?\n" );
I'm not sure why, but this v2 didn't make it into patchworks, so I can't apply it. Can you please resend?
Also please make sure you don't change indentation (tabs -> spaces), because it looks like that's what happened here.
Quoted 5 lines
tools/lib/bpf/btf.c +0
-1return -EINVAL ; }return 0 ; --2.47.0
Quoted 25 lines · Andrii Nakryiko
Quoted 24 lines · Matthew
From
22ed11ee2153fc921987eac7de24f564da9f9230Mon Sep 17 00:00:00 2001
From: Ben Olson <[email protected]>
Date: Thu, 21 Nov 2024 11:26:35 -0600
Subject: [PATCH v2 bpf-next] libbpf: Improve debug message when the base BTF
cannot be foundWhen running
bpftoolon a kernel module installed in/lib/modules..., this error is encountered if the user does not specify--base-btfto point to a valid base BTF (e.g. usually in/sys/kernel/btf/vmlinux). However, looking at the debug output to determine the cause of the error simply saysInvalid BTF string section, which does not point to the actual source of the error. This just improves that debug message to tell users what happened.Signed-off-by Ben Olson <[email protected]>---
Changed in v2:
* Made error message better reflect the conditiontools/lib/bpf/btf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines
tools/lib/bpf/btf.c static int btf_parse_str_sec(struct btf *btf) · line 286
Quoted 10 lines
tools/lib/bpf/btf.c +1
-1@@ -283,7 +283,7 @@ static int btf_parse_str_sec(struct btf *btf)return -EINVAL ; }if (!btf->base_btf && start[0 ]) { -pr_debug ("Invalid BTF string section\n" ); +pr_debug ("Malformed BTF string section, did you forget to provide base BTF?\n" );I'm not sure why, but this v2 didn't make it into patchworks, so I can't apply it. Can you please resend?
Sure thing. Thanks.
Quoted 3 lines
Also please make sure you don't change indentation (tabs -> spaces), because it looks like that's what happened here.
Ach, rookie mistake. I'll add clang-format to my git hooks.
Quoted 6 lines
Quoted 6 lines
tools/lib/bpf/btf.c +0
-1return -EINVAL ; }return 0 ; --2.47.0
Quoted 40 lines · Matthew
Quoted 25 lines · Andrii Nakryiko
Quoted 24 lines · Matthew
From
22ed11ee2153fc921987eac7de24f564da9f9230Mon Sep 17 00:00:00 2001
From: Ben Olson <[email protected]>
Date: Thu, 21 Nov 2024 11:26:35 -0600
Subject: [PATCH v2 bpf-next] libbpf: Improve debug message when the base BTF
cannot be foundWhen running
bpftoolon a kernel module installed in/lib/modules..., this error is encountered if the user does not specify--base-btfto point to a valid base BTF (e.g. usually in/sys/kernel/btf/vmlinux). However, looking at the debug output to determine the cause of the error simply saysInvalid BTF string section, which does not point to the actual source of the error. This just improves that debug message to tell users what happened.Signed-off-by Ben Olson <[email protected]>---
Changed in v2:
* Made error message better reflect the conditiontools/lib/bpf/btf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 13 lines
tools/lib/bpf/btf.c static int btf_parse_str_sec(struct btf *btf) · line 286
Quoted 10 lines
tools/lib/bpf/btf.c +1
-1@@ -283,7 +283,7 @@ static int btf_parse_str_sec(struct btf *btf)return -EINVAL ; }if (!btf->base_btf && start[0 ]) { -pr_debug ("Invalid BTF string section\n" ); +pr_debug ("Malformed BTF string section, did you forget to provide base BTF?\n" );I'm not sure why, but this v2 didn't make it into patchworks, so I can't apply it. Can you please resend?
Quoted 1 line
Sure thing. Thanks.
Ah, I think I figured out why it didn't make it into patchworks; I'll resend yet again.
Quoted 14 lines
Quoted 4 lines
Also please make sure you don't change indentation (tabs -> spaces), because it looks like that's what happened here.
Ach, rookie mistake. I'll add clang-format to my git hooks.
Quoted 6 lines
Quoted 6 lines
tools/lib/bpf/btf.c +0
-1return -EINVAL ; }return 0 ; --2.47.0