From 64c93862d73dab11b6856101d1877aaa30cbe4c1 Mon Sep 17 00:00:00 2001 From: Lawrence Lee Date: Fri, 16 Feb 2024 11:05:56 +0000 Subject: [PATCH] Implement multi VLAN neighbor learning Signed-off-by: Lawrence Lee --- orchagent/neighorch.cpp | 21 +++++++++++++++++++++ orchagent/portsorch.cpp | 7 +++++++ orchagent/portsorch.h | 4 ++++ 3 files changed, 32 insertions(+) diff --git a/orchagent/neighorch.cpp b/orchagent/neighorch.cpp index efbe7ff481..ad664fc380 100644 --- a/orchagent/neighorch.cpp +++ b/orchagent/neighorch.cpp @@ -933,6 +933,27 @@ bool NeighOrch::addNeighbor(const NeighborEntry &neighborEntry, const MacAddress } } + PortsOrch* ports_orch = gDirectory.get(); + 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(); bool hw_config = isHwConfigured(neighborEntry); diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 0ce38850d0..f864a39730 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -1156,6 +1156,11 @@ map& PortsOrch::getAllPorts() return m_portList; } +unordered_set& PortsOrch::getVlanPorts() +{ + return m_vlanPorts; +} + bool PortsOrch::getPort(string alias, Port &p) { SWSS_LOG_ENTER(); @@ -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; } @@ -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; } diff --git a/orchagent/portsorch.h b/orchagent/portsorch.h index 4d069ccfc5..ce31361e7c 100755 --- a/orchagent/portsorch.h +++ b/orchagent/portsorch.h @@ -2,6 +2,7 @@ #define SWSS_PORTSORCH_H #include +#include #include "acltable.h" #include "orch.h" @@ -150,6 +151,8 @@ class PortsOrch : public Orch, public Subject bool createVlanHostIntf(Port& vl, string hostif_name); bool removeVlanHostIntf(Port vl); + unordered_set& getVlanPorts(); + bool createBindAclTableGroup(sai_object_id_t port_oid, sai_object_id_t acl_table_oid, sai_object_id_t &group_oid, @@ -306,6 +309,7 @@ class PortsOrch : public Orch, public Subject map m_gearboxPortMap; map> m_gearboxPortListLaneMap; + unordered_set m_vlanPorts; port_config_state_t m_portConfigState = PORT_CONFIG_MISSING; sai_uint32_t m_portCount; map, sai_object_id_t> m_portListLaneMap;