Skip to content

Commit

Permalink
Align orchagent MTU value as SAI default (sonic-net#713)
Browse files Browse the repository at this point in the history
* Default orchagent MTU value change 

* Fix for LAG and VLAN mtu values
  • Loading branch information
prsunny authored Nov 28, 2018
1 parent fbe7dc7 commit 823aab5
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
13 changes: 8 additions & 5 deletions cfgmgr/vlanmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ using namespace swss;
#define VLAN_PREFIX "Vlan"
#define LAG_PREFIX "PortChannel"
#define DEFAULT_VLAN_ID "1"
#define MAX_MTU 9100
#define DEFAULT_MTU_STR "9100"
#define VLAN_HLEN 4

extern MacAddress gMacAddress;
Expand Down Expand Up @@ -246,7 +246,7 @@ void VlanMgr::doVlanTask(Consumer &consumer)
if (op == SET_COMMAND)
{
string admin_status;
uint32_t mtu = 0;
string mtu = DEFAULT_MTU_STR;
vector<FieldValueTuple> fvVector;
string members;

Expand Down Expand Up @@ -282,14 +282,13 @@ void VlanMgr::doVlanTask(Consumer &consumer)
/* Set vlan mtu */
else if (fvField(i) == "mtu")
{
mtu = (uint32_t)stoul(fvValue(i));
mtu = fvValue(i);
/*
* TODO: support host VLAN mtu setting.
* Host VLAN mtu should be set only after member configured
* and VLAN state is not UNKNOWN.
*/
SWSS_LOG_DEBUG("%s mtu %u: Host VLAN mtu setting to be supported.", key.c_str(), mtu);
fvVector.push_back(i);
SWSS_LOG_DEBUG("%s mtu %s: Host VLAN mtu setting to be supported.", key.c_str(), mtu.c_str());
}
else if (fvField(i) == "members@") {
members = fvValue(i);
Expand All @@ -301,6 +300,10 @@ void VlanMgr::doVlanTask(Consumer &consumer)
FieldValueTuple a("admin_status", "up");
fvVector.push_back(a);
}

FieldValueTuple m("mtu", mtu);
fvVector.push_back(m);

m_appVlanTableProducer.set(key, fvVector);
m_vlans.insert(key);

Expand Down
7 changes: 6 additions & 1 deletion orchagent/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ extern "C" {
#include <map>

#define DEFAULT_PORT_VLAN_ID 1
#define DEFAULT_MTU 9100
/*
* Default MTU is derived from SAI_PORT_ATTR_MTU (1514)
* Orchagent adds extra 22 bytes for Ethernet header and FCS,
* hence setting to 1492 (1514 - 22)
*/
#define DEFAULT_MTU 1492

namespace swss {

Expand Down
31 changes: 30 additions & 1 deletion orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1870,6 +1870,16 @@ void PortsOrch::doVlanTask(Consumer &consumer)

if (op == SET_COMMAND)
{
// Retrieve attributes
uint32_t mtu = 0;
for (auto i : kfvFieldsValues(t))
{
if (fvField(i) == "mtu")
{
mtu = (uint32_t)stoul(fvValue(i));
}
}

/*
* Only creation is supported for now.
* We may add support for VLAN mac learning enable/disable,
Expand All @@ -1884,6 +1894,25 @@ void PortsOrch::doVlanTask(Consumer &consumer)
}
}

// Process attributes
Port vl;
if (!getPort(vlan_alias, vl))
{
SWSS_LOG_ERROR("Failed to get VLAN %s", vlan_alias.c_str());
}
else
{
if (mtu != 0)
{
vl.m_mtu = mtu;
m_portList[vlan_alias] = vl;
if (vl.m_rif_id)
{
gIntfsOrch->setRouterIntfsMtu(vl);
}
}
}

it = consumer.m_toSync.erase(it);
}
else if (op == DEL_COMMAND)
Expand Down Expand Up @@ -2063,7 +2092,7 @@ void PortsOrch::doLagTask(Consumer &consumer)
}
else
{
if (mtu != 0 && l.m_rif_id)
if (mtu != 0)
{
l.m_mtu = mtu;
m_portList[alias] = l;
Expand Down

0 comments on commit 823aab5

Please sign in to comment.