aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/lacp/input.c10
-rw-r--r--src/plugins/lacp/lacp.c28
-rw-r--r--src/vnet/bonding/cli.c30
-rw-r--r--src/vnet/bonding/node.h8
4 files changed, 64 insertions, 12 deletions
diff --git a/src/plugins/lacp/input.c b/src/plugins/lacp/input.c
index befb2ed408b..ccefc20e7b2 100644
--- a/src/plugins/lacp/input.c
+++ b/src/plugins/lacp/input.c
@@ -16,6 +16,7 @@
#define _GNU_SOURCE
#include <vnet/bonding/node.h>
#include <lacp/node.h>
+#include <vpp/stats/stat_segment.h>
static int
lacp_packet_scan (vlib_main_t * vm, slave_if_t * sif)
@@ -136,12 +137,14 @@ handle_marker_protocol (vlib_main_t * vm, slave_if_t * sif)
lacp_error_t
lacp_input (vlib_main_t * vm, vlib_buffer_t * b0, u32 bi0)
{
+ bond_main_t *bm = &bond_main;
lacp_main_t *lm = &lacp_main;
slave_if_t *sif;
uword nbytes;
lacp_error_t e;
marker_pdu_t *marker;
uword last_packet_signature;
+ bond_if_t *bif;
sif =
bond_get_slave_by_sw_if_index (vnet_buffer (b0)->sw_if_index[VLIB_RX]);
@@ -214,6 +217,13 @@ lacp_input (vlib_main_t * vm, vlib_buffer_t * b0, u32 bi0)
{
/* Actually scan the packet */
e = lacp_packet_scan (vm, sif);
+ 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);
+ stat_segment_set_state_counter (bm->stats[bif->sw_if_index]
+ [sif->sw_if_index].partner_state,
+ sif->partner.state);
sif->last_packet_signature_valid = 1;
sif->last_packet_signature = last_packet_signature;
}
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);
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
@@ -352,6 +352,12 @@ typedef void (*lacp_enable_disable_func) (vlib_main_t * vm, bond_if_t * bif,
typedef struct
{
+ u32 partner_state;
+ u32 actor_state;
+} lacp_stats_t;
+
+typedef struct
+{
/* pool of bonding interfaces */
bond_if_t *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 */