Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f0b2cec
changes needed to support VOQ FS
lakshmi-nexthop Aug 27, 2025
9925e34
connect to chassis db if present
lakshmi-nexthop Aug 27, 2025
a878c08
UT fix
lakshmi-nexthop Aug 29, 2025
756c48c
format
lakshmi-nexthop Oct 7, 2025
77b17bf
formatting
lakshmi-nexthop Oct 7, 2025
a63b4d9
format
lakshmi-nexthop Oct 7, 2025
49d7b93
format
lakshmi-nexthop Oct 7, 2025
f1a54fa
Merge branch 'master' into single_voq_swss
lakshmi-nexthop Oct 7, 2025
7e36333
conflict
lakshmi-nexthop Oct 7, 2025
6140dd1
UT for fixed system voq
lakshmi-nexthop Oct 15, 2025
a5a7d9b
Merge branch 'master' into single_voq_swss
lakshmi-nexthop Oct 22, 2025
4028a48
UT invocation
lakshmi-nexthop Oct 22, 2025
49f2df5
removed call to 2nd run-tests.sh
lakshmi-nexthop Oct 23, 2025
a9b094d
removed docker-sonic-vs changes also
lakshmi-nexthop Oct 23, 2025
5561705
Added UT back
lakshmi-nexthop Oct 23, 2025
7a6d0ae
change name
lakshmi-nexthop Oct 24, 2025
0780b1c
Merge branch 'master' into single_voq_swss
lakshmi-nexthop Oct 24, 2025
504be65
Merge branch 'master' into single_voq_swss
lakshmi-nexthop Oct 25, 2025
212f021
Merge branch 'master' into single_voq_swss
lakshmi-nexthop Oct 28, 2025
340f91a
refactor to reduce checks for single asic
lakshmi-nexthop Nov 13, 2025
b90964a
Merge branch 'single_voq_swss' of github.com:lakshmi-nexthop/sonic-sw…
lakshmi-nexthop Nov 13, 2025
e563a9b
removed extra lines
lakshmi-nexthop Nov 13, 2025
74427f6
add line
lakshmi-nexthop Nov 13, 2025
b220bb4
Merge branch 'master' into single_voq_swss
lakshmi-nexthop Nov 13, 2025
566e45b
removed more checks
lakshmi-nexthop Nov 13, 2025
f2e9985
removed additional check for voq
lakshmi-nexthop Nov 13, 2025
eae99a5
format
lakshmi-nexthop Nov 14, 2025
5e89254
format
lakshmi-nexthop Nov 14, 2025
36fd1c2
Merge branch 'master' into single_voq_swss
lakshmi-nexthop Nov 15, 2025
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
20 changes: 18 additions & 2 deletions orchagent/intfsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@ IntfsOrch::IntfsOrch(DBConnector *db, string tableName, VRFOrch *vrf_orch, DBCon
RIF_PLUGIN_FIELD,
rifRateSha);

if(gMySwitchType == "voq")
/* check if this is a single asic voq */
if (chassisAppDb == nullptr) {
m_singleVoq = true;
}

