On Fri, May 05, 2017 at 06:21:17PM +0800, JingPiao Chen wrote: > * netlink.c (decode_payload): Decode NLMSG_DONE message. > * tests/netlink_protocol.c: Add check for decoding > of NLMSG_DONE message. > --- > netlink.c | 5 +++++ > tests/netlink_protocol.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 52 insertions(+) > > diff --git a/netlink.c b/netlink.c > index 16550d6..d00ff42 100644 > --- a/netlink.c > +++ b/netlink.c > @@ -113,6 +113,11 @@ decode_payload(struct tcb *const tcp, > { > if (nlmsghdr->nlmsg_type == NLMSG_ERROR && len >= sizeof(int)) { > decode_nlmsgerr(tcp, addr, len); > + } else if (nlmsghdr->nlmsg_type == NLMSG_DONE && len >= sizeof(int)) { > + int total_len; > + > + if (!umove_or_printaddr(tcp, addr, &total_len)) > + tprintf("%d", total_len); > } else { > printstrn(tcp, addr, len); > }
Unlike NLMSG_ERROR, there are no universal NLMSG_DONE messages. While many NLMSG_DONE messages indeed have payload containing just one integer, there are exceptions. For example, net/netfilter/nfnetlink_log.c:__nfulnl_send() sends struct nfgenmsg, drivers/connector/connector.c:cn_netlink_send_mult() sends struct cn_msg, drivers/scsi/scsi_transport_iscsi.c:iscsi_if_send_reply() sends struct iscsi_uevent, kernel/auditfilter.c:audit_list_rules() sends struct audit_rule_data, kernel/audit.c:audit_get_feature() sends struct audit_features, kernel/audit.c:audit_receive_msg() sends struct audit_status, audit_sig_info, audit_tty_status, and so on. I suggest implementing a default decoder of NLMSG_DONE messages that would print the integer in case of len == sizeof(int) and fall back to printstrn for other lengths. When protocol specific netlink decoders are added, they could either decode NLMSG_DONE themselves (and return true) or just return false to fall back to default decoder. -- ldv
signature.asc
Description: PGP signature
------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel