Skip to content

Commit

Permalink
Cosmetic cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
dgsudharsan committed Oct 12, 2021
1 parent ffbf06a commit c750f17
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 81 deletions.
1 change: 0 additions & 1 deletion orchagent/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,6 @@ int main(int argc, char **argv)
orchDaemon = make_shared<FabricOrchDaemon>(&appl_db, &config_db, &state_db, chassis_app_db.get());
}


if (!orchDaemon->init())
{
SWSS_LOG_ERROR("Failed to initialize orchestration daemon");
Expand Down
5 changes: 2 additions & 3 deletions orchagent/orchdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ bool OrchDaemon::init()
CoppOrch *copp_orch = new CoppOrch(m_applDb, APP_COPP_TABLE_NAME);
TunnelDecapOrch *tunnel_decap_orch = new TunnelDecapOrch(m_applDb, APP_TUNNEL_DECAP_TABLE_NAME);

VxlanTunnelOrch *vxlan_tunnel_orch = new VxlanTunnelOrch(m_stateDb, m_applDb, APP_VXLAN_TUNNEL_TABLE_NAME);
gDirectory.set(vxlan_tunnel_orch);
VxlanTunnelMapOrch *vxlan_tunnel_map_orch = new VxlanTunnelMapOrch(m_applDb, APP_VXLAN_TUNNEL_MAP_TABLE_NAME);
gDirectory.set(vxlan_tunnel_map_orch);
VxlanVrfMapOrch *vxlan_vrf_orch = new VxlanVrfMapOrch(m_applDb, APP_VXLAN_VRF_TABLE_NAME);
Expand All @@ -177,9 +179,6 @@ bool OrchDaemon::init()
EvpnNvoOrch* evpn_nvo_orch = new EvpnNvoOrch(m_applDb, APP_VXLAN_EVPN_NVO_TABLE_NAME);
gDirectory.set(evpn_nvo_orch);

VxlanTunnelOrch *vxlan_tunnel_orch = new VxlanTunnelOrch(m_stateDb, m_applDb,
APP_VXLAN_TUNNEL_TABLE_NAME);
gDirectory.set(vxlan_tunnel_orch);

vector<string> qos_tables = {
CFG_TC_TO_QUEUE_MAP_TABLE_NAME,
Expand Down
155 changes: 78 additions & 77 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4508,6 +4508,84 @@ bool PortsOrch::getVlanByVlanId(sai_vlan_id_t vlan_id, Port &vlan)
return false;
}

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

if (!end_point_ip.empty())
{
if ((uuc_sup_flood_control_type.find(SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED)
== uuc_sup_flood_control_type.end()) ||
(bc_sup_flood_control_type.find(SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED)
== bc_sup_flood_control_type.end()))
{
SWSS_LOG_ERROR("Flood group with end point ip is not supported");
return false;
}
return addVlanFloodGroups(vlan, port, end_point_ip);
}

sai_attribute_t attr;
vector<sai_attribute_t> attrs;

attr.id = SAI_VLAN_MEMBER_ATTR_VLAN_ID;
attr.value.oid = vlan.m_vlan_info.vlan_oid;
attrs.push_back(attr);

attr.id = SAI_VLAN_MEMBER_ATTR_BRIDGE_PORT_ID;
attr.value.oid = port.m_bridge_port_id;
attrs.push_back(attr);


sai_vlan_tagging_mode_t sai_tagging_mode = SAI_VLAN_TAGGING_MODE_TAGGED;
attr.id = SAI_VLAN_MEMBER_ATTR_VLAN_TAGGING_MODE;
if (tagging_mode == "untagged")
sai_tagging_mode = SAI_VLAN_TAGGING_MODE_UNTAGGED;
else if (tagging_mode == "tagged")
sai_tagging_mode = SAI_VLAN_TAGGING_MODE_TAGGED;
else if (tagging_mode == "priority_tagged")
sai_tagging_mode = SAI_VLAN_TAGGING_MODE_PRIORITY_TAGGED;
else assert(false);
attr.value.s32 = sai_tagging_mode;
attrs.push_back(attr);

sai_object_id_t vlan_member_id;
sai_status_t status = sai_vlan_api->create_vlan_member(&vlan_member_id, gSwitchId, (uint32_t)attrs.size(), attrs.data());
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to 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);
task_process_status handle_status = handleSaiCreateStatus(SAI_API_VLAN, status);
if (handle_status != task_success)
{
return parseHandleSaiStatusFailure(handle_status);
}
}
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);

