bpf: print fields that interpreted as pointers using printaddr64

* bpf.c (BEGIN_BPF_CMD_DECODER(BPF_MAP_LOOKUP_ELEM),
BEGIN_BPF_CMD_DECODER(BPF_MAP_UPDATE_ELEM)): Print key and value
fields using PRINT_FIELD_ADDR64.
(BEGIN_BPF_CMD_DECODER(BPF_MAP_DELETE_ELEM)): Print key field using
PRINT_FIELD_ADDR64.
(BEGIN_BPF_CMD_DECODER(BPF_MAP_GET_NEXT_KEY)): Print key and next_key
field using PRINT_FIELD_ADDR64.
(BEGIN_BPF_CMD_DECODER(BPF_PROG_LOAD)): Print insns and log_buf fields
using PRINT_FIELD_ADDR64.
(BEGIN_BPF_CMD_DECODER(BPF_PROG_TEST_RUN)): Print data_in and data_out
fields using PRINT_FIELD_ADDR64.
* tests/bpf.c: Update expected output.
This commit is contained in:
Eugene Syromyatnikov 2018-03-26 06:37:16 +02:00 committed by Dmitry V. Levin
parent fc8294cbc2
commit aa01b5368d
2 changed files with 19 additions and 19 deletions

22
bpf.c
View File

@ -188,16 +188,16 @@ END_BPF_CMD_DECODER(RVAL_DECODED | RVAL_FD)
BEGIN_BPF_CMD_DECODER(BPF_MAP_LOOKUP_ELEM)
{
PRINT_FIELD_FD("{", attr, map_fd, tcp);
PRINT_FIELD_X(", ", attr, key);
PRINT_FIELD_X(", ", attr, value);
PRINT_FIELD_ADDR64(", ", attr, key);
PRINT_FIELD_ADDR64(", ", attr, value);
}
END_BPF_CMD_DECODER(RVAL_DECODED)
BEGIN_BPF_CMD_DECODER(BPF_MAP_UPDATE_ELEM)
{
PRINT_FIELD_FD("{", attr, map_fd, tcp);
PRINT_FIELD_X(", ", attr, key);
PRINT_FIELD_X(", ", attr, value);
PRINT_FIELD_ADDR64(", ", attr, key);
PRINT_FIELD_ADDR64(", ", attr, value);
PRINT_FIELD_XVAL(", ", attr, flags, bpf_map_update_elem_flags,
"BPF_???");
}
@ -206,15 +206,15 @@ END_BPF_CMD_DECODER(RVAL_DECODED)
BEGIN_BPF_CMD_DECODER(BPF_MAP_DELETE_ELEM)
{
PRINT_FIELD_FD("{", attr, map_fd, tcp);
PRINT_FIELD_X(", ", attr, key);
PRINT_FIELD_ADDR64(", ", attr, key);
}
END_BPF_CMD_DECODER(RVAL_DECODED)
BEGIN_BPF_CMD_DECODER(BPF_MAP_GET_NEXT_KEY)
{
PRINT_FIELD_FD("{", attr, map_fd, tcp);
PRINT_FIELD_X(", ", attr, key);
PRINT_FIELD_X(", ", attr, next_key);
PRINT_FIELD_ADDR64(", ", attr, key);
PRINT_FIELD_ADDR64(", ", attr, next_key);
}
END_BPF_CMD_DECODER(RVAL_DECODED)
@ -223,7 +223,7 @@ BEGIN_BPF_CMD_DECODER(BPF_PROG_LOAD)
PRINT_FIELD_XVAL("{", attr, prog_type, bpf_prog_types,
"BPF_PROG_TYPE_???");
PRINT_FIELD_U(", ", attr, insn_cnt);
PRINT_FIELD_X(", ", attr, insns);
PRINT_FIELD_ADDR64(", ", attr, insns);
tprintf(", license=");
print_big_u64_addr(attr.license);
@ -234,7 +234,7 @@ BEGIN_BPF_CMD_DECODER(BPF_PROG_LOAD)
break;
PRINT_FIELD_U(", ", attr, log_level);
PRINT_FIELD_U(", ", attr, log_size);
PRINT_FIELD_X(", ", attr, log_buf);
PRINT_FIELD_ADDR64(", ", attr, log_buf);
/* kern_version field was added in Linux commit v4.1-rc1~84^2~50. */
if (len <= offsetof(struct BPF_PROG_LOAD_struct, kern_version))
@ -309,8 +309,8 @@ BEGIN_BPF_CMD_DECODER(BPF_PROG_TEST_RUN)
PRINT_FIELD_U(", ", attr, retval);
PRINT_FIELD_U(", ", attr, data_size_in);
PRINT_FIELD_U(", ", attr, data_size_out);
PRINT_FIELD_X(", ", attr, data_in);
PRINT_FIELD_X(", ", attr, data_out);
PRINT_FIELD_ADDR64(", ", attr, data_in);
PRINT_FIELD_ADDR64(", ", attr, data_out);
PRINT_FIELD_U(", ", attr, repeat);
PRINT_FIELD_U(", ", attr, duration);
tprints("}");

