Skip to content

Commit

Permalink
update latest changes after synching with master
Browse files Browse the repository at this point in the history
  • Loading branch information
anilkpandey committed Dec 4, 2020
1 parent 757cf70 commit 56e330e
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 164 deletions.
12 changes: 6 additions & 6 deletions cfgmgr/vlanmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,12 @@ void VlanMgr::doVlanTask(Consumer &consumer)
{
/* Set vlan admin status */
if (fvField(i) == "admin_status")
{
admin_status = fvValue(i);
setHostVlanAdminState(vlan_id, admin_status);
fvVector.push_back(i);
}
/* Set vlan mtu */
{
admin_status = fvValue(i);
setHostVlanAdminState(vlan_id, admin_status);
fvVector.push_back(i);
}
/* Set vlan mtu */
else if (fvField(i) == "mtu")
{
mtu = fvValue(i);
Expand Down
1 change: 0 additions & 1 deletion cfgmgr/vlanmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <string>

namespace swss {

class VlanMgr : public Orch
{
public:
Expand Down
138 changes: 42 additions & 96 deletions orchagent/fdborch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ bool FdbOrch::storeFdbEntryState(const FdbUpdate& update)
const FdbData fdbdata = {update.port.m_bridge_port_id, update.type};
const Port& port = update.port;
const MacAddress& mac = entry.mac;
string portName = port.m_alias;
Port vlan;

if (!m_portsOrch->getPort(entry.bv_id, vlan))
Expand Down Expand Up @@ -233,7 +234,8 @@ void FdbOrch::update(sai_fdb_event_t type,
if (vlan.m_members.find(update.port.m_alias) == vlan.m_members.end())
{
update.type = "static";
saved_fdb_entries[update.port.m_alias].push_back({existing_entry->first.mac, vlan.m_vlan_info.vlan_id, "static"});
saved_fdb_entries[update.port.m_alias].push_back({existing_entry->first.mac, vlan.m_vlan_info.vlan_id, "static"});

}
else
{
Expand Down Expand Up @@ -327,33 +329,12 @@ void FdbOrch::update(sai_fdb_event_t type,
}
break;
}
case SAI_FDB_EVENT_FLUSHED:

SWSS_LOG_INFO("FDB Flush event received: [ %s , 0x%" PRIx64 " ], \
bridge port ID: 0x%" PRIx64 ".",
update.entry.mac.to_string().c_str(), entry->bv_id,
bridge_port_id);

string vlanName = "-";
if (entry->bv_id) {
Port vlan;

if (!m_portsOrch->getPort(entry->bv_id, vlan))
{
SWSS_LOG_ERROR("FdbOrch notification: Failed to locate vlan\
port from bv_id 0x%" PRIx64, entry->bv_id);
return;
}
vlanName = "Vlan" + to_string(vlan.m_vlan_info.vlan_id);
}


if (bridge_port_id == SAI_NULL_OBJECT_ID &&
entry->bv_id == SAI_NULL_OBJECT_ID)
case SAI_FDB_EVENT_FLUSHED:
SWSS_LOG_INFO("Received FLUSH event for bvid=%lx mac=%s port=%lx", entry->bv_id, update.entry.mac.to_string().c_str(), bridge_port_id);
for (auto itr = m_entries.begin(); itr != m_entries.end();)
{
SWSS_LOG_INFO("FDB Flush: [ %s , %s ] = { port: - }",
update.entry.mac.to_string().c_str(), vlanName.c_str());
for (auto itr = m_entries.begin(); itr != m_entries.end();)
if (itr->second.type == "static")
{
itr++;
continue;
Expand All @@ -367,69 +348,41 @@ void FdbOrch::update(sai_fdb_event_t type,
if (!m_portsOrch->getPortByBridgePortId(itr->second.bridge_port_id, update.port))
{
SWSS_LOG_ERROR("FdbOrch FLUSH notification: Failed to get port by bridge port ID 0x%lx", itr->second.bridge_port_id);
itr++;
continue;
}

if (!m_portsOrch->getPort(itr->first.bv_id, vlan))
{
SWSS_LOG_NOTICE("FdbOrch FLUSH notification: Failed to locate vlan port from bv_id 0x%lx", itr->first.bv_id);
itr++;
continue;
}

update.entry.mac = itr->first.mac;
update.entry.bv_id = itr->first.bv_id;
update.add = false;
update.vlan_id = vlan.m_vlan_info.vlan_id;
itr++;


update.port.m_fdb_count--;
m_portsOrch->setPort(update.port.m_alias, update.port);
vlan.m_fdb_count--;
m_portsOrch->setPort(vlan.m_alias, vlan);

/* This will invalidate the current iterator hence itr++ is done before */
storeFdbEntryState(update);

for (auto observer: m_observers)
{
observer->update(SUBJECT_TYPE_FDB_CHANGE, &update);
}
}
}
else if (entry->bv_id == SAI_NULL_OBJECT_ID)
{
/* FLUSH based on port */
SWSS_LOG_INFO("FDB Flush: [ %s , %s ] = { port: %s }",
update.entry.mac.to_string().c_str(),
vlanName.c_str(), update.port.m_alias.c_str());
SWSS_LOG_DEBUG("FdbOrch FLUSH notification: mac %s was removed", update.entry.mac.to_string().c_str());

for (auto itr = m_entries.begin(); itr != m_entries.end();)
notify(SUBJECT_TYPE_FDB_CHANGE, &update);
}
else
{
auto next_item = std::next(itr);
if (itr->port_name == update.port.m_alias)
{
update.entry.mac = itr->mac;
update.entry.bv_id = itr->bv_id;
update.add = false;

storeFdbEntryState(update);

for (auto observer: m_observers)
{
observer->update(SUBJECT_TYPE_FDB_CHANGE, &update);
}
}
itr = next_item;
itr++;
}
}
else if (bridge_port_id == SAI_NULL_OBJECT_ID)
{
/* FLUSH based on VLAN - unsupported */
SWSS_LOG_ERROR("Unsupported FDB Flush: [ %s , %s ] = { port: - }",
update.entry.mac.to_string().c_str(),
vlanName.c_str());

}
else
{
/* FLUSH based on port and VLAN - unsupported */
SWSS_LOG_ERROR("Unsupported FDB Flush: [ %s , %s ] = { port: %s }",
update.entry.mac.to_string().c_str(),
vlanName.c_str(), update.port.m_alias.c_str());
}
break;
}

Expand Down Expand Up @@ -566,7 +519,7 @@ void FdbOrch::doTask(Consumer& consumer)
/* FDB type is either dynamic or static */
assert(type == "dynamic" || type == "static");

if (addFdbEntry(entry, type))
if (addFdbEntry(entry, port, type))
it = consumer.m_toSync.erase(it);
else
it++;
Expand Down Expand Up @@ -719,14 +672,14 @@ void FdbOrch::notifyObserversFDBFlush(Port &port, sai_object_id_t& bvid)

for (auto itr = m_entries.begin(); itr != m_entries.end(); ++itr)
{
if ((itr->port_name == port.m_alias) &&
(itr->bv_id == bvid))
if ((itr->second.bridge_port_id == port.m_bridge_port_id) &&
(itr->first.bv_id == bvid))
{
SWSS_LOG_INFO("Adding MAC learnt on [ port:%s , bvid:0x%" PRIx64 "]\
to ARP flush", port.m_alias.c_str(), bvid);
FdbEntry entry;
entry.mac = itr->mac;
entry.bv_id = itr->bv_id;
entry.mac = itr->first.mac;
entry.bv_id = itr->first.bv_id;
flushUpdate.entries.push_back(entry);
}
}
Expand Down Expand Up @@ -768,44 +721,37 @@ void FdbOrch::updatePortOperState(const PortOperStateUpdate& update)

void FdbOrch::updateVlanMember(const VlanMemberUpdate& update)
{
string port_name = update.member.m_alias;
string vlan_name = update.vlan.m_alias;

SWSS_LOG_ENTER();

if (!update.add)
{
swss::Port vlan = update.vlan;
swss::Port port = update.member;
flushFDBEntries(port.m_bridge_port_id, vlan.m_vlan_info.vlan_oid);
flushFdbByPortVlan(port.m_alias, vlan.m_alias, 1);
notifyObserversFDBFlush(port, vlan.m_vlan_info.vlan_oid);
return;
}

string port_name = update.member.m_alias;
auto fdb_list = std::move(saved_fdb_entries[port_name]);
saved_fdb_entries[port_name].clear();
for (const auto& fdb: fdb_list)
{
for (const auto& fdb: fdb_list)
if(fdb.vlanId == update.vlan.m_vlan_info.vlan_id)
{
// try to insert an FDB entry. If the FDB entry is not ready to be inserted yet,
// it would be added back to the saved_fdb_entries structure by addFDBEntry()
if(fdb.vlanId == update.vlan.m_vlan_info.vlan_id)
{
FdbEntry entry;
entry.mac = fdb.mac;
entry.bv_id = update.vlan.m_vlan_info.vlan_oid;
(void)addFdbEntry(entry, port_name, fdb.type);
}
else
{
saved_fdb_entries[port_name].push_back(fdb);
}
FdbEntry entry;
entry.mac = fdb.mac;
entry.bv_id = update.vlan.m_vlan_info.vlan_oid;
(void)addFdbEntry(entry, port_name, fdb.type);
}
else
{
saved_fdb_entries[port_name].push_back(fdb);
}
}
}

bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& type)
bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& port_name, const string& type)
{
Port vlan;
Port port;
Expand Down Expand Up @@ -915,7 +861,7 @@ bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& type)
m_fdbStateTable.del(key);

gCrmOrch->decCrmResUsedCounter(CrmResourceType::CRM_FDB_ENTRY);
FdbUpdate update = {entry, port, type, true};
FdbUpdate update = {entry, port, vlan.m_vlan_info.vlan_id, type, true};
for (auto observer: m_observers)
{
observer->update(SUBJECT_TYPE_FDB_CHANGE, &update);
Expand Down Expand Up @@ -951,7 +897,7 @@ bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& type)
gCrmOrch->incCrmResUsedCounter(CrmResourceType::CRM_FDB_ENTRY);
}

FdbUpdate update = {entry, port, type, true};
FdbUpdate update = {entry, port, vlan.m_vlan_info.vlan_id, type, true};
for (auto observer: m_observers)
{
observer->update(SUBJECT_TYPE_FDB_CHANGE, &update);
Expand Down Expand Up @@ -1016,7 +962,7 @@ bool FdbOrch::removeFdbEntry(const FdbEntry& entry)

gCrmOrch->decCrmResUsedCounter(CrmResourceType::CRM_FDB_ENTRY);

FdbUpdate update = {entry, port, fdbData.type, false};
FdbUpdate update = {entry, port, vlan.m_vlan_info.vlan_id, fdbData.type, false};
for (auto observer: m_observers)
{
observer->update(SUBJECT_TYPE_FDB_CHANGE, &update);
Expand Down
14 changes: 7 additions & 7 deletions orchagent/fdborch.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,23 @@ struct FdbUpdate
{
FdbEntry entry;
Port port;
uint16_t vlan_id;
string type;
bool add;
};

struct FdbData
{
sai_object_id_t bridge_port_id;
string type;
};

struct FdbFlushUpdate
{
vector<FdbEntry> entries;
Port port;
};

struct FdbData
{
sai_object_id_t bridge_port_id;
string type;
};

struct SavedFdbEntry
{
MacAddress mac;
Expand Down Expand Up @@ -95,7 +96,6 @@ class FdbOrch: public Orch, public Subject, public Observer
void deleteFdbEntryFromSavedFDB(const MacAddress &mac, const unsigned short &vlanId, const string portName="");

void updatePortOperState(const PortOperStateUpdate&);
bool removeFdbEntry(const FdbEntry&);
bool storeFdbEntryState(const FdbUpdate& update);
};

Expand Down
2 changes: 1 addition & 1 deletion orchagent/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ class Port
sai_object_id_t m_tunnel_id = 0;
sai_object_id_t m_ingress_acl_table_group_id = 0;
sai_object_id_t m_egress_acl_table_group_id = 0;
vlan_members_t m_vlan_members;
sai_object_id_t m_parent_port_id = 0;
vlan_members_t m_vlan_members;
uint32_t m_dependency_bitmap = 0;
sai_port_oper_status_t m_oper_status = SAI_PORT_OPER_STATUS_UNKNOWN;
std::set<std::string> m_members;
Expand Down
Loading

0 comments on commit 56e330e

Please sign in to comment.