Skip to content

Commit

Permalink
Implement multi VLAN neighbor learning
Browse files Browse the repository at this point in the history
Signed-off-by: Lawrence Lee <[email protected]>
  • Loading branch information
theasianpianist committed Feb 16, 2024
1 parent f783d77 commit 64c9386
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
21 changes: 21 additions & 0 deletions orchagent/neighorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,27 @@ bool NeighOrch::addNeighbor(const NeighborEntry &neighborEntry, const MacAddress
}
}

PortsOrch* ports_orch = gDirectory.get<PortsOrch*>();
auto vlan_ports = ports_orch->getVlanPorts();

for (auto vlan_port: vlan_ports)
{
if (vlan_port == alias)
{
continue;
}
NeighborEntry temp_entry = { ip_address, vlan_port };
if (m_syncdNeighbors.find(temp_entry) != m_syncdNeighbors.end())
{
SWSS_LOG_ERROR("Neighbor %s on %s already exists, removing before adding new neighbor", ip_address.to_string().c_str(), vlan_port.c_str());
if (!removeNeighbor(temp_entry))
{
SWSS_LOG_ERROR("Failed to remove neighbor %s on %s", ip_address.to_string().c_str(), vlan_port.c_str());
return false;
}
}
}

MuxOrch* mux_orch = gDirectory.get<MuxOrch*>();
bool hw_config = isHwConfigured(neighborEntry);

Expand Down
7 changes: 7 additions & 0 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,11 @@ map<string, Port>& PortsOrch::getAllPorts()
return m_portList;
}

unordered_set<string>& PortsOrch::getVlanPorts()
{
return m_vlanPorts;
}

bool PortsOrch::getPort(string alias, Port &p)
{
SWSS_LOG_ENTER();
Expand Down Expand Up @@ -5743,6 +5748,7 @@ bool PortsOrch::addVlan(string vlan_alias)
m_portList[vlan_alias] = vlan;
m_port_ref_count[vlan_alias] = 0;
saiOidToAlias[vlan_oid] = vlan_alias;
m_vlanPorts.emplace(vlan_alias);

return true;
}
Expand Down Expand Up @@ -5809,6 +5815,7 @@ bool PortsOrch::removeVlan(Port vlan)
saiOidToAlias.erase(vlan.m_vlan_info.vlan_oid);
m_portList.erase(vlan.m_alias);
m_port_ref_count.erase(vlan.m_alias);
m_vlanPorts.erase(vlan.m_alias);

return true;
}
Expand Down
4 changes: 4 additions & 0 deletions orchagent/portsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define SWSS_PORTSORCH_H

#include <map>
#include <unordered_set>

#include "acltable.h"
#include "orch.h"
Expand Down Expand Up @@ -150,6 +151,8 @@ class PortsOrch : public Orch, public Subject
bool createVlanHostIntf(Port& vl, string hostif_name);
bool removeVlanHostIntf(Port vl);

unordered_set<string>& getVlanPorts();

bool createBindAclTableGroup(sai_object_id_t port_oid,
sai_object_id_t acl_table_oid,
sai_object_id_t &group_oid,
Expand Down Expand Up @@ -306,6 +309,7 @@ class PortsOrch : public Orch, public Subject
map<int, gearbox_port_t> m_gearboxPortMap;
map<sai_object_id_t, tuple<sai_object_id_t, sai_object_id_t>> m_gearboxPortListLaneMap;

unordered_set<string> m_vlanPorts;
port_config_state_t m_portConfigState = PORT_CONFIG_MISSING;
sai_uint32_t m_portCount;
map<set<uint32_t>, sai_object_id_t> m_portListLaneMap;
Expand Down

0 comments on commit 64c9386

Please sign in to comment.