Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into evpn_fdb_orchagent
Browse files Browse the repository at this point in the history
  • Loading branch information
anilkpandey committed Dec 29, 2020
2 parents 3ceb819 + e32b9d0 commit 9021773
Show file tree
Hide file tree
Showing 14 changed files with 2,288 additions and 24 deletions.
49 changes: 48 additions & 1 deletion cfgmgr/vlanmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,34 @@ VlanMgr::VlanMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, c
m_stateVlanTable(stateDb, STATE_VLAN_TABLE_NAME),
m_stateVlanMemberTable(stateDb, STATE_VLAN_MEMBER_TABLE_NAME),
m_appVlanTableProducer(appDb, APP_VLAN_TABLE_NAME),
m_appVlanMemberTableProducer(appDb, APP_VLAN_MEMBER_TABLE_NAME)
m_appVlanMemberTableProducer(appDb, APP_VLAN_MEMBER_TABLE_NAME),
replayDone(false)
{
SWSS_LOG_ENTER();

if (WarmStart::isWarmStart())
{
vector<string> vlanKeys, vlanMemberKeys;

/* cache all vlan and vlan member config */
m_cfgVlanTable.getKeys(vlanKeys);
m_cfgVlanMemberTable.getKeys(vlanMemberKeys);
for (auto k : vlanKeys)
{
m_vlanReplay.insert(k);
}
for (auto k : vlanMemberKeys)
{
m_vlanMemberReplay.insert(k);
}
if (m_vlanReplay.empty())
{
replayDone = true;
WarmStart::setWarmStartState("vlanmgrd", WarmStart::REPLAYED);
SWSS_LOG_NOTICE("vlanmgr warmstart state set to REPLAYED");
WarmStart::setWarmStartState("vlanmgrd", WarmStart::RECONCILED);
SWSS_LOG_NOTICE("vlanmgr warmstart state set to RECONCILED");
}
const std::string cmds = std::string("")
+ IP_CMD + " link show " + DOT1Q_BRIDGE_NAME + " 2>/dev/null";

Expand Down Expand Up @@ -298,6 +320,7 @@ void VlanMgr::doVlanTask(Consumer &consumer)
if (isVlanStateOk(key) && m_vlans.find(key) == m_vlans.end())
{
m_vlans.insert(key);
m_vlanReplay.erase(kfvKey(t));
it = consumer.m_toSync.erase(it);
SWSS_LOG_DEBUG("%s already created", kfvKey(t).c_str());
continue;
Expand All @@ -308,6 +331,7 @@ void VlanMgr::doVlanTask(Consumer &consumer)
{
addHostVlan(vlan_id);
}
m_vlanReplay.erase(kfvKey(t));

/* set up host env .... */
for (auto i : kfvFieldsValues(t))
Expand Down Expand Up @@ -394,6 +418,16 @@ void VlanMgr::doVlanTask(Consumer &consumer)
it = consumer.m_toSync.erase(it);
}
}
if (!replayDone && m_vlanReplay.empty() &&
m_vlanMemberReplay.empty() &&
WarmStart::isWarmStart())
{
replayDone = true;
WarmStart::setWarmStartState("vlanmgrd", WarmStart::REPLAYED);
SWSS_LOG_NOTICE("vlanmgr warmstart state set to REPLAYED");
WarmStart::setWarmStartState("vlanmgrd", WarmStart::RECONCILED);
SWSS_LOG_NOTICE("vlanmgr warmstart state set to RECONCILED");
}
}

bool VlanMgr::isMemberStateOk(const string &alias)
Expand Down Expand Up @@ -536,6 +570,7 @@ void VlanMgr::doVlanMemberTask(Consumer &consumer)
if (isVlanMemberStateOk(kfvKey(t)))
{
SWSS_LOG_DEBUG("%s already set", kfvKey(t).c_str());
m_vlanMemberReplay.erase(kfvKey(t));
it = consumer.m_toSync.erase(it);
continue;
}
Expand Down Expand Up @@ -577,6 +612,8 @@ void VlanMgr::doVlanMemberTask(Consumer &consumer)
FieldValueTuple s("state", "ok");
fvVector.push_back(s);
m_stateVlanMemberTable.set(kfvKey(t), fvVector);

