Skip to content

Commit

Permalink
[orchagent]: Support LAG/VLAN with SAI 1.0
Browse files Browse the repository at this point in the history
1. Change the initialization order
   After switch initialization, remove all VLAN members from the default
   VLAN and all bridge ports from the default .1Q bridge. Later, router
   interfaces and LAG members could be created directly upon the raw ports.
2. VLAN members are created by first creating the corresponding .1Q bridge
   ports and then using the bridge ports to create VLAN members.
3. Remove bimap data structure as bridge port ID is not one to one mapping
   to port ID. Further work is needed to support multiple bridge port per
   port scenarios.
4. Fix ECMP group member removal issue. Use set to store member IDs per
   next hop group.
  • Loading branch information
Shu0T1an ChenG committed Jul 12, 2017
1 parent 009c862 commit b749b1a
Show file tree
Hide file tree
Showing 7 changed files with 206 additions and 183 deletions.
13 changes: 7 additions & 6 deletions orchagent/fdborch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

extern sai_fdb_api_t *sai_fdb_api;

void FdbOrch::update(sai_fdb_event_t type, const sai_fdb_entry_t* entry, sai_object_id_t portOid)
void FdbOrch::update(sai_fdb_event_t type, const sai_fdb_entry_t* entry, sai_object_id_t bridge_port_id)
{
SWSS_LOG_ENTER();

Expand All @@ -19,9 +19,9 @@ void FdbOrch::update(sai_fdb_event_t type, const sai_fdb_entry_t* entry, sai_obj
switch (type)
{
case SAI_FDB_EVENT_LEARNED:
if (!m_portsOrch->getBridgePort(portOid, update.port))
if (!m_portsOrch->getPortByBridgePortId(bridge_port_id, update.port))
{
SWSS_LOG_ERROR("Failed to get port for %lu OID", portOid);
SWSS_LOG_ERROR("Failed to get port by bridge port ID %lu", bridge_port_id);
return;
}

Expand Down Expand Up @@ -60,13 +60,14 @@ bool FdbOrch::getPort(const MacAddress& mac, uint16_t vlan, Port& port)
sai_status_t status = sai_fdb_api->get_fdb_entry_attribute(&entry, 1, &attr);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to get port for FDB entry OID");
SWSS_LOG_ERROR("Failed to get bridge port ID for FDB entry %s, rv:%d",
mac.to_string().c_str(), status);
return false;
}

if (!m_portsOrch->getBridgePort(attr.value.oid, port))
if (!m_portsOrch->getPortByBridgePortId(attr.value.oid, port))
{
SWSS_LOG_ERROR("Failed to get port for %lu OID", attr.value.oid);
SWSS_LOG_ERROR("Failed to get port by bridge port ID %lu", attr.value.oid);
return false;
}

Expand Down
10 changes: 4 additions & 6 deletions orchagent/intfsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,6 @@ bool IntfsOrch::addRouterIntfs(Port &port)
return true;
}

if (port.m_type == Port::PHY)
{
gPortsOrch->removeBridgePort(port);
}

/* Create router interface if the router interface doesn't exist */
sai_attribute_t attr;
vector<sai_attribute_t> attrs;
Expand Down Expand Up @@ -365,8 +360,11 @@ void IntfsOrch::addIp2MeRoute(const IpPrefix &ip_prefix)
attr.value.s32 = SAI_PACKET_ACTION_FORWARD;
attrs.push_back(attr);

Port cpu_port;
gPortsOrch->getCpuPort(cpu_port);

attr.id = SAI_ROUTE_ENTRY_ATTR_NEXT_HOP_ID;
attr.value.oid = gPortsOrch->getCpuPort();
attr.value.oid = cpu_port.m_port_id;
attrs.push_back(attr);

sai_status_t status = sai_route_api->create_route_entry(&unicast_route_entry, attrs.size(), attrs.data());
Expand Down
1 change: 1 addition & 0 deletions orchagent/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class Port
int m_ifindex = 0;
sai_object_id_t m_port_id = 0;
sai_object_id_t m_vlan_oid = 0;
sai_object_id_t m_bridge_port_id = 0; // TODO: port could have multiple bridge port IDs
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
Loading

0 comments on commit b749b1a

Please sign in to comment.