[PATCH 07/27] netlink: add basic attribute parser of ndtmsg of NETLINK_ROUTE

JingPiao Chen chenjingpiao at gmail.com
Tue Aug 15 04:41:15 UTC 2017


* rtnl_neightbl.c: Include "nlattr.h" and "xlat/rtnl_neightbl_attrs.h".
(decode_ndtmsg): Call decode_nlattr.
* xlat/rtnl_neightbl_attrs.in: New file.

Co-authored-by: Fabien Siron <fabien.siron at epita.fr>
---
 rtnl_neightbl.c             | 10 ++++++++++
 xlat/rtnl_neightbl_attrs.in | 10 ++++++++++
 2 files changed, 20 insertions(+)
 create mode 100644 xlat/rtnl_neightbl_attrs.in

diff --git a/rtnl_neightbl.c b/rtnl_neightbl.c
index ef0b138..41f8c92 100644
--- a/rtnl_neightbl.c
+++ b/rtnl_neightbl.c
@@ -29,6 +29,7 @@
 
 #include "defs.h"
 #include "netlink_route.h"
+#include "nlattr.h"
 #include "print_fields.h"
 
 #include "netlink.h"
@@ -37,10 +38,19 @@
 # include <linux/neighbour.h>
 #endif
 
+#include "xlat/rtnl_neightbl_attrs.h"
+
 DECL_NETLINK_ROUTE_DECODER(decode_ndtmsg)
 {
 	struct ndtmsg ndtmsg = { .ndtm_family = family };
 
 	PRINT_FIELD_XVAL("{", ndtmsg, ndtm_family, addrfams, "AF_???");
 	tprints("}");
+
+	const size_t offset = NLMSG_ALIGN(sizeof(ndtmsg));
+	if (len > offset) {
+		tprints(", ");
+		decode_nlattr(tcp, addr + offset, len - offset,
+			      rtnl_neightbl_attrs, "NDTA_???", NULL, 0, NULL);
+	}
 }
diff --git a/xlat/rtnl_neightbl_attrs.in b/xlat/rtnl_neightbl_attrs.in
new file mode 100644
index 0000000..ea840f6
--- /dev/null
+++ b/xlat/rtnl_neightbl_attrs.in
@@ -0,0 +1,10 @@
+NDTA_UNSPEC		0
+NDTA_NAME		1
+NDTA_THRESH1		2
+NDTA_THRESH2		3
+NDTA_THRESH3		4
+NDTA_CONFIG		5
+NDTA_PARMS		6
+NDTA_STATS		7
+NDTA_GC_INTERVAL	8
+NDTA_PAD		9
-- 
2.7.4





More information about the Strace-devel mailing list