-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[chassisorch]: Add everflow feature for chassis (#1024)
Signed-off-by: Ze Gan <[email protected]>
- Loading branch information
Showing
6 changed files
with
347 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#include "chassisorch.h" | ||
#include "routeorch.h" | ||
|
||
ChassisOrch::ChassisOrch( | ||
DBConnector* cfgDb, | ||
DBConnector* applDb, | ||
const std::vector<std::string>& tableNames, | ||
VNetRouteOrch* vNetRouteOrch) : | ||
Orch(cfgDb, tableNames), | ||
m_passThroughRouteTable(applDb, APP_PASS_THROUGH_ROUTE_TABLE_NAME), | ||
m_vNetRouteOrch(vNetRouteOrch) | ||
{ | ||
} | ||
|
||
void ChassisOrch::update(SubjectType type, void* ctx) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
VNetNextHopUpdate* updateInfo = reinterpret_cast<VNetNextHopUpdate*>(ctx); | ||
if (updateInfo->op == SET_COMMAND) | ||
{ | ||
addRouteToPassThroughRouteTable(*updateInfo); | ||
} | ||
else | ||
{ | ||
deleteRoutePassThroughRouteTable(*updateInfo); | ||
} | ||
} | ||
|
||
void ChassisOrch::addRouteToPassThroughRouteTable(const VNetNextHopUpdate& update) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
std::vector<FieldValueTuple> fvVector; | ||
fvVector.emplace_back("redistribute", "true"); | ||
fvVector.emplace_back("next_vrf_name", update.vnet); | ||
fvVector.emplace_back("next_hop_ip", update.nexthop.ips.to_string()); | ||
fvVector.emplace_back("ifname", update.nexthop.ifname); | ||
fvVector.emplace_back("source", "CHASSIS_ORCH"); | ||
const std::string everflow_route = IpPrefix(update.destination.to_string()).to_string(); | ||
m_passThroughRouteTable.set(everflow_route, fvVector); | ||
} | ||
|
||
void ChassisOrch::deleteRoutePassThroughRouteTable(const VNetNextHopUpdate& update) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
const std::string everflow_route = IpPrefix(update.destination.to_string()).to_string(); | ||
m_passThroughRouteTable.del(everflow_route); | ||
} | ||
|
||
void ChassisOrch::doTask(Consumer &consumer) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
const std::string & tableName = consumer.getTableName(); | ||
auto it = consumer.m_toSync.begin(); | ||
while (it != consumer.m_toSync.end()) | ||
{ | ||
auto t = it->second; | ||
const std::string & op = kfvOp(t); | ||
const std::string & ip = kfvKey(t); | ||
|
||
if (op == SET_COMMAND) | ||
{ | ||
m_vNetRouteOrch->attach(this, ip); | ||
} | ||
else | ||
{ | ||
m_vNetRouteOrch->detach(this, ip); | ||
} | ||
it = consumer.m_toSync.erase(it); | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#ifndef SWSS_CHASSISORCH_H | ||
#define SWSS_CHASSISORCH_H | ||
|
||
#include <map> | ||
#include <set> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "dbconnector.h" | ||
#include "producerstatetable.h" | ||
#include "orch.h" | ||
#include "observer.h" | ||
#include "vnetorch.h" | ||
|
||
class ChassisOrch : public Orch, public Observer | ||
{ | ||
public: | ||
ChassisOrch( | ||
DBConnector* cfgDb, | ||
DBConnector *applDb, | ||
const std::vector<std::string> &tableNames, | ||
VNetRouteOrch * vNetRouteOrch); | ||
|
||
private: | ||
|
||
void update(SubjectType, void*); | ||
void addRouteToPassThroughRouteTable(const VNetNextHopUpdate& update); | ||
void deleteRoutePassThroughRouteTable(const VNetNextHopUpdate& update); | ||
|
||
virtual void doTask(Consumer &consumer); | ||
|
||
Table m_passThroughRouteTable; | ||
VNetRouteOrch* m_vNetRouteOrch; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.