Skip to contentSkip to conversation

bpftool: fix output for skipping kernel config check

PATCH Applied Chethan Suresh 3 participants 3 messages Jan 9, 2023 – Jan 11, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bpftool: fix output for skipping kernel config check

When bpftool feature does not find kernel config
files under default path or wrong format,
do not output CONFIG_XYZ is not set.
Skip kernel config check and continue.

---
 tools/bpf/bpftool/feature.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tools/bpf/bpftool/feature.c +4 -4
index 36cf0f1517c9..da16e6a27ccc 100644
@@ -486,16 +486,16 @@ static void probe_kernel_image_config(const char *define_prefix)
 		}
 	}
 
-end_parse:
-	if (file)
-		gzclose(file);
-
 	for (i = 0; i < ARRAY_SIZE(options); i++) {
 		if (define_prefix && !options[i].macro_dump)
 			continue;
 		print_kernel_option(options[i].name, values[i], define_prefix);
 		free(values[i]);
 	}
+
+end_parse:
+	if (file)
+		gzclose(file);
 }
 
 static bool probe_bpf_syscall(const char *define_prefix)
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw

2023-01-09 08:07 UTC+0530 ~ Chethan Suresh <[email protected]>

Quoted 26 lines

When bpftool feature does not find kernel config
files under default path or wrong format,
do not output CONFIG_XYZ is not set.
Skip kernel config check and continue.

---
 tools/bpf/bpftool/feature.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tools/bpf/bpftool/feature.c +0 -4
index 36cf0f1517c9..da16e6a27ccc 100644
@@ -486,16 +486,16 @@ static void probe_kernel_image_config(const char *define_prefix)
 		}
 	}
 
-end_parse:
-	if (file)
-		gzclose(file);
-
 	for (i = 0; i < ARRAY_SIZE(options); i++) {
 		if (define_prefix && !options[i].macro_dump)
 			continue;

tools/bpf/bpftool/feature.c static void probe_kernel_image_config(const char *define_prefix) · line 501

Quoted 10 lines
tools/bpf/bpftool/feature.c +4 -0
 		print_kernel_option(options[i].name, values[i], define_prefix);
 		free(values[i]);
 	}
+
+end_parse:
+	if (file)
+		gzclose(file);
 }
 
 static bool probe_bpf_syscall(const char *define_prefix)

Thanks!

This will remove the output for the kernel config options in case the config file is not found, including from the JSON output. I can't remember the motivation for printing negative values in that case, at the time. I'm somewhat concerned to see the JSON entries disappear when the config file is missing. Ideally, we should have an alternative state for when config file is not here; but even using a specific string in that case could play badly with scripts expecting that the kconfig option is set if the JSON probing output contains anything else than 'null' for that entry.

So I think we can go with this patch indeed, and see if anyone complains about it. After all, this is consistent with what we do elsewhere: We skip entirely most probes if BPF_SYSCALL is not set, or probes for helpers related to unsupported program types.

#2 lore raw
In reply to Chethan Suresh
This patch was applied to bpf/bpf-next.git (master) by Martin KaFai Lau <[email protected]>:

Hello:

This patch was applied to bpf/bpf-next.git (master) by Martin KaFai Lau <[email protected]>:

Quoted 9 lines · On Mon, 9 Jan 2023 08:07:42 +0530 you wrote:

When bpftool feature does not find kernel config
files under default path or wrong format,
do not output CONFIG_XYZ is not set.
Skip kernel config check and continue.

[...]

Here is the summary with links:
- [bpf-next] bpftool: fix output for skipping kernel config check

    https://git.kernel.org/bpf/bpf-next/c/75514e4c6619

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html