[PATCH 6/7] rtnl_link: decode IFLA_PROTINFO netlink attribute of ifinfomsg

JingPiao Chen chenjingpiao at gmail.com
Thu Aug 31 02:39:24 UTC 2017


* configure.ac (AC_CHECK_TYPES): Check for
struct ifla_bridge_id in <linux/if_link.h>
* rtnl_link.c: Include "xlat/rtnl_ifla_brport_attrs.h".
(decode_ifla_bridge_id, decode_ifla_protinfo): New functions.
(ifla_brport_nla_decoders): New array.
(ifinfomsg_nla_decoders) <IFLA_PROTINFO>: Use decode_ifla_protinfo.
* xlat/rtnl_ifla_brport_attrs.in: New file.
---
 configure.ac                   |  5 ++-
 rtnl_link.c                    | 73 +++++++++++++++++++++++++++++++++++++++++-
 xlat/rtnl_ifla_brport_attrs.in | 31 ++++++++++++++++++
 3 files changed, 107 insertions(+), 2 deletions(-)
 create mode 100644 xlat/rtnl_ifla_brport_attrs.in

diff --git a/configure.ac b/configure.ac
index 28e9a34..81f7dad 100644
--- a/configure.ac
+++ b/configure.ac
@@ -460,7 +460,10 @@ AC_CHECK_TYPES(m4_normalize([
 	struct ndt_stats
 ]),,, [#include <linux/neighbour.h>])
 
-AC_CHECK_TYPES([struct rtnl_link_stats64],,, [#include <linux/if_link.h>])
+AC_CHECK_TYPES(m4_normalize([
+	struct ifla_bridge_id,
+	struct rtnl_link_stats64
+]),,, [#include <linux/if_link.h>])
 AC_CHECK_MEMBERS(m4_normalize([
 	struct rtnl_link_stats.rx_nohandler,
 	struct rtnl_link_stats64.rx_nohandler
diff --git a/rtnl_link.c b/rtnl_link.c
index 227a452..9909684 100644
--- a/rtnl_link.c
+++ b/rtnl_link.c
@@ -38,6 +38,7 @@
 #endif
 #include <linux/rtnetlink.h>
 
+#include "xlat/rtnl_ifla_brport_attrs.h"
 #include "xlat/rtnl_link_attrs.h"
 
 static bool
@@ -91,6 +92,76 @@ decode_rtnl_link_stats(struct tcb *const tcp,
 }
 
 static bool
+decode_ifla_bridge_id(struct tcb *const tcp,
+		      const kernel_ulong_t addr,
+		      const unsigned int len,
+		      const void *const opaque_data)
+{
+#ifdef HAVE_STRUCT_IFLA_BRIDGE_ID
+	struct ifla_bridge_id id;
+
+	if (len < sizeof(id))
+		return false;
+	else if (!umove_or_printaddr(tcp, addr, &id)) {
+		tprintf("{prio=[%u, %u], addr=%02x:%02x:%02x:%02x:%02x:%02x}",
+			id.prio[0], id.prio[1],
+			id.addr[0], id.addr[1], id.addr[2],
+			id.addr[3], id.addr[4], id.addr[5]);
+	}
+
+	return true;
+#else
+	return false;
+#endif
+}
+
+static const nla_decoder_t ifla_brport_nla_decoders[] = {
+	[IFLA_BRPORT_STATE]			= decode_nla_u8,
+	[IFLA_BRPORT_PRIORITY]			= decode_nla_u16,
+	[IFLA_BRPORT_COST]			= decode_nla_u32,
+	[IFLA_BRPORT_MODE]			= decode_nla_u8,
+	[IFLA_BRPORT_GUARD]			= decode_nla_u8,
+	[IFLA_BRPORT_PROTECT]			= decode_nla_u8,
+	[IFLA_BRPORT_FAST_LEAVE]		= decode_nla_u8,
+	[IFLA_BRPORT_LEARNING]			= decode_nla_u8,
+	[IFLA_BRPORT_UNICAST_FLOOD]		= decode_nla_u8,
+	[IFLA_BRPORT_PROXYARP]			= decode_nla_u8,
+	[IFLA_BRPORT_LEARNING_SYNC]		= decode_nla_u8,
+	[IFLA_BRPORT_PROXYARP_WIFI]		= decode_nla_u8,
+	[IFLA_BRPORT_ROOT_ID]			= decode_ifla_bridge_id,
+	[IFLA_BRPORT_BRIDGE_ID]			= decode_ifla_bridge_id,
+	[IFLA_BRPORT_DESIGNATED_PORT]		= decode_nla_u16,
+	[IFLA_BRPORT_DESIGNATED_COST]		= decode_nla_u16,
+	[IFLA_BRPORT_ID]			= decode_nla_u16,
+	[IFLA_BRPORT_NO]			= decode_nla_u16,
+	[IFLA_BRPORT_TOPOLOGY_CHANGE_ACK]	= decode_nla_u8,
+	[IFLA_BRPORT_CONFIG_PENDING]		= decode_nla_u8,
+	[IFLA_BRPORT_MESSAGE_AGE_TIMER]		= decode_nla_u64,
+	[IFLA_BRPORT_FORWARD_DELAY_TIMER]	= decode_nla_u64,
+	[IFLA_BRPORT_HOLD_TIMER]		= decode_nla_u64,
+	[IFLA_BRPORT_FLUSH]			= NULL,
+	[IFLA_BRPORT_MULTICAST_ROUTER]		= decode_nla_u8,
+	[IFLA_BRPORT_PAD]			= NULL,
+	[IFLA_BRPORT_MCAST_FLOOD]		= decode_nla_u8,
+	[IFLA_BRPORT_MCAST_TO_UCAST]		= decode_nla_u8,
+	[IFLA_BRPORT_VLAN_TUNNEL]		= decode_nla_u8,
+	[IFLA_BRPORT_BCAST_FLOOD]		= decode_nla_u8
+};
+
+static bool
+decode_ifla_protinfo(struct tcb *const tcp,
+		     const kernel_ulong_t addr,
+		     const unsigned int len,
+		     const void *const opaque_data)
+{
+	decode_nlattr(tcp, addr, len, rtnl_ifla_brport_attrs,
+		      "IFLA_BRPORT_???", ifla_brport_nla_decoders,
+		      ARRAY_SIZE(ifla_brport_nla_decoders), opaque_data);
+
+	return true;
+}
+
+static bool
 decode_rtnl_link_ifmap(struct tcb *const tcp,
 		       const kernel_ulong_t addr,
 		       const unsigned int len,
@@ -181,7 +252,7 @@ static const nla_decoder_t ifinfomsg_nla_decoders[] = {
 	[IFLA_PRIORITY]		= NULL, /* unused */
 	[IFLA_MASTER]		= decode_nla_u32,
 	[IFLA_WIRELESS]		= NULL, /* unimplemented */
-	[IFLA_PROTINFO]		= NULL, /* unimplemented */
+	[IFLA_PROTINFO]		= decode_ifla_protinfo,
 	[IFLA_TXQLEN]		= decode_nla_u32,
 	[IFLA_MAP]		= decode_rtnl_link_ifmap,
 	[IFLA_WEIGHT]		= decode_nla_u32,
diff --git a/xlat/rtnl_ifla_brport_attrs.in b/xlat/rtnl_ifla_brport_attrs.in
new file mode 100644
index 0000000..e18e8c5
--- /dev/null
+++ b/xlat/rtnl_ifla_brport_attrs.in
@@ -0,0 +1,31 @@
+IFLA_BRPORT_UNSPEC		0
+IFLA_BRPORT_STATE		1
+IFLA_BRPORT_PRIORITY		2
+IFLA_BRPORT_COST		3
+IFLA_BRPORT_MODE		4
+IFLA_BRPORT_GUARD		5
+IFLA_BRPORT_PROTECT		6
+IFLA_BRPORT_FAST_LEAVE		7
+IFLA_BRPORT_LEARNING		8
+IFLA_BRPORT_UNICAST_FLOOD	9
+IFLA_BRPORT_PROXYARP		10
+IFLA_BRPORT_LEARNING_SYNC	11
+IFLA_BRPORT_PROXYARP_WIFI	12
+IFLA_BRPORT_ROOT_ID		13
+IFLA_BRPORT_BRIDGE_ID		14
+IFLA_BRPORT_DESIGNATED_PORT	15
+IFLA_BRPORT_DESIGNATED_COST	16
+IFLA_BRPORT_ID			17
+IFLA_BRPORT_NO			18
+IFLA_BRPORT_TOPOLOGY_CHANGE_ACK	19
+IFLA_BRPORT_CONFIG_PENDING	20
+IFLA_BRPORT_MESSAGE_AGE_TIMER	21
+IFLA_BRPORT_FORWARD_DELAY_TIMER	22
+IFLA_BRPORT_HOLD_TIMER		23
+IFLA_BRPORT_FLUSH		24
+IFLA_BRPORT_MULTICAST_ROUTER	25
+IFLA_BRPORT_PAD			26
+IFLA_BRPORT_MCAST_FLOOD		27
+IFLA_BRPORT_MCAST_TO_UCAST	28
+IFLA_BRPORT_VLAN_TUNNEL		29
+IFLA_BRPORT_BCAST_FLOOD		30
-- 
2.7.4





More information about the Strace-devel mailing list