Hi Ilya,

On 04/09/2026 18:41, Ilya Maximets wrote:
> On 9/4/26 6:13 PM, Matthieu Baerts (NGI0) wrote:
>> KHDR_INCLUDES is typically used to include headers from the kernel
>> source directory instead of only relying on the ones from the host: they
>> can be missing or outdated.
>>
>> The kselftest doc recommends assigning KHDR_INCLUDES to CFLAGS in a
>> target Makefile. lib.mk will set KHDR_INCLUDES to "-isystem
>> $(top_srcdir)/usr/include" if the user didn't set it, e.g. if the kernel
>> was built in a different build directory.
>>
>> Other net targets have KHDR_INCLUDES added to their CFLAGS.
>>
>> Fixes: 3f189349e52a ("selftests: netfilter: move to net subdir")
> 
> I think, this should point to a commit that added the first C test:
> 
> Fixes: a64d558d8cf9 ("selftests: netfilter: add nfqueue test case")

Good catch! I saw that CFLAGS was set before, but indeed, KHDR_INCLUDES
wasn't.

If we want to change the Fixes tag, we will also need to add:

Fixes: a52540522c95 ("selftests/landlock: Fix out-of-tree builds")

Which is when KHDR_INCLUDES got introduced. (Or it is enough with the
current Fixes tag, as long as it is included in the last stable version:
that's probably enough for CIs using kselftests from the last stable
version on older ones.)

@Net maintainers: please tell me if I need to change the Fixes tag in a v2.

>> Link: 
>> https://docs.kernel.org/dev-tools/kselftest.html#contributing-new-tests-details
>> Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
>> ---
>>  tools/testing/selftests/net/netfilter/Makefile | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/tools/testing/selftests/net/netfilter/Makefile 
>> b/tools/testing/selftests/net/netfilter/Makefile
>> index f88dd4ef8d26..df3c20c90f5d 100644
>> --- a/tools/testing/selftests/net/netfilter/Makefile
>> +++ b/tools/testing/selftests/net/netfilter/Makefile
>> @@ -2,6 +2,8 @@
>>  
>>  top_srcdir = ../../../../..
>>  
>> +CFLAGS += $(KHDR_INCLUDES)
>> +
>>  HOSTPKG_CONFIG := pkg-config
>>  MNL_CFLAGS := $(shell $(HOSTPKG_CONFIG) --cflags libmnl 2>/dev/null)
>>  MNL_LDLIBS := $(shell $(HOSTPKG_CONFIG) --libs libmnl 2>/dev/null || echo 
>> -lmnl)
>>
> 
> This solves my problem with building netfilter tests locally with uAPI
> modifications.  Beside the Fixes tag, LGTM.
Thank you for having checked!

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.


Reply via email to