From 5a55ea5b888e083b944212b2ff2c50eb884f04a0 Mon Sep 17 00:00:00 2001 From: Shu0T1an ChenG Date: Fri, 10 Aug 2018 11:43:09 -0700 Subject: [PATCH] [intfsorch]: Add setRouterIntfsMtu function 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 --- orchagent/intfsorch.cpp | 26 ++++++++++++++++++++++++-- orchagent/intfsorch.h | 2 ++ orchagent/orchdaemon.cpp | 7 ++++--- orchagent/port.h | 2 +- orchagent/portsorch.cpp | 8 +++++++- 5 files changed, 38 insertions(+), 7 deletions(-) diff --git a/orchagent/intfsorch.cpp b/orchagent/intfsorch.cpp index a49b52ec4eb..3d67767c6d8 100644 --- a/orchagent/intfsorch.cpp +++ b/orchagent/intfsorch.cpp @@ -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; @@ -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(); @@ -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()); } diff --git a/orchagent/intfsorch.h b/orchagent/intfsorch.h index 0c08350d338..61df9dee591 100644 --- a/orchagent/intfsorch.h +++ b/orchagent/intfsorch.h @@ -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); diff --git a/orchagent/orchdaemon.cpp b/orchagent/orchdaemon.cpp index 26bd446da27..76b8611be32 100644 --- a/orchagent/orchdaemon.cpp +++ b/orchagent/orchdaemon.cpp @@ -22,6 +22,7 @@ extern sai_object_id_t gSwitchId; */ PortsOrch *gPortsOrch; FdbOrch *gFdbOrch; +IntfsOrch *gIntfsOrch; NeighOrch *gNeighOrch; RouteOrch *gRouteOrch; AclOrch *gAclOrch; @@ -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); @@ -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) diff --git a/orchagent/port.h b/orchagent/port.h index cd17d858a2e..4f955dab51e 100644 --- a/orchagent/port.h +++ b/orchagent/port.h @@ -11,7 +11,7 @@ extern "C" { #include #define DEFAULT_PORT_VLAN_ID 1 -#define DEFAULT_MTU 9100 +#define DEFAULT_MTU 9100 namespace swss { diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 8d6f58988c5..7c85eca5182 100644 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -1,4 +1,6 @@ #include "portsorch.h" +#include "intfsorch.h" +#include "bufferorch.h" #include "neighorch.h" #include @@ -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; @@ -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; @@ -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 {