Skip to content

Commit

Permalink
[intfsorch]: Add setRouterIntfsMtu function
Browse files Browse the repository at this point in the history
This function allows the propagation of MTU from port MTU to router
interface MTU if the router interface is created based on this port.

Once the port MTU gets changes, the router interface MTU will also
get changed.

Signed-off-by: Shu0T1an ChenG <[email protected]>
  • Loading branch information
Shu0T1an ChenG committed Aug 10, 2018
1 parent d220a80 commit 5a55ea5
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 7 deletions.
26 changes: 24 additions & 2 deletions orchagent/intfsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ extern sai_router_interface_api_t* sai_router_intfs_api;
extern sai_route_api_t* sai_route_api;
extern sai_neighbor_api_t* sai_neighbor_api;

extern PortsOrch *gPortsOrch;
extern sai_object_id_t gSwitchId;
extern PortsOrch *gPortsOrch;
extern CrmOrch *gCrmOrch;
extern BufferOrch *gBufferOrch;

Expand Down Expand Up @@ -57,6 +57,27 @@ void IntfsOrch::decreaseRouterIntfsRefCount(const string &alias)
alias.c_str(), m_syncdIntfses[alias].ref_count);
}

bool IntfsOrch::setRouterIntfsMtu(Port &port)
{
SWSS_LOG_ENTER();

sai_attribute_t attr;
attr.id = SAI_ROUTER_INTERFACE_ATTR_MTU;
attr.value.u32 = port.m_mtu;

sai_status_t status = sai_router_intfs_api->
set_router_interface_attribute(port.m_rif_id, &attr);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to set router interface %s MTU to %u, rv:%d",
port.m_alias.c_str(), port.m_mtu, status);
return false;
}
SWSS_LOG_NOTICE("Set router interface %s MTU to %u",
port.m_alias.c_str(), port.m_mtu);
return true;
}

void IntfsOrch::doTask(Consumer &consumer)
{
SWSS_LOG_ENTER();
Expand Down Expand Up @@ -159,7 +180,8 @@ void IntfsOrch::doTask(Consumer &consumer)

addSubnetRoute(port, ip_prefix);
addIp2MeRoute(ip_prefix);
if(port.m_type == Port::VLAN && ip_prefix.isV4())

if (port.m_type == Port::VLAN && ip_prefix.isV4())
{
addDirectedBroadcast(port, ip_prefix.getBroadcastIp());
}
Expand Down
2 changes: 2 additions & 0 deletions orchagent/intfsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class IntfsOrch : public Orch

void increaseRouterIntfsRefCount(const string&);
void decreaseRouterIntfsRefCount(const string&);

bool setRouterIntfsMtu(Port &port);
private:
IntfsTable m_syncdIntfses;
void doTask(Consumer &consumer);
Expand Down
7 changes: 4 additions & 3 deletions orchagent/orchdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ extern sai_object_id_t gSwitchId;
*/
PortsOrch *gPortsOrch;
FdbOrch *gFdbOrch;
IntfsOrch *gIntfsOrch;
NeighOrch *gNeighOrch;
RouteOrch *gRouteOrch;
AclOrch *gAclOrch;
Expand Down Expand Up @@ -64,8 +65,8 @@ bool OrchDaemon::init()
gCrmOrch = new CrmOrch(m_configDb, CFG_CRM_TABLE_NAME);
gPortsOrch = new PortsOrch(m_applDb, ports_tables);
gFdbOrch = new FdbOrch(m_applDb, APP_FDB_TABLE_NAME, gPortsOrch);
IntfsOrch *intfs_orch = new IntfsOrch(m_applDb, APP_INTF_TABLE_NAME);
gNeighOrch = new NeighOrch(m_applDb, APP_NEIGH_TABLE_NAME, intfs_orch);
gIntfsOrch = new IntfsOrch(m_applDb, APP_INTF_TABLE_NAME);
gNeighOrch = new NeighOrch(m_applDb, APP_NEIGH_TABLE_NAME, gIntfsOrch);
gRouteOrch = new RouteOrch(m_applDb, APP_ROUTE_TABLE_NAME, gNeighOrch);
CoppOrch *copp_orch = new CoppOrch(m_applDb, APP_COPP_TABLE_NAME);
TunnelDecapOrch *tunnel_decap_orch = new TunnelDecapOrch(m_applDb, APP_TUNNEL_DECAP_TABLE_NAME);
Expand Down Expand Up @@ -116,7 +117,7 @@ bool OrchDaemon::init()
CFG_DTEL_EVENT_TABLE_NAME
};

m_orchList = { switch_orch, gCrmOrch, gBufferOrch, gPortsOrch, intfs_orch, gNeighOrch, gRouteOrch, copp_orch, tunnel_decap_orch, qos_orch, mirror_orch };
m_orchList = { switch_orch, gCrmOrch, gBufferOrch, gPortsOrch, gIntfsOrch, gNeighOrch, gRouteOrch, copp_orch, tunnel_decap_orch, qos_orch, mirror_orch };

bool initialize_dtel = false;
if (platform == BFN_PLATFORM_SUBSTRING || platform == VS_PLATFORM_SUBSTRING)
Expand Down
2 changes: 1 addition & 1 deletion orchagent/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extern "C" {
#include <map>

#define DEFAULT_PORT_VLAN_ID 1
#define DEFAULT_MTU 9100
#define DEFAULT_MTU 9100

namespace swss {

Expand Down
8 changes: 7 additions & 1 deletion orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "portsorch.h"
#include "intfsorch.h"
#include "bufferorch.h"
#include "neighorch.h"

#include <cassert>
Expand All @@ -18,7 +20,6 @@
#include "sai_serialize.h"
#include "crmorch.h"
#include "countercheckorch.h"
#include "bufferorch.h"
#include "notifier.h"

extern sai_switch_api_t *sai_switch_api;
Expand All @@ -30,6 +31,7 @@ extern sai_hostif_api_t* sai_hostif_api;
extern sai_acl_api_t* sai_acl_api;
extern sai_queue_api_t *sai_queue_api;
extern sai_object_id_t gSwitchId;
extern IntfsOrch *gIntfsOrch;
extern NeighOrch *gNeighOrch;
extern CrmOrch *gCrmOrch;
extern BufferOrch *gBufferOrch;
Expand Down Expand Up @@ -1532,6 +1534,10 @@ void PortsOrch::doPortTask(Consumer &consumer)
p.m_mtu = mtu;
m_portList[alias] = p;
SWSS_LOG_NOTICE("Set port %s MTU to %u", alias.c_str(), mtu);
if (p.m_rif_id)
{
gIntfsOrch->setRouterIntfsMtu(p);
}
}
else
{
Expand Down

0 comments on commit 5a55ea5

Please sign in to comment.