m_vlanMemberReplay.erase(kfvKey(t));
}
}
else if (op == DEL_COMMAND)
Expand All @@ -603,6 +640,16 @@ void VlanMgr::doVlanMemberTask(Consumer &consumer)
/* Other than the case of member port/lag is not ready, no retry will be performed */
it = consumer.m_toSync.erase(it);
}
if (!replayDone && m_vlanMemberReplay.empty() &&
WarmStart::isWarmStart())
{
replayDone = true;
WarmStart::setWarmStartState("vlanmgrd", WarmStart::REPLAYED);
SWSS_LOG_NOTICE("vlanmgr warmstart state set to REPLAYED");
WarmStart::setWarmStartState("vlanmgrd", WarmStart::RECONCILED);
SWSS_LOG_NOTICE("vlanmgr warmstart state set to RECONCILED");

}
}

void VlanMgr::doTask(Consumer &consumer)
Expand Down
5 changes: 4 additions & 1 deletion cfgmgr/vlanmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ class VlanMgr : public Orch
Table m_statePortTable, m_stateLagTable;
Table m_stateVlanTable, m_stateVlanMemberTable;
std::set<std::string> m_vlans;

std::set<std::string> m_vlanReplay;
std::set<std::string> m_vlanMemberReplay;
bool replayDone;

void doTask(Consumer &consumer);
void doVlanTask(Consumer &consumer);
void doVlanMemberTask(Consumer &consumer);
Expand Down
11 changes: 10 additions & 1 deletion doc/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,16 @@ group name and IP ranges in **BGP_PEER_RANGE** table.
"ipv4_neighbor_low_threshold": "70",
"acl_group_threshold_type": "percentage",
"ipv4_nexthop_high_threshold": "85",
"ipv6_route_threshold_type": "percentage"
"ipv6_route_threshold_type": "percentage",
"snat_entry_threshold_type": "percentage",
"snat_entry_high_threshold": "85",
"snat_entry_low_threshold": "70",
"dnat_entry_threshold_type": "percentage",
"dnat_entry_high_threshold": "85",
"dnat_entry_low_threshold": "70",
"ipmc_entry_threshold_type": "percentage",
"ipmc_entry_high_threshold": "85",
"ipmc_entry_low_threshold": "70"
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion orchagent/aclorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ static const acl_capabilities_t defaultAclActionsSupported =
ACL_STAGE_INGRESS,
{
SAI_ACL_ACTION_TYPE_PACKET_ACTION,
SAI_ACL_ACTION_TYPE_MIRROR_INGRESS
SAI_ACL_ACTION_TYPE_MIRROR_INGRESS,
SAI_ACL_ACTION_TYPE_NO_NAT
}
},
{
Expand Down
82 changes: 67 additions & 15 deletions orchagent/crmorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ const map<CrmResourceType, string> crmResTypeNameMap =
{ CrmResourceType::CRM_ACL_GROUP, "ACL_GROUP" },
{ CrmResourceType::CRM_ACL_ENTRY, "ACL_ENTRY" },
{ CrmResourceType::CRM_ACL_COUNTER, "ACL_COUNTER" },
{ CrmResourceType::CRM_FDB_ENTRY, "FDB_ENTRY" }
{ CrmResourceType::CRM_FDB_ENTRY, "FDB_ENTRY" },
{ CrmResourceType::CRM_IPMC_ENTRY, "IPMC_ENTRY" },
{ CrmResourceType::CRM_SNAT_ENTRY, "SNAT_ENTRY" },
{ CrmResourceType::CRM_DNAT_ENTRY, "DNAT_ENTRY" }
};

