Skip to content

Commit

Permalink
[subport] Allow to add Subport without vlan argument
Browse files Browse the repository at this point in the history
The alias of subport already contains the VLAN ID information. If no vlan
be specified in the input argument, it would use the vlan in the alias as
the vlan id
  • Loading branch information
gord1306 committed Jul 23, 2024
1 parent 5081dfb commit a3e64ab
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1237,13 +1237,21 @@ bool PortsOrch::addSubPort(Port &port, const string &alias, const string &vlan,
subIntf subIf(alias);
string parentAlias = subIf.parentIntf();
sai_vlan_id_t vlan_id;

try
{
vlan_id = static_cast<sai_vlan_id_t>(stoul(vlan));
if (vlan.empty())
{
vlan_id = static_cast<sai_vlan_id_t>(subIf.subIntfIdx());
}
else
{
vlan_id = static_cast<sai_vlan_id_t>(stoul(vlan));
}
}
catch (const std::invalid_argument &e)
{
SWSS_LOG_ERROR("Invalid argument %s to %s()", vlan.c_str(), e.what());
SWSS_LOG_ERROR("Invalid arguments alias %s or vlan %s to %s()", alias.c_str(), vlan.c_str(), e.what());
return false;
}
catch (const std::out_of_range &e)
Expand Down

0 comments on commit a3e64ab

Please sign in to comment.