Skip to content

Commit 27a93ff

Browse files
authored
Don't learn fdb entries on LAG when rif based (sonic-net#538)
Also will prevent print warnings on finding bridge when port is part of LAG, it will then try to find bridge for that LAG if it's not rif based.
1 parent 5ef1764 commit 27a93ff

File tree

1 file changed

+48
-2
lines changed

1 file changed

+48
-2
lines changed

vslib/src/sai_vs_hostintf.cpp

+48-2
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,10 @@ void processFdbInfo(
261261
}
262262
}
263263

264+
bool getLagFromPort(
265+
_In_ sai_object_id_t port_id,
266+
_Inout_ sai_object_id_t& lag_id);
267+
264268
void findBridgeVlanForPortVlan(
265269
_In_ sai_object_id_t port_id,
266270
_In_ sai_vlan_id_t vlan_id,
@@ -299,6 +303,15 @@ void findBridgeVlanForPortVlan(
299303

300304
// iterate via all bridge ports to find match on port id
301305

306+
sai_object_id_t lag_id = SAI_NULL_OBJECT_ID;
307+
308+
if (getLagFromPort(port_id,lag_id))
309+
{
310+
SWSS_LOG_INFO("got lag %s for port %s",
311+
sai_serialize_object_id(lag_id).c_str(),
312+
sai_serialize_object_id(port_id).c_str());
313+
}
314+
302315
bool bv_id_set = false;
303316

304317
for (auto it = objectHash.begin(); it != objectHash.end(); ++it)
@@ -316,10 +329,33 @@ void findBridgeVlanForPortVlan(
316329

317330
if (status != SAI_STATUS_SUCCESS)
318331
{
332+
SWSS_LOG_WARN("failed to get attr PORT_ID and TYPE for bridge port %s",
333+
sai_serialize_object_id(bpid).c_str());
319334
continue;
320335
}
321336

322-
if (port_id != attrs[0].value.oid)
337+
if (lag_id != SAI_NULL_OBJECT_ID)
338+
{
339+
// if port is member of lag, we should check if port_id is that LAG
340+
341+
if (port_id == attrs[0].value.oid)
342+
{
343+
// there should be no case that the same port is lag member and has bridge port object on it
344+
345+
SWSS_LOG_ERROR("port %s is member of lag %s, and also has bridge port created: %s",
346+
sai_serialize_object_id(port_id).c_str(),
347+
sai_serialize_object_id(lag_id).c_str(),
348+
sai_serialize_object_id(attrs[0].value.oid).c_str());
349+
continue;
350+
}
351+
352+
if (lag_id != attrs[0].value.oid)
353+
{
354+
// this is not expected port
355+
continue;
356+
}
357+
}
358+
else if (port_id != attrs[0].value.oid)
323359
{
324360
// this is not expected port
325361
continue;
@@ -403,6 +439,7 @@ void findBridgeVlanForPortVlan(
403439

404440
if (!bv_id_set)
405441
{
442+
// if port is lag member, then we didn't found bridge_port for that lag (expected for rif lag)
406443
SWSS_LOG_WARN("failed to find bv_id for vlan %d and port_id %s",
407444
vlan_id,
408445
sai_serialize_object_id(port_id).c_str());
@@ -630,6 +667,15 @@ void hostif_info_t::process_packet_for_fdb_event(
630667
}
631668
}
632669

670+
sai_object_id_t lag_id;
671+
if (getLagFromPort(portid, lag_id) && isLagOrPortRifBased(lag_id))
672+
{
673+
SWSS_LOG_DEBUG("lag %s is rif based, skip mac learning for port %s",
674+
sai_serialize_object_id(lag_id).c_str(),
675+
sai_serialize_object_id(portid).c_str());
676+
return;
677+
}
678+
633679
if (isLagOrPortRifBased(portid))
634680
{
635681
SWSS_LOG_DEBUG("port %s is rif based, skip mac learning",
@@ -641,7 +687,7 @@ void hostif_info_t::process_packet_for_fdb_event(
641687

642688
fdb_info_t fi;
643689

644-
fi.port_id = portid;
690+
fi.port_id = (lag_id != SAI_NULL_OBJECT_ID) ? lag_id : portid;
645691
fi.vlan_id = vlan_id;
646692

647693
memcpy(fi.fdb_entry.mac_address, eh->h_source, sizeof(sai_mac_t));

0 commit comments

Comments
 (0)