[PATCH 12/27] netlink: add basic attribute parser of netconfmsg of NETLINK_ROUTE

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


* rtnl_netconf.c: Include "netlink.h", "nlattr.h"
and "xlat/rtnl_netconf_attrs.h".
(decode_netconfmsg): Call decode_nlattr.
* xlat/rtnl_netconf_attrs.in: New file.

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

diff --git a/rtnl_netconf.c b/rtnl_netconf.c
index 852e908..7e9b173 100644
--- a/rtnl_netconf.c
+++ b/rtnl_netconf.c
@@ -32,9 +32,13 @@
 #ifdef HAVE_STRUCT_NETCONFMSG
 
 # include "netlink_route.h"
+# include "nlattr.h"
 # include "print_fields.h"
 
 # include <linux/netconf.h>
+# include "netlink.h"
+
+# include "xlat/rtnl_netconf_attrs.h"
 
 DECL_NETLINK_ROUTE_DECODER(decode_netconfmsg)
 {
@@ -42,6 +46,14 @@ DECL_NETLINK_ROUTE_DECODER(decode_netconfmsg)
 
 	PRINT_FIELD_XVAL("{", ncm, ncm_family, addrfams, "AF_???");
 	tprints("}");
+
+	const size_t offset = NLMSG_ALIGN(sizeof(ncm));
+	if (len > offset) {
+		tprints(", ");
+		decode_nlattr(tcp, addr + offset, len - offset,
+			      rtnl_netconf_attrs, "NETCONFA_???",
+			      NULL, 0, NULL);
+	}
 }
 
 #endif
diff --git a/xlat/rtnl_netconf_attrs.in b/xlat/rtnl_netconf_attrs.in
new file mode 100644
index 0000000..b376b78
--- /dev/null
+++ b/xlat/rtnl_netconf_attrs.in
@@ -0,0 +1,8 @@
+NETCONFA_UNSPEC				0
+NETCONFA_IFINDEX			1
+NETCONFA_FORWARDING			2
+NETCONFA_RP_FILTER			3
+NETCONFA_MC_FORWARDING			4
+NETCONFA_PROXY_NEIGH			5
+NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN	6
+NETCONFA_INPUT				7
-- 
2.7.4





More information about the Strace-devel mailing list