diff options
author | Eugene Syromyatnikov <evgsyr@gmail.com> | 2021-12-16 02:27:18 +0100 |
---|---|---|
committer | Dmitry V. Levin <ldv@strace.io> | 2022-07-31 21:03:01 +0000 |
commit | 73be9ad60dd7b079ab8229bece552efd4f780baa (patch) | |
tree | cb0c3f5c70b4cfe987bb84b18d3d9f74a9357041 | |
parent | 70424e674b8644be675587389c31afdae29b9132 (diff) | |
download | strace-73be9ad60dd7b079ab8229bece552efd4f780baa.tar.gz |
inet_diag: implement INET_DIAG_CGROUP_ID attribute decoding
* src/netlink_inet_diag.c (inet_diag_msg_nla_decoders)
<[INET_DIAG_CGROUP_ID]>: New entry, set to decode_nla_u64.
* tests/nlattr_inet_diag_msg.c: Add checks for uint attributes.
-rw-r--r-- | src/netlink_inet_diag.c | 1 | ||||
-rw-r--r-- | tests/nlattr_inet_diag_msg.c | 41 |
2 files changed, 42 insertions, 0 deletions
diff --git a/src/netlink_inet_diag.c b/src/netlink_inet_diag.c index 8b1a6ac2f..93ae94ad5 100644 --- a/src/netlink_inet_diag.c +++ b/src/netlink_inet_diag.c @@ -688,6 +688,7 @@ static const nla_decoder_t inet_diag_msg_nla_decoders[] = { [INET_DIAG_MD5SIG] = decode_tcp_md5sig, [INET_DIAG_ULP_INFO] = decode_diag_ulp_info, [INET_DIAG_SK_BPF_STORAGES] = decode_diag_bpf_storages, + [INET_DIAG_CGROUP_ID] = decode_nla_u64, }; DECL_NETLINK_DIAG_DECODER(decode_inet_diag_msg) diff --git a/tests/nlattr_inet_diag_msg.c b/tests/nlattr_inet_diag_msg.c index 5a3bf040c..792f60d28 100644 --- a/tests/nlattr_inet_diag_msg.c +++ b/tests/nlattr_inet_diag_msg.c @@ -336,6 +336,47 @@ main(void) DEFAULT_STRLEN, str, DEFAULT_STRLEN, printf("\"%s\"", str)); + /* u8 INET_DIAG_* attrs */ + static const struct strval16 u8_attrs[] = { + { ENUM_KNOWN(0x5, INET_DIAG_TOS) }, + { ENUM_KNOWN(0x6, INET_DIAG_TCLASS) }, + { ENUM_KNOWN(0xb, INET_DIAG_SKV6ONLY) }, + }; + void *nlh_u8 = midtail_alloc(NLMSG_SPACE(hdrlen), sizeof(uint8_t)); + + for (size_t i = 0; i < ARRAY_SIZE(u8_attrs); i++) { + check_u8_nlattr(fd, nlh_u8, hdrlen, + init_inet_diag_msg, print_inet_diag_msg, + u8_attrs[i].val, u8_attrs[i].str, pattern, 0); + } + + /* u32 INET_DIAG_* attrs */ + static const struct strval16 u32_attrs[] = { + { ENUM_KNOWN(0xf, INET_DIAG_MARK) }, + { ENUM_KNOWN(0x11, INET_DIAG_CLASS_ID) }, + }; + void *nlh_u32 = midtail_alloc(NLMSG_SPACE(hdrlen), sizeof(uint32_t)); + + for (size_t i = 0; i < ARRAY_SIZE(u32_attrs); i++) { + check_u32_nlattr(fd, nlh_u32, hdrlen, + init_inet_diag_msg, print_inet_diag_msg, + u32_attrs[i].val, u32_attrs[i].str, + pattern, 0); + } + + /* u64 INET_DIAG_* attrs */ + static const struct strval16 u64_attrs[] = { + { ENUM_KNOWN(0x15, INET_DIAG_CGROUP_ID) }, + }; + void *nlh_u64 = midtail_alloc(NLMSG_SPACE(hdrlen), sizeof(uint64_t)); + + for (size_t i = 0; i < ARRAY_SIZE(u64_attrs); i++) { + check_u64_nlattr(fd, nlh_u64, hdrlen, + init_inet_diag_msg, print_inet_diag_msg, + u64_attrs[i].val, u64_attrs[i].str, + pattern, 0); + } + /* INET_DIAG_PROTOCOL */ static const struct strval8 protos[] = { { 0, "IPPROTO_IP" }, |