const map<CrmResourceType, uint32_t> crmResSaiAvailAttrMap =
Expand All @@ -54,7 +57,10 @@ const map<CrmResourceType, uint32_t> crmResSaiAvailAttrMap =
{ CrmResourceType::CRM_ACL_GROUP, SAI_SWITCH_ATTR_AVAILABLE_ACL_TABLE_GROUP },
{ CrmResourceType::CRM_ACL_ENTRY, SAI_ACL_TABLE_ATTR_AVAILABLE_ACL_ENTRY },
{ CrmResourceType::CRM_ACL_COUNTER, SAI_ACL_TABLE_ATTR_AVAILABLE_ACL_COUNTER },
{ CrmResourceType::CRM_FDB_ENTRY, SAI_SWITCH_ATTR_AVAILABLE_FDB_ENTRY }
{ CrmResourceType::CRM_FDB_ENTRY, SAI_SWITCH_ATTR_AVAILABLE_FDB_ENTRY },
{ CrmResourceType::CRM_IPMC_ENTRY, SAI_SWITCH_ATTR_AVAILABLE_IPMC_ENTRY},
{ CrmResourceType::CRM_SNAT_ENTRY, SAI_SWITCH_ATTR_AVAILABLE_SNAT_ENTRY },
{ CrmResourceType::CRM_DNAT_ENTRY, SAI_SWITCH_ATTR_AVAILABLE_DNAT_ENTRY }
};

const map<string, CrmResourceType> crmThreshTypeResMap =
Expand All @@ -71,7 +77,10 @@ const map<string, CrmResourceType> crmThreshTypeResMap =
{ "acl_group_threshold_type", CrmResourceType::CRM_ACL_GROUP },
{ "acl_entry_threshold_type", CrmResourceType::CRM_ACL_ENTRY },
{ "acl_counter_threshold_type", CrmResourceType::CRM_ACL_COUNTER },
{ "fdb_entry_threshold_type", CrmResourceType::CRM_FDB_ENTRY }
{ "fdb_entry_threshold_type", CrmResourceType::CRM_FDB_ENTRY },
{ "ipmc_entry_threshold_type", CrmResourceType::CRM_IPMC_ENTRY },
{ "snat_entry_threshold_type", CrmResourceType::CRM_SNAT_ENTRY },
{ "dnat_entry_threshold_type", CrmResourceType::CRM_DNAT_ENTRY }
};

const map<string, CrmResourceType> crmThreshLowResMap =
Expand All @@ -89,6 +98,9 @@ const map<string, CrmResourceType> crmThreshLowResMap =
{"acl_entry_low_threshold", CrmResourceType::CRM_ACL_ENTRY },
{"acl_counter_low_threshold", CrmResourceType::CRM_ACL_COUNTER },
{"fdb_entry_low_threshold", CrmResourceType::CRM_FDB_ENTRY },
{"ipmc_entry_low_threshold", CrmResourceType::CRM_IPMC_ENTRY },
{"snat_entry_low_threshold", CrmResourceType::CRM_SNAT_ENTRY },
{"dnat_entry_low_threshold", CrmResourceType::CRM_DNAT_ENTRY }
};

const map<string, CrmResourceType> crmThreshHighResMap =
Expand All @@ -105,7 +117,10 @@ const map<string, CrmResourceType> crmThreshHighResMap =
{"acl_group_high_threshold", CrmResourceType::CRM_ACL_GROUP },
{"acl_entry_high_threshold", CrmResourceType::CRM_ACL_ENTRY },
{"acl_counter_high_threshold", CrmResourceType::CRM_ACL_COUNTER },
{"fdb_entry_high_threshold", CrmResourceType::CRM_FDB_ENTRY }
{"fdb_entry_high_threshold", CrmResourceType::CRM_FDB_ENTRY },
{"ipmc_entry_high_threshold", CrmResourceType::CRM_IPMC_ENTRY },
{"snat_entry_high_threshold", CrmResourceType::CRM_SNAT_ENTRY },
{"dnat_entry_high_threshold", CrmResourceType::CRM_DNAT_ENTRY }
};

const map<string, CrmThresholdType> crmThreshTypeMap =
Expand All @@ -129,7 +144,10 @@ const map<string, CrmResourceType> crmAvailCntsTableMap =
{ "crm_stats_acl_group_available", CrmResourceType::CRM_ACL_GROUP },
{ "crm_stats_acl_entry_available", CrmResourceType::CRM_ACL_ENTRY },
{ "crm_stats_acl_counter_available", CrmResourceType::CRM_ACL_COUNTER },
{ "crm_stats_fdb_entry_available", CrmResourceType::CRM_FDB_ENTRY }
{ "crm_stats_fdb_entry_available", CrmResourceType::CRM_FDB_ENTRY },
{ "crm_stats_ipmc_entry_available", CrmResourceType::CRM_IPMC_ENTRY },
{ "crm_stats_snat_entry_available", CrmResourceType::CRM_SNAT_ENTRY },
{ "crm_stats_dnat_entry_available", CrmResourceType::CRM_DNAT_ENTRY }
};

