Skip to content

Commit

Permalink
use vlan oid instead of vlan id (sonic-net#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
lguohan authored Jun 26, 2017
1 parent 61ad2d1 commit 83363a7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
2 changes: 1 addition & 1 deletion orchagent/intfsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ bool IntfsOrch::addRouterIntfs(Port &port)
break;
case Port::VLAN:
attr.id = SAI_ROUTER_INTERFACE_ATTR_VLAN_ID;
attr.value.u16 = port.m_vlan_id;
attr.value.oid = port.m_vlan_oid;
break;
default:
SWSS_LOG_ERROR("Unsupported port type: %d", port.m_type);
Expand Down
1 change: 1 addition & 0 deletions orchagent/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class Port
int m_index = 0; // PHY_PORT: index
int m_ifindex = 0;
sai_object_id_t m_port_id = 0;
sai_object_id_t m_vlan_oid = 0;
sai_vlan_id_t m_vlan_id = 0;
sai_vlan_id_t m_port_vlan_id = DEFAULT_PORT_VLAN_ID; // Port VLAN ID
sai_object_id_t m_vlan_member_id = 0;
Expand Down
18 changes: 5 additions & 13 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,6 @@ bool PortsOrch::addVlan(string vlan_alias)
{
SWSS_LOG_ENTER();

// TODO: how to use vlan_oid??
sai_object_id_t vlan_oid;

sai_vlan_id_t vlan_id = stoi(vlan_alias.substr(4));
Expand All @@ -1031,17 +1030,8 @@ bool PortsOrch::addVlan(string vlan_alias)

SWSS_LOG_NOTICE("Create an empty VLAN %s vid:%hu", vlan_alias.c_str(), vlan_id);

/*
// create vlan rif(s)
sai_attribute_t rif_attr_list[2];
rif_attr_list[0].id = SAI_ROUTER_INTERFACE_ATTR_VLAN_ID;
rif_attr_list[0].value = vlan_id;
rif_attr_list[1].id = SAI_ROUTER_INTERFACE_ATTR_SRC_MAC_ADDRESS;
rif_attr_list[1].value = mac;
sai_create_rif_fn(&rif1, 2, rif_list);
*/

Port vlan(vlan_alias, Port::VLAN);
vlan.m_vlan_oid = vlan_oid;
vlan.m_vlan_id = vlan_id;
vlan.m_members = set<string>();
m_portList[vlan_alias] = vlan;
Expand All @@ -1060,7 +1050,7 @@ bool PortsOrch::removeVlan(Port vlan)
return false;
}

sai_status_t status = sai_vlan_api->remove_vlan(vlan.m_vlan_id);
sai_status_t status = sai_vlan_api->remove_vlan(vlan.m_vlan_oid);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to remove VLAN %s vid:%hu", vlan.m_alias.c_str(), vlan.m_vlan_id);
Expand All @@ -1082,7 +1072,7 @@ bool PortsOrch::addVlanMember(Port vlan, Port port, string& tagging_mode)
vector<sai_attribute_t> attrs;

attr.id = SAI_VLAN_MEMBER_ATTR_VLAN_ID;
attr.value.u16 = vlan.m_vlan_id;
attr.value.oid = vlan.m_vlan_oid;
attrs.push_back(attr);

attr.id = SAI_VLAN_MEMBER_ATTR_BRIDGE_PORT_ID;
Expand Down Expand Up @@ -1110,6 +1100,7 @@ bool PortsOrch::addVlanMember(Port vlan, Port port, string& tagging_mode)
SWSS_LOG_NOTICE("Add member %s to VLAN %s vid:%hu pid%lx",
port.m_alias.c_str(), vlan.m_alias.c_str(), vlan.m_vlan_id, port.m_port_id);

#if 0
// Set port bind mode
sai_attribute_t port_attr;
port_attr.id = SAI_PORT_ATTR_BIND_MODE;
Expand All @@ -1121,6 +1112,7 @@ bool PortsOrch::addVlanMember(Port vlan, Port port, string& tagging_mode)
port.m_port_id, status);
return false;
}
#endif

port.m_vlan_id = vlan.m_vlan_id;
port.m_port_vlan_id = vlan.m_vlan_id;
Expand Down

0 comments on commit 83363a7

Please sign in to comment.