Commit de179966 authored by Vivien Didelot's avatar Vivien Didelot Committed by Jakub Kicinski

net: bridge: add STP xstats

This adds rx_bpdu, tx_bpdu, rx_tcn, tx_tcn, transition_blk,
transition_fwd xstats counters to the bridge ports copied over via
netlink, providing useful information for STP.
Signed-off-by: default avatarVivien Didelot <vivien.didelot@gmail.com>
Acked-by: default avatarNikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
parent ea6a5476
...@@ -156,6 +156,15 @@ struct bridge_vlan_xstats { ...@@ -156,6 +156,15 @@ struct bridge_vlan_xstats {
__u32 pad2; __u32 pad2;
}; };
struct bridge_stp_xstats {
__u64 transition_blk;
__u64 transition_fwd;
__u64 rx_bpdu;
__u64 tx_bpdu;
__u64 rx_tcn;
__u64 tx_tcn;
};
/* Bridge multicast database attributes /* Bridge multicast database attributes
* [MDBA_MDB] = { * [MDBA_MDB] = {
* [MDBA_MDB_ENTRY] = { * [MDBA_MDB_ENTRY] = {
...@@ -262,6 +271,7 @@ enum { ...@@ -262,6 +271,7 @@ enum {
BRIDGE_XSTATS_VLAN, BRIDGE_XSTATS_VLAN,
BRIDGE_XSTATS_MCAST, BRIDGE_XSTATS_MCAST,
BRIDGE_XSTATS_PAD, BRIDGE_XSTATS_PAD,
BRIDGE_XSTATS_STP,
__BRIDGE_XSTATS_MAX __BRIDGE_XSTATS_MAX
}; };
#define BRIDGE_XSTATS_MAX (__BRIDGE_XSTATS_MAX - 1) #define BRIDGE_XSTATS_MAX (__BRIDGE_XSTATS_MAX - 1)
......
...@@ -1607,6 +1607,19 @@ static int br_fill_linkxstats(struct sk_buff *skb, ...@@ -1607,6 +1607,19 @@ static int br_fill_linkxstats(struct sk_buff *skb,
br_multicast_get_stats(br, p, nla_data(nla)); br_multicast_get_stats(br, p, nla_data(nla));
} }
#endif #endif
if (p) {
nla = nla_reserve_64bit(skb, BRIDGE_XSTATS_STP,
sizeof(p->stp_xstats),
BRIDGE_XSTATS_PAD);
if (!nla)
goto nla_put_failure;
spin_lock_bh(&br->lock);
memcpy(nla_data(nla), &p->stp_xstats, sizeof(p->stp_xstats));
spin_unlock_bh(&br->lock);
}
nla_nest_end(skb, nest); nla_nest_end(skb, nest);
*prividx = 0; *prividx = 0;
......
...@@ -283,6 +283,8 @@ struct net_bridge_port { ...@@ -283,6 +283,8 @@ struct net_bridge_port {
#endif #endif
u16 group_fwd_mask; u16 group_fwd_mask;
u16 backup_redirected_cnt; u16 backup_redirected_cnt;
struct bridge_stp_xstats stp_xstats;
}; };
#define kobj_to_brport(obj) container_of(obj, struct net_bridge_port, kobj) #define kobj_to_brport(obj) container_of(obj, struct net_bridge_port, kobj)
......
...@@ -45,6 +45,17 @@ void br_set_state(struct net_bridge_port *p, unsigned int state) ...@@ -45,6 +45,17 @@ void br_set_state(struct net_bridge_port *p, unsigned int state)
br_info(p->br, "port %u(%s) entered %s state\n", br_info(p->br, "port %u(%s) entered %s state\n",
(unsigned int) p->port_no, p->dev->name, (unsigned int) p->port_no, p->dev->name,
br_port_state_names[p->state]); br_port_state_names[p->state]);
if (p->br->stp_enabled == BR_KERNEL_STP) {
switch (p->state) {
case BR_STATE_BLOCKING:
p->stp_xstats.transition_blk++;
break;
case BR_STATE_FORWARDING:
p->stp_xstats.transition_fwd++;
break;
}
}
} }
/* called under bridge lock */ /* called under bridge lock */
...@@ -484,6 +495,8 @@ void br_received_config_bpdu(struct net_bridge_port *p, ...@@ -484,6 +495,8 @@ void br_received_config_bpdu(struct net_bridge_port *p,
struct net_bridge *br; struct net_bridge *br;
int was_root; int was_root;
p->stp_xstats.rx_bpdu++;
br = p->br; br = p->br;
was_root = br_is_root_bridge(br); was_root = br_is_root_bridge(br);
...@@ -517,6 +530,8 @@ void br_received_config_bpdu(struct net_bridge_port *p, ...@@ -517,6 +530,8 @@ void br_received_config_bpdu(struct net_bridge_port *p,
/* called under bridge lock */ /* called under bridge lock */
void br_received_tcn_bpdu(struct net_bridge_port *p) void br_received_tcn_bpdu(struct net_bridge_port *p)
{ {
p->stp_xstats.rx_tcn++;
if (br_is_designated_port(p)) { if (br_is_designated_port(p)) {
br_info(p->br, "port %u(%s) received tcn bpdu\n", br_info(p->br, "port %u(%s) received tcn bpdu\n",
(unsigned int) p->port_no, p->dev->name); (unsigned int) p->port_no, p->dev->name);
......
...@@ -118,6 +118,8 @@ void br_send_config_bpdu(struct net_bridge_port *p, struct br_config_bpdu *bpdu) ...@@ -118,6 +118,8 @@ void br_send_config_bpdu(struct net_bridge_port *p, struct br_config_bpdu *bpdu)
br_set_ticks(buf+33, bpdu->forward_delay); br_set_ticks(buf+33, bpdu->forward_delay);
br_send_bpdu(p, buf, 35); br_send_bpdu(p, buf, 35);
p->stp_xstats.tx_bpdu++;
} }
/* called under bridge lock */ /* called under bridge lock */
...@@ -133,6 +135,8 @@ void br_send_tcn_bpdu(struct net_bridge_port *p) ...@@ -133,6 +135,8 @@ void br_send_tcn_bpdu(struct net_bridge_port *p)
buf[2] = 0; buf[2] = 0;
buf[3] = BPDU_TYPE_TCN; buf[3] = BPDU_TYPE_TCN;
br_send_bpdu(p, buf, 4); br_send_bpdu(p, buf, 4);
p->stp_xstats.tx_tcn++;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment