]> granicus.if.org Git - strace/commitdiff
bpf: print kern_version in the form of KERNEL_VERSION macro
authorEugene Syromyatnikov <evgsyr@gmail.com>
Thu, 22 Feb 2018 01:44:04 +0000 (02:44 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 7 Mar 2018 22:07:20 +0000 (22:07 +0000)
* bpf.c (DEF_BPF_CMD_DECODER(BPF_PROG_LOAD)): Print
union bpf_attr.kern_version in the form of KERNEL_VERSION macro call.
* tests/bpf.c: Update expected output.

bpf.c
tests/bpf.c

diff --git a/bpf.c b/bpf.c
index 59d1e749915d04064f1e6eab07c9bf811e8227a8..0e07444a5db357f2839059cb853df183fdfbce27 100644 (file)
--- a/bpf.c
+++ b/bpf.c
@@ -213,7 +213,10 @@ DEF_BPF_CMD_DECODER(BPF_PROG_LOAD)
        PRINT_FIELD_U(", ", attr, log_level);
        PRINT_FIELD_U(", ", attr, log_size);
        PRINT_FIELD_X(", ", attr, log_buf);
-       PRINT_FIELD_U(", ", attr, kern_version);
+       tprintf(", kern_version=KERNEL_VERSION(%u, %u, %u)",
+               attr.kern_version >> 16,
+               (attr.kern_version >> 8) & 0xFF,
+               attr.kern_version & 0xFF);
        PRINT_FIELD_FLAGS(", ", attr, prog_flags, bpf_prog_flags, "BPF_F_???");
        decode_attr_extra_data(tcp, data, size, sizeof(attr));
        tprints("}");
index 3f963fa3f009e7dfcaee396e0dc5599a329e548f..a275fded78b4580f81161ff87c542cfcea8aa67b 100644 (file)
@@ -376,7 +376,7 @@ print_BPF_PROG_LOAD_first(const unsigned long addr)
 
        printf("prog_type=BPF_PROG_TYPE_SOCKET_FILTER, insn_cnt=0, insns=0"
               ", license=NULL, log_level=0, log_size=0, log_buf=0"
-              ", kern_version=0, prog_flags=0");
+              ", kern_version=KERNEL_VERSION(0, 0, 0), prog_flags=0");
 }
 
 static const struct bpf_insn insns[] = {
@@ -411,9 +411,10 @@ print_BPF_PROG_LOAD_attr(const unsigned long addr)
 {
        printf("prog_type=BPF_PROG_TYPE_SOCKET_FILTER, insn_cnt=%u, insns=%p"
               ", license=\"GPL\", log_level=42, log_size=4096, log_buf=%p"
-              ", kern_version=%u, prog_flags=BPF_F_STRICT_ALIGNMENT",
+              ", kern_version=KERNEL_VERSION(51966, 240, 13)"
+              ", prog_flags=BPF_F_STRICT_ALIGNMENT",
               (unsigned int) ARRAY_SIZE(insns), insns,
-              log_buf, 0xcafef00d);
+              log_buf);
 }
 
 # endif /* HAVE_UNION_BPF_ATTR_PROG_FLAGS */