Skip to content

Commit

Permalink
[Orchagent]: FdbOrch changes for EVPN VXLAN (#1275)
Browse files Browse the repository at this point in the history
* [Orchagent]: FdbOrch changes for EVPN VXLAN
* Support for EVPN advertised mac routes
  • Loading branch information
jainp1979 authored Jan 8, 2021
1 parent 097cfda commit a960e2e
Show file tree
Hide file tree
Showing 11 changed files with 1,263 additions and 133 deletions.
789 changes: 676 additions & 113 deletions orchagent/fdborch.cpp

Large diffs are not rendered by default.

59 changes: 52 additions & 7 deletions orchagent/fdborch.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
#include "observer.h"
#include "portsorch.h"

enum FdbOrigin
{
FDB_ORIGIN_INVALID = 0,
FDB_ORIGIN_LEARN = 1,
FDB_ORIGIN_PROVISIONED = 2,
FDB_ORIGIN_VXLAN_ADVERTIZED = 4
};

struct FdbEntry
{
MacAddress mac;
Expand All @@ -15,12 +23,17 @@ struct FdbEntry
{
return tie(mac, bv_id) < tie(other.mac, other.bv_id);
}
bool operator==(const FdbEntry& other) const
{
return tie(mac, bv_id) == tie(other.mac, other.bv_id);
}
};

struct FdbUpdate
{
FdbEntry entry;
Port port;
string type;
bool add;
};

Expand All @@ -30,10 +43,35 @@ struct FdbFlushUpdate
Port port;
};

struct SavedFdbEntry
struct FdbData
{
FdbEntry entry;
sai_object_id_t bridge_port_id;
string type;
FdbOrigin origin;
/**
{"dynamic", FDB_ORIGIN_LEARN} => dynamically learnt
{"dynamic", FDB_ORIGIN_PROVISIONED} => provisioned dynamic with swssconfig in APPDB
{"dynamic", FDB_ORIGIN_ADVERTIZED} => synced from remote device e.g. BGP MAC route
{"static", FDB_ORIGIN_LEARN} => Invalid
{"static", FDB_ORIGIN_PROVISIONED} => statically provisioned
{"static", FDB_ORIGIN_ADVERTIZED} => sticky synced from remote device
*/

/* Remote FDB related info */
string remote_ip;
string esi;
unsigned int vni;
};

struct SavedFdbEntry
{
MacAddress mac;
unsigned short vlanId;
FdbData fdbData;
bool operator==(const SavedFdbEntry& other) const
{
return tie(mac, vlanId) == tie(other.mac, other.vlanId);
}
};

typedef unordered_map<string, vector<SavedFdbEntry>> fdb_entries_by_port_t;
Expand All @@ -42,7 +80,7 @@ class FdbOrch: public Orch, public Subject, public Observer
{
public:

FdbOrch(TableConnector applDbConnector, TableConnector stateDbConnector, PortsOrch *port);
FdbOrch(DBConnector* applDbConnector, vector<table_name_with_pri_t> appFdbTables, TableConnector stateDbFdbConnector, PortsOrch *port);

~FdbOrch()
{
Expand All @@ -53,15 +91,19 @@ class FdbOrch: public Orch, public Subject, public Observer
void update(sai_fdb_event_t, const sai_fdb_entry_t *, sai_object_id_t);
void update(SubjectType type, void *cntx);
bool getPort(const MacAddress&, uint16_t, Port&);

bool removeFdbEntry(const FdbEntry& entry, FdbOrigin origin=FDB_ORIGIN_PROVISIONED);

static const int fdborch_pri;
void flushFDBEntries(sai_object_id_t bridge_port_oid,
sai_object_id_t vlan_oid);
void notifyObserversFDBFlush(Port &p, sai_object_id_t&);

private:
PortsOrch *m_portsOrch;
set<FdbEntry> m_entries;
map<FdbEntry, FdbData> m_entries;
fdb_entries_by_port_t saved_fdb_entries;
Table m_table;
vector<Table*> m_appTables;
Table m_fdbStateTable;
NotificationConsumer* m_flushNotificationsConsumer;
NotificationConsumer* m_fdbNotificationConsumer;
Expand All @@ -71,9 +113,12 @@ class FdbOrch: public Orch, public Subject, public Observer

void updateVlanMember(const VlanMemberUpdate&);
void updatePortOperState(const PortOperStateUpdate&);
bool addFdbEntry(const FdbEntry&, const string&);
bool removeFdbEntry(const FdbEntry&);

bool addFdbEntry(const FdbEntry&, const string&, FdbData fdbData);
void deleteFdbEntryFromSavedFDB(const MacAddress &mac, const unsigned short &vlanId, FdbOrigin origin, const string portName="");

bool storeFdbEntryState(const FdbUpdate& update);
void notifyTunnelOrch(Port& port);
};

#endif /* SWSS_FDBORCH_H */
8 changes: 6 additions & 2 deletions orchagent/orchdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,15 @@ bool OrchDaemon::init()
{ APP_LAG_MEMBER_TABLE_NAME, portsorch_base_pri }
};