/* Use untagged VLAN as pvid of the member port */
if (sai_tagging_mode == SAI_VLAN_TAGGING_MODE_UNTAGGED)
{
if(!setPortPvid(port, vlan.m_vlan_info.vlan_id))
{
return false;
}
}

/* a physical port may join multiple vlans */
VlanMemberEntry vme = {vlan_member_id, sai_tagging_mode};
port.m_vlan_members[vlan.m_vlan_info.vlan_id] = vme;
m_portList[port.m_alias] = port;
vlan.m_members.insert(port.m_alias);
m_portList[vlan.m_alias] = vlan;

VlanMemberUpdate update = { vlan, port, true };
notify(SUBJECT_TYPE_VLAN_MEMBER_CHANGE, static_cast<void *>(&update));

return true;
}

bool PortsOrch::addVlanFloodGroups(Port &vlan, Port &port, string end_point_ip)
{
SWSS_LOG_ENTER();
Expand Down Expand Up @@ -4628,83 +4706,6 @@ bool PortsOrch::addVlanFloodGroups(Port &vlan, Port &port, string end_point_ip)
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 ((uuc_sup_flood_control_type.find(SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED)
== uuc_sup_flood_control_type.end()) ||
(bc_sup_flood_control_type.find(SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED)
== bc_sup_flood_control_type.end()))
{
SWSS_LOG_ERROR("Flood group with end point ip is not supported");
return false;
}
return addVlanFloodGroups(vlan, port, end_point_ip);
}

sai_attribute_t attr;
vector<sai_attribute_t> attrs;

attr.id = SAI_VLAN_MEMBER_ATTR_VLAN_ID;
attr.value.oid = vlan.m_vlan_info.vlan_oid;
attrs.push_back(attr);

attr.id = SAI_VLAN_MEMBER_ATTR_BRIDGE_PORT_ID;
attr.value.oid = port.m_bridge_port_id;
attrs.push_back(attr);


sai_vlan_tagging_mode_t sai_tagging_mode = SAI_VLAN_TAGGING_MODE_TAGGED;
attr.id = SAI_VLAN_MEMBER_ATTR_VLAN_TAGGING_MODE;
if (tagging_mode == "untagged")
sai_tagging_mode = SAI_VLAN_TAGGING_MODE_UNTAGGED;
else if (tagging_mode == "tagged")
sai_tagging_mode = SAI_VLAN_TAGGING_MODE_TAGGED;
else if (tagging_mode == "priority_tagged")
sai_tagging_mode = SAI_VLAN_TAGGING_MODE_PRIORITY_TAGGED;
else assert(false);
attr.value.s32 = sai_tagging_mode;
attrs.push_back(attr);

sai_object_id_t vlan_member_id;
sai_status_t status = sai_vlan_api->create_vlan_member(&vlan_member_id, gSwitchId, (uint32_t)attrs.size(), attrs.data());
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to 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);
task_process_status handle_status = handleSaiCreateStatus(SAI_API_VLAN, status);
if (handle_status != task_success)
{
return parseHandleSaiStatusFailure(handle_status);
}
}
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);

/* Use untagged VLAN as pvid of the member port */
if (sai_tagging_mode == SAI_VLAN_TAGGING_MODE_UNTAGGED)
{
if(!setPortPvid(port, vlan.m_vlan_info.vlan_id))
{
return false;
}
}

/* a physical port may join multiple vlans */
VlanMemberEntry vme = {vlan_member_id, sai_tagging_mode};
port.m_vlan_members[vlan.m_vlan_info.vlan_id] = vme;
m_portList[port.m_alias] = port;
vlan.m_members.insert(port.m_alias);
m_portList[vlan.m_alias] = vlan;

VlanMemberUpdate update = { vlan, port, true };
notify(SUBJECT_TYPE_VLAN_MEMBER_CHANGE, static_cast<void *>(&update));

return true;
}

bool PortsOrch::removeVlanEndPointIp(Port &vlan, Port &port, string end_point_ip)
{
Expand Down

0 comments on commit c750f17

Please sign in to comment.