Skip to content

Commit

Permalink
Addressing code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dgsudharsan committed Sep 1, 2021
1 parent beeb58a commit 04858de
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 29 deletions.
2 changes: 1 addition & 1 deletion orchagent/fdborch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ void FdbOrch::doTask(Consumer& consumer)
{
VxlanTunnelOrch* tunnel_orch = gDirectory.get<VxlanTunnelOrch*>();

if (tunnel_orch->dipTunnelsUsed())
if (tunnel_orch->isDipTunnelsSupported())
{
if(!remote_ip.length())
{
Expand Down
37 changes: 16 additions & 21 deletions orchagent/vxlanorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ bool VxlanTunnel::createTunnelHw(uint8_t mapper_list, tunnel_map_use_t map_src,
void VxlanTunnel::deletePendingSIPTunnel()
{
VxlanTunnelOrch* tunnel_orch = gDirectory.get<VxlanTunnelOrch*>();
bool dip_tunnels_used = tunnel_orch->dipTunnelsUsed();
bool dip_tunnels_used = tunnel_orch->isDipTunnelsSupported();

if ((!dip_tunnels_used || getDipTunnelCnt() == 0) && del_tnl_hw_pending)
{
Expand Down Expand Up @@ -1480,7 +1480,7 @@ bool VxlanTunnelOrch::addTunnelUser(const std::string remote_vtep, uint32_t vni
return false;
}

if (!dipTunnelsUsed() && usr == TUNNEL_USER_IP)
if (!isDipTunnelsSupported())
{
vtep_ptr->updateRemoteEndPointIpRef(remote_vtep, true);
return true;
Expand Down Expand Up @@ -1512,9 +1512,7 @@ bool VxlanTunnelOrch::delTunnelUser(const std::string remote_vtep, uint32_t vni
{
if (TUNNEL_USER_MAC == usr) return true;

auto port_tunnel_name = getTunnelPortName(remote_vtep);
EvpnNvoOrch* evpn_orch = gDirectory.get<EvpnNvoOrch*>();

auto vtep_ptr = evpn_orch->getEVPNVtep();

if (!vtep_ptr)
Expand All @@ -1525,11 +1523,13 @@ bool VxlanTunnelOrch::delTunnelUser(const std::string remote_vtep, uint32_t vni
}

Port tunnelPort;
gPortsOrch->getPort(port_tunnel_name,tunnelPort);
bool ret;
string port_tunnel_name;

if (!dipTunnelsUsed())
if (!isDipTunnelsSupported())
{
port_tunnel_name = getTunnelPortName(vtep_ptr->getSrcIP().to_string(), true);
gPortsOrch->getPort(port_tunnel_name,tunnelPort);
vtep_ptr->updateRemoteEndPointIpRef(remote_vtep, false);
if (vtep_ptr->del_tnl_hw_pending && !vtep_ptr->isTunnelReferenced())
{
Expand All @@ -1546,6 +1546,8 @@ bool VxlanTunnelOrch::delTunnelUser(const std::string remote_vtep, uint32_t vni
return true;
}

port_tunnel_name = getTunnelPortName(remote_vtep);
gPortsOrch->getPort(port_tunnel_name,tunnelPort);
if ((vtep_ptr->getDipTunnelRefCnt(remote_vtep) == 1) &&
tunnelPort.m_fdb_count == 0)
{
Expand Down Expand Up @@ -1584,7 +1586,8 @@ void VxlanTunnelOrch::deleteTunnelPort(Port &tunnelPort)
return;
}

if (isSrcVtepTunnel(tunnelPort))
/* P2MP scenario where P2MP tunnel port is used for FDB learning */
if (!isDipTunnelsSupported())
{
if (vtep_ptr->del_tnl_hw_pending && !vtep_ptr->isTunnelReferenced())
{
Expand Down Expand Up @@ -1646,14 +1649,6 @@ std::string VxlanTunnelOrch::getTunnelPortName(const std::string& vtep, bool loc
return tunnelPortName;
}

bool VxlanTunnelOrch::isSrcVtepTunnel(Port& tunnelPort)
{
string tunnel_port_name = tunnelPort.m_alias;
string prefix = LOCAL_TUNNEL_PORT_PREFIX;
return (tunnel_port_name.compare(0, prefix.length(), prefix) == 0);
}


void VxlanTunnelOrch::getTunnelNameFromDIP(const string& dip, string& tunnel_name)
{
tunnel_name = EVPN_TUNNEL_NAME_PREFIX + dip;
Expand Down Expand Up @@ -1760,7 +1755,7 @@ bool VxlanTunnel::isTunnelReferenced()
auto port_tunnel_name = tunnel_orch->getTunnelPortName(src_vtep, true);
bool ret;
Port tunnelPort;
bool dip_tunnels_used = tunnel_orch->dipTunnelsUsed();
bool dip_tunnels_used = tunnel_orch->isDipTunnelsSupported();

ret = gPortsOrch->getPort(port_tunnel_name, tunnelPort);
if (!ret)
Expand All @@ -1769,17 +1764,17 @@ bool VxlanTunnel::isTunnelReferenced()
return false;
}

if (tunnelPort.m_fdb_count != 0)
{
return true;
}

if (dip_tunnels_used)
{
return (getDipTunnelCnt() != 0);
}
else
{
if (tunnelPort.m_fdb_count != 0)
{
return true;
}
/* Bridge port will have reference since on IMET routes reception L2MC group member
would be created with end point IP and the P2MP tunnel bridge port */

Expand Down Expand Up @@ -1983,7 +1978,7 @@ bool VxlanTunnelMapOrch::delOperation(const Request& request)
else
{
tunnel_obj->del_tnl_hw_pending = true;
if (tunnel_orch->dipTunnelsUsed())
if (tunnel_orch->isDipTunnelsSupported())
{
SWSS_LOG_WARN("Postponing the SIP Tunnel HW deletion DIP Tunnel count = %d",
tunnel_obj->getDipTunnelCnt());
Expand Down
13 changes: 6 additions & 7 deletions orchagent/vxlanorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ typedef enum
#define MIN_VLAN_ID 1
#define MAX_VLAN_ID 4095

#define MAX_VNI_ID (1<<24)
#define MAX_VNI_ID 16777215

typedef enum
{
Expand Down Expand Up @@ -256,9 +256,9 @@ typedef std::map<IpAddress, VxlanTunnel*> VTEPTable;
class VxlanTunnelOrch : public Orch2
{
public:
VxlanTunnelOrch(DBConnector *statedb, DBConnector *db, const std::string& tableName, bool dipTunnelsSupported) :
VxlanTunnelOrch(DBConnector *statedb, DBConnector *db, const std::string& tableName, bool isP2pTunnelsSupported) :
Orch2(db, tableName, request_),
m_stateVxlanTable(statedb, STATE_VXLAN_TUNNEL_TABLE_NAME), dip_tunnels_used(dipTunnelsSupported)
m_stateVxlanTable(statedb, STATE_VXLAN_TUNNEL_TABLE_NAME), is_dip_tunnel_supported(isP2pTunnelsSupported)
{}


Expand Down Expand Up @@ -326,7 +326,6 @@ class VxlanTunnelOrch : public Orch2
void addRemoveStateTableEntry(const string, IpAddress&, IpAddress&, tunnel_creation_src_t, bool);

std::string getTunnelPortName(const std::string& vtep, bool local=false);
bool isSrcVtepTunnel(Port& tunnelPort);
void getTunnelNameFromDIP(const string& dip, string& tunnel_name);
void getTunnelNameFromPort(string& tunnel_portname, string& tunnel_name);
void getTunnelDIPFromPort(Port& tunnelPort, string& remote_vtep);
Expand Down Expand Up @@ -354,9 +353,9 @@ class VxlanTunnelOrch : public Orch2
vxlan_vni_vlan_map_table_.erase(vni);
}

bool dipTunnelsUsed(void)
bool isDipTunnelsSupported(void)
{
return dip_tunnels_used;
return is_dip_tunnel_supported;
}


Expand All @@ -369,7 +368,7 @@ class VxlanTunnelOrch : public Orch2
VxlanVniVlanMapTable vxlan_vni_vlan_map_table_;
VTEPTable vtep_table_;
Table m_stateVxlanTable;
bool dip_tunnels_used;
bool is_dip_tunnel_supported;
};

const request_description_t vxlan_tunnel_map_request_description = {
Expand Down

0 comments on commit 04858de

Please sign in to comment.