[PATCH v2 7/7] Netlink: handle multi netlink messages

Fabien Siron fabien.siron at epita.fr
Mon Jun 13 14:37:27 UTC 2016


* netlink.c (decode_netlink_or_printaddr_msg): From
decode_netlink_or_printaddr().
(decode_netlink_or_printaddr): Call decode_netlink_or_printaddr_msg().
---
 netlink.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/netlink.c b/netlink.c
index bb2c3a7..9b0d352 100644
--- a/netlink.c
+++ b/netlink.c
@@ -59,11 +59,11 @@ nlmsg_next(struct tcb *tcp, unsigned long nlh, unsigned long *len) {
 		((char *)(nlh) + NLMSG_ALIGN(nlmsghdr.nlmsg_len));
 }
 
-void
-decode_netlink_or_printaddr(struct tcb *tcp, unsigned long addr,
+#ifdef AF_NETLINK
+static void
+decode_netlink_msg(struct tcb *tcp, unsigned long addr,
 			    unsigned long size)
 {
-#ifdef AF_NETLINK
 	struct nlmsghdr nlmsghdr;
 	memset(&nlmsghdr, 0, sizeof(nlmsghdr));
 	if (umoven(tcp, addr, sizeof(nlmsghdr), &nlmsghdr) == -1)
@@ -88,6 +88,21 @@ decode_netlink_or_printaddr(struct tcb *tcp, unsigned long addr,
 
 	tprints("}");
 
+}
+#endif
+
+void
+decode_netlink_or_printaddr(struct tcb *tcp, unsigned long addr,
+			    unsigned long size)
+{
+#ifdef AF_NETLINK
+	if (!nlmsg_ok(tcp, addr, size))
+		return;
+
+	for (; nlmsg_ok(tcp, addr, size);
+	     addr = nlmsg_next(tcp, addr, &size)) {
+		decode_netlink_msg(tcp, addr, size);
+	}
 #else
 	printaddr(addr);
 #endif
-- 
2.8.3





More information about the Strace-devel mailing list