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.
This commit is contained in:
Eugene Syromyatnikov 2018-02-22 02:44:04 +01:00 committed by Dmitry V. Levin
parent 8c209d1ad1
commit ffcd3a837f
2 changed files with 8 additions and 4 deletions

5
bpf.c
View File

@ -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("}");

View 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 */