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

Fabien Siron fabien.siron at epita.fr
Wed Jun 15 12:43:05 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 | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/netlink.c b/netlink.c
index c1a9ad4..7581f2b 100644
--- a/netlink.c
+++ b/netlink.c
@@ -57,8 +57,9 @@ nlmsg_next(struct tcb *tcp, unsigned long nlh, unsigned long *len) {
 		((char *)(nlh) + NLMSG_ALIGN(nlmsghdr.nlmsg_len));
 }
 
-void
-decode_netlink(struct tcb *tcp, unsigned long addr, unsigned long size)
+static void
+decode_netlink_msg(struct tcb *tcp, unsigned long addr,
+			    unsigned long size)
 {
 	struct nlmsghdr nlmsghdr;
 
@@ -89,6 +90,17 @@ decode_netlink(struct tcb *tcp, unsigned long addr, unsigned long size)
 	tprints("}");
 }
 
+void
+decode_netlink(struct tcb *tcp, unsigned long addr, unsigned long size) {
+	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);
+	}
+}
+
 static bool
 _decode_netlink(struct tcb *tcp, void *elem_buf, size_t elem_size,
 		void *opaque_data) {
-- 
2.8.3





More information about the Strace-devel mailing list