Skip to content

Commit

Permalink
Add support for FDB notification in virtual switch (sonic-net#287)
Browse files Browse the repository at this point in the history
* Add support for FDB notification in virtual switch

* Change aging fdb time to default

* Address comments

* Address comments

* Address comments

* Change notification to debug on fdb

* Move sleep after processing to avoid deadlock

* Remove join thread to remove possible deadlock

* Bring back thread join

Without join if process will call uninitialize and thread
was running we will get coredump caused by not finished thread

* Fix deadlock problem with try_lock
  • Loading branch information
kcudnik authored and lguohan committed Jan 29, 2018
1 parent a6b5be8 commit ac42493
Show file tree
Hide file tree
Showing 5 changed files with 610 additions and 6 deletions.
36 changes: 36 additions & 0 deletions vslib/inc/sai_vs_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,38 @@ typedef std::map<sai_object_type_t, std::map<std::string, AttrHash>> ObjectHash;

#define DEFAULT_VLAN_NUMBER 1

typedef struct _fdb_info_t
{
sai_object_id_t port_id;

sai_object_id_t bridge_port_id;

sai_fdb_entry_t fdb_entry;

uint32_t timestamp;

bool operator<(const _fdb_info_t& other) const
{
int res = memcmp(fdb_entry.mac_address, other.fdb_entry.mac_address, sizeof(sai_mac_t));

if (res < 0)
return true;

if (res > 0)
return false;

return fdb_entry.vlan_id < other.fdb_entry.vlan_id;
}

bool operator() (const _fdb_info_t& lhs, const _fdb_info_t & rhs) const
{
return lhs < rhs;
}

} fdb_info_t;

extern std::set<fdb_info_t> g_fdb_info_set;

class SwitchState
{
public:
Expand Down Expand Up @@ -236,4 +268,8 @@ sai_object_id_t vs_create_real_object_id(
_In_ sai_object_type_t object_type,
_In_ sai_object_id_t switch_id);

void processFdbInfo(
_In_ const fdb_info_t &fi,
_In_ sai_fdb_event_t fdb_event);

#endif // __SAI_VS_STATE__
Loading

0 comments on commit ac42493

Please sign in to comment.