summaryrefslogtreecommitdiffstats
path: root/src/plugins/lacp/lacp.c
diff options
context:
space:
mode:
authorSteven Luong <sluong@cisco.com>2019-11-12 19:45:49 -0800
committerDamjan Marion <dmarion@me.com>2019-12-13 22:28:55 +0000
commitaa72578637e2a346ee845545b2e26aad83e12192 (patch)
tree4f27b494f38fd72fadc76428e86925d9e5caea25 /src/plugins/lacp/lacp.c
parent380e857830985e1b50257b39ba6045b829c833c1 (diff)
bonding: Add /if/lacp/<bond-sw_if_index>/<slave-sw_if_index>/partner-state
We already had /if/lacp/<bond-sw_if_index>/<slave-sw_if_index>/state in the stats segment. Add also the partner-state to be complete. Change to populate stats segment with the states at startup, after processing an lacp pdu, and after timer expiration. Unit test --------- sudo vpp_get_stats dump | grep /if/lacp 63.00 /if/lacp/3/1/state 61.00 /if/lacp/3/1/partner-state 63.00 /if/lacp/3/2/state 61.00 /if/lacp/3/2/partner-state Type: feature Signed-off-by: Steven Luong <sluong@cisco.com> Change-Id: Ib7b8e1183d572bb6e422a846aaa2b7b3559a0dc7
Diffstat (limited to 'src/plugins/lacp/lacp.c')
-rw-r--r--src/plugins/lacp/lacp.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/plugins/lacp/lacp.c b/src/plugins/lacp/lacp.c
index dba6cb17f63..e789de52911 100644
--- a/src/plugins/lacp/lacp.c
+++ b/src/plugins/lacp/lacp.c
@@ -21,6 +21,7 @@
#include <vppinfra/hash.h>
#include <vnet/bonding/node.h>
#include <lacp/node.h>
+#include <vpp/stats/stat_segment.h>
lacp_main_t lacp_main;
@@ -140,6 +141,8 @@ lacp_periodic (vlib_main_t * vm)
bond_main_t *bm = &bond_main;
lacp_main_t *lm = &lacp_main;
slave_if_t *sif;
+ bond_if_t *bif;
+ u8 actor_state, partner_state;
/* *INDENT-OFF* */
pool_foreach (sif, bm->neighbors,
@@ -147,6 +150,8 @@ lacp_periodic (vlib_main_t * vm)
if (sif->port_enabled == 0)
continue;
+ actor_state = sif->actor.state;
+ partner_state = sif->partner.state;
if (lacp_timer_is_running (sif->current_while_timer) &&
lacp_timer_is_expired (lm->vlib_main, sif->current_while_timer))
{
@@ -167,6 +172,20 @@ lacp_periodic (vlib_main_t * vm)
lacp_stop_timer (&sif->wait_while_timer);
lacp_selection_logic (vm, sif);
}
+ if (actor_state != sif->actor.state)
+ {
+ bif = bond_get_master_by_dev_instance (sif->bif_dev_instance);
+ stat_segment_set_state_counter (bm->stats[bif->sw_if_index]
+ [sif->sw_if_index].actor_state,
+ sif->actor.state);
+ }
+ if (partner_state != sif->partner.state)
+ {
+ bif = bond_get_master_by_dev_instance (sif->bif_dev_instance);
+ stat_segment_set_state_counter (bm->stats[bif->sw_if_index]
+ [sif->sw_if_index].partner_state,
+ sif->partner.state);
+ }
}));
/* *INDENT-ON* */
}
@@ -356,10 +375,19 @@ lacp_init_neighbor (slave_if_t * sif, u8 * hw_address, u16 port_number,
void
lacp_init_state_machines (vlib_main_t * vm, slave_if_t * sif)
{
+ bond_main_t *bm = &bond_main;
+ bond_if_t *bif = bond_get_master_by_dev_instance (sif->bif_dev_instance);
+
lacp_init_tx_machine (vm, sif);
lacp_init_mux_machine (vm, sif);
lacp_init_ptx_machine (vm, sif);
lacp_init_rx_machine (vm, sif);
+ stat_segment_set_state_counter (bm->stats[bif->sw_if_index]
+ [sif->sw_if_index].actor_state,
+ sif->actor.state);
+ stat_segment_set_state_counter (bm->stats[bif->sw_if_index]
+ [sif->sw_if_index].partner_state,
+ sif->partner.state);
}
VLIB_INIT_FUNCTION (lacp_periodic_init);