]> granicus.if.org Git - strace/commitdiff
netlink: pass NLMSG_DONE messages to family specific payload decoders
authorJingPiao Chen <chenjingpiao@gmail.com>
Tue, 27 Jun 2017 08:16:56 +0000 (16:16 +0800)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 27 Jun 2017 09:37:09 +0000 (09:37 +0000)
While many NLMSG_DONE messages indeed have payload containing
just one integer, there are exceptions. Handle this by passing
payloads of NLMSG_DONE messages to family specific netlink
payload decoders.

* netlink.c (print_nlmsghdr): Do not skip family detection
for nlmsg_type == NLMSG_DONE.
(decode_nlmsg_type): Skip family specific type decoders
for type == NLMSG_DONE.
(decode_nlmsg_flags): Skip family specific decoding of flags
for type == NLMSG_DONE.
(decode_netlink_sock_diag): Skip for nlmsg_type == NLMSG_DONE.

netlink.c
netlink_sock_diag.c

index 87b389c436cc7752d3cc4bb4d30c6a2f630d5890..f74c3a070a0b286df3d72b4f26c56918d2cdd519 100644 (file)
--- a/netlink.c
+++ b/netlink.c
@@ -177,7 +177,7 @@ decode_nlmsg_type(const uint16_t type, const unsigned int family)
        const struct xlat *xlat = netlink_types;
        const char *dflt = "NLMSG_???";
 
-       if (family < ARRAY_SIZE(nlmsg_types)) {
+       if (type != NLMSG_DONE && family < ARRAY_SIZE(nlmsg_types)) {
                if (nlmsg_types[family].decoder)
                        decoder = nlmsg_types[family].decoder;
                if (nlmsg_types[family].xlat)
@@ -194,6 +194,9 @@ decode_nlmsg_flags(const uint16_t flags, const uint16_t type, const int family)
 {
        const struct xlat *table = NULL;
 
+       if (type == NLMSG_DONE)
+               goto end;
+
        switch (family) {
        case NETLINK_SOCK_DIAG:
                table = netlink_get_flags;
@@ -233,6 +236,7 @@ decode_nlmsg_flags(const uint16_t flags, const uint16_t type, const int family)
                break;
        }
 
+end:
        printflags_ex(flags, "NLM_F_???", netlink_flags, table, NULL);
 }
 
@@ -246,7 +250,8 @@ print_nlmsghdr(struct tcb *tcp,
 
        tprintf("{len=%u, type=", nlmsghdr->nlmsg_len);
 
-       const int hdr_family = (nlmsghdr->nlmsg_type < NLMSG_MIN_TYPE)
+       const int hdr_family = (nlmsghdr->nlmsg_type < NLMSG_MIN_TYPE
+                               && nlmsghdr->nlmsg_type != NLMSG_DONE)
                               ? NL_FAMILY_DEFAULT
                               : (family != NL_FAMILY_DEFAULT
                                  ? family : get_fd_nl_family(tcp, fd));
index d854808e023377e3094054e99267c9d5b638dd9b..4b096f87f30f3c36119c3c647a075098ffe8f4eb 100644 (file)
@@ -536,6 +536,9 @@ decode_netlink_sock_diag(struct tcb *const tcp,
 {
        uint8_t family;
 
+       if (nlmsghdr->nlmsg_type == NLMSG_DONE)
+               return false;
+
        if (!umove_or_printaddr(tcp, addr, &family)) {
                if (family < ARRAY_SIZE(diag_decoders)
                    && len > sizeof(family)) {