const map<string, CrmResourceType> crmUsedCntsTableMap =
Expand All @@ -146,7 +164,10 @@ const map<string, CrmResourceType> crmUsedCntsTableMap =
{ "crm_stats_acl_group_used", CrmResourceType::CRM_ACL_GROUP },
{ "crm_stats_acl_entry_used", CrmResourceType::CRM_ACL_ENTRY },
{ "crm_stats_acl_counter_used", CrmResourceType::CRM_ACL_COUNTER },
{ "crm_stats_fdb_entry_used", CrmResourceType::CRM_FDB_ENTRY }
{ "crm_stats_fdb_entry_used", CrmResourceType::CRM_FDB_ENTRY },
{ "crm_stats_ipmc_entry_used", CrmResourceType::CRM_IPMC_ENTRY },
{ "crm_stats_snat_entry_used", CrmResourceType::CRM_SNAT_ENTRY },
{ "crm_stats_dnat_entry_used", CrmResourceType::CRM_DNAT_ENTRY }
};

CrmOrch::CrmOrch(DBConnector *db, string tableName):
Expand Down Expand Up @@ -429,10 +450,18 @@ void CrmOrch::getResAvailableCounters()
case SAI_SWITCH_ATTR_AVAILABLE_NEXT_HOP_GROUP_MEMBER_ENTRY:
case SAI_SWITCH_ATTR_AVAILABLE_NEXT_HOP_GROUP_ENTRY:
case SAI_SWITCH_ATTR_AVAILABLE_FDB_ENTRY:
case SAI_SWITCH_ATTR_AVAILABLE_IPMC_ENTRY:
case SAI_SWITCH_ATTR_AVAILABLE_SNAT_ENTRY:
case SAI_SWITCH_ATTR_AVAILABLE_DNAT_ENTRY:
{
sai_status_t status = sai_switch_api->get_switch_attribute(gSwitchId, 1, &attr);
if (status != SAI_STATUS_SUCCESS)
{
if(status == SAI_STATUS_NOT_SUPPORTED)
{
// remove unsupported resources from map
m_resourcesMap.erase(res.first);
}
SWSS_LOG_ERROR("Failed to get switch attribute %u , rv:%d", attr.id, status);
break;
}
Expand Down Expand Up @@ -504,22 +533,36 @@ void CrmOrch::updateCrmCountersTable()
// Update CRM used counters in COUNTERS_DB
for (const auto &i : crmUsedCntsTableMap)
{
for (const auto &cnt : m_resourcesMap.at(i.second).countersMap)
try
{
for (const auto &cnt : m_resourcesMap.at(i.second).countersMap)
{
FieldValueTuple attr(i.first, to_string(cnt.second.usedCounter));
vector<FieldValueTuple> attrs = { attr };
m_countersCrmTable->set(cnt.first, attrs);
}
}
catch(const out_of_range &e)
{
FieldValueTuple attr(i.first, to_string(cnt.second.usedCounter));
vector<FieldValueTuple> attrs = { attr };
m_countersCrmTable->set(cnt.first, attrs);
// expected when a resource is unavailable
}
}

// Update CRM available counters in COUNTERS_DB
for (const auto &i : crmAvailCntsTableMap)
{
for (const auto &cnt : m_resourcesMap.at(i.second).countersMap)
try
{
FieldValueTuple attr(i.first, to_string(cnt.second.availableCounter));
vector<FieldValueTuple> attrs = { attr };
m_countersCrmTable->set(cnt.first, attrs);
for (const auto &cnt : m_resourcesMap.at(i.second).countersMap)
{
FieldValueTuple attr(i.first, to_string(cnt.second.availableCounter));
vector<FieldValueTuple> attrs = { attr };
m_countersCrmTable->set(cnt.first, attrs);
}
}
catch(const out_of_range &e)
{
// expected when a resource is unavailable
}
}
}
Expand All @@ -541,7 +584,16 @@ void CrmOrch::checkCrmThresholds()