if(gMySwitchType == "voq" && !m_singleVoq)
{
//Add subscriber to process VOQ system interface
tableName = CHASSIS_APP_SYSTEM_INTERFACE_TABLE_NAME;
Expand Down Expand Up @@ -1670,6 +1675,10 @@ bool IntfsOrch::isLocalSystemPortIntf(string alias)

void IntfsOrch::voqSyncAddIntf(string &alias)
{
if (m_singleVoq) {
return;
}

//Sync only local interface. Confirm for the local interface and
//get the system port alias for key for syncing to CHASSIS_APP_DB
Port port;
Expand Down Expand Up @@ -1710,6 +1719,10 @@ void IntfsOrch::voqSyncAddIntf(string &alias)

void IntfsOrch::voqSyncDelIntf(string &alias)
{
if (m_singleVoq) {
return;
}

//Sync only local interface. Confirm for the local interface and
//get the system port alias for key for syncing to CHASSIS_APP_DB
Port port;
Expand Down Expand Up @@ -1743,6 +1756,10 @@ void IntfsOrch::voqSyncDelIntf(string &alias)

void IntfsOrch::voqSyncIntfState(string &alias, bool isUp)
{
if (m_singleVoq) {
return;
}

Port port;
string port_alias;
if(gPortsOrch->getPort(alias, port))
Expand Down Expand Up @@ -1773,4 +1790,3 @@ void IntfsOrch::voqSyncIntfState(string &alias, bool isUp)
}

}

1 change: 1 addition & 0 deletions orchagent/intfsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class IntfsOrch : public Orch

private:

bool m_singleVoq = false;
SelectableTimer* m_updateMapsTimer = nullptr;
std::vector<Port> m_rifsToAdd;

Expand Down
32 changes: 29 additions & 3 deletions orchagent/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ extern "C" {
#include <stdexcept>
#include <stdlib.h>
#include <string.h>
#include <fstream>
#include <nlohmann/json.hpp>

#include <sys/time.h>
#include <sairedis.h>
Expand Down Expand Up @@ -205,6 +207,18 @@ void getCfgSwitchType(DBConnector *cfgDb, string &switch_type, string &switch_su

}

bool isChassisAppDbPresent()
{
std::ifstream file("/etc/sonic/database_config.json");
if (!file.is_open()) return false;

nlohmann::json db_config;
file >> db_config;

return db_config.contains("DATABASES") &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we handle this by any other field in Config_DB and not reading file? @arlakshm

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point, there was an idea/suggestion to use a different flag in DEVICE_METADATA to indicate this mode. It's definitely a plausible solution, but a bit redundant and we have to worry about inconsistency between what that flag says and the presence/absence of this file. Both are valid approaches though and it will be good to see what @arlakshm suggests here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tjchadaga : can you put final conclusion here ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prsunny, currently we do not have any config_db entry to identify this. We can keep the check for chassis_db.conf. We will revisit this once we have any config_db entry is added

db_config["DATABASES"].contains("CHASSIS_APP_DB");
}

bool getSystemPortConfigList(DBConnector *cfgDb, DBConnector *appDb, vector<sai_system_port_config_t> &sysportcfglist)
{
Table cfgDeviceMetaDataTable(cfgDb, CFG_DEVICE_METADATA_TABLE_NAME);
Expand Down Expand Up @@ -607,7 +621,15 @@ int main(int argc, char **argv)

//Connect to CHASSIS_APP_DB in redis-server in control/supervisor card as per
//connection info in database_config.json
chassis_app_db = make_shared<DBConnector>("CHASSIS_APP_DB", 0, true);
chassis_app_db = nullptr;
if (isChassisAppDbPresent()) {
try {
chassis_app_db = make_shared<DBConnector>("CHASSIS_APP_DB", 0, true);
}
catch (const std::exception& e) {
SWSS_LOG_NOTICE("CHASSIS_APP_DB not available, operating in standalone VOQ mode");
}
}
}
else if (gMySwitchType == "fabric")
{
Expand Down Expand Up @@ -804,6 +826,10 @@ int main(int argc, char **argv)
}

shared_ptr<OrchDaemon> orchDaemon;
DBConnector *chassis_db = nullptr;
if (chassis_app_db != nullptr) {
chassis_db = chassis_app_db.get();
}

/*
* Declare shared pointers for dpu specific databases.
Expand All @@ -821,7 +847,7 @@ int main(int argc, char **argv)

else if (gMySwitchType != "fabric")
{
orchDaemon = make_shared<OrchDaemon>(&appl_db, &config_db, &state_db, chassis_app_db.get(), zmq_server.get());
orchDaemon = make_shared<OrchDaemon>(&appl_db, &config_db, &state_db, chassis_db, zmq_server.get());
if (gMySwitchType == "voq")
{
orchDaemon->setFabricEnabled(true);
Expand All @@ -831,7 +857,7 @@ int main(int argc, char **argv)
}
else
{
orchDaemon = make_shared<FabricOrchDaemon>(&appl_db, &config_db, &state_db, chassis_app_db.get(), zmq_server.get());
orchDaemon = make_shared<FabricOrchDaemon>(&appl_db, &config_db, &state_db, chassis_db, zmq_server.get());
}

if (gRingMode) {
Expand Down
31 changes: 27 additions & 4 deletions orchagent/neighorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ NeighOrch::NeighOrch(DBConnector *appDb, string tableName, IntfsOrch *intfsOrch,
gBfdOrch->attach(this);
}

if(gMySwitchType == "voq")
/* check if this is a single asic voq */
if (chassisAppDb == nullptr) {
m_singleVoq = true;
}

if(gMySwitchType == "voq" && !m_singleVoq)
{
//Add subscriber to process VOQ system neigh
tableName = CHASSIS_APP_SYSTEM_NEIGH_TABLE_NAME;
Expand Down Expand Up @@ -1926,7 +1931,9 @@ void NeighOrch::doVoqSystemNeighTask(Consumer &consumer)
if (removeNeighbor(ctx))
{
//neigh successfully deleted from SAI. Set STATE DB to signal to remove entries from kernel
m_stateSystemNeighTable->del(state_key);
if (!m_singleVoq) {
m_stateSystemNeighTable->del(state_key);
}
}
else
{
Expand Down Expand Up @@ -1976,7 +1983,9 @@ void NeighOrch::doVoqSystemNeighTask(Consumer &consumer)
vector<FieldValueTuple> fvVector;
FieldValueTuple mac("neigh", mac_address.to_string());
fvVector.push_back(mac);
m_stateSystemNeighTable->set(state_key, fvVector);
if (!m_singleVoq) {
m_stateSystemNeighTable->set(state_key, fvVector);
}

it = consumer.m_toSync.erase(it);
}
Expand Down Expand Up @@ -2013,7 +2022,9 @@ void NeighOrch::doVoqSystemNeighTask(Consumer &consumer)
if (removeNeighbor(ctx))
{
//neigh successfully deleted from SAI. Set STATE DB to signal to remove entries from kernel
m_stateSystemNeighTable->del(state_key);
if (!m_singleVoq) {
m_stateSystemNeighTable->del(state_key);
}

it = consumer.m_toSync.erase(it);
}
Expand Down Expand Up @@ -2162,6 +2173,10 @@ bool NeighOrch::delInbandNeighbor(string alias, IpAddress ip_address)

bool NeighOrch::getSystemPortNeighEncapIndex(string &alias, IpAddress &ip, uint32_t &encap_index)
{
if (m_singleVoq) {
return true;
}

string value;
string key = alias + m_tableVoqSystemNeighTable->getTableNameSeparator().c_str() + ip.to_string();

Expand Down Expand Up @@ -2203,6 +2218,10 @@ bool NeighOrch::addVoqEncapIndex(string &alias, IpAddress &ip, vector<sai_attrib

void NeighOrch::voqSyncAddNeigh(string &alias, IpAddress &ip_address, const MacAddress &mac, sai_neighbor_entry_t &neighbor_entry)
{
if (m_singleVoq) {
return;
}

sai_attribute_t attr;
sai_status_t status;

Expand Down Expand Up @@ -2273,6 +2292,10 @@ void NeighOrch::voqSyncAddNeigh(string &alias, IpAddress &ip_address, const MacA

void NeighOrch::voqSyncDelNeigh(string &alias, IpAddress &ip_address)
{
if (m_singleVoq) {
return;
}

//Sync only local neigh. Confirm for the local neigh and
//get the system port alias for key for syncing to CHASSIS_APP_DB
Port port;
Expand Down
1 change: 1 addition & 0 deletions orchagent/neighorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class NeighOrch : public Orch, public Subject, public Observer
void clearBulkers();

private:
bool m_singleVoq = false;
PortsOrch *m_portsOrch;
IntfsOrch *m_intfsOrch;
FdbOrch *m_fdbOrch;
Expand Down
37 changes: 24 additions & 13 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,12 @@ PortsOrch::PortsOrch(DBConnector *db, DBConnector *stateDb, vector<table_name_wi
Orch::addExecutor(portHostTxReadyNotificatier);
}

if (gMySwitchType == "voq")
/* check if this is a single asic voq */
if (chassisAppDb == nullptr) {
m_singleVoq = true;
}

if (gMySwitchType == "voq" && !m_singleVoq)
{
string tableName;
//Add subscriber to process system LAG (System PortChannel) table
Expand Down Expand Up @@ -7283,14 +7288,16 @@ bool PortsOrch::addLag(string lag_alias, uint32_t spa_id, int32_t switch_id)
switch_id = gVoqMySwitchId;
system_lag_alias = gMyHostName + "|" + gMyAsicName + "|" + lag_alias;

// Allocate unique lag id
spa_id = m_lagIdAllocator->lagIdAdd(system_lag_alias, 0);
if (!m_singleVoq) {
// Allocate unique lag id
spa_id = m_lagIdAllocator->lagIdAdd(system_lag_alias, 0);

if ((int32_t)spa_id <= 0)
{
SWSS_LOG_ERROR("Failed to allocate unique LAG id for local lag %s rv:%d", lag_alias.c_str(), spa_id);
return false;
}
if ((int32_t)spa_id <= 0)
{
SWSS_LOG_ERROR("Failed to allocate unique LAG id for local lag %s rv:%d", lag_alias.c_str(), spa_id);
return false;
}
}
}

sai_attribute_t attr;
Expand Down Expand Up @@ -7401,7 +7408,7 @@ bool PortsOrch::removeLag(Port lag)

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

if (gMySwitchType == "voq")
if (gMySwitchType == "voq" && !m_singleVoq)
{
// Free the lag id, if this is local LAG

Expand Down Expand Up @@ -9946,7 +9953,8 @@ void PortsOrch::voqSyncAddLag (Port &lag)

// Sync only local lag add to CHASSIS_APP_DB

if (switch_id != gVoqMySwitchId)
if (switch_id != gVoqMySwitchId ||
m_singleVoq)
{
return;
}
Expand All @@ -9969,7 +9977,8 @@ void PortsOrch::voqSyncAddLag (Port &lag)
void PortsOrch::voqSyncDelLag(Port &lag)
{
// Sync only local lag del to CHASSIS_APP_DB
if (lag.m_system_lag_info.switch_id != gVoqMySwitchId)
if (lag.m_system_lag_info.switch_id != gVoqMySwitchId ||
m_singleVoq)
{
return;
}
Expand All @@ -9982,7 +9991,8 @@ void PortsOrch::voqSyncDelLag(Port &lag)
void PortsOrch::voqSyncAddLagMember(Port &lag, Port &port, string status)
{
// Sync only local lag's member add to CHASSIS_APP_DB
if (lag.m_system_lag_info.switch_id != gVoqMySwitchId)
if (lag.m_system_lag_info.switch_id != gVoqMySwitchId ||
m_singleVoq)
{
return;
}
Expand All @@ -9998,7 +10008,8 @@ void PortsOrch::voqSyncAddLagMember(Port &lag, Port &port, string status)
void PortsOrch::voqSyncDelLagMember(Port &lag, Port &port)
{
// Sync only local lag's member del to CHASSIS_APP_DB
if (lag.m_system_lag_info.switch_id != gVoqMySwitchId)
if (lag.m_system_lag_info.switch_id != gVoqMySwitchId ||
m_singleVoq)
{
return;
}
Expand Down
1 change: 1 addition & 0 deletions orchagent/portsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ class PortsOrch : public Orch, public Subject
private:
unique_ptr<CounterNameMapUpdater> m_counterNameMapUpdater;
// unique_ptr<Table> m_counterTable;
bool m_singleVoq = false;
unique_ptr<Table> m_counterSysPortTable;
unique_ptr<Table> m_counterLagTable;
unique_ptr<Table> m_portTable;
Expand Down
5 changes: 5 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1669,6 +1669,11 @@ def create_vct_ctn(self, ctndir):
vol = {}
vol[chassis_config_dir] = {"bind": "/usr/share/sonic/virtual_chassis", "mode": "ro"}

# Mount database_config.json when connect_to_chassis_db is set to 1
if defcfg.get("connect_to_chassis_db") == 1:
database_config_file = cwd + "/virtual_chassis/database_config.json"
vol[database_config_file] = {"bind": "/etc/sonic/database_config.json", "mode": "ro"}

# pass self.ns into the vs to be use for vs restarts by swss conftest.
# connection to chassbr is setup by chassis_connect.py within the vs
data = {}
Expand Down
Loading
Loading