Skip to content

Commit

Permalink
Changes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
dgsudharsan committed Jun 9, 2021
1 parent 3b6b5f7 commit 6694900
Showing 1 changed file with 119 additions and 17 deletions.
136 changes: 119 additions & 17 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4130,6 +4130,8 @@ bool PortsOrch::getVlanByVlanId(sai_vlan_id_t vlan_id, Port &vlan)

bool PortsOrch::addVlanFloodGroups(Port &vlan, Port &port, string &tagging_mode, string end_point_ip)
{
SWSS_LOG_ENTER();

sai_object_id_t l2mc_group_id = SAI_NULL_OBJECT_ID;
sai_status_t status;

Expand Down Expand Up @@ -4242,28 +4244,13 @@ bool PortsOrch::addVlanFloodGroups(Port &vlan, Port &port, string &tagging_mode,
return true;
}

bool PortsOrch::addVlanMember(Port &vlan, Port &port, string &tagging_mode, string end_point_ip = "")
bool PortsOrch::createVlanMember(Port &vlan, Port &port, string &tagging_mode)
{
SWSS_LOG_ENTER();

sai_attribute_t attr;
vector<sai_attribute_t> attrs;

if (!end_point_ip.empty())
{
if (!((vlan.m_vlan_info.uuc_flood_type == SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED) ||
(vlan.m_vlan_info.umc_flood_type == SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED) ||
(vlan.m_vlan_info.bc_flood_type == SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED))
{
SWSS_LOG_ERROR("Flood group with end point ip is not supported");
return false;
}
if (vlan.m_members.find(port.m_alias) == vlan.m_members.end())
{

}
}

attr.id = SAI_VLAN_MEMBER_ATTR_VLAN_ID;
attr.value.oid = vlan.m_vlan_info.vlan_oid;
attrs.push_back(attr);
Expand Down Expand Up @@ -4298,6 +4285,34 @@ bool PortsOrch::addVlanMember(Port &vlan, Port &port, string &tagging_mode, stri
}
SWSS_LOG_NOTICE("Add member %s to VLAN %s vid:%hu pid%" PRIx64,
port.m_alias.c_str(), vlan.m_alias.c_str(), vlan.m_vlan_info.vlan_id, port.m_port_id);
return true;

}

bool PortsOrch::addVlanMember(Port &vlan, Port &port, string &tagging_mode, string end_point_ip = "")
{
SWSS_LOG_ENTER();

if (!end_point_ip.empty())
{
if (!((vlan.m_vlan_info.uuc_flood_type == SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED) ||
(vlan.m_vlan_info.umc_flood_type == SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED) ||
(vlan.m_vlan_info.bc_flood_type == SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED))
{
SWSS_LOG_ERROR("Flood group with end point ip is not supported");
return false;
}
if (vlan.m_members.find(port.m_alias) == vlan.m_members.end())
{

}
return addVlanFloodGroups(vlan, port, end_point_ip);
}

if(!createVlanMember(vlan, port, tagging_mode))
{
return false;
}

/* Use untagged VLAN as pvid of the member port */
if (sai_tagging_mode == SAI_VLAN_TAGGING_MODE_UNTAGGED)
Expand All @@ -4321,10 +4336,97 @@ bool PortsOrch::addVlanMember(Port &vlan, Port &port, string &tagging_mode, stri
return true;
}

bool PortsOrch::removeVlanMember(Port &vlan, Port &port)
bool PortsOrch::removeVlanEndPointIP(Port &vlan, Port &port, string end_point_ip)
{
SWSS_LOG_ENTER();

sai_status_t status;

if(vlan.m_vlan_info.l2mc_members.find(end_point_ip) == vlan.m_vlan_info.l2mc_members.end())
{
SWSS_LOG_NOTICE("End point ip %s is not part of vlan %hu",
end_point_ip, vlan.m_vlan_info.vlan_id);
return true;
}

status = sai_l2mc_group_api->remove_l2mc_group_member(vlan.m_vlan_info.l2mc_members[end_point_ip]);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to remove end point ip %s from vlan %hu",
end_point_ip, vlan.m_vlan_info.vlan_id);
return false;
}
vlan.m_vlan_info.l2mc_members.erase(end_point_ip);
sai_object_id_t l2mc_group_id = SAI_NULL_OBJECT_ID;

if (vlan.m_vlan_info.l2mc_members.empty())
{
if (vlan.m_vlan_info.uuc_flood_type == SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED)
{
attr.id = SAI_VLAN_ATTR_UNKNOWN_UNICAST_FLOOD_GROUP;
attr.value.oid = SAI_NULL_OBJECT_ID;

status = sai_vlan_api->set_vlan_attribute(vlan.m_vlan_info.vlan_oid, &attr);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to set null l2mc group %"
" to vlan %hu for unknown unicast flooding",
vlan.m_vlan_info.vlan_id);
return false;
}
l2mc_group_id = vlan.m_vlan_info.uuc_flood_group;
vlan.m_vlan_info.uuc_flood_group = SAI_NULL_OBJECT_ID;
}
if (vlan.m_vlan_info.umc_flood_type == SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED)
{
attr.id = SAI_VLAN_ATTR_UNKNOWN_MULTICAST_FLOOD_CONTROL_TYPE;
attr.value.oid = SAI_NULL_OBJECT_ID;

status = sai_vlan_api->set_vlan_attribute(vlan.m_vlan_info.vlan_oid, &attr);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to set null l2mc group %"
" to vlan %hu for unknown multicast flooding",
vlan.m_vlan_info.vlan_id);
return false;
}
l2mc_group_id = vlan.m_vlan_info.umc_flood_group;
vlan.m_vlan_info.umc_flood_group = SAI_NULL_OBJECT_ID;
}
if (vlan.m_vlan_info.bc_flood_type == SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED)
{
attr.id = SAI_VLAN_ATTR_BROADCAST_FLOOD_GROUP;
attr.value.oid = SAI_NULL_OBJECT_ID;

status = sai_vlan_api->set_vlan_attribute(vlan.m_vlan_info.vlan_oid, &attr);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to set null l2mc group %"
" to vlan %hu for broadcast flooding",
vlan.m_vlan_info.vlan_id);
return false;
}
l2mc_group_id = vlan.m_vlan_info.bc_flood_group;
vlan.m_vlan_info.bc_flood_group = SAI_NULL_OBJECT_ID;
}
status = sai_l2mc_group_api->remove_l2mc_group(l2mc_group_id);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to remove l2mc group %" PRIx64, l2mc_group_id);
return false;
}
}
return true;
}

bool PortsOrch::removeVlanMember(Port &vlan, Port &port, string end_point_ip="")
{
SWSS_LOG_ENTER();

if (!end_point_ip.empty())
{
return removeVlanEndPointIP(vlan, port, end_point_ip);
}
sai_object_id_t vlan_member_id;
sai_vlan_tagging_mode_t sai_tagging_mode;
auto vlan_member = port.m_vlan_members.find(vlan.m_vlan_info.vlan_id);
Expand Down

0 comments on commit 6694900

Please sign in to comment.