[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <538c811d36953b024e4da1f8bd937cedd8d918b3.1652104101.git.petrm@nvidia.com>
Date: Mon, 9 May 2022 16:00:01 +0200
From: Petr Machata <petrm@...dia.com>
To: <netdev@...r.kernel.org>
CC: David Ahern <dsahern@...il.com>, Ido Schimmel <idosch@...dia.com>,
"Petr Machata" <petrm@...dia.com>
Subject: [PATCH iproute2-next 08/10] ipstats: Expose bridge stats in ipstats
Bridge supports two suites, STP and IGMP, carried by attributes
BRIDGE_XSTATS_STP and BRIDGE_XSTATS_MCAST. Expose them as suites "stp" and
"mcast" (to correspond to the attribute name).
For example:
# ip stats show dev swp1 group xstats_slave subgroup bridge
56: swp1: group xstats_slave subgroup bridge suite mcast
IGMP queries:
RX: v1 0 v2 0 v3 0
TX: v1 0 v2 0 v3 0
IGMP reports:
RX: v1 0 v2 0 v3 0
TX: v1 0 v2 0 v3 0
IGMP leaves: RX: 0 TX: 0
IGMP parse errors: 0
MLD queries:
RX: v1 0 v2 0
TX: v1 0 v2 0
MLD reports:
RX: v1 0 v2 0
TX: v1 0 v2 0
MLD leaves: RX: 0 TX: 0
MLD parse errors: 0
56: swp1: group xstats_slave subgroup bridge suite stp
STP BPDU: RX: 0 TX: 0
STP TCN: RX: 0 TX: 0
STP Transitions: Blocked: 1 Forwarding: 0
# ip -j stats show dev swp1 group xstats_slave subgroup bridge | jq
[
{
"ifindex": 56,
"ifname": "swp1",
"group": "xstats_slave",
"subgroup": "bridge",
"suite": "mcast",
"multicast": {
"igmp_queries": {
"rx_v1": 0,
"rx_v2": 0,
"rx_v3": 0,
"tx_v1": 0,
"tx_v2": 0,
"tx_v3": 0
},
"igmp_reports": {
"rx_v1": 0,
"rx_v2": 0,
"rx_v3": 0,
"tx_v1": 0,
"tx_v2": 0,
"tx_v3": 0
},
"igmp_leaves": {
"rx": 0,
"tx": 0
},
"igmp_parse_errors": 0,
"mld_queries": {
"rx_v1": 0,
"rx_v2": 0,
"tx_v1": 0,
"tx_v2": 0
},
"mld_reports": {
"rx_v1": 0,
"rx_v2": 0,
"tx_v1": 0,
"tx_v2": 0
},
"mld_leaves": {
"rx": 0,
"tx": 0
},
"mld_parse_errors": 0
}
},
{
"ifindex": 56,
"ifname": "swp1",
"group": "xstats_slave",
"subgroup": "bridge",
"suite": "stp",
"stp": {
"rx_bpdu": 0,
"tx_bpdu": 0,
"rx_tcn": 0,
"tx_tcn": 0,
"transition_blk": 1,
"transition_fwd": 0
}
}
]
Signed-off-by: Petr Machata <petrm@...dia.com>
Reviewed-by: Ido Schimmel <idosch@...dia.com>
---
ip/ip_common.h | 2 ++
ip/iplink_bridge.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++
ip/ipstats.c | 2 ++
3 files changed, 84 insertions(+)
diff --git a/ip/ip_common.h b/ip/ip_common.h
index 8b7ec645..c58f2090 100644
--- a/ip/ip_common.h
+++ b/ip/ip_common.h
@@ -142,6 +142,8 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type);
void br_dump_bridge_id(const struct ifla_bridge_id *id, char *buf, size_t len);
int bridge_parse_xstats(struct link_util *lu, int argc, char **argv);
int bridge_print_xstats(struct nlmsghdr *n, void *arg);
+extern const struct ipstats_stat_desc ipstats_stat_desc_xstats_bridge_group;
+extern const struct ipstats_stat_desc ipstats_stat_desc_xstats_slave_bridge_group;
int bond_parse_xstats(struct link_util *lu, int argc, char **argv);
int bond_print_xstats(struct nlmsghdr *n, void *arg);
diff --git a/ip/iplink_bridge.c b/ip/iplink_bridge.c
index 493be6fe..3feb6109 100644
--- a/ip/iplink_bridge.c
+++ b/ip/iplink_bridge.c
@@ -936,3 +936,83 @@ struct link_util bridge_link_util = {
.parse_ifla_xstats = bridge_parse_xstats,
.print_ifla_xstats = bridge_print_xstats,
};
+
+static const struct ipstats_stat_desc ipstats_stat_desc_bridge_tmpl_stp = {
+ .name = "stp",
+ .kind = IPSTATS_STAT_DESC_KIND_LEAF,
+ .show = &ipstats_stat_desc_show_xstats,
+ .pack = &ipstats_stat_desc_pack_xstats,
+};
+
+static const struct ipstats_stat_desc ipstats_stat_desc_bridge_tmpl_mcast = {
+ .name = "mcast",
+ .kind = IPSTATS_STAT_DESC_KIND_LEAF,
+ .show = &ipstats_stat_desc_show_xstats,
+ .pack = &ipstats_stat_desc_pack_xstats,
+};
+
+static const struct ipstats_stat_desc_xstats
+ipstats_stat_desc_xstats_bridge_stp = {
+ .desc = ipstats_stat_desc_bridge_tmpl_stp,
+ .xstats_at = IFLA_STATS_LINK_XSTATS,
+ .link_type_at = LINK_XSTATS_TYPE_BRIDGE,
+ .inner_max = BRIDGE_XSTATS_MAX,
+ .inner_at = BRIDGE_XSTATS_STP,
+ .show_cb = &bridge_print_stats_stp,
+};
+
+static const struct ipstats_stat_desc_xstats
+ipstats_stat_desc_xstats_bridge_mcast = {
+ .desc = ipstats_stat_desc_bridge_tmpl_mcast,
+ .xstats_at = IFLA_STATS_LINK_XSTATS,
+ .link_type_at = LINK_XSTATS_TYPE_BRIDGE,
+ .inner_max = BRIDGE_XSTATS_MAX,
+ .inner_at = BRIDGE_XSTATS_MCAST,
+ .show_cb = &bridge_print_stats_mcast,
+};
+
+static const struct ipstats_stat_desc *
+ipstats_stat_desc_xstats_bridge_subs[] = {
+ &ipstats_stat_desc_xstats_bridge_stp.desc,
+ &ipstats_stat_desc_xstats_bridge_mcast.desc,
+};
+
+const struct ipstats_stat_desc ipstats_stat_desc_xstats_bridge_group = {
+ .name = "bridge",
+ .kind = IPSTATS_STAT_DESC_KIND_GROUP,
+ .subs = ipstats_stat_desc_xstats_bridge_subs,
+ .nsubs = ARRAY_SIZE(ipstats_stat_desc_xstats_bridge_subs),
+};
+
+static const struct ipstats_stat_desc_xstats
+ipstats_stat_desc_xstats_slave_bridge_stp = {
+ .desc = ipstats_stat_desc_bridge_tmpl_stp,
+ .xstats_at = IFLA_STATS_LINK_XSTATS_SLAVE,
+ .link_type_at = LINK_XSTATS_TYPE_BRIDGE,
+ .inner_max = BRIDGE_XSTATS_MAX,
+ .inner_at = BRIDGE_XSTATS_STP,
+ .show_cb = &bridge_print_stats_stp,
+};
+
+static const struct ipstats_stat_desc_xstats
+ipstats_stat_desc_xstats_slave_bridge_mcast = {
+ .desc = ipstats_stat_desc_bridge_tmpl_mcast,
+ .xstats_at = IFLA_STATS_LINK_XSTATS_SLAVE,
+ .link_type_at = LINK_XSTATS_TYPE_BRIDGE,
+ .inner_max = BRIDGE_XSTATS_MAX,
+ .inner_at = BRIDGE_XSTATS_MCAST,
+ .show_cb = &bridge_print_stats_mcast,
+};
+
+static const struct ipstats_stat_desc *
+ipstats_stat_desc_xstats_slave_bridge_subs[] = {
+ &ipstats_stat_desc_xstats_slave_bridge_stp.desc,
+ &ipstats_stat_desc_xstats_slave_bridge_mcast.desc,
+};
+
+const struct ipstats_stat_desc ipstats_stat_desc_xstats_slave_bridge_group = {
+ .name = "bridge",
+ .kind = IPSTATS_STAT_DESC_KIND_GROUP,
+ .subs = ipstats_stat_desc_xstats_slave_bridge_subs,
+ .nsubs = ARRAY_SIZE(ipstats_stat_desc_xstats_slave_bridge_subs),
+};
diff --git a/ip/ipstats.c b/ip/ipstats.c
index 0691a3f0..1051976d 100644
--- a/ip/ipstats.c
+++ b/ip/ipstats.c
@@ -605,6 +605,7 @@ int ipstats_stat_desc_show_xstats(struct ipstats_stat_show_attrs *attrs,
}
static const struct ipstats_stat_desc *ipstats_stat_desc_xstats_subs[] = {
+ &ipstats_stat_desc_xstats_bridge_group,
};
static const struct ipstats_stat_desc ipstats_stat_desc_xstats_group = {
@@ -615,6 +616,7 @@ static const struct ipstats_stat_desc ipstats_stat_desc_xstats_group = {
};
static const struct ipstats_stat_desc *ipstats_stat_desc_xstats_slave_subs[] = {
+ &ipstats_stat_desc_xstats_slave_bridge_group,
};
static const struct ipstats_stat_desc ipstats_stat_desc_xstats_slave_group = {
--
2.31.1
Powered by blists - more mailing lists