55#include " observer.h"
66#include " portsorch.h"
77
8+ enum FdbOrigin
9+ {
10+ FDB_ORIGIN_INVALID = 0 ,
11+ FDB_ORIGIN_LEARN = 1 ,
12+ FDB_ORIGIN_PROVISIONED = 2 ,
13+ FDB_ORIGIN_VXLAN_ADVERTIZED = 4
14+ };
15+
816struct FdbEntry
917{
1018 MacAddress mac;
@@ -15,12 +23,17 @@ struct FdbEntry
1523 {
1624 return tie (mac, bv_id) < tie (other.mac , other.bv_id );
1725 }
26+ bool operator ==(const FdbEntry& other) const
27+ {
28+ return tie (mac, bv_id) == tie (other.mac , other.bv_id );
29+ }
1830};
1931
2032struct FdbUpdate
2133{
2234 FdbEntry entry;
2335 Port port;
36+ string type;
2437 bool add;
2538};
2639
@@ -30,10 +43,35 @@ struct FdbFlushUpdate
3043 Port port;
3144};
3245
33- struct SavedFdbEntry
46+ struct FdbData
3447{
35- FdbEntry entry ;
48+ sai_object_id_t bridge_port_id ;
3649 string type;
50+ FdbOrigin origin;
51+ /* *
52+ {"dynamic", FDB_ORIGIN_LEARN} => dynamically learnt
53+ {"dynamic", FDB_ORIGIN_PROVISIONED} => provisioned dynamic with swssconfig in APPDB
54+ {"dynamic", FDB_ORIGIN_ADVERTIZED} => synced from remote device e.g. BGP MAC route
55+ {"static", FDB_ORIGIN_LEARN} => Invalid
56+ {"static", FDB_ORIGIN_PROVISIONED} => statically provisioned
57+ {"static", FDB_ORIGIN_ADVERTIZED} => sticky synced from remote device
58+ */
59+
60+ /* Remote FDB related info */
61+ string remote_ip;
62+ string esi;
63+ unsigned int vni;
64+ };
65+
66+ struct SavedFdbEntry
67+ {
68+ MacAddress mac;
69+ unsigned short vlanId;
70+ FdbData fdbData;
71+ bool operator ==(const SavedFdbEntry& other) const
72+ {
73+ return tie (mac, vlanId) == tie (other.mac , other.vlanId );
74+ }
3775};
3876
3977typedef unordered_map<string, vector<SavedFdbEntry>> fdb_entries_by_port_t ;
@@ -42,7 +80,7 @@ class FdbOrch: public Orch, public Subject, public Observer
4280{
4381public:
4482
45- FdbOrch (TableConnector applDbConnector, TableConnector stateDbConnector , PortsOrch *port);
83+ FdbOrch (DBConnector* applDbConnector, vector< table_name_with_pri_t > appFdbTables, TableConnector stateDbFdbConnector , PortsOrch *port);
4684
4785 ~FdbOrch ()
4886 {
@@ -53,15 +91,19 @@ class FdbOrch: public Orch, public Subject, public Observer
5391 void update (sai_fdb_event_t , const sai_fdb_entry_t *, sai_object_id_t );
5492 void update (SubjectType type, void *cntx);
5593 bool getPort (const MacAddress&, uint16_t , Port&);
94+
95+ bool removeFdbEntry (const FdbEntry& entry, FdbOrigin origin=FDB_ORIGIN_PROVISIONED);
96+
97+ static const int fdborch_pri;
5698 void flushFDBEntries (sai_object_id_t bridge_port_oid,
5799 sai_object_id_t vlan_oid);
58100 void notifyObserversFDBFlush (Port &p, sai_object_id_t &);
59101
60102private:
61103 PortsOrch *m_portsOrch;
62- set <FdbEntry> m_entries;
104+ map <FdbEntry, FdbData > m_entries;
63105 fdb_entries_by_port_t saved_fdb_entries;
64- Table m_table ;
106+ vector< Table*> m_appTables ;
65107 Table m_fdbStateTable;
66108 NotificationConsumer* m_flushNotificationsConsumer;
67109 NotificationConsumer* m_fdbNotificationConsumer;
@@ -71,9 +113,12 @@ class FdbOrch: public Orch, public Subject, public Observer
71113
72114 void updateVlanMember (const VlanMemberUpdate&);
73115 void updatePortOperState (const PortOperStateUpdate&);
74- bool addFdbEntry (const FdbEntry&, const string&);
75- bool removeFdbEntry (const FdbEntry&);
116+
117+ bool addFdbEntry (const FdbEntry&, const string&, FdbData fdbData);
118+ void deleteFdbEntryFromSavedFDB (const MacAddress &mac, const unsigned short &vlanId, FdbOrigin origin, const string portName=" " );
119+
76120 bool storeFdbEntryState (const FdbUpdate& update);
121+ void notifyTunnelOrch (Port& port);
77122};
78123
79124#endif /* SWSS_FDBORCH_H */
0 commit comments