[Devel] [PATCH RHEL10 COMMIT] selftests/ve_devcg_bpf: factor device program insns into DEVCG_PROG_INSNS

Konstantin Khorenko khorenko at virtuozzo.com
Fri Jul 31 16:42:01 MSK 2026


The commit is pushed to "branch-rh10-6.12.0-211.39.1.16.x.vz10-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh10-6.12.0-211.39.1.16.1.vz10
------>
commit 40e9a5892e2996abc386cc1f0dee4d5813cc232e
Author: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
Date:   Tue Jul 28 13:08:10 2026 +0200

    selftests/ve_devcg_bpf: factor device program insns into DEVCG_PROG_INSNS
    
    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>
    Reviewed-by: Vasileios Almpanis <vasileios.almpanis at virtuozzo.com>
---
 .../selftests/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];
 


More information about the Devel mailing list