From aa72578637e2a346ee845545b2e26aad83e12192 Mon Sep 17 00:00:00 2001 From: Steven Luong Date: Tue, 12 Nov 2019 19:45:49 -0800 Subject: bonding: Add /if/lacp///partner-state We already had /if/lacp///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 Change-Id: Ib7b8e1183d572bb6e422a846aaa2b7b3559a0dc7 --- src/vnet/bonding/cli.c | 30 +++++++++++++++++++----------- src/vnet/bonding/node.h | 8 +++++++- 2 files changed, 26 insertions(+), 12 deletions(-) (limited to 'src/vnet') diff --git a/src/vnet/bonding/cli.c b/src/vnet/bonding/cli.c index 554ffe9f5ba..e6d8f1c2bc8 100644 --- a/src/vnet/bonding/cli.c +++ b/src/vnet/bonding/cli.c @@ -63,10 +63,6 @@ bond_disable_collecting_distributing (vlib_main_t * vm, slave_if_t * sif) vlib_process_signal_event (bm->vlib_main, bond_process_node.index, BOND_SEND_GARP_NA, bif->hw_if_index); clib_spinlock_unlock_if_init (&bif->lockp); - - if (bif->mode == BOND_MODE_LACP) - stat_segment_set_state_counter (bm->stats[bif->sw_if_index] - [sif->sw_if_index], sif->actor.state); } /* @@ -175,10 +171,6 @@ bond_enable_collecting_distributing (vlib_main_t * vm, slave_if_t * sif) done: clib_spinlock_unlock_if_init (&bif->lockp); - - if (bif->mode == BOND_MODE_LACP) - stat_segment_set_state_counter (bm->stats[bif->sw_if_index] - [sif->sw_if_index], sif->actor.state); } int @@ -329,8 +321,12 @@ bond_delete_neighbor (vlib_main_t * vm, bond_if_t * bif, slave_if_t * sif) (*bm->lacp_enable_disable) (vm, bif, sif, 0); if (bif->mode == BOND_MODE_LACP) - stat_segment_deregister_state_counter - (bm->stats[bif->sw_if_index][sif->sw_if_index]); + { + stat_segment_deregister_state_counter + (bm->stats[bif->sw_if_index][sif->sw_if_index].actor_state); + stat_segment_deregister_state_counter + (bm->stats[bif->sw_if_index][sif->sw_if_index].partner_state); + } pool_put (bm->neighbors, sif); } @@ -628,7 +624,19 @@ bond_enslave (vlib_main_t * vm, bond_enslave_args_t * args) vec_validate (bm->stats[bif->sw_if_index], args->slave); args->error = stat_segment_register_state_counter - (name, &bm->stats[bif->sw_if_index][args->slave]); + (name, &bm->stats[bif->sw_if_index][args->slave].actor_state); + if (args->error != 0) + { + args->rv = VNET_API_ERROR_INVALID_INTERFACE; + vec_free (name); + return; + } + + vec_reset_length (name); + name = format (0, "/if/lacp/%u/%u/partner-state%c", bif->sw_if_index, + args->slave, 0); + args->error = stat_segment_register_state_counter + (name, &bm->stats[bif->sw_if_index][args->slave].partner_state); vec_free (name); if (args->error != 0) { diff --git a/src/vnet/bonding/node.h b/src/vnet/bonding/node.h index 4c91200ef04..8ead0228523 100644 --- a/src/vnet/bonding/node.h +++ b/src/vnet/bonding/node.h @@ -350,6 +350,12 @@ typedef struct typedef void (*lacp_enable_disable_func) (vlib_main_t * vm, bond_if_t * bif, slave_if_t * sif, u8 enable); +typedef struct +{ + u32 partner_state; + u32 actor_state; +} lacp_stats_t; + typedef struct { /* pool of bonding interfaces */ @@ -377,7 +383,7 @@ typedef struct bond_per_thread_data_t *per_thread_data; - u32 **stats; + lacp_stats_t **stats; } bond_main_t; /* bond packet trace capture */ -- cgit 1.2.3-korg