Skip to content

Commit

Permalink
bpftool: Only probe trace_vprintk feature in 'full' mode
Browse files Browse the repository at this point in the history
Since commit 368cb0e ("bpftool: Make probes which emit dmesg
warnings optional"), some helpers aren't probed by bpftool unless
`full` arg is added to `bpftool feature probe`.

bpf_trace_vprintk can emit dmesg warnings when probed, so include it.

Signed-off-by: Dave Marchevsky <davemarchevsky@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20210917182911.2426606-7-davemarchevsky@fb.com
  • Loading branch information
Dave Marchevsky authored and Alexei Starovoitov committed Sep 17, 2021
1 parent 6c66b0e commit 4190c29
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
1 change: 1 addition & 0 deletions tools/bpf/bpftool/feature.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ probe_helpers_for_progtype(enum bpf_prog_type prog_type, bool supported_type,
*/
switch (id) {
case BPF_FUNC_trace_printk:
case BPF_FUNC_trace_vprintk:
case BPF_FUNC_probe_write_user:
if (!full_mode)
continue;
Expand Down
22 changes: 9 additions & 13 deletions tools/testing/selftests/bpf/test_bpftool.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ def wrapper(*args, **kwargs):
return f(*args, iface, **kwargs)
return wrapper

DMESG_EMITTING_HELPERS = [
"bpf_probe_write_user",
"bpf_trace_printk",
"bpf_trace_vprintk",
]

class TestBpftool(unittest.TestCase):
@classmethod
Expand All @@ -67,10 +72,7 @@ def setUpClass(cls):

@default_iface
def test_feature_dev_json(self, iface):
unexpected_helpers = [
"bpf_probe_write_user",
"bpf_trace_printk",
]
unexpected_helpers = DMESG_EMITTING_HELPERS
expected_keys = [
"syscall_config",
"program_types",
Expand All @@ -94,10 +96,7 @@ def test_feature_kernel(self):
bpftool_json(["feature", "probe"]),
bpftool_json(["feature"]),
]
unexpected_helpers = [
"bpf_probe_write_user",
"bpf_trace_printk",
]
unexpected_helpers = DMESG_EMITTING_HELPERS
expected_keys = [
"syscall_config",
"system_config",
Expand All @@ -121,10 +120,7 @@ def test_feature_kernel_full(self):
bpftool_json(["feature", "probe", "kernel", "full"]),
bpftool_json(["feature", "probe", "full"]),
]
expected_helpers = [
"bpf_probe_write_user",
"bpf_trace_printk",
]
expected_helpers = DMESG_EMITTING_HELPERS

for tc in test_cases:
# Check if expected helpers are included at least once in any
Expand Down Expand Up @@ -157,7 +153,7 @@ def test_feature_kernel_full_vs_not_full(self):
not_full_set.add(helper)

self.assertCountEqual(full_set - not_full_set,
{"bpf_probe_write_user", "bpf_trace_printk"})
set(DMESG_EMITTING_HELPERS))
self.assertCountEqual(not_full_set - full_set, set())

def test_feature_macros(self):
Expand Down

0 comments on commit 4190c29

Please sign in to comment.