vector<table_name_with_pri_t> app_fdb_tables = {
{ APP_FDB_TABLE_NAME, FdbOrch::fdborch_pri},
{ APP_VXLAN_FDB_TABLE_NAME, FdbOrch::fdborch_pri}
};

gCrmOrch = new CrmOrch(m_configDb, CFG_CRM_TABLE_NAME);
gPortsOrch = new PortsOrch(m_applDb, ports_tables);
TableConnector applDbFdb(m_applDb, APP_FDB_TABLE_NAME);
TableConnector stateDbFdb(m_stateDb, STATE_FDB_TABLE_NAME);
gFdbOrch = new FdbOrch(applDbFdb, stateDbFdb, gPortsOrch);
gFdbOrch = new FdbOrch(m_applDb, app_fdb_tables, stateDbFdb, gPortsOrch);

vector<string> vnet_tables = {
APP_VNET_RT_TABLE_NAME,
Expand Down
3 changes: 1 addition & 2 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,13 @@ PortsOrch::PortsOrch(DBConnector *db, vector<table_name_with_pri_t> &tableNames)
/* Initialize counter table */
m_counter_db = shared_ptr<DBConnector>(new DBConnector("COUNTERS_DB", 0));
m_counterTable = unique_ptr<Table>(new Table(m_counter_db.get(), COUNTERS_PORT_NAME_MAP));

m_counterLagTable = unique_ptr<Table>(new Table(m_counter_db.get(), COUNTERS_LAG_NAME_MAP));
FieldValueTuple tuple("", "");
vector<FieldValueTuple> defaultLagFv;
defaultLagFv.push_back(tuple);
m_counterLagTable->set("", defaultLagFv);

/* Initialize port table */
/* Initialize port and vlan table */
m_portTable = unique_ptr<Table>(new Table(db, APP_PORT_TABLE_NAME));

/* Initialize gearbox */
Expand Down
1 change: 1 addition & 0 deletions orchagent/portsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class PortsOrch : public Orch, public Subject

bool setHostIntfsOperStatus(const Port& port, bool up) const;
void updateDbPortOperStatus(const Port& port, sai_port_oper_status_t status) const;

bool createBindAclTableGroup(sai_object_id_t port_oid,
sai_object_id_t acl_table_oid,
sai_object_id_t &group_oid,
Expand Down
18 changes: 18 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,24 @@ def setup_db(self):
self.cdb = swsscommon.DBConnector(4, self.redis_sock, 0)
self.sdb = swsscommon.DBConnector(6, self.redis_sock, 0)

def getSwitchOid(self):
tbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_SWITCH")
keys = tbl.getKeys()
return str(keys[0])

def getVlanOid(self, vlanId):
tbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_VLAN")
vlan_oid = None
keys = tbl.getKeys()
for k in keys:
(status, fvs) = tbl.get(k)
assert status == True, "Could not read vlan from DB"
for fv in fvs:
if fv[0] == "SAI_VLAN_ATTR_VLAN_ID" and fv[1] == str(vlanId):
vlan_oid = str(k)
break
return vlan_oid

# deps: acl_portchannel, fdb
def getCrmCounterValue(self, key, counter):
counters_db = swsscommon.DBConnector(swsscommon.COUNTERS_DB, self.redis_sock, 0)
Expand Down
7 changes: 6 additions & 1 deletion tests/mock_tests/aclorch_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,13 @@ namespace aclorch_test
TableConnector applDbFdb(m_app_db.get(), APP_FDB_TABLE_NAME);
TableConnector stateDbFdb(m_state_db.get(), STATE_FDB_TABLE_NAME);

vector<table_name_with_pri_t> app_fdb_tables = {
{ APP_FDB_TABLE_NAME, FdbOrch::fdborch_pri},
{ APP_VXLAN_FDB_TABLE_NAME, FdbOrch::fdborch_pri}
};

ASSERT_EQ(gFdbOrch, nullptr);
gFdbOrch = new FdbOrch(applDbFdb, stateDbFdb, gPortsOrch);
gFdbOrch = new FdbOrch(m_app_db.get(), app_fdb_tables, stateDbFdb, gPortsOrch);

ASSERT_EQ(gNeighOrch, nullptr);
gNeighOrch = new NeighOrch(m_app_db.get(), APP_NEIGH_TABLE_NAME, gIntfsOrch, gFdbOrch, gPortsOrch);
Expand Down
Loading

0 comments on commit a960e2e

Please sign in to comment.