Skip to content

Commit

Permalink
Merge branch 'master' into add_subnet_decap
Browse files Browse the repository at this point in the history
  • Loading branch information
prsunny authored May 24, 2024
2 parents 1400b3f + 5ffb0b5 commit 7ce3870
Show file tree
Hide file tree
Showing 67 changed files with 2,434 additions and 1,214 deletions.
2 changes: 1 addition & 1 deletion .azure-pipelines/test-docker-sonic-vs-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
# install packages for vs test
sudo apt-get install -y net-tools bridge-utils vlan
sudo apt-get install -y python3-pip
sudo pip3 install pytest==4.6.2 attrs==19.1.0 exabgp==4.0.10 distro==1.5.0 docker>=4.4.1 redis==3.3.4 flaky==3.7.0
sudo pip3 install pytest==4.6.2 attrs==19.1.0 exabgp==4.0.10 distro==1.5.0 docker>=4.4.1 redis==3.3.4 flaky==3.7.0 requests==2.31.0
sudo pip3 install lcov_cobertura
displayName: "Install dependencies"
Expand Down
2 changes: 1 addition & 1 deletion cfgmgr/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ CFLAGS_SAI = -I /usr/include/sai
LIBNL_CFLAGS = -I/usr/include/libnl3
LIBNL_LIBS = -lnl-genl-3 -lnl-route-3 -lnl-3
SAIMETA_LIBS = -lsaimeta -lsaimetadata -lzmq
COMMON_LIBS = -lswsscommon
COMMON_LIBS = -lswsscommon -lpthread

bin_PROGRAMS = vlanmgrd teammgrd portmgrd intfmgrd buffermgrd vrfmgrd nbrmgrd vxlanmgrd sflowmgrd natmgrd coppmgrd tunnelmgrd macsecmgrd fabricmgrd

Expand Down
13 changes: 7 additions & 6 deletions cfgmgr/coppmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,13 @@ bool CoppMgr::isTrapIdDisabled(string trap_id)
{
return false;
}
break;
if (isFeatureEnabled(trap_name))
{
return false;
}
}
}

if (isFeatureEnabled(trap_name))
{
return false;
}
return true;
}

Expand Down Expand Up @@ -941,7 +940,9 @@ void CoppMgr::doFeatureTask(Consumer &consumer)
{
if (m_featuresCfgTable.find(key) == m_featuresCfgTable.end())
{
m_featuresCfgTable.emplace(key, kfvFieldsValues(t));
// Init with empty feature state which will be updated in setFeatureTrapIdsStatus
FieldValueTuple fv("state", "");
m_featuresCfgTable[key].push_back(fv);
}
for (auto i : kfvFieldsValues(t))
{
Expand Down
11 changes: 11 additions & 0 deletions cfgmgr/vlanmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,17 @@ VlanMgr::VlanMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, c

EXEC_WITH_ERROR_THROW(echo_cmd_backup, res);
}

// not learn from link-local frames
// /bin/echo 1 > /sys/class/net/Bridge/bridge/no_linklocal_learn
const std::string no_ll_learn_cmd = std::string("")
+ ECHO_CMD + " 1 > /sys/class/net/" + DOT1Q_BRIDGE_NAME + "/bridge/no_linklocal_learn";

ret = swss::exec(no_ll_learn_cmd, res);
if (ret != 0) {
EXEC_WITH_ERROR_THROW(no_ll_learn_cmd, res);
}

}

bool VlanMgr::addHostVlan(int vlan_id)
Expand Down
3 changes: 2 additions & 1 deletion mclagsyncd/mclaglink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ void MclagLink::setPortIsolate(char *msg)
static const unordered_set<string> supported {
BRCM_PLATFORM_SUBSTRING,
BFN_PLATFORM_SUBSTRING,
CTC_PLATFORM_SUBSTRING
CTC_PLATFORM_SUBSTRING,
MRVL_PLATFORM_SUBSTRING
};

