stats: fix state counter removal

Avoid using vec_del1() for directory vector to keep indexes valid all
the time.

There are state counters for each slave in LACP bond mode which can be
dynamically created and removed. Vector index is used to access these
counters. But also vec_del1() is used to remove counter from vector.
This function changes the index of the last element, so after this we
are unable to access ex-last element using old index.

As a result it is not possible to add-del-add two interfaces to the LACP
bond:

DBGvpp# create bond mode lacp
BondEthernet0
DBGvpp# create packet-generator interface pg1
DBGvpp# create packet-generator interface pg2
DBGvpp# bond add BondEthernet0 pg1
DBGvpp# bond add BondEthernet0 pg2
DBGvpp# bond del pg1
DBGvpp# bond del pg2
DBGvpp# bond add BondEthernet0 pg1
DBGvpp# bond add BondEthernet0 pg2
bond add: /if/lacp/1/3/partner-state is already register

Type: fix

Signed-off-by: Vladimir Isaev <visaev@netgate.com>
Change-Id: I2c86e13905eefdef6233369cd4ab5c1b53d123bd
This commit is contained in:
Vladimir Isaev
2020-02-04 11:54:27 +03:00
committed by Ole Trøan
parent a488f37559
commit 72e31bc2d9
9 changed files with 172 additions and 92 deletions
+5 -6
View File
@@ -38,6 +38,8 @@ stat_client::stat_data_t::stat_data_t(const stat_segment_data_t& stat_seg_data)
break;
case STAT_DIR_TYPE_ILLEGAL:
break;
case STAT_DIR_TYPE_EMPTY:
break;
}
}
@@ -95,8 +97,7 @@ stat_client::stat_client(std::vector<std::string>& pattern)
, m_counter_vec()
, m_stat_seg_data(nullptr)
, m_stat_data()
{
}
{}
stat_client::stat_client(std::string socket_name,
std::vector<std::string> patterns)
@@ -106,8 +107,7 @@ stat_client::stat_client(std::string socket_name,
, m_counter_vec()
, m_stat_seg_data(nullptr)
, m_stat_data()
{
}
{}
stat_client::stat_client()
: m_socket_name("/run/vpp/stats.sock")
@@ -131,8 +131,7 @@ stat_client::~stat_client()
stat_client::stat_client(const stat_client& o)
: m_socket_name(o.m_socket_name)
, m_patterns(o.m_patterns)
{
}
{}
int
stat_client::connect()
+4 -7
View File
@@ -22,17 +22,13 @@ stat_reader::stat_indexes_t stat_reader::m_stat_itf_indexes;
stat_reader::stat_reader()
: m_client()
{
}
{}
stat_reader::stat_reader(stat_client sc)
: m_client(sc)
{
}
{}
stat_reader::~stat_reader()
{
}
stat_reader::~stat_reader() {}
int
stat_reader::connect()
@@ -80,6 +76,7 @@ stat_reader::read()
case STAT_DIR_TYPE_SCALAR_INDEX:
case STAT_DIR_TYPE_NAME_VECTOR:
case STAT_DIR_TYPE_ILLEGAL:
case STAT_DIR_TYPE_EMPTY:
break;
case STAT_DIR_TYPE_COUNTER_VECTOR_SIMPLE: {