Skip to content

Commit

Permalink
[vrfmgrd]: Support VNET setting (#657)
Browse files Browse the repository at this point in the history
* [vrfmgrd]: Support VNET setting

Signed-off-by: Marian Pritsak <marianp@mellanox.com>

* Use VRF/VNET as a tunnel map name

Signed-off-by: Marian Pritsak <marianp@mellanox.com>

* Handle VNET and VRF the same way

Signed-off-by: Marian Pritsak <marianp@mellanox.com>
  • Loading branch information
marian-pritsak authored and lguohan committed Nov 7, 2018
1 parent f666011 commit 5de5054
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cfgmgr/vrfmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ using namespace swss;

VrfMgr::VrfMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const vector<string> &tableNames) :
Orch(cfgDb, tableNames),
m_appVrfTableProducer(appDb, APP_VRF_TABLE_NAME),
m_appVnetTableProducer(appDb, APP_VNET_TABLE_NAME),
m_stateVrfTable(stateDb, STATE_VRF_TABLE_NAME)
{
for (uint32_t i = VRF_TABLE_START; i < VRF_TABLE_END; i++)
Expand Down Expand Up @@ -160,6 +162,14 @@ void VrfMgr::doTask(Consumer &consumer)
m_stateVrfTable.set(vrfName, fvVector);

SWSS_LOG_NOTICE("Created vrf netdev %s", vrfName.c_str());
if (consumer.getTableName() == APP_VRF_TABLE_NAME)
{
m_appVrfTableProducer.set(vrfName, kfvFieldsValues(t));
}
else
{
m_appVnetTableProducer.set(vrfName, kfvFieldsValues(t));
}
}
else if (op == DEL_COMMAND)
{
Expand All @@ -170,6 +180,15 @@ void VrfMgr::doTask(Consumer &consumer)

m_stateVrfTable.del(vrfName);

if (consumer.getTableName() == APP_VRF_TABLE_NAME)
{
m_appVrfTableProducer.del(vrfName);
}
else
{
m_appVnetTableProducer.del(vrfName);
}

SWSS_LOG_NOTICE("Removed vrf netdev %s", vrfName.c_str());
}
else
Expand Down
2 changes: 2 additions & 0 deletions cfgmgr/vrfmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ class VrfMgr : public Orch
bool setLink(const string& vrfName);
void recycleTable(uint32_t table);
uint32_t getFreeTable(void);
void handleVnetConfigSet(KeyOpFieldsValuesTuple &t);
void doTask(Consumer &consumer);

map<string, uint32_t> m_vrfTableMap;
set<uint32_t> m_freeTables;

Table m_stateVrfTable;
ProducerStateTable m_appVrfTableProducer, m_appVnetTableProducer;
};

}
Expand Down
1 change: 1 addition & 0 deletions cfgmgr/vrfmgrd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ int main(int argc, char **argv)
{
vector<string> cfg_vrf_tables = {
CFG_VRF_TABLE_NAME,
CFG_VNET_TABLE_NAME,
};

DBConnector cfgDb(CONFIG_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);
Expand Down

0 comments on commit 5de5054

Please sign in to comment.