Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions orchagent/intfsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ extern NeighOrch *gNeighOrch;
extern string gMySwitchType;
extern int32_t gVoqMySwitchId;
extern bool gTraditionalFlexCounter;
extern bool isChassisDbInUse();
extern bool isVoqChassisDbInUse();

const int intfsorch_pri = 35;

Expand Down Expand Up @@ -99,7 +99,7 @@ IntfsOrch::IntfsOrch(DBConnector *db, string tableName, VRFOrch *vrf_orch, DBCon
RIF_PLUGIN_FIELD,
rifRateSha);

if(isChassisDbInUse())
if(isVoqChassisDbInUse())
{
//Add subscriber to process VOQ system interface
tableName = CHASSIS_APP_SYSTEM_INTERFACE_TABLE_NAME;
Expand All @@ -109,6 +109,7 @@ IntfsOrch::IntfsOrch(DBConnector *db, string tableName, VRFOrch *vrf_orch, DBCon

}


sai_object_id_t IntfsOrch::getRouterIntfsId(const string &alias)
{
Port port;
Expand Down Expand Up @@ -1311,7 +1312,7 @@ bool IntfsOrch::addRouterIntfs(sai_object_id_t vrf_id, Port &port, string loopba

SWSS_LOG_NOTICE("Create router interface %s MTU %u", port.m_alias.c_str(), port.m_mtu);

if(isChassisDbInUse())
if(isVoqChassisDbInUse())
{
// Sync the interface of local port/LAG to the SYSTEM_INTERFACE table of CHASSIS_APP_DB
voqSyncAddIntf(port.m_alias);
Expand Down Expand Up @@ -1364,7 +1365,7 @@ bool IntfsOrch::removeRouterIntfs(Port &port)

SWSS_LOG_NOTICE("Remove router interface for port %s", port.m_alias.c_str());

if(isChassisDbInUse())
if(isVoqChassisDbInUse())
{
// Sync the removal of interface of local port/LAG to the SYSTEM_INTERFACE table of CHASSIS_APP_DB
voqSyncDelIntf(port.m_alias);
Expand Down
2 changes: 1 addition & 1 deletion orchagent/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ bool gTraditionalFlexCounter = false;
uint32_t create_switch_timeout = 0;
bool gMultiAsicVoq = false;

bool isChassisDbInUse()
bool isVoqChassisDbInUse()
{
return gMultiAsicVoq;
}
Expand Down
36 changes: 27 additions & 9 deletions orchagent/neighorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "subscriberstatetable.h"
#include "nhgorch.h"

#include <boost/algorithm/string.hpp>

extern sai_neighbor_api_t* sai_neighbor_api;
extern sai_next_hop_api_t* sai_next_hop_api;

Expand All @@ -24,8 +26,9 @@ extern int32_t gVoqMySwitchId;
extern BfdOrch *gBfdOrch;
extern size_t gMaxBulkSize;
extern string gMyHostName;
extern string gMyAsicName;

extern bool isChassisDbInUse();
extern bool isVoqChassisDbInUse();

const int neighorch_pri = 30;

Expand All @@ -48,7 +51,7 @@ NeighOrch::NeighOrch(DBConnector *appDb, string tableName, IntfsOrch *intfsOrch,
gBfdOrch->attach(this);
}

if(isChassisDbInUse())
if(isVoqChassisDbInUse())
{
//Add subscriber to process VOQ system neigh
tableName = CHASSIS_APP_SYSTEM_NEIGH_TABLE_NAME;
Expand Down Expand Up @@ -1233,7 +1236,7 @@ bool NeighOrch::addNeighbor(NeighborContext& ctx)
NeighborUpdate update = { neighborEntry, macAddress, true };
notify(SUBJECT_TYPE_NEIGH_CHANGE, static_cast<void *>(&update));

if(isChassisDbInUse())
if(isVoqChassisDbInUse())
{
//Sync the neighbor to add to the CHASSIS_APP_DB
voqSyncAddNeigh(alias, ip_address, macAddress, neighbor_entry);
Expand Down Expand Up @@ -1382,7 +1385,7 @@ bool NeighOrch::removeNeighbor(NeighborContext& ctx, bool disable)
NeighborUpdate update = { neighborEntry, MacAddress(), false };
notify(SUBJECT_TYPE_NEIGH_CHANGE, static_cast<void *>(&update));

if(isChassisDbInUse())
if(isVoqChassisDbInUse())
{
//Sync the neighbor to delete from the CHASSIS_APP_DB
voqSyncDelNeigh(alias, ip_address);
Expand Down Expand Up @@ -1867,11 +1870,26 @@ void NeighOrch::doVoqSystemNeighTask(Consumer &consumer)

string alias = key.substr(0, found);

size_t pos = alias.find('|');
std::string port_hostname = (pos != std::string::npos) ? alias.substr(0, pos) : alias;
if(gIntfsOrch->isLocalSystemPortIntf(alias))
{
//Synced local neighbor. Skip
// VoQ aliases can include <hostname>|<asic>|<local-alias> even without chassis DB.
const auto alias_tokens = tokenize(alias, '|');
std::string port_hostname = alias_tokens.empty() ? alias : alias_tokens[0];
bool is_local_by_host_asic = false;
if (isVoqChassisDbInUse() && gMyHostName == port_hostname)
{
std::string port_asic = alias_tokens.size() > 1 ? alias_tokens[1] : "";
std::string lower_port_asic = port_asic;
std::string lower_my_asic = gMyAsicName;
boost::algorithm::to_lower(lower_port_asic);
boost::algorithm::to_lower(lower_my_asic);
SWSS_LOG_DEBUG("doVoqSystemNeighTask: alias=%s hostname=%s asic=%s local_asic=%s",
alias.c_str(), port_hostname.c_str(), port_asic.c_str(), gMyAsicName.c_str());
is_local_by_host_asic = (lower_port_asic == lower_my_asic);
}
bool is_local_intf = gIntfsOrch->isLocalSystemPortIntf(alias);
if(is_local_intf || is_local_by_host_asic)
{
SWSS_LOG_DEBUG("doVoqSystemNeighTask: skipping local neighbor %s (isLocalIntf=%d isLocalByHostAsic=%d)",
alias.c_str(), is_local_intf, is_local_by_host_asic);
it = consumer.m_toSync.erase(it);
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion orchagent/p4orch/tests/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ string gMySwitchType = "switch";
event_handle_t g_events_handle;

bool gMultiAsicVoq = false;
bool isChassisDbInUse()
bool isVoqChassisDbInUse()
{
return gMultiAsicVoq;
}
Expand Down
45 changes: 34 additions & 11 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include <sstream>
#include <unordered_set>

#include <boost/algorithm/string.hpp>

#include <netinet/if_ether.h>
#include "net/if.h"

Expand Down Expand Up @@ -69,7 +71,7 @@ extern int32_t gVoqMySwitchId;
extern string gMyHostName;
extern string gMyAsicName;
extern event_handle_t g_events_handle;
extern bool isChassisDbInUse();
extern bool isVoqChassisDbInUse();
extern bool gMultiAsicVoq;

// defines ------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -1070,7 +1072,7 @@ PortsOrch::PortsOrch(DBConnector *db, DBConnector *stateDb, vector<table_name_wi
Orch::addExecutor(portHostTxReadyNotificatier);
}

if (isChassisDbInUse())
if (isVoqChassisDbInUse())
{
string tableName;
//Add subscriber to process system LAG (System PortChannel) table
Expand Down Expand Up @@ -6213,12 +6215,33 @@ void PortsOrch::doLagMemberTask(Consumer &consumer)
{
if (gMySwitchType == "voq")
{
size_t pos = lag_alias.find('|');
std::string port_hostname = (pos != std::string::npos) ? lag_alias.substr(0, pos) : lag_alias;
// VoQ LAG aliases can include <hostname>|<asic>|<local-alias> even without chassis DB.
const auto alias_tokens = tokenize(lag_alias, '|');
std::string port_hostname = alias_tokens.empty() ? lag_alias : alias_tokens[0];
if (gMyHostName == port_hostname)
{
it = consumer.m_toSync.erase(it);
continue;
if (isVoqChassisDbInUse())
{
std::string port_asic = alias_tokens.size() > 1 ? alias_tokens[1] : "";
std::string lower_port_asic = port_asic;
std::string lower_my_asic = gMyAsicName;
boost::algorithm::to_lower(lower_port_asic);
boost::algorithm::to_lower(lower_my_asic);
SWSS_LOG_DEBUG("doLagMemberTask: lag_alias=%s hostname=%s asic=%s local_asic=%s",
lag_alias.c_str(), port_hostname.c_str(), port_asic.c_str(), gMyAsicName.c_str());
if (lower_port_asic == lower_my_asic)
{
SWSS_LOG_DEBUG("doLagMemberTask: erasing local entry %s (same host and asic)", lag_alias.c_str());
it = consumer.m_toSync.erase(it);
continue;
}
}
else
{
SWSS_LOG_DEBUG("doLagMemberTask: erasing local entry %s (single-asic voq)", lag_alias.c_str());
it = consumer.m_toSync.erase(it);
continue;
}
}
}
SWSS_LOG_INFO("Failed to locate LAG %s", lag_alias.c_str());
Expand Down Expand Up @@ -6289,7 +6312,7 @@ void PortsOrch::doLagMemberTask(Consumer &consumer)
}
}

if (isChassisDbInUse() && (port.m_type != Port::SYSTEM))
if (isVoqChassisDbInUse() && (port.m_type != Port::SYSTEM))
{
//Sync to SYSTEM_LAG_MEMBER_TABLE of CHASSIS_APP_DB
voqSyncAddLagMember(lag, port, status);
Expand Down Expand Up @@ -8028,7 +8051,7 @@ bool PortsOrch::removeLag(Port lag)

m_counterLagTable->hdel("", lag.m_alias);

if (isChassisDbInUse())
if (isVoqChassisDbInUse())
{
// Free the lag id, if this is local LAG

Expand Down Expand Up @@ -8141,7 +8164,7 @@ bool PortsOrch::addLagMember(Port &lag, Port &port, string member_status)
LagMemberUpdate update = { lag, port, true };
notify(SUBJECT_TYPE_LAG_MEMBER_CHANGE, static_cast<void *>(&update));

if (isChassisDbInUse())
if (isVoqChassisDbInUse())
{
//Sync to SYSTEM_LAG_MEMBER_TABLE of CHASSIS_APP_DB
voqSyncAddLagMember(lag, port, member_status);
Expand Down Expand Up @@ -8189,7 +8212,7 @@ bool PortsOrch::removeLagMember(Port &lag, Port &port)
LagMemberUpdate update = { lag, port, false };
notify(SUBJECT_TYPE_LAG_MEMBER_CHANGE, static_cast<void *>(&update));

if (isChassisDbInUse())
if (isVoqChassisDbInUse())
{
//Sync to SYSTEM_LAG_MEMBER_TABLE of CHASSIS_APP_DB
voqSyncDelLagMember(lag, port);
Expand Down Expand Up @@ -9812,7 +9835,7 @@ void PortsOrch::updatePortOperStatus(Port &port, sai_port_oper_status_t status)
}
}

if(isChassisDbInUse())
if(isVoqChassisDbInUse())
{
if (gIntfsOrch->isLocalSystemPortIntf(port.m_alias))
{
Expand Down
2 changes: 1 addition & 1 deletion tests/mock_tests/mock_orchagent_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ VRFOrch *gVrfOrch;
void syncd_apply_view() {}

bool gMultiAsicVoq = false;
bool isChassisDbInUse()
bool isVoqChassisDbInUse()
{
return gMultiAsicVoq;
}
Loading
Loading