From: JingPiao Chen Date: Fri, 7 Jul 2017 01:44:09 +0000 (+0800) Subject: netlink: print unrecognized netlink messages in hex X-Git-Tag: v4.19~327 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5626a08061a538e4e80ebbee6da067167a8508d8;p=strace netlink: print unrecognized netlink messages in hex * netlink.c (fetch_nlmsghdr): Replace printstrn with printstr_ex and set QUOTE_FORCE_HEX flag. * tests/netlink_protocol.c (send_query): Update expected output. --- diff --git a/netlink.c b/netlink.c index cd1296fe..d09724f1 100644 --- a/netlink.c +++ b/netlink.c @@ -53,7 +53,7 @@ fetch_nlmsghdr(struct tcb *const tcp, struct nlmsghdr *const nlmsghdr, const kernel_ulong_t addr, const kernel_ulong_t len) { if (len < sizeof(struct nlmsghdr)) { - printstrn(tcp, addr, len); + printstr_ex(tcp, addr, len, QUOTE_FORCE_HEX); return false; } diff --git a/tests/netlink_protocol.c b/tests/netlink_protocol.c index ebb93c42..a3e09cb9 100644 --- a/tests/netlink_protocol.c +++ b/tests/netlink_protocol.c @@ -83,7 +83,8 @@ send_query(const int fd) /* whole message length < sizeof(struct nlmsghdr) */ rc = sendto(fd, req->magic, sizeof(req->magic), MSG_DONTWAIT, NULL, 0); - printf("sendto(%d, \"abcd\", %u, MSG_DONTWAIT, NULL, 0) = %s\n", + printf("sendto(%d, \"\\x61\\x62\\x63\\x64\"" + ", %u, MSG_DONTWAIT, NULL, 0) = %s\n", fd, (unsigned) sizeof(req->magic), sprintrc(rc)); /* a single message with some data */ @@ -155,8 +156,8 @@ send_query(const int fd) printf("sendto(%d, [{{len=%u, type=NLMSG_NOOP, flags=NLM_F_REQUEST|0x%x" ", seq=0, pid=0}, \"\\x61\\x62\\x63\\x64\"}, ", fd, reqs->req1.nlh.nlmsg_len, NLM_F_DUMP); - print_quoted_memory((void *) &reqs->req2.nlh, - sizeof(reqs->req2) - sizeof(req->nlh)); + print_quoted_hex((void *) &reqs->req2.nlh, + sizeof(reqs->req2) - sizeof(req->nlh)); printf("], %u, MSG_DONTWAIT, NULL, 0) = %s\n", (unsigned) (sizeof(*reqs) - sizeof(req->nlh)), errstr);