Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Orchagent]: FdbOrch changes for EVPN VXLAN #1275

Merged
merged 27 commits into from
Jan 8, 2021
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6d3d2b5
[Orchagent]: FdbOrch changes for EVPN VXLAN
jainp1979 Apr 28, 2020
84642fc
This commit contains:
jainp1979 Jun 23, 2020
4d9bd0a
Fixed LGTM Warnings
jainp1979 Jun 24, 2020
187388e
[Orchagent]: FdbOrch changes for EVPN VXLAN
jainp1979 Oct 28, 2020
fb85618
[Orchagent]: FdbOrch changes for EVPN VXLAN
jainp1979 Oct 28, 2020
304234e
Merge branch 'master' into evpn_fdb_orchagent
jainp1979 Oct 28, 2020
073da4a
reverted vlanmgr changes
anilkpandey Dec 16, 2020
7025c7e
Merge remote-tracking branch 'upstream/master' into evpn_fdb_orchagent
anilkpandey Dec 16, 2020
7a83154
fix build issue
anilkpandey Dec 16, 2020
88f487e
Update portsorch.cpp
anilkpandey Dec 16, 2020
b9e696a
Merge remote-tracking branch 'upstream/master' into evpn_fdb_orchagent
anilkpandey Dec 18, 2020
2c0b5f5
fix build issue
anilkpandey Dec 18, 2020
e119e4f
Update fdborch.cpp
anilkpandey Dec 18, 2020
4c58722
Update aclorch_ut.cpp
anilkpandey Dec 18, 2020
e84411e
fix lgtm
anilkpandey Dec 19, 2020
e209750
Update test_evpn_fdb.py
anilkpandey Dec 21, 2020
eedde3c
Update test_evpn_fdb.py
anilkpandey Dec 21, 2020
ef3adf8
Update test_evpn_fdb.py
anilkpandey Dec 22, 2020
f97af78
Merge remote-tracking branch 'upstream/master' into evpn_fdb_orchagent
anilkpandey Dec 23, 2020
5f38e64
remove fdb flush related changes
anilkpandey Dec 23, 2020
41a4a18
updated as per review comments
anilkpandey Dec 24, 2020
f17b20e
Update fdborch.cpp
anilkpandey Dec 28, 2020
3ceb819
updated as per latest review comments
anilkpandey Dec 29, 2020
9021773
Merge remote-tracking branch 'upstream/master' into evpn_fdb_orchagent
anilkpandey Dec 29, 2020
df6b9e7
Update portsorch.cpp
anilkpandey Dec 29, 2020
1665c71
Merge remote-tracking branch 'upstream/master' into evpn_fdb_orchagent
anilkpandey Dec 31, 2020
798d5fe
fix vs test
anilkpandey Dec 31, 2020
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
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
Copy link
Contributor

@vasant17 vasant17 Oct 8, 2020

Choose a reason for hiding this comment

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

This structure will contain all the information related to an FDB entry, so, it would be neat keep VxLAN related info in a separate structure and add it here as a variable, but I will leave it up to you!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

keeping it the same for now.

{
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;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did we remove FdbEntry and added mac and vlanID explicitly. Can we keep FdbEntry and use its overloaded comparision operator to compare savedFdbEntry?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SaveFdbEntry is used for storing an FDB which has valid vlan (vlan is created) but is waiting for the port to become the associated vlan's member.
now if vlan gets deleted, this entry is stuck in the saveFdbEntry;
later when user deletes the FDB, there is no way to compare it with bv_id (because that is no more there) hence changed to vlan-id so that delete request can be compared against FDBs in savedFdbEntry.

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 @@ -87,11 +87,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 @@ -316,8 +316,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