From: Eugene Syromyatnikov Date: Thu, 22 Feb 2018 01:44:04 +0000 (+0100) Subject: bpf: print kern_version in the form of KERNEL_VERSION macro X-Git-Tag: v4.22~106 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ffcd3a837f734ddf3a55d40117edbb9a7c4e90e2;p=strace bpf: print kern_version in the form of KERNEL_VERSION macro * 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. --- diff --git a/bpf.c b/bpf.c index 59d1e749..0e07444a 100644 --- 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("}"); diff --git a/tests/bpf.c b/tests/bpf.c index 3f963fa3..a275fded 100644 --- a/tests/bpf.c +++ b/tests/bpf.c @@ -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 */