Skip to content

Commit

Permalink
Fix findBridgeVlanForPortVlan for 1Q bridge (sonic-net#345)
Browse files Browse the repository at this point in the history
Signed-off-by: Qi Luo <qiluo-msft@users.noreply.github.com>
  • Loading branch information
qiluo-msft authored and lguohan committed Sep 12, 2018
1 parent e402ff6 commit 5ef97ca
Showing 1 changed file with 32 additions and 29 deletions.
61 changes: 32 additions & 29 deletions vslib/src/sai_vs_hostintf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,61 +187,63 @@ void findBridgeVlanForPortVlan(

sai_deserialize_object_id(it->first, bpid);

sai_attribute_t attr;
sai_attribute_t attrs[2];

attr.id = SAI_BRIDGE_PORT_ATTR_PORT_ID;
attrs[0].id = SAI_BRIDGE_PORT_ATTR_PORT_ID;
attrs[1].id = SAI_BRIDGE_PORT_ATTR_TYPE;

sai_status_t status = vs_generic_get(SAI_OBJECT_TYPE_BRIDGE_PORT, bpid, 1, &attr);
sai_status_t status = vs_generic_get(SAI_OBJECT_TYPE_BRIDGE_PORT, bpid, sizeof(attrs)/sizeof(attrs[0]), attrs);

if (status != SAI_STATUS_SUCCESS)
{
continue;
}

if (port_id != attr.value.oid)
if (port_id != attrs[0].value.oid)
{
// this is not expected port
continue;
}

bridge_port_id = bpid;

// XXX: need to also check the vlan_id match if the bridge port type is subport
// get the 1D bridge id if the bridge port type is subport
auto bp_type = attrs[1].value.s32;

SWSS_LOG_DEBUG("found bridge port %s for port %s",
SWSS_LOG_DEBUG("found bridge port %s of type %d",
sai_serialize_object_id(bridge_port_id).c_str(),
sai_serialize_object_id(port_id).c_str());

attr.id = SAI_BRIDGE_PORT_ATTR_BRIDGE_ID;
bp_type);

status = vs_generic_get(SAI_OBJECT_TYPE_BRIDGE_PORT, bridge_port_id, 1, &attr);

if (status != SAI_STATUS_SUCCESS)
if (bp_type == SAI_BRIDGE_PORT_TYPE_SUB_PORT)
{
break;
}
sai_attribute_t attr;
attr.id = SAI_BRIDGE_PORT_ATTR_BRIDGE_ID;

bridge_id = attr.value.oid;
status = vs_generic_get(SAI_OBJECT_TYPE_BRIDGE_PORT, bridge_port_id, 1, &attr);

SWSS_LOG_DEBUG("found bridge %s for port %s",
sai_serialize_object_id(bridge_id).c_str(),
sai_serialize_object_id(port_id).c_str());
if (status != SAI_STATUS_SUCCESS)
{
break;
}

attr.id = SAI_BRIDGE_ATTR_TYPE;
bridge_id = attr.value.oid;

status = vs_generic_get(SAI_OBJECT_TYPE_BRIDGE, bridge_id, 1, &attr);
SWSS_LOG_DEBUG("found bridge %s for port %s",
sai_serialize_object_id(bridge_id).c_str(),
sai_serialize_object_id(port_id).c_str());

if (status != SAI_STATUS_SUCCESS)
{
break;
}
attr.id = SAI_BRIDGE_ATTR_TYPE;

SWSS_LOG_DEBUG("bridge %s type is %d",
sai_serialize_object_id(bridge_id).c_str(),
attr.value.s32);
status = vs_generic_get(SAI_OBJECT_TYPE_BRIDGE, bridge_id, 1, &attr);

if (attr.value.s32 == SAI_BRIDGE_TYPE_1D)
{
if (status != SAI_STATUS_SUCCESS)
{
break;
}

SWSS_LOG_DEBUG("bridge %s type is %d",
sai_serialize_object_id(bridge_id).c_str(),
attr.value.s32);
bv_id = bridge_id;
}
else
Expand All @@ -256,6 +258,7 @@ void findBridgeVlanForPortVlan(

sai_deserialize_object_id(it2->first, vlan_oid);

sai_attribute_t attr;
attr.id = SAI_VLAN_ATTR_VLAN_ID;

status = vs_generic_get(SAI_OBJECT_TYPE_VLAN, vlan_oid, 1, &attr);
Expand Down

0 comments on commit 5ef97ca

Please sign in to comment.