diff options
author | Petr Machata <petrm@nvidia.com> | 2022-05-09 16:00:01 +0200 |
---|---|---|
committer | David Ahern <dsahern@kernel.org> | 2022-05-12 11:08:26 -0600 |
commit | 36e10429dafc4e80307d73585be00f81088e6ccd (patch) | |
tree | ca8810abf9a536b6705ae5e78675978e6d264a08 | |
parent | 79f5ad95c17c7b8ae56b34f677f22ca88d9c3975 (diff) | |
download | iproute2-36e10429dafc4e80307d73585be00f81088e6ccd.tar.gz |
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@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
-rw-r--r-- | ip/ip_common.h | 2 | ||||
-rw-r--r-- | ip/iplink_bridge.c | 80 | ||||
-rw-r--r-- | ip/ipstats.c | 2 |
3 files changed, 84 insertions, 0 deletions
diff --git a/ip/ip_common.h b/ip/ip_common.h index 8b7ec6452..c58f20907 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 493be6fe7..3feb6109f 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 0691a3f05..1051976d5 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 = { |