Skip to content

Commit 5ef97ca

Browse files
qiluo-msftlguohan
authored andcommitted
Fix findBridgeVlanForPortVlan for 1Q bridge (sonic-net#345)
Signed-off-by: Qi Luo <[email protected]>
1 parent e402ff6 commit 5ef97ca

File tree

1 file changed

+32
-29
lines changed

1 file changed

+32
-29
lines changed

vslib/src/sai_vs_hostintf.cpp

+32-29
Original file line numberDiff line numberDiff line change
@@ -187,61 +187,63 @@ void findBridgeVlanForPortVlan(
187187

188188
sai_deserialize_object_id(it->first, bpid);
189189

190-
sai_attribute_t attr;
190+
sai_attribute_t attrs[2];
191191

192-
attr.id = SAI_BRIDGE_PORT_ATTR_PORT_ID;
192+
attrs[0].id = SAI_BRIDGE_PORT_ATTR_PORT_ID;
193+
attrs[1].id = SAI_BRIDGE_PORT_ATTR_TYPE;
193194

194-
sai_status_t status = vs_generic_get(SAI_OBJECT_TYPE_BRIDGE_PORT, bpid, 1, &attr);
195+
sai_status_t status = vs_generic_get(SAI_OBJECT_TYPE_BRIDGE_PORT, bpid, sizeof(attrs)/sizeof(attrs[0]), attrs);
195196

196197
if (status != SAI_STATUS_SUCCESS)
197198
{
198199
continue;
199200
}
200201

201-
if (port_id != attr.value.oid)
202+
if (port_id != attrs[0].value.oid)
202203
{
203204
// this is not expected port
204205
continue;
205206
}
206207

207208
bridge_port_id = bpid;
208209

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

211-
SWSS_LOG_DEBUG("found bridge port %s for port %s",
213+
SWSS_LOG_DEBUG("found bridge port %s of type %d",
212214
sai_serialize_object_id(bridge_port_id).c_str(),
213-
sai_serialize_object_id(port_id).c_str());
214-
215-
attr.id = SAI_BRIDGE_PORT_ATTR_BRIDGE_ID;
215+
bp_type);
216216

217-
status = vs_generic_get(SAI_OBJECT_TYPE_BRIDGE_PORT, bridge_port_id, 1, &attr);
218-
219-
if (status != SAI_STATUS_SUCCESS)
217+
if (bp_type == SAI_BRIDGE_PORT_TYPE_SUB_PORT)
220218
{
221-
break;
222-
}
219+
sai_attribute_t attr;
220+
attr.id = SAI_BRIDGE_PORT_ATTR_BRIDGE_ID;
223221

224-
bridge_id = attr.value.oid;
222+
status = vs_generic_get(SAI_OBJECT_TYPE_BRIDGE_PORT, bridge_port_id, 1, &attr);
225223

226-
SWSS_LOG_DEBUG("found bridge %s for port %s",
227-
sai_serialize_object_id(bridge_id).c_str(),
228-
sai_serialize_object_id(port_id).c_str());
224+
if (status != SAI_STATUS_SUCCESS)
225+
{
226+
break;
227+
}
229228

230-
attr.id = SAI_BRIDGE_ATTR_TYPE;
229+
bridge_id = attr.value.oid;
231230

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

234-
if (status != SAI_STATUS_SUCCESS)
235-
{
236-
break;
237-
}
235+
attr.id = SAI_BRIDGE_ATTR_TYPE;
238236

239-
SWSS_LOG_DEBUG("bridge %s type is %d",
240-
sai_serialize_object_id(bridge_id).c_str(),
241-
attr.value.s32);
237+
status = vs_generic_get(SAI_OBJECT_TYPE_BRIDGE, bridge_id, 1, &attr);
242238

243-
if (attr.value.s32 == SAI_BRIDGE_TYPE_1D)
244-
{
239+
if (status != SAI_STATUS_SUCCESS)
240+
{
241+
break;
242+
}
243+
244+
SWSS_LOG_DEBUG("bridge %s type is %d",
245+
sai_serialize_object_id(bridge_id).c_str(),
246+
attr.value.s32);
245247
bv_id = bridge_id;
246248
}
247249
else
@@ -256,6 +258,7 @@ void findBridgeVlanForPortVlan(
256258

257259
sai_deserialize_object_id(it2->first, vlan_oid);
258260

261+
sai_attribute_t attr;
259262
attr.id = SAI_VLAN_ATTR_VLAN_ID;
260263

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

0 commit comments

Comments
 (0)