From 91e231c09f68b6ba97fef53e3f8016731caeb4f1 Mon Sep 17 00:00:00 2001 From: Vitaliy Senchyshyn <43479243+vsenchyshyn@users.noreply.github.com> Date: Thu, 28 Jan 2021 15:51:07 -0800 Subject: [PATCH] [portsorch] Configure hostif tagging for subports (#1573) Configure SAI_HOSTIF_VLAN_TAG_KEEP for the parent port hostif when a first subport is added and restore it to SAI_HOSTIF_VLAN_TAG_STRIP when the last subport is removed. Signed-off-by: Vitaliy Senchyshyn --- orchagent/portsorch.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 2c5ca7189423..334cd68f1807 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -706,6 +706,17 @@ bool PortsOrch::addSubPort(Port &port, const string &alias, const bool &adminUp, } p.m_vlan_info.vlan_id = vlan_id; + // Change hostif vlan tag for the parent port only when a first subport is created + if (parentPort.m_child_ports.empty()) + { + if (!setHostIntfsStripTag(parentPort, SAI_HOSTIF_VLAN_TAG_KEEP)) + { + SWSS_LOG_ERROR("Failed to set %s for hostif of port %s", + hostif_vlan_tag[SAI_HOSTIF_VLAN_TAG_KEEP], parentPort.m_alias.c_str()); + return false; + } + } + parentPort.m_child_ports.insert(p.m_alias); m_portList[alias] = p; @@ -742,6 +753,21 @@ bool PortsOrch::removeSubPort(const string &alias) m_portList[parentPort.m_alias] = parentPort; m_portList.erase(it); + + // Restore hostif vlan tag for the parent port when the last subport is removed + if (parentPort.m_child_ports.empty()) + { + if (parentPort.m_bridge_port_id == SAI_NULL_OBJECT_ID) + { + if (!setHostIntfsStripTag(parentPort, SAI_HOSTIF_VLAN_TAG_STRIP)) + { + SWSS_LOG_ERROR("Failed to set %s for hostif of port %s", + hostif_vlan_tag[SAI_HOSTIF_VLAN_TAG_STRIP], parentPort.m_alias.c_str()); + return false; + } + } + } + return true; }