[PATCH 11/27] netlink: add basic attribute parser of dcbmsg of NETLINK_ROUTE

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


* rtnl_dcb.c: Include "netlink.h", "nlattr.h" and "xlat/rtnl_dcb_attrs.h".
(decode_dcbmsg): Call decode_nlattr.
* xlat/rtnl_dcb_attrs.in: New file.

Co-authored-by: Fabien Siron <fabien.siron at epita.fr>
---
 rtnl_dcb.c             | 14 +++++++++++++-
 xlat/rtnl_dcb_attrs.in | 17 +++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)
 create mode 100644 xlat/rtnl_dcb_attrs.in

diff --git a/rtnl_dcb.c b/rtnl_dcb.c
index 7c1c57e..0724dcb 100644
--- a/rtnl_dcb.c
+++ b/rtnl_dcb.c
@@ -32,16 +32,20 @@
 #ifdef HAVE_STRUCT_DCBMSG
 
 # include "netlink_route.h"
+# include "nlattr.h"
 # include "print_fields.h"
 
 # include <linux/dcbnl.h>
+# include "netlink.h"
 
 # include "xlat/dcb_commands.h"
+# include "xlat/rtnl_dcb_attrs.h"
 
 DECL_NETLINK_ROUTE_DECODER(decode_dcbmsg)
 {
 	struct dcbmsg dcb = { .dcb_family = family };
-	const size_t offset = sizeof(dcb.dcb_family);
+	size_t offset = sizeof(dcb.dcb_family);
+	bool decode_nla = false;
 
 	PRINT_FIELD_XVAL("{", dcb, dcb_family, addrfams, "AF_???");
 
@@ -52,10 +56,18 @@ DECL_NETLINK_ROUTE_DECODER(decode_dcbmsg)
 					 (void *) &dcb + offset)) {
 			PRINT_FIELD_XVAL("", dcb, cmd,
 					 dcb_commands, "DCB_CMD_???");
+			decode_nla = true;
 		}
 	} else
 		tprints("...");
 	tprints("}");
+
+	offset = NLMSG_ALIGN(sizeof(dcb));
+	if (decode_nla && len > offset) {
+		tprints(", ");
+		decode_nlattr(tcp, addr + offset, len - offset,
+			      rtnl_dcb_attrs, "DCB_ATTR_???", NULL, 0, NULL);
+	}
 }
 
 #endif
diff --git a/xlat/rtnl_dcb_attrs.in b/xlat/rtnl_dcb_attrs.in
new file mode 100644
index 0000000..dd2ddf7
--- /dev/null
+++ b/xlat/rtnl_dcb_attrs.in
@@ -0,0 +1,17 @@
+DCB_ATTR_UNDEFINED	0
+DCB_ATTR_IFNAME		1
+DCB_ATTR_STATE		2
+DCB_ATTR_PFC_STATE	3
+DCB_ATTR_PFC_CFG	4
+DCB_ATTR_NUM_TC		5
+DCB_ATTR_PG_CFG		6
+DCB_ATTR_SET_ALL	7
+DCB_ATTR_PERM_HWADDR	8
+DCB_ATTR_CAP		9
+DCB_ATTR_NUMTCS		10
+DCB_ATTR_BCN		11
+DCB_ATTR_APP		12
+DCB_ATTR_IEEE		13
+DCB_ATTR_DCBX		14
+DCB_ATTR_FEATCFG	15
+DCB_ATTR_CEE		16
-- 
2.7.4





More information about the Strace-devel mailing list