Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[portsorch]: Update default bridge port removal logic #263

Merged
merged 2 commits into from
Jul 22, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void PortsOrch::removeDefaultVlanMembers()
}

/* Remove VLAN members in default VLAN */
for (size_t i = 0; i < attr.value.objlist.count; i++)
for (uint32_t i = 0; i < attr.value.objlist.count; i++)
{
status = sai_vlan_api->remove_vlan_member(vlan_member_list[i]);
if (status != SAI_STATUS_SUCCESS)
Expand All @@ -172,13 +172,16 @@ void PortsOrch::removeDefaultVlanMembers()
throw "PortsOrch initialization failure";
}
}

SWSS_LOG_NOTICE("Remove VLAN members from default VLAN");
}

void PortsOrch::removeDefaultBridgePorts()
{
/* Get bridge ports in default 1Q bridge */
// FIXME: Mellanox SAI implementation will response SAI_BRIDGE_ATTR_PORT_LIST
// all the front panel ports and CPU port. The CPU bug should be there by SAI spec.
/* Get bridge ports in default 1Q bridge
* By default, there will be m_portCount number of SAI_BRIDGE_PORT_TYPE_PORT
* ports and one SAI_BRIDGE_PORT_TYPE_1Q_ROUTER port. The former type of
* ports will be removed. */
vector<sai_object_id_t> bridge_port_list(m_portCount + 1);

sai_attribute_t attr;
Expand All @@ -193,16 +196,32 @@ void PortsOrch::removeDefaultBridgePorts()
throw "PortsOrch initialization failure";
}

/* Remove bridge ports in default 1Q bridge */
for (size_t i = 0; i < attr.value.objlist.count; i++)
auto bridge_port_count = attr.value.objlist.count;

/* Remove SAI_BRIDGE_PORT_TYPE_PORT bridge ports in default 1Q bridge */
for (uint32_t i = 0; i < bridge_port_count; i++)
{
status = sai_bridge_api->remove_bridge_port(bridge_port_list[i]);
attr.id = SAI_BRIDGE_PORT_ATTR_TYPE;
attr.value.s32 = SAI_NULL_OBJECT_ID;

status = sai_bridge_api->get_bridge_port_attribute(bridge_port_list[i], 1, &attr);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to remove bridge port, rv:%d", status);
SWSS_LOG_ERROR("Failed to get bridge port type, rv:%d", status);
throw "PortsOrch initialization failure";
}
if (attr.value.s32 == SAI_BRIDGE_PORT_TYPE_PORT)
{
status = sai_bridge_api->remove_bridge_port(bridge_port_list[i]);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to remove bridge port, rv:%d", status);
throw "PortsOrch initialization failure";
}
}
}

SWSS_LOG_NOTICE("Remove bridge ports from default 1Q bridge");
}

bool PortsOrch::isInitDone()
Expand Down