From: Jens Axboe <axboe@kernel.dk>
To: Yang Xiuwei <yangxiuwei@kylinos.cn>
Cc: io-uring@vger.kernel.org
Subject: Re: [PATCH 2/2] test/cbpf_filter: skip when openat2.h is not available
Date: Sun, 15 Mar 2026 08:45:12 -0600 [thread overview]
Message-ID: <3ecf01a7-4057-423e-bafa-881454f6e014@kernel.dk> (raw)
In-Reply-To: <20260315050217.121292-1-yangxiuwei@kylinos.cn>
On 3/14/26 11:02 PM, Yang Xiuwei wrote:
> Hi Jens,
>
> On 2026-03-14 13:35 UTC, Jens Axboe wrote:
>> liburing defines open_how if it's not in the system headers. I feel
>> like all you need to do here is remove the openat2.h include, rather
>> than disable the test entirely?
>
> Thanks for the suggestion. I had actually tried that first: removing only the
> #include <linux/openat2.h> and relying on liburing's compat for struct open_how.
> It turned out that this test also uses the RESOLVE_IN_ROOT macro (and the
> filter logic is built around it). Without the header, the build fails with
> 'RESOLVE_IN_ROOT' undeclared. RESOLVE_IN_ROOT and the other RESOLVE_* flags
> come from <linux/openat2.h>; compat.h only provides struct open_how when the
> header is missing, not those constants.
>
> Defining RESOLVE_IN_ROOT (and friends) ourselves in compat or in the test
> would duplicate kernel UAPI and could get out of sync if the kernel ever
> changes them. So I went back to the more conservative approach: wrap the
> test in #ifdef CONFIG_HAVE_OPEN_HOW and provide a stub main that returns
> T_EXIT_SKIP when openat2.h is not available. The test then always compiles;
> on systems without the header it simply skips at runtime.
>
> If you have a better approach in mind, I'd be glad to follow that instead.
I think just defining RESOLVE_IN_ROOT if it's not available should be
fine. And yes the test will always compile when you stub everything out,
but it also won't do anything at all. This will prevent running this
test case on a host with old headers, but with a current kernel. How
about the below, hopefully that should do it. That'll keep the test
functional, rather than wrap it all in a define that just disables it
entirely.
diff --git a/test/cbpf_filter.c b/test/cbpf_filter.c
index 41fd284e4434..b80b15033662 100644
--- a/test/cbpf_filter.c
+++ b/test/cbpf_filter.c
@@ -15,12 +15,15 @@
#include <sys/wait.h>
#include <sys/prctl.h>
#include <linux/filter.h>
-#include <linux/openat2.h>
#include "liburing.h"
#include "liburing/io_uring/bpf_filter.h"
#include "helpers.h"
+#ifndef RESOLVE_IN_ROOT
+#define RESOLVE_IN_ROOT 0x10
+#endif
+
/*
* cBPF filter context layout (struct io_uring_bpf_ctx):
* offset 0: user_data (u64)
--
Jens Axboe
next prev parent reply other threads:[~2026-03-15 14:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-14 8:35 [PATCH Liburing 0/2] build and compiler warning fixes Yang Xiuwei
2026-03-14 8:35 ` [PATCH 1/2] examples/send-zerocopy: fix -Wstringop-truncation on ifr.ifr_name Yang Xiuwei
2026-03-14 8:35 ` [PATCH 2/2] test/cbpf_filter: skip when openat2.h is not available Yang Xiuwei
2026-03-14 13:35 ` Jens Axboe
2026-03-15 5:02 ` Yang Xiuwei
2026-03-15 14:45 ` Jens Axboe [this message]
2026-03-16 1:02 ` Yang Xiuwei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3ecf01a7-4057-423e-bafa-881454f6e014@kernel.dk \
--to=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
--cc=yangxiuwei@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox