[PATCH 2/7] rtnl_addrlabel: decode ifaddrlblmsg netlink attributes

JingPiao Chen chenjingpiao at gmail.com
Thu Aug 31 01:48:37 UTC 2017


* rtnl_addrlabel.c (decode_ifal_address): New function.
(ifaddrlblmsg_nla_decoders): New array.
(decode_ifaddrlblmsg): Use it.
---
 rtnl_addrlabel.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/rtnl_addrlabel.c b/rtnl_addrlabel.c
index 53cfb2c..7fc4875 100644
--- a/rtnl_addrlabel.c
+++ b/rtnl_addrlabel.c
@@ -40,6 +40,24 @@
 
 # include "xlat/rtnl_addrlabel_attrs.h"
 
+static bool
+decode_ifal_address(struct tcb *const tcp,
+		    const kernel_ulong_t addr,
+		    const unsigned int len,
+		    const void *const opaque_data)
+{
+	const struct ifaddrlblmsg *const ifal = opaque_data;
+
+	decode_inet_addr(tcp, addr, len, ifal->ifal_family, NULL);
+
+	return true;
+}
+
+static const nla_decoder_t ifaddrlblmsg_nla_decoders[] = {
+	[IFAL_ADDRESS]	= decode_ifal_address,
+	[IFAL_LABEL]	= decode_nla_u32
+};
+
 DECL_NETLINK_ROUTE_DECODER(decode_ifaddrlblmsg)
 {
 	struct ifaddrlblmsg ifal = { .ifal_family = family };
@@ -67,7 +85,9 @@ DECL_NETLINK_ROUTE_DECODER(decode_ifaddrlblmsg)
 	if (decode_nla && len > offset) {
 		tprints(", ");
 		decode_nlattr(tcp, addr + offset, len - offset,
-			      rtnl_addrlabel_attrs, "IFAL_???", NULL, 0, NULL);
+			      rtnl_addrlabel_attrs, "IFAL_???",
+			      ifaddrlblmsg_nla_decoders,
+			      ARRAY_SIZE(ifaddrlblmsg_nla_decoders), &ifal);
 	}
 }
 
-- 
2.7.4





More information about the Strace-devel mailing list