const char *platform = getenv("platform");
Expand Down
1 change: 1 addition & 0 deletions mclagsyncd/mclaglink.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#define BRCM_PLATFORM_SUBSTRING "broadcom"
#define BFN_PLATFORM_SUBSTRING "barefoot"
#define CTC_PLATFORM_SUBSTRING "centec"
#define MRVL_PLATFORM_SUBSTRING "marvell"

using namespace std;

Expand Down
1 change: 1 addition & 0 deletions orchagent/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dist_swss_DATA = \
pfc_detect_innovium.lua \
pfc_detect_mellanox.lua \
pfc_detect_broadcom.lua \
pfc_detect_marvell.lua \
pfc_detect_barefoot.lua \
pfc_detect_nephos.lua \
pfc_detect_cisco-8000.lua \
Expand Down
46 changes: 18 additions & 28 deletions orchagent/bufferorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ extern string gMySwitchType;
extern string gMyHostName;
extern string gMyAsicName;

#define BUFFER_POOL_WATERMARK_FLEX_STAT_COUNTER_POLL_MSECS "60000"


static const vector<sai_buffer_pool_stat_t> bufferPoolWatermarkStatIds =
{
SAI_BUFFER_POOL_STAT_WATERMARK_BYTES,
Expand All @@ -52,9 +49,6 @@ std::map<string, std::map<size_t, string>> queue_port_flags;

BufferOrch::BufferOrch(DBConnector *applDb, DBConnector *confDb, DBConnector *stateDb, vector<string> &tableNames) :
Orch(applDb, tableNames),
m_flexCounterDb(new DBConnector("FLEX_COUNTER_DB", 0)),
m_flexCounterTable(new ProducerTable(m_flexCounterDb.get(), FLEX_COUNTER_TABLE)),
m_flexCounterGroupTable(new ProducerTable(m_flexCounterDb.get(), FLEX_COUNTER_GROUP_TABLE)),
m_countersDb(new DBConnector("COUNTERS_DB", 0)),
m_stateBufferMaximumValueTable(stateDb, STATE_BUFFER_MAXIMUM_VALUE_TABLE)
{
Expand Down Expand Up @@ -229,22 +223,23 @@ void BufferOrch::initBufferConstants()
void BufferOrch::initFlexCounterGroupTable(void)
{
string bufferPoolWmPluginName = "watermark_bufferpool.lua";
string bufferPoolWmSha;

try
{
string bufferPoolLuaScript = swss::loadLuaScript(bufferPoolWmPluginName);
string bufferPoolWmSha = swss::loadRedisScript(m_countersDb.get(), bufferPoolLuaScript);

vector<FieldValueTuple> fvTuples;
fvTuples.emplace_back(BUFFER_POOL_PLUGIN_FIELD, bufferPoolWmSha);
fvTuples.emplace_back(POLL_INTERVAL_FIELD, BUFFER_POOL_WATERMARK_FLEX_STAT_COUNTER_POLL_MSECS);

m_flexCounterGroupTable->set(BUFFER_POOL_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP, fvTuples);
bufferPoolWmSha = swss::loadRedisScript(m_countersDb.get(), bufferPoolLuaScript);
}
catch (const runtime_error &e)
{
SWSS_LOG_ERROR("Buffer pool watermark lua script and/or flex counter group not set successfully. Runtime error: %s", e.what());
}

setFlexCounterGroupParameter(BUFFER_POOL_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP,
BUFFER_POOL_WATERMARK_FLEX_STAT_COUNTER_POLL_MSECS,
"", // do not touch stats_mode
BUFFER_POOL_PLUGIN_FIELD,
bufferPoolWmSha);
}

bool BufferOrch::isPortReady(const std::string& port_name) const
Expand Down Expand Up @@ -275,7 +270,7 @@ void BufferOrch::clearBufferPoolWatermarkCounterIdList(const sai_object_id_t obj
if (m_isBufferPoolWatermarkCounterIdListGenerated)
{
string key = BUFFER_POOL_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP ":" + sai_serialize_object_id(object_id);
m_flexCounterTable->del(key);
stopFlexCounterPolling(gSwitchId, key);
}
}

Expand Down Expand Up @@ -326,37 +321,32 @@ void BufferOrch::generateBufferPoolWatermarkCounterIdList(void)

if (!noWmClrCapability)
{
vector<FieldValueTuple> fvs;

fvs.emplace_back(STATS_MODE_FIELD, STATS_MODE_READ_AND_CLEAR);
m_flexCounterGroupTable->set(BUFFER_POOL_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP, fvs);
setFlexCounterGroupStatsMode(BUFFER_POOL_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP,
STATS_MODE_READ_AND_CLEAR);
}

// Push buffer pool watermark COUNTER_ID_LIST to FLEX_COUNTER_TABLE on a per buffer pool basis
vector<FieldValueTuple> fvTuples;
fvTuples.emplace_back(BUFFER_POOL_COUNTER_ID_LIST, statList);
string stats_mode;

bitMask = 1;

for (const auto &it : *(m_buffer_type_maps[APP_BUFFER_POOL_TABLE_NAME]))
{
string key = BUFFER_POOL_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP ":" + sai_serialize_object_id(it.second.m_saiObjectId);

stats_mode = "";

if (noWmClrCapability)
{
string stats_mode = STATS_MODE_READ_AND_CLEAR;
if (noWmClrCapability & bitMask)
{
stats_mode = STATS_MODE_READ;
}
fvTuples.emplace_back(STATS_MODE_FIELD, stats_mode);

m_flexCounterTable->set(key, fvTuples);
fvTuples.pop_back();
bitMask <<= 1;
}
else
{
m_flexCounterTable->set(key, fvTuples);
}

startFlexCounterPolling(gSwitchId, key, statList, BUFFER_POOL_COUNTER_ID_LIST, stats_mode);
}

m_isBufferPoolWatermarkCounterIdListGenerated = true;
Expand Down
5 changes: 1 addition & 4 deletions orchagent/bufferorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "redisapi.h"

#define BUFFER_POOL_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP "BUFFER_POOL_WATERMARK_STAT_COUNTER"
#define BUFFER_POOL_WATERMARK_FLEX_STAT_COUNTER_POLL_MSECS "60000"

const string buffer_size_field_name = "size";
const string buffer_pool_type_field_name = "type";
Expand Down Expand Up @@ -63,10 +64,6 @@ class BufferOrch : public Orch
std::unordered_map<std::string, bool> m_ready_list;
std::unordered_map<std::string, std::vector<std::string>> m_port_ready_list_ref;

unique_ptr<DBConnector> m_flexCounterDb;
unique_ptr<ProducerTable> m_flexCounterGroupTable;
unique_ptr<ProducerTable> m_flexCounterTable;

Table m_stateBufferMaximumValueTable;

unique_ptr<DBConnector> m_countersDb;
Expand Down
21 changes: 11 additions & 10 deletions orchagent/copporch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ extern sai_object_id_t gSwitchId;
extern PortsOrch* gPortsOrch;
extern Directory<Orch*> gDirectory;
extern bool gIsNatSupported;
extern bool gTraditionalFlexCounter;

#define FLEX_COUNTER_UPD_INTERVAL 1

Expand Down Expand Up @@ -126,11 +127,9 @@ const uint HOSTIF_TRAP_COUNTER_POLLING_INTERVAL_MS = 10000;
CoppOrch::CoppOrch(DBConnector* db, string tableName) :
Orch(db, tableName),
m_counter_db(std::shared_ptr<DBConnector>(new DBConnector("COUNTERS_DB", 0))),
m_flex_db(std::shared_ptr<DBConnector>(new DBConnector("FLEX_COUNTER_DB", 0))),
m_asic_db(std::shared_ptr<DBConnector>(new DBConnector("ASIC_DB", 0))),
m_counter_table(std::unique_ptr<Table>(new Table(m_counter_db.get(), COUNTERS_TRAP_NAME_MAP))),
m_vidToRidTable(std::unique_ptr<Table>(new Table(m_asic_db.get(), "VIDTORID"))),
m_flex_counter_group_table(std::unique_ptr<ProducerTable>(new ProducerTable(m_flex_db.get(), FLEX_COUNTER_GROUP_TABLE))),
m_trap_counter_manager(HOSTIF_TRAP_COUNTER_FLEX_COUNTER_GROUP, StatsMode::READ, HOSTIF_TRAP_COUNTER_POLLING_INTERVAL_MS, false)
{
SWSS_LOG_ENTER();
Expand Down Expand Up @@ -633,7 +632,7 @@ task_process_status CoppOrch::processCoppRule(Consumer& consumer)
if (!trap_id_attribs.empty())
{
vector<sai_hostif_trap_type_t> group_trap_ids;
TrapIdAttribs trap_attr;
TrapIdAttribs trap_attr = m_trap_group_trap_id_attrs[trap_group_name];
getTrapIdsFromTrapGroup(m_trap_group_map[trap_group_name],
group_trap_ids);
for (auto trap_id : group_trap_ids)
Expand Down Expand Up @@ -772,7 +771,7 @@ void CoppOrch::doTask(SelectableTimer &timer)
for (auto it = m_pendingAddToFlexCntr.begin(); it != m_pendingAddToFlexCntr.end(); )
{
const auto id = sai_serialize_object_id(it->first);
if (m_vidToRidTable->hget("", id, value))
if (!gTraditionalFlexCounter || m_vidToRidTable->hget("", id, value))
{
SWSS_LOG_INFO("Registering %s, id %s", it->second.c_str(), id.c_str());

Expand Down Expand Up @@ -1205,20 +1204,22 @@ void CoppOrch::initTrapRatePlugin()
}

std::string trapRatePluginName = "trap_rates.lua";
std::string trapSha;
try
{
std::string trapLuaScript = swss::loadLuaScript(trapRatePluginName);
std::string trapSha = swss::loadRedisScript(m_counter_db.get(), trapLuaScript);

vector<FieldValueTuple> fieldValues;
fieldValues.emplace_back(FLOW_COUNTER_PLUGIN_FIELD, trapSha);
fieldValues.emplace_back(STATS_MODE_FIELD, STATS_MODE_READ);
m_flex_counter_group_table->set(HOSTIF_TRAP_COUNTER_FLEX_COUNTER_GROUP, fieldValues);
trapSha = swss::loadRedisScript(m_counter_db.get(), trapLuaScript);
}
catch (const runtime_error &e)
{
SWSS_LOG_ERROR("Trap flex counter groups were not set successfully: %s", e.what());
}

setFlexCounterGroupParameter(HOSTIF_TRAP_COUNTER_FLEX_COUNTER_GROUP,
"", // Do not touch poll interval
STATS_MODE_READ,
FLOW_COUNTER_PLUGIN_FIELD,
trapSha);
m_trap_rate_plugin_loaded = true;
}

Expand Down
2 changes: 0 additions & 2 deletions orchagent/copporch.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,9 @@ class CoppOrch : public Orch
std::map<sai_object_id_t, std::string> m_pendingAddToFlexCntr;

std::shared_ptr<DBConnector> m_counter_db;
std::shared_ptr<DBConnector> m_flex_db;
std::shared_ptr<DBConnector> m_asic_db;
std::unique_ptr<Table> m_counter_table;
std::unique_ptr<Table> m_vidToRidTable;
std::unique_ptr<ProducerTable> m_flex_counter_group_table;

FlexCounterManager m_trap_counter_manager;

Expand Down
Loading

0 comments on commit 7ce3870

Please sign in to comment.