Skip to content

Commit

Permalink
Changes #8 UT
Browse files Browse the repository at this point in the history
  • Loading branch information
dgsudharsan committed Jun 25, 2021
1 parent 594b136 commit e2fa96c
Show file tree
Hide file tree
Showing 10 changed files with 3,058 additions and 745 deletions.
21 changes: 13 additions & 8 deletions orchagent/fdborch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@ void FdbOrch::doTask(Consumer& consumer)

/* FDB type is either dynamic or static */
assert(type == "dynamic" || type == "static");
bool check_vlan_member = true;

if(origin == FDB_ORIGIN_VXLAN_ADVERTIZED)
{
Expand All @@ -648,6 +649,7 @@ void FdbOrch::doTask(Consumer& consumer)
{
EvpnNvoOrch* evpn_nvo_orch = gDirectory.get<EvpnNvoOrch*>();
VxlanTunnel* sip_tunnel = evpn_nvo_orch->getEVPNVtep();
check_vlan_member = false;
if (sip_tunnel == NULL)
{
it = consumer.m_toSync.erase(it);
Expand All @@ -665,7 +667,7 @@ void FdbOrch::doTask(Consumer& consumer)
fdbData.remote_ip = remote_ip;
fdbData.esi = esi;
fdbData.vni = vni;
if (addFdbEntry(entry, port, fdbData))
if (addFdbEntry(entry, port, fdbData, check_vlan_member))
it = consumer.m_toSync.erase(it);
else
it++;
Expand Down Expand Up @@ -907,15 +909,15 @@ void FdbOrch::updateVlanMember(const VlanMemberUpdate& update)
}

bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& port_name,
FdbData fdbData)
FdbData fdbData, bool check_vlan_member)
{
Port vlan;
Port port;

SWSS_LOG_ENTER();
SWSS_LOG_INFO("mac=%s bv_id=0x%" PRIx64 " port_name=%s type=%s origin=%d",
SWSS_LOG_INFO("mac=%s bv_id=0x%" PRIx64 " port_name=%s type=%s origin=%d remote_ip=%s",
entry.mac.to_string().c_str(), entry.bv_id, port_name.c_str(),
fdbData.type.c_str(), fdbData.origin);
fdbData.type.c_str(), fdbData.origin, fdbData.remote_ip.c_str());

if (!m_portsOrch->getPort(entry.bv_id, vlan))
{
Expand All @@ -933,7 +935,7 @@ bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& port_name,
}

/* Retry until port is member of vlan*/
if (vlan.m_members.find(port_name) == vlan.m_members.end())
if (check_vlan_member && vlan.m_members.find(port_name) == vlan.m_members.end())
{
SWSS_LOG_INFO("Saving a fdb entry until port %s becomes vlan %s member", port_name.c_str(), vlan.m_alias.c_str());
saved_fdb_entries[port_name].push_back({entry.mac,
Expand All @@ -949,6 +951,7 @@ bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& port_name,

Port oldPort;
string oldType;
string oldRemoteIp;
FdbOrigin oldOrigin = FDB_ORIGIN_INVALID ;
bool macUpdate = false;
auto it = m_entries.find(entry);
Expand All @@ -957,19 +960,21 @@ bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& port_name,
/* get existing port and type */
oldType = it->second.type;
oldOrigin = it->second.origin;
oldRemoteIp = it->second.remote_ip;

if (!m_portsOrch->getPortByBridgePortId(it->second.bridge_port_id, oldPort))
{
SWSS_LOG_ERROR("Existing port 0x%" PRIx64 " details not found", it->second.bridge_port_id);
return false;
}

if ((oldOrigin == fdbData.origin) && (oldType == fdbData.type) && (port.m_bridge_port_id == it->second.bridge_port_id))
if ((oldOrigin == fdbData.origin) && (oldType == fdbData.type) && (port.m_bridge_port_id == it->second.bridge_port_id)
&& (oldRemoteIp == fdbData.remote_ip))
{
/* Duplicate Mac */
SWSS_LOG_INFO("FdbOrch: mac=%s %s port=%s type=%s origin=%d is duplicate", entry.mac.to_string().c_str(),
SWSS_LOG_INFO("FdbOrch: mac=%s %s port=%s type=%s origin=%d remote_ip=%s is duplicate", entry.mac.to_string().c_str(),
vlan.m_alias.c_str(), port_name.c_str(),
fdbData.type.c_str(), fdbData.origin);
fdbData.type.c_str(), fdbData.origin, fdbData.remote_ip.c_str());
return true;
}
else if (fdbData.origin != oldOrigin)
Expand Down
2 changes: 1 addition & 1 deletion orchagent/fdborch.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class FdbOrch: public Orch, public Subject, public Observer
void updateVlanMember(const VlanMemberUpdate&);
void updatePortOperState(const PortOperStateUpdate&);

bool addFdbEntry(const FdbEntry&, const string&, FdbData fdbData);
bool addFdbEntry(const FdbEntry&, const string&, FdbData fdbData, bool check_vlan_member=true);
void deleteFdbEntryFromSavedFDB(const MacAddress &mac, const unsigned short &vlanId, FdbOrigin origin, const string portName="");

bool storeFdbEntryState(const FdbUpdate& update);
Expand Down
59 changes: 24 additions & 35 deletions orchagent/vxlanorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1522,44 +1522,33 @@ void VxlanTunnelOrch::deleteTunnelPort(Port &tunnelPort)

if (isSrcVtepTunnel(tunnelPort))
{
// Remove Bridge port and Port objects for this SIP tunnel
ret = gPortsOrch->removeBridgePort(tunnelPort);
if (!ret)
{
SWSS_LOG_ERROR("Remove Bridge port failed for remote = %s fdbcount = %d",
remote_vtep.c_str(), tunnelPort.m_fdb_count);
return;
}
gPortsOrch->removeTunnel(tunnelPort);
return;
}
else
{
getTunnelDIPFromPort(tunnelPort, remote_vtep);

//If there are IMR/IP routes to the remote VTEP then ignore this call
refcnt = vtep_ptr->getDipTunnelRefCnt(remote_vtep);
if (refcnt > 0)
{
SWSS_LOG_INFO("Tunnel bridge port not removed. remote = %s refcnt = %d",
remote_vtep.c_str(), refcnt);
return;
}
getTunnelDIPFromPort(tunnelPort, remote_vtep);

// Remove Bridge port and Port objects for this DIP tunnel
ret = gPortsOrch->removeBridgePort(tunnelPort);
if (!ret)
{
SWSS_LOG_ERROR("Remove Bridge port failed for remote = %s fdbcount = %d",
remote_vtep.c_str(), tunnelPort.m_fdb_count);
return;
}
gPortsOrch->removeTunnel(tunnelPort);
//If there are IMR/IP routes to the remote VTEP then ignore this call
refcnt = vtep_ptr->getDipTunnelRefCnt(remote_vtep);
if (refcnt > 0)
{
SWSS_LOG_INFO("Tunnel bridge port not removed. remote = %s refcnt = %d",
remote_vtep.c_str(), refcnt);
return;
}

// Remove DIP Tunnel HW
vtep_ptr->deleteDynamicDIPTunnel(remote_vtep, TUNNEL_USER_IMR, false);
SWSS_LOG_NOTICE("diprefcnt for remote %s = %d",
remote_vtep.c_str(), vtep_ptr->getDipTunnelRefCnt(remote_vtep));
// Remove Bridge port and Port objects for this DIP tunnel
ret = gPortsOrch->removeBridgePort(tunnelPort);
if (!ret)
{
SWSS_LOG_ERROR("Remove Bridge port failed for remote = %s fdbcount = %d",
remote_vtep.c_str(), tunnelPort.m_fdb_count);
return;
}
gPortsOrch->removeTunnel(tunnelPort);

// Remove DIP Tunnel HW
vtep_ptr->deleteDynamicDIPTunnel(remote_vtep, TUNNEL_USER_IMR, false);
SWSS_LOG_NOTICE("diprefcnt for remote %s = %d",
remote_vtep.c_str(), vtep_ptr->getDipTunnelRefCnt(remote_vtep));
// Remove SIP Tunnel HW which might be pending on delete
vtep_ptr->deletePendingSIPTunnel();

Expand All @@ -1585,7 +1574,7 @@ bool VxlanTunnelOrch::isSrcVtepTunnel(Port& tunnelPort)
{
string tunnel_port_name = tunnelPort.m_alias;
string prefix = "Port_SRC_VTEP_";
return (tunnel_port_name.compare(0, sizeof(prefix), prefix) == 0);
return (tunnel_port_name.compare(0, prefix.length(), prefix) == 0);
}


Expand Down
Loading

0 comments on commit e2fa96c

Please sign in to comment.