if (cnt.usedCounter != 0)
{
percentageUtil = (uint32_t)((cnt.usedCounter * 100) / (uint64_t)(cnt.usedCounter + cnt.availableCounter));
uint32_t dvsr = cnt.usedCounter + cnt.availableCounter;
if (dvsr != 0)
{
percentageUtil = (cnt.usedCounter * 100) / dvsr;
}
else
{
SWSS_LOG_WARN("%s Exception occured (div by Zero): Used count %u free count %u",
res.name.c_str(), cnt.usedCounter, cnt.availableCounter);
}
}

switch (res.thresholdType)
Expand Down
3 changes: 3 additions & 0 deletions orchagent/crmorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ enum class CrmResourceType
CRM_ACL_ENTRY,
CRM_ACL_COUNTER,
CRM_FDB_ENTRY,
CRM_IPMC_ENTRY,
CRM_SNAT_ENTRY,
CRM_DNAT_ENTRY,
};

enum class CrmThresholdType
Expand Down
5 changes: 2 additions & 3 deletions orchagent/intfsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const int intfsorch_pri = 35;
#define RIF_FLEX_STAT_COUNTER_POLL_MSECS "1000"
#define UPDATE_MAPS_SEC 1

#define LOOPBACK_PREFIX "Loopback"

static const vector<sai_router_interface_stat_t> rifStatIds =
{
Expand All @@ -57,7 +56,7 @@ IntfsOrch::IntfsOrch(DBConnector *db, string tableName, VRFOrch *vrf_orch) :
{
SWSS_LOG_ENTER();

/* Initialize DB connectors */
/* Initialize DB connectors */
m_counter_db = shared_ptr<DBConnector>(new DBConnector("COUNTERS_DB", 0));
m_flex_db = shared_ptr<DBConnector>(new DBConnector("FLEX_COUNTER_DB", 0));
m_asic_db = shared_ptr<DBConnector>(new DBConnector("ASIC_DB", 0));
Expand Down Expand Up @@ -576,7 +575,7 @@ void IntfsOrch::doTask(Consumer &consumer)
SWSS_LOG_ERROR("Invalid mac argument %s to %s()", value.c_str(), e.what());
continue;
}
}
}
else if (field == "nat_zone")
{
try
Expand Down
10 changes: 8 additions & 2 deletions orchagent/routeorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,13 @@ void RouteOrch::doTask(Consumer& consumer)

for (auto alias : alsv)
{
if (alias == "eth0" || alias == "lo" || alias == "docker0")
/* skip route to management, docker, loopback
* TODO: for route to loopback interface, the proper
* way is to create loopback interface and then create
* route pointing to it, so that we can traps packets to
* CPU */
if (alias == "eth0" || alias == "docker0" ||
alias == "lo" || !alias.compare(0, strlen(LOOPBACK_PREFIX), LOOPBACK_PREFIX))
{
excp_intfs_flag = true;
break;
Expand Down Expand Up @@ -1231,7 +1237,7 @@ bool RouteOrch::addRoute(RouteBulkContext& ctx, const NextHopGroupKey &nextHops)
&& vrf_id == gVirtualRouterId)
{
/* Only support the default vrf for Fine Grained ECMP */
SWSS_LOG_INFO("Reroute %s:%s to fgNhgOrch", ipPrefix.to_string().c_str(),
SWSS_LOG_INFO("Reroute %s:%s to fgNhgOrch", ipPrefix.to_string().c_str(),
nextHops.to_string().c_str());
return m_fgNhgOrch->addRoute(vrf_id, ipPrefix, nextHops);
}
Expand Down
2 changes: 2 additions & 0 deletions orchagent/routeorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
/* Length of the Interface Id value in EUI64 format */
#define EUI64_INTF_ID_LEN 8

#define LOOPBACK_PREFIX "Loopback"

typedef std::map<NextHopKey, sai_object_id_t> NextHopGroupMembers;

struct NextHopGroupEntry
Expand Down
Loading

0 comments on commit 9021773

Please sign in to comment.