Skip to content

Commit

Permalink
[VS] Fix context config guid on RealObjectIdManager (sonic-net#847)
Browse files Browse the repository at this point in the history
Will help using multiple switches in VS with multiple contextes.
  • Loading branch information
kcudnik committed Jul 13, 2021
1 parent 6fe1e75 commit 8123e32
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions vslib/inc/VirtualSwitchSaiInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

#include "SwitchStateBase.h"
#include "WarmBootState.h"
#include "SwitchConfigContainer.h"
#include "RealObjectIdManager.h"
#include "SwitchStateBase.h"
#include "EventQueue.h"
#include "EventPayloadPacket.h"
#include "EventPayloadNetLinkMsg.h"
#include "ContextConfig.h"

#include "lib/inc/SaiInterface.h"

Expand Down Expand Up @@ -70,7 +70,7 @@ namespace saivs
public:

VirtualSwitchSaiInterface(
_In_ const std::shared_ptr<SwitchConfigContainer> scc);
_In_ std::shared_ptr<ContextConfig> contextConfig);

virtual ~VirtualSwitchSaiInterface();

Expand Down Expand Up @@ -394,7 +394,7 @@ namespace saivs

std::map<sai_object_id_t, WarmBootState> m_warmBootState;

std::shared_ptr<SwitchConfigContainer> m_switchConfigContainer;
std::shared_ptr<ContextConfig> m_contextConfig;

std::shared_ptr<RealObjectIdManager> m_realObjectIdManager;

Expand Down
2 changes: 1 addition & 1 deletion vslib/src/Sai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ sai_status_t Sai::initialize(

// TODO move to Context class

m_vsSai = std::make_shared<VirtualSwitchSaiInterface>(scc);
m_vsSai = std::make_shared<VirtualSwitchSaiInterface>(contextConfig);

m_meta = std::make_shared<saimeta::Meta>(m_vsSai);

Expand Down
11 changes: 6 additions & 5 deletions vslib/src/VirtualSwitchSaiInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ using namespace saimeta;
using namespace sairediscommon;

VirtualSwitchSaiInterface::VirtualSwitchSaiInterface(
_In_ const std::shared_ptr<SwitchConfigContainer> scc)
_In_ std::shared_ptr<ContextConfig> contextConfig):
m_contextConfig(contextConfig)
{
SWSS_LOG_ENTER();

m_realObjectIdManager = std::make_shared<RealObjectIdManager>(0, scc); // TODO fix global context

m_switchConfigContainer = scc;
m_realObjectIdManager = std::make_shared<RealObjectIdManager>(
m_contextConfig->m_guid,
m_contextConfig->m_scc);
}

VirtualSwitchSaiInterface::~VirtualSwitchSaiInterface()
Expand Down Expand Up @@ -625,7 +626,7 @@ sai_status_t VirtualSwitchSaiInterface::create(
{
auto switchIndex = RealObjectIdManager::getSwitchIndex(switchId);

auto config = m_switchConfigContainer->getConfig(switchIndex);
auto config = m_contextConfig->m_scc->getConfig(switchIndex);

if (config == nullptr)
{
Expand Down

0 comments on commit 8123e32

Please sign in to comment.