Skip to content

Commit fab3cea

Browse files
hzheng5lguohan
authored andcommitted
add IP mtu support for port and lag (sonic-net#402)
* [mtu] Update the mtu on host interfaces if config DB changes * [mtu] Get ip mtu val from port while create router interfaces * Portsorch updates port.m_mtu whenever PORT/LAG mtu changes * Intfsorch applies port.m_mtu as SAI_ROUTER_INTERFACE_ATTR_MTU while creating the router interfaces over the PORT/LAG Signed-off-by: Haiyang Zheng <[email protected]>
1 parent a46eaf7 commit fab3cea

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

orchagent/intfsorch.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ bool IntfsOrch::addRouterIntfs(Port &port)
259259
}
260260
attrs.push_back(attr);
261261

262+
attr.id = SAI_ROUTER_INTERFACE_ATTR_MTU;
263+
attr.value.u32 = port.m_mtu;
264+
attrs.push_back(attr);
265+
262266
sai_status_t status = sai_router_intfs_api->create_router_interface(&port.m_rif_id, gSwitchId, (uint32_t)attrs.size(), attrs.data());
263267
if (status != SAI_STATUS_SUCCESS)
264268
{
@@ -268,7 +272,7 @@ bool IntfsOrch::addRouterIntfs(Port &port)
268272

269273
gPortsOrch->setPort(port.m_alias, port);
270274

271-
SWSS_LOG_NOTICE("Create router interface for port %s", port.m_alias.c_str());
275+
SWSS_LOG_NOTICE("Create router interface for port %s mtu %u", port.m_alias.c_str(), port.m_mtu);
272276

273277
return true;
274278
}

orchagent/port.h

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ extern "C" {
1111
#include <map>
1212

1313
#define DEFAULT_PORT_VLAN_ID 1
14+
#define DEFAULT_MTU 9100
1415

1516
namespace swss {
1617

@@ -64,6 +65,7 @@ class Port
6465
Type m_type;
6566
int m_index = 0; // PHY_PORT: index
6667
int m_ifindex = 0;
68+
uint32_t m_mtu = DEFAULT_MTU;
6769
sai_object_id_t m_port_id = 0;
6870
sai_port_fec_mode_t m_fec_mode = SAI_PORT_FEC_MODE_NONE;
6971
VlanInfo m_vlan_info;

orchagent/portsorch.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1127,6 +1127,7 @@ void PortsOrch::doPortTask(Consumer &consumer)
11271127
{
11281128
if (setPortMtu(p.m_port_id, mtu))
11291129
{
1130+
p.m_mtu = mtu;
11301131
SWSS_LOG_NOTICE("Set port %s MTU to %u", alias.c_str(), mtu);
11311132
}
11321133
else

0 commit comments

Comments
 (0)