[Devel] [PATCH VZ10 2/3] selftests/ve_devcg_bpf: factor device program insns into DEVCG_PROG_INSNS
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Tue Jul 28 14:08:10 MSK 2026
Introduce a DEVCG_PROG_INSNS macro holding the minimal CGROUP_DEVICE
program (r0 = 1; exit) and use it in load_devcg_prog(). This lets the
loader and the upcoming orig_insns dump checks share one definition so
they cannot drift.
Feature: BPF checkpoint/restore
https://virtuozzo.atlassian.net/browse/VSTOR-121776
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
.../ve_devcg_bpf/ve_devcg_bpf_test.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/tools/testing/selftests/ve_devcg_bpf/ve_devcg_bpf_test.c b/tools/testing/selftests/ve_devcg_bpf/ve_devcg_bpf_test.c
index a7e6a9217b191..da55f82492f5b 100644
--- a/tools/testing/selftests/ve_devcg_bpf/ve_devcg_bpf_test.c
+++ b/tools/testing/selftests/ve_devcg_bpf/ve_devcg_bpf_test.c
@@ -97,6 +97,15 @@ enum {
TEST_PROG_LOAD_OVERSIZED_DENIED,
};
+/*
+ * Minimal BPF_PROG_TYPE_CGROUP_DEVICE program:
+ * r0 = 1 (allow device access)
+ * exit
+ */
+#define DEVCG_PROG_INSNS \
+ BPF_MOV64_IMM(BPF_REG_0, 1), \
+ BPF_EXIT_INSN()
+
struct fargs {
int cgv2_fd;
int ctid;
@@ -105,15 +114,7 @@ struct fargs {
static int load_devcg_prog(void)
{
- /*
- * Minimal BPF_PROG_TYPE_CGROUP_DEVICE program:
- * r0 = 1 (allow device access)
- * exit
- */
- struct bpf_insn insns[] = {
- BPF_MOV64_IMM(BPF_REG_0, 1),
- BPF_EXIT_INSN(),
- };
+ struct bpf_insn insns[] = { DEVCG_PROG_INSNS };
union bpf_attr attr;
static char log_buf[4096];
--
2.54.0
More information about the Devel
mailing list