Skip to content

Commit a1d6300

Browse files
authored
[sub intf] ecmp hardware convergence acceleration at parent port oper status changes (#1492)
Take sub port interface into ecmp acceleration account when a next hop object goes through a local sub port interface. Signed-off-by: Wenda Ni <[email protected]>
1 parent c88d77f commit a1d6300

File tree

4 files changed

+403
-35
lines changed

4 files changed

+403
-35
lines changed

orchagent/neighorch.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,15 @@ bool NeighOrch::addNextHop(const IpAddress &ipAddress, const string &alias)
133133
ipAddress.to_string().c_str(), alias.c_str());
134134
return false;
135135
}
136+
if (p.m_type == Port::SUBPORT)
137+
{
138+
if (!gPortsOrch->getPort(p.m_parent_port_id, p))
139+
{
140+
SWSS_LOG_ERROR("Neighbor %s seen on sub interface %s whose parent port doesn't exist",
141+
ipAddress.to_string().c_str(), alias.c_str());
142+
return false;
143+
}
144+
}
136145

137146
NextHopKey nexthop = { ipAddress, alias };
138147
assert(!hasNextHop(nexthop));
@@ -185,7 +194,7 @@ bool NeighOrch::addNextHop(const IpAddress &ipAddress, const string &alias)
185194
gFgNhgOrch->validNextHopInNextHopGroup(nexthop);
186195

187196
// For nexthop with incoming port which has down oper status, NHFLAGS_IFDOWN
188-
// flag Should be set on it.
197+
// flag should be set on it.
189198
// This scenario may happen under race condition where buffered neighbor event
190199
// is processed after incoming port is down.
191200
if (p.m_oper_status == SAI_PORT_OPER_STATUS_DOWN)

orchagent/portsorch.cpp

+22-26
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ bool PortsOrch::addSubPort(Port &port, const string &alias, const bool &adminUp,
635635
}
636636
if (vlan_id > MAX_VALID_VLAN_ID)
637637
{
638-
SWSS_LOG_ERROR("sub interface %s Port object creation failed: invalid VLAN id %u", alias.c_str(), vlan_id);
638+
SWSS_LOG_ERROR("Sub interface %s Port object creation failed: invalid VLAN id %u", alias.c_str(), vlan_id);
639639
return false;
640640
}
641641

@@ -2815,7 +2815,6 @@ void PortsOrch::doLagTask(Consumer &consumer)
28152815
// Retrieve attributes
28162816
uint32_t mtu = 0;
28172817
string learn_mode;
2818-
bool operation_status_changed = false;
28192818
string operation_status;
28202819

28212820
for (auto i : kfvFieldsValues(t))
@@ -2837,16 +2836,6 @@ void PortsOrch::doLagTask(Consumer &consumer)
28372836
it++;
28382837
continue;
28392838
}
2840-
2841-
gNeighOrch->ifChangeInformNextHop(alias,
2842-
(operation_status == "up"));
2843-
Port lag;
2844-
if (getPort(alias, lag))
2845-
{
2846-
operation_status_changed =
2847-
(string_oper_status.at(operation_status) !=
2848-
lag.m_oper_status);
2849-
}
28502839
}
28512840
}
28522841

@@ -2868,19 +2857,13 @@ void PortsOrch::doLagTask(Consumer &consumer)
28682857
}
28692858
else
28702859
{
2871-
28722860
if (!operation_status.empty())
28732861
{
2874-
l.m_oper_status = string_oper_status.at(operation_status);
2862+
updatePortOperStatus(l, string_oper_status.at(operation_status));
2863+
28752864
m_portList[alias] = l;
28762865
}
2877-
if (operation_status_changed)
2878-
{
2879-
PortOperStateUpdate update;
2880-
update.port = l;
2881-
update.operStatus = string_oper_status.at(operation_status);
2882-
notify(SUBJECT_TYPE_PORT_OPER_STATE_CHANGE, static_cast<void *>(&update));
2883-
}
2866+
28842867
if (mtu != 0)
28852868
{
28862869
l.m_mtu = mtu;
@@ -4124,22 +4107,35 @@ void PortsOrch::updatePortOperStatus(Port &port, sai_port_oper_status_t status)
41244107
oper_status_strings.at(status).c_str());
41254108
if (status == port.m_oper_status)
41264109
{
4127-
return ;
4110+
return;
41284111
}
41294112

4130-
updateDbPortOperStatus(port, status);
4113+
if (port.m_type == Port::PHY)
4114+
{
4115+
updateDbPortOperStatus(port, status);
4116+
}
41314117
port.m_oper_status = status;
41324118

41334119
bool isUp = status == SAI_PORT_OPER_STATUS_UP;
4134-
if (!setHostIntfsOperStatus(port, isUp))
4120+
if (port.m_type == Port::PHY)
41354121
{
4136-
SWSS_LOG_ERROR("Failed to set host interface %s operational status %s", port.m_alias.c_str(),
4137-
isUp ? "up" : "down");
4122+
if (!setHostIntfsOperStatus(port, isUp))
4123+
{
4124+
SWSS_LOG_ERROR("Failed to set host interface %s operational status %s", port.m_alias.c_str(),
4125+
isUp ? "up" : "down");
4126+
}
41384127
}
41394128
if (!gNeighOrch->ifChangeInformNextHop(port.m_alias, isUp))
41404129
{
41414130
SWSS_LOG_WARN("Inform nexthop operation failed for interface %s", port.m_alias.c_str());
41424131
}
4132+
for (const auto &child_port : port.m_child_ports)
4133+
{
4134+
if (!gNeighOrch->ifChangeInformNextHop(child_port, isUp))
4135+
{
4136+
SWSS_LOG_WARN("Inform nexthop operation failed for sub interface %s", child_port.c_str());
4137+
}
4138+
}
41434139

41444140
PortOperStateUpdate update = {port, status};
41454141
notify(SUBJECT_TYPE_PORT_OPER_STATE_CHANGE, static_cast<void *>(&update));

orchagent/portsorch.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ static const map<sai_port_oper_status_t, string> oper_status_strings =
3737

3838
static const unordered_map<string, sai_port_oper_status_t> string_oper_status =
3939
{
40-
{ "unknown", SAI_PORT_OPER_STATUS_UNKNOWN },
41-
{ "up", SAI_PORT_OPER_STATUS_UP },
42-
{ "down", SAI_PORT_OPER_STATUS_DOWN },
43-
{ "testing", SAI_PORT_OPER_STATUS_TESTING },
40+
{ "unknown", SAI_PORT_OPER_STATUS_UNKNOWN },
41+
{ "up", SAI_PORT_OPER_STATUS_UP },
42+
{ "down", SAI_PORT_OPER_STATUS_DOWN },
43+
{ "testing", SAI_PORT_OPER_STATUS_TESTING },
4444
{ "not present", SAI_PORT_OPER_STATUS_NOT_PRESENT }
4545
};
4646

0 commit comments

Comments
 (0)