Skip to content

Commit 41a4a18

Browse files
committed
updated as per review comments
1 parent 5f38e64 commit 41a4a18

File tree

4 files changed

+49
-38
lines changed

4 files changed

+49
-38
lines changed

orchagent/fdborch.cpp

+47-33
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ void FdbOrch::update(sai_fdb_event_t type,
199199
}
200200

201201
update.add = true;
202+
update.entry.port_name = update.port.m_alias;
202203
update.type = "dynamic";
203204

204205
storeFdbEntryState(update);
@@ -226,11 +227,11 @@ void FdbOrch::update(sai_fdb_event_t type,
226227

227228
if (existing_entry->second.bridge_port_id != bridge_port_id)
228229
{
229-
SWSS_LOG_NOTICE("FdbOrch AGE notification: Stale aging event received for mac-bv_id %s-0x%lx with bp=0x%lx existing bp=0x%lx", update.entry.mac.to_string().c_str(), entry->bv_id, bridge_port_id, existing_entry->second.bridge_port_id);
230+
SWSS_LOG_INFO("FdbOrch AGE notification: Stale aging event received for mac-bv_id %s-0x%lx with bp=0x%lx existing bp=0x%lx", update.entry.mac.to_string().c_str(), entry->bv_id, bridge_port_id, existing_entry->second.bridge_port_id);
230231
// We need to get the port for bridge-port in existing fdb
231232
if (!m_portsOrch->getPortByBridgePortId(existing_entry->second.bridge_port_id, update.port))
232233
{
233-
SWSS_LOG_NOTICE("FdbOrch AGE notification: Failed to get port by bridge port ID 0x%lx", existing_entry->second.bridge_port_id);
234+
SWSS_LOG_INFO("FdbOrch AGE notification: Failed to get port by bridge port ID 0x%lx", existing_entry->second.bridge_port_id);
234235
}
235236
// dont return, let it delete just to bring SONiC and SAI in sync
236237
// return;
@@ -832,11 +833,24 @@ void FdbOrch::updateVlanMember(const VlanMemberUpdate& update)
832833
string port_name = update.member.m_alias;
833834
auto fdb_list = std::move(saved_fdb_entries[port_name]);
834835
saved_fdb_entries[port_name].clear();
835-
for (const auto& fdb: fdb_list)
836+
if(!fdb_list.empty())
836837
{
837-
// try to insert an FDB entry. If the FDB entry is not ready to be inserted yet,
838-
// it would be added back to the saved_fdb_entries structure by addFDBEntry()
839-
(void)addFdbEntry(fdb.entry, port_name, fdb.fdbData);
838+
for (const auto& fdb: fdb_list)
839+
{
840+
// try to insert an FDB entry. If the FDB entry is not ready to be inserted yet,
841+
// it would be added back to the saved_fdb_entries structure by addFDBEntry()
842+
if(fdb.vlanId == update.vlan.m_vlan_info.vlan_id)
843+
{
844+
FdbEntry entry;
845+
entry.mac = fdb.mac;
846+
entry.bv_id = update.vlan.m_vlan_info.vlan_oid;
847+
(void)addFdbEntry(entry, port_name, fdb.fdbData);
848+
}
849+
else
850+
{
851+
saved_fdb_entries[port_name].push_back(fdb);
852+
}
853+
}
840854
}
841855
}
842856

@@ -847,7 +861,7 @@ bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& port_name,
847861
Port port;
848862

849863
SWSS_LOG_ENTER();
850-
SWSS_LOG_NOTICE("mac=%s bv_id=0x%lx port_name=%s type=%s origin=%d",
864+
SWSS_LOG_INFO("mac=%s bv_id=0x%lx port_name=%s type=%s origin=%d",
851865
entry.mac.to_string().c_str(), entry.bv_id, port_name.c_str(),
852866
fdbData.type.c_str(), fdbData.origin);
853867

@@ -886,7 +900,7 @@ bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& port_name,
886900
FdbOrigin oldOrigin = FDB_ORIGIN_INVALID ;
887901
bool macUpdate = false;
888902
auto it = m_entries.find(entry);
889-
if(it != m_entries.end())
903+
if (it != m_entries.end())
890904
{
891905
/* get existing port and type */
892906
oldType = it->second.type;
@@ -898,18 +912,18 @@ bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& port_name,
898912
return false;
899913
}
900914

901-
if((oldOrigin == fdbData.origin) && (oldType == fdbData.type) && (port.m_bridge_port_id == it->second.bridge_port_id))
915+
if ((oldOrigin == fdbData.origin) && (oldType == fdbData.type) && (port.m_bridge_port_id == it->second.bridge_port_id))
902916
{
903917
/* Duplicate Mac */
904-
SWSS_LOG_NOTICE("FdbOrch: mac=%s %s port=%s type=%s origin=%d is duplicate", entry.mac.to_string().c_str(),
918+
SWSS_LOG_INFO("FdbOrch: mac=%s %s port=%s type=%s origin=%d is duplicate", entry.mac.to_string().c_str(),
905919
vlan.m_alias.c_str(), port_name.c_str(),
906920
fdbData.type.c_str(), fdbData.origin);
907921
return true;
908922
}
909-
else if(fdbData.origin != oldOrigin)
923+
else if (fdbData.origin != oldOrigin)
910924
{
911925
/* Mac origin has changed */
912-
if((oldType == "static") && (oldOrigin == FDB_ORIGIN_PROVISIONED))
926+
if ((oldType == "static") && (oldOrigin == FDB_ORIGIN_PROVISIONED))
913927
{
914928
/* old mac was static and provisioned, it can not be changed by Remote Mac */
915929
SWSS_LOG_NOTICE("Already existing static MAC:%s in Vlan:%d. "
@@ -920,20 +934,20 @@ bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& port_name,
920934

921935
return true;
922936
}
923-
else if((oldType == "static") && (oldOrigin ==
937+
else if ((oldType == "static") && (oldOrigin ==
924938
FDB_ORIGIN_VXLAN_ADVERTIZED) && (fdbData.type == "dynamic"))
925939
{
926940
/* old mac was static and received from remote, it can not be changed by dynamic locally provisioned Mac */
927-
SWSS_LOG_NOTICE("Already existing static MAC:%s in Vlan:%d "
941+
SWSS_LOG_INFO("Already existing static MAC:%s in Vlan:%d "
928942
"from Peer:%s. Now same is provisioned as dynamic; "
929943
"Provisioned dynamic mac is ignored",
930944
entry.mac.to_string().c_str(), vlan.m_vlan_info.vlan_id,
931945
it->second.remote_ip.c_str());
932946
return true;
933947
}
934-
else if(oldOrigin == FDB_ORIGIN_VXLAN_ADVERTIZED)
948+
else if (oldOrigin == FDB_ORIGIN_VXLAN_ADVERTIZED)
935949
{
936-
if((oldType == "static") && (fdbData.type == "static"))
950+
if ((oldType == "static") && (fdbData.type == "static"))
937951
{
938952
SWSS_LOG_WARN("You have just overwritten existing static MAC:%s "
939953
"in Vlan:%d from Peer:%s, "
@@ -982,11 +996,11 @@ bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& port_name,
982996
attr.value.oid = port.m_bridge_port_id;
983997
attrs.push_back(attr);
984998

985-
if(fdbData.origin == FDB_ORIGIN_VXLAN_ADVERTIZED)
999+
if (fdbData.origin == FDB_ORIGIN_VXLAN_ADVERTIZED)
9861000
{
9871001
IpAddress remote = IpAddress(fdbData.remote_ip);
9881002
sai_ip_address_t ipaddr;
989-
if(remote.isV4())
1003+
if (remote.isV4())
9901004
{
9911005
ipaddr.addr_family = SAI_IP_ADDR_FAMILY_IPV4;
9921006
ipaddr.addr.ip4 = remote.getV4Addr();
@@ -1000,7 +1014,7 @@ bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& port_name,
10001014
attr.value.ipaddr = ipaddr;
10011015
attrs.push_back(attr);
10021016
}
1003-
else if(macUpdate
1017+
else if (macUpdate
10041018
&& (oldOrigin == FDB_ORIGIN_VXLAN_ADVERTIZED)
10051019
&& (fdbData.origin != oldOrigin))
10061020
{
@@ -1015,9 +1029,9 @@ bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& port_name,
10151029
attrs.push_back(attr);
10161030
}
10171031

1018-
if(macUpdate && (oldOrigin == FDB_ORIGIN_VXLAN_ADVERTIZED))
1032+
if (macUpdate && (oldOrigin == FDB_ORIGIN_VXLAN_ADVERTIZED))
10191033
{
1020-
if((fdbData.origin != oldOrigin)
1034+
if ((fdbData.origin != oldOrigin)
10211035
|| ((oldType == "dynamic") && (oldType != fdbData.type)))
10221036
{
10231037
attr.id = SAI_FDB_ENTRY_ATTR_ALLOW_MAC_MOVE;
@@ -1027,13 +1041,13 @@ bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& port_name,
10271041
}
10281042

10291043

1030-
if(macUpdate)
1044+
if (macUpdate)
10311045
{
1032-
SWSS_LOG_NOTICE("MAC-Update FDB %s in %s on from-%s:to-%s from-%s:to-%s origin-%d-to-%d",
1046+
SWSS_LOG_INFO("MAC-Update FDB %s in %s on from-%s:to-%s from-%s:to-%s origin-%d-to-%d",
10331047
entry.mac.to_string().c_str(), vlan.m_alias.c_str(), oldPort.m_alias.c_str(),
10341048
port_name.c_str(), oldType.c_str(), fdbData.type.c_str(),
10351049
oldOrigin, fdbData.origin);
1036-
for(auto itr : attrs)
1050+
for (auto itr : attrs)
10371051
{
10381052
status = sai_fdb_api->set_fdb_entry_attribute(&fdb_entry, &itr);
10391053
if (status != SAI_STATUS_SUCCESS)
@@ -1046,7 +1060,7 @@ bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& port_name,
10461060
}
10471061
else
10481062
{
1049-
SWSS_LOG_NOTICE("MAC-Create %s FDB %s in %s on %s", fdbData.type.c_str(), entry.mac.to_string().c_str(), vlan.m_alias.c_str(), port_name.c_str());
1063+
SWSS_LOG_INFO("MAC-Create %s FDB %s in %s on %s", fdbData.type.c_str(), entry.mac.to_string().c_str(), vlan.m_alias.c_str(), port_name.c_str());
10501064

10511065
status = sai_fdb_api->create_fdb_entry(&fdb_entry, (uint32_t)attrs.size(), attrs.data());
10521066
if (status != SAI_STATUS_SUCCESS)
@@ -1086,7 +1100,7 @@ bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& port_name,
10861100
m_fdbStateTable.del(key);
10871101
}
10881102

1089-
if(!macUpdate)
1103+
if (!macUpdate)
10901104
{
10911105
gCrmOrch->incCrmResUsedCounter(CrmResourceType::CRM_FDB_ENTRY);
10921106
}
@@ -1109,7 +1123,7 @@ bool FdbOrch::removeFdbEntry(const FdbEntry& entry, FdbOrigin origin)
11091123

11101124
SWSS_LOG_ENTER();
11111125

1112-
SWSS_LOG_NOTICE("FdbOrch RemoveFDBEntry: mac=%s bv_id=0x%lx origin %d", entry.mac.to_string().c_str(), entry.bv_id, origin);
1126+
SWSS_LOG_INFO("FdbOrch RemoveFDBEntry: mac=%s bv_id=0x%lx origin %d", entry.mac.to_string().c_str(), entry.bv_id, origin);
11131127

11141128
if (!m_portsOrch->getPort(entry.bv_id, vlan))
11151129
{
@@ -1118,7 +1132,7 @@ bool FdbOrch::removeFdbEntry(const FdbEntry& entry, FdbOrigin origin)
11181132
}
11191133

11201134
auto it= m_entries.find(entry);
1121-
if(it == m_entries.end())
1135+
if (it == m_entries.end())
11221136
{
11231137
SWSS_LOG_INFO("FdbOrch RemoveFDBEntry: FDB entry isn't found. mac=%s bv_id=0x%lx", entry.mac.to_string().c_str(), entry.bv_id);
11241138

@@ -1134,7 +1148,7 @@ bool FdbOrch::removeFdbEntry(const FdbEntry& entry, FdbOrigin origin)
11341148
return false;
11351149
}
11361150

1137-
if(fdbData.origin != origin)
1151+
if (fdbData.origin != origin)
11381152
{
11391153
/* When mac is moved from remote to local
11401154
* BGP will delete the mac from vxlan_fdb_table
@@ -1207,14 +1221,14 @@ void FdbOrch::deleteFdbEntryFromSavedFDB(const MacAddress &mac,
12071221

12081222
for (auto& itr: saved_fdb_entries)
12091223
{
1210-
if(portName.empty() || (portName == itr.first))
1224+
if (portName.empty() || (portName == itr.first))
12111225
{
12121226
auto iter = saved_fdb_entries[itr.first].begin();
12131227
while(iter != saved_fdb_entries[itr.first].end())
12141228
{
12151229
if (*iter == entry)
12161230
{
1217-
if(iter->fdbData.origin == origin)
1231+
if (iter->fdbData.origin == origin)
12181232
{
12191233
SWSS_LOG_NOTICE("FDB entry found in saved fdb. deleting..."
12201234
"mac=%s vlan_id=0x%x origin:%d port:%s",
@@ -1237,7 +1251,7 @@ void FdbOrch::deleteFdbEntryFromSavedFDB(const MacAddress &mac,
12371251
iter++;
12381252
}
12391253
}
1240-
if(found)
1254+
if (found)
12411255
break;
12421256
}
12431257
}
@@ -1247,7 +1261,7 @@ void FdbOrch::notifyTunnelOrch(Port& port)
12471261
{
12481262
VxlanTunnelOrch* tunnel_orch = gDirectory.get<VxlanTunnelOrch*>();
12491263

1250-
if(port.m_type != Port::TUNNEL)
1264+
if (port.m_type != Port::TUNNEL)
12511265
return;
12521266

12531267
tunnel_orch->deleteTunnelPort(port);

orchagent/port.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ namespace swss {
2626

2727
struct VlanMemberEntry
2828
{
29-
std::string alias;
3029
sai_object_id_t vlan_member_id;
3130
sai_vlan_tagging_mode_t vlan_mode;
3231
};
@@ -110,7 +109,7 @@ class Port
110109
uint32_t m_nat_zone_id = 0;
111110
uint32_t m_vnid = VNID_NONE;
112111
uint32_t m_fdb_count = 0;
113-
uint32_t m_up_member_count = 0;
112+
uint32_t m_up_member_count = 0;
114113

115114
/*
116115
* Following two bit vectors are used to lock

orchagent/portsorch.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ extern BufferOrch *gBufferOrch;
4646
extern FdbOrch *gFdbOrch;
4747
extern Directory<Orch*> gDirectory;
4848

49-
5049
#define VLAN_PREFIX "Vlan"
5150
#define DEFAULT_VLAN_ID 1
5251
#define MAX_VALID_VLAN_ID 4094

orchagent/portsorch.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ class PortsOrch : public Orch, public Subject
9292
void decreasePortRefCount(const string &alias);
9393
bool getPortByBridgePortId(sai_object_id_t bridge_port_id, Port &port);
9494
void setPort(string alias, Port port);
95-
void erasePort(string alias);
9695
void getCpuPort(Port &port);
9796
bool getVlanByVlanId(sai_vlan_id_t vlan_id, Port &vlan);
9897

@@ -172,7 +171,7 @@ class PortsOrch : public Orch, public Subject
172171
Port m_cpuPort;
173172
// TODO: Add Bridge/Vlan class
174173
sai_object_id_t m_default1QBridge;
175-
sai_vlan_id_t m_defaultVlan;
174+
sai_object_id_t m_defaultVlan;
176175

177176
typedef enum
178177
{

0 commit comments

Comments
 (0)