View File

@ -392,7 +392,7 @@ static const struct bpf_attr_check BPF_MAP_LOOKUP_ELEM_checks[] = {
{
.data = { .BPF_MAP_LOOKUP_ELEM_data = { .map_fd = -1 } },
.size = offsetofend(struct BPF_MAP_LOOKUP_ELEM_struct, map_fd),
.str = "map_fd=-1, key=0, value=0"
.str = "map_fd=-1, key=NULL, value=NULL"
},
{
.data = { .BPF_MAP_LOOKUP_ELEM_data = {
@ -409,7 +409,7 @@ static const struct bpf_attr_check BPF_MAP_UPDATE_ELEM_checks[] = {
{
.data = { .BPF_MAP_UPDATE_ELEM_data = { .map_fd = -1 } },
.size = offsetofend(struct BPF_MAP_UPDATE_ELEM_struct, map_fd),
.str = "map_fd=-1, key=0, value=0, flags=BPF_ANY"
.str = "map_fd=-1, key=NULL, value=NULL, flags=BPF_ANY"
},
{
.data = { .BPF_MAP_UPDATE_ELEM_data = {
@ -428,7 +428,7 @@ static const struct bpf_attr_check BPF_MAP_DELETE_ELEM_checks[] = {
{
.data = { .BPF_MAP_DELETE_ELEM_data = { .map_fd = -1 } },
.size = offsetofend(struct BPF_MAP_DELETE_ELEM_struct, map_fd),
.str = "map_fd=-1, key=0"
.str = "map_fd=-1, key=NULL"
},
{
.data = { .BPF_MAP_DELETE_ELEM_data = {
@ -444,7 +444,7 @@ static const struct bpf_attr_check BPF_MAP_GET_NEXT_KEY_checks[] = {
{
.data = { .BPF_MAP_GET_NEXT_KEY_data = { .map_fd = -1 } },
.size = offsetofend(struct BPF_MAP_GET_NEXT_KEY_struct, map_fd),
.str = "map_fd=-1, key=0, next_key=0"
.str = "map_fd=-1, key=NULL, next_key=NULL"
},
{
.data = { .BPF_MAP_GET_NEXT_KEY_data = {
@ -512,7 +512,7 @@ static struct bpf_attr_check BPF_PROG_LOAD_checks[] = {
.data = { .BPF_PROG_LOAD_data = { .prog_type = 1 } },
.size = offsetofend(struct BPF_PROG_LOAD_struct, prog_type),
.str = "prog_type=BPF_PROG_TYPE_SOCKET_FILTER"
", insn_cnt=0, insns=0, license=NULL"
", insn_cnt=0, insns=NULL, license=NULL"
},
{ /* 1 */
.data = { .BPF_PROG_LOAD_data = {
@ -528,8 +528,8 @@ static struct bpf_attr_check BPF_PROG_LOAD_checks[] = {
} },
.size = offsetofend(struct BPF_PROG_LOAD_struct, prog_flags),
.str = "prog_type=0x10 /* BPF_PROG_TYPE_??? */"
", insn_cnt=3134983661, insns=0, license=NULL"
", log_level=42, log_size=3141592653, log_buf=0"
", insn_cnt=3134983661, insns=NULL, license=NULL"
", log_level=42, log_size=3141592653, log_buf=NULL"
", kern_version=KERNEL_VERSION(51966, 240, 13)"
", prog_flags=0",
},
@ -688,7 +688,7 @@ static const struct bpf_attr_check BPF_PROG_TEST_RUN_checks[] = {
.data = { .BPF_PROG_TEST_RUN_data = { .prog_fd = -1 } },
.size = offsetofend(struct BPF_PROG_TEST_RUN_struct, prog_fd),
.str = "test={prog_fd=-1, retval=0, data_size_in=0"
", data_size_out=0, data_in=0, data_out=0"
", data_size_out=0, data_in=NULL, data_out=NULL"
", repeat=0, duration=0}"
},
{