]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/bpf: Handle !CONFIG_SMC in bpf_smc.c
authorAlan Maguire <alan.maguire@oracle.com>
Tue, 10 Mar 2026 11:13:29 +0000 (11:13 +0000)
committerMartin KaFai Lau <martin.lau@kernel.org>
Wed, 11 Mar 2026 00:40:15 +0000 (17:40 -0700)
commite95e85b8914be1c951a1ead34b1353592719e26e
tree16f60327fb41051da3180fdba00b244d8710b7ae
parent0c55d4817aff454cfaded4f161ab13f2049758a9
selftests/bpf: Handle !CONFIG_SMC in bpf_smc.c

Currently BPF selftests will fail to compile if CONFIG_SMC
is not set.

Use BPF CO-RE to work around the case where CONFIG_SMC is
not set; use ___local variants of relevant structures and
utilize bpf_core_field_exists() for net->smc.

The test continues to pass where

  CONFIG_SMC=y
  CONFIG_SMC_HS_CTRL_BPF=y

but these changes allow the selftests to build in the absence
of CONFIG_SMC=y.

Also ensure that we get a pure skip rather than a skip+fail
by removing the SMC is unsupported part from the ASSERT_FALSE()
in get_smc_nl_family(); doing this means we get a skip without
a fail when CONFIG_SMC is not set:

$ sudo ./test_progs -t bpf_smc
Summary: 1/0 PASSED, 1 SKIPPED, 0 FAILED

Fixes: beb3c67297d9 ("bpf/selftests: Add selftest for bpf_smc_hs_ctrl")
Reported-by: Colm Harrington <colm.harrington@oracle.com>
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Tested-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://patch.msgid.link/20260310111330.601765-1-alan.maguire@oracle.com
tools/testing/selftests/bpf/prog_tests/test_bpf_smc.c
tools/testing/selftests/bpf/progs/bpf_smc.c