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:
parent
fc8294cbc2
commit
aa01b5368d
22
bpf.c
22
bpf.c
@ -188,16 +188,16 @@ END_BPF_CMD_DECODER(RVAL_DECODED | RVAL_FD)
|
|||||||
BEGIN_BPF_CMD_DECODER(BPF_MAP_LOOKUP_ELEM)
|
BEGIN_BPF_CMD_DECODER(BPF_MAP_LOOKUP_ELEM)
|
||||||
{
|
{
|
||||||
PRINT_FIELD_FD("{", attr, map_fd, tcp);
|
PRINT_FIELD_FD("{", attr, map_fd, tcp);
|
||||||
PRINT_FIELD_X(", ", attr, key);
|
PRINT_FIELD_ADDR64(", ", attr, key);
|
||||||
PRINT_FIELD_X(", ", attr, value);
|
PRINT_FIELD_ADDR64(", ", attr, value);
|
||||||
}
|
}
|
||||||
END_BPF_CMD_DECODER(RVAL_DECODED)
|
END_BPF_CMD_DECODER(RVAL_DECODED)
|
||||||
|
|
||||||
BEGIN_BPF_CMD_DECODER(BPF_MAP_UPDATE_ELEM)
|
BEGIN_BPF_CMD_DECODER(BPF_MAP_UPDATE_ELEM)
|
||||||
{
|
{
|
||||||
PRINT_FIELD_FD("{", attr, map_fd, tcp);
|
PRINT_FIELD_FD("{", attr, map_fd, tcp);
|
||||||
PRINT_FIELD_X(", ", attr, key);
|
PRINT_FIELD_ADDR64(", ", attr, key);
|
||||||
PRINT_FIELD_X(", ", attr, value);
|
PRINT_FIELD_ADDR64(", ", attr, value);
|
||||||
PRINT_FIELD_XVAL(", ", attr, flags, bpf_map_update_elem_flags,
|
PRINT_FIELD_XVAL(", ", attr, flags, bpf_map_update_elem_flags,
|
||||||
"BPF_???");
|
"BPF_???");
|
||||||
}
|
}
|
||||||
@ -206,15 +206,15 @@ END_BPF_CMD_DECODER(RVAL_DECODED)
|
|||||||
BEGIN_BPF_CMD_DECODER(BPF_MAP_DELETE_ELEM)
|
BEGIN_BPF_CMD_DECODER(BPF_MAP_DELETE_ELEM)
|
||||||
{
|
{
|
||||||
PRINT_FIELD_FD("{", attr, map_fd, tcp);
|
PRINT_FIELD_FD("{", attr, map_fd, tcp);
|
||||||
PRINT_FIELD_X(", ", attr, key);
|
PRINT_FIELD_ADDR64(", ", attr, key);
|
||||||
}
|
}
|
||||||
END_BPF_CMD_DECODER(RVAL_DECODED)
|
END_BPF_CMD_DECODER(RVAL_DECODED)
|
||||||
|
|
||||||
BEGIN_BPF_CMD_DECODER(BPF_MAP_GET_NEXT_KEY)
|
BEGIN_BPF_CMD_DECODER(BPF_MAP_GET_NEXT_KEY)
|
||||||
{
|
{
|
||||||
PRINT_FIELD_FD("{", attr, map_fd, tcp);
|
PRINT_FIELD_FD("{", attr, map_fd, tcp);
|
||||||
PRINT_FIELD_X(", ", attr, key);
|
PRINT_FIELD_ADDR64(", ", attr, key);
|
||||||
PRINT_FIELD_X(", ", attr, next_key);
|
PRINT_FIELD_ADDR64(", ", attr, next_key);
|
||||||
}
|
}
|
||||||
END_BPF_CMD_DECODER(RVAL_DECODED)
|
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,
|
PRINT_FIELD_XVAL("{", attr, prog_type, bpf_prog_types,
|
||||||
"BPF_PROG_TYPE_???");
|
"BPF_PROG_TYPE_???");
|
||||||
PRINT_FIELD_U(", ", attr, insn_cnt);
|
PRINT_FIELD_U(", ", attr, insn_cnt);
|
||||||
PRINT_FIELD_X(", ", attr, insns);
|
PRINT_FIELD_ADDR64(", ", attr, insns);
|
||||||
|
|
||||||
tprintf(", license=");
|
tprintf(", license=");
|
||||||
print_big_u64_addr(attr.license);
|
print_big_u64_addr(attr.license);
|
||||||
@ -234,7 +234,7 @@ BEGIN_BPF_CMD_DECODER(BPF_PROG_LOAD)
|
|||||||
break;
|
break;
|
||||||
PRINT_FIELD_U(", ", attr, log_level);
|
PRINT_FIELD_U(", ", attr, log_level);
|
||||||
PRINT_FIELD_U(", ", attr, log_size);
|
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. */
|
/* kern_version field was added in Linux commit v4.1-rc1~84^2~50. */
|
||||||
if (len <= offsetof(struct BPF_PROG_LOAD_struct, kern_version))
|
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, retval);
|
||||||
PRINT_FIELD_U(", ", attr, data_size_in);
|
PRINT_FIELD_U(", ", attr, data_size_in);
|
||||||
PRINT_FIELD_U(", ", attr, data_size_out);
|
PRINT_FIELD_U(", ", attr, data_size_out);
|
||||||
PRINT_FIELD_X(", ", attr, data_in);
|
PRINT_FIELD_ADDR64(", ", attr, data_in);
|
||||||
PRINT_FIELD_X(", ", attr, data_out);
|
PRINT_FIELD_ADDR64(", ", attr, data_out);
|
||||||
PRINT_FIELD_U(", ", attr, repeat);
|
PRINT_FIELD_U(", ", attr, repeat);
|
||||||
PRINT_FIELD_U(", ", attr, duration);
|
PRINT_FIELD_U(", ", attr, duration);
|
||||||
tprints("}");
|
tprints("}");
|
||||||
|
16
tests/bpf.c
16
tests/bpf.c
@ -392,7 +392,7 @@ static const struct bpf_attr_check BPF_MAP_LOOKUP_ELEM_checks[] = {
|
|||||||
{
|
{
|
||||||
.data = { .BPF_MAP_LOOKUP_ELEM_data = { .map_fd = -1 } },
|
.data = { .BPF_MAP_LOOKUP_ELEM_data = { .map_fd = -1 } },
|
||||||
.size = offsetofend(struct BPF_MAP_LOOKUP_ELEM_struct, map_fd),
|
.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 = {
|
.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 } },
|
.data = { .BPF_MAP_UPDATE_ELEM_data = { .map_fd = -1 } },
|
||||||
.size = offsetofend(struct BPF_MAP_UPDATE_ELEM_struct, map_fd),
|
.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 = {
|
.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 } },
|
.data = { .BPF_MAP_DELETE_ELEM_data = { .map_fd = -1 } },
|
||||||
.size = offsetofend(struct BPF_MAP_DELETE_ELEM_struct, map_fd),
|
.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 = {
|
.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 } },
|
.data = { .BPF_MAP_GET_NEXT_KEY_data = { .map_fd = -1 } },
|
||||||
.size = offsetofend(struct BPF_MAP_GET_NEXT_KEY_struct, map_fd),
|
.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 = {
|
.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 } },
|
.data = { .BPF_PROG_LOAD_data = { .prog_type = 1 } },
|
||||||
.size = offsetofend(struct BPF_PROG_LOAD_struct, prog_type),
|
.size = offsetofend(struct BPF_PROG_LOAD_struct, prog_type),
|
||||||
.str = "prog_type=BPF_PROG_TYPE_SOCKET_FILTER"
|
.str = "prog_type=BPF_PROG_TYPE_SOCKET_FILTER"
|
||||||
", insn_cnt=0, insns=0, license=NULL"
|
", insn_cnt=0, insns=NULL, license=NULL"
|
||||||
},
|
},
|
||||||
{ /* 1 */
|
{ /* 1 */
|
||||||
.data = { .BPF_PROG_LOAD_data = {
|
.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),
|
.size = offsetofend(struct BPF_PROG_LOAD_struct, prog_flags),
|
||||||
.str = "prog_type=0x10 /* BPF_PROG_TYPE_??? */"
|
.str = "prog_type=0x10 /* BPF_PROG_TYPE_??? */"
|
||||||
", insn_cnt=3134983661, insns=0, license=NULL"
|
", insn_cnt=3134983661, insns=NULL, license=NULL"
|
||||||
", log_level=42, log_size=3141592653, log_buf=0"
|
", log_level=42, log_size=3141592653, log_buf=NULL"
|
||||||
", kern_version=KERNEL_VERSION(51966, 240, 13)"
|
", kern_version=KERNEL_VERSION(51966, 240, 13)"
|
||||||
", prog_flags=0",
|
", 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 } },
|
.data = { .BPF_PROG_TEST_RUN_data = { .prog_fd = -1 } },
|
||||||
.size = offsetofend(struct BPF_PROG_TEST_RUN_struct, prog_fd),
|
.size = offsetofend(struct BPF_PROG_TEST_RUN_struct, prog_fd),
|
||||||
.str = "test={prog_fd=-1, retval=0, data_size_in=0"
|
.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}"
|
", repeat=0, duration=0}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user