From 39bfa1615fd1cafe5df6d8fc9d34528e8d3906e2 Mon Sep 17 00:00:00 2001 From: Pim van Pelt Date: Fri, 13 Aug 2021 15:02:31 +0200 Subject: [PATCH] Add sync of VPP mtu changes into Linux interfaces This is a straight foward copy of the VPP L3 (packet) MTU into the Linux host interface, for any change on an interface/sub-int for which a LIP is defined. As with Linux itself, no care is taken to ensure that the parent interface (e0) has a higher MTU than the child interface (e0.10). DBGvpp# create sub TenGigabitEthernet3/0/0 10 DBGvpp# lcp create TenGigabitEthernet3/0/0 host-if e0 DBGvpp# lcp create TenGigabitEthernet3/0/0.10 host-if e0.10 602: e0: mtu 9000 qdisc mq state DOWN mode DEFAULT group default qlen 1000 603: e0.10@e0: mtu 9000 qdisc noop state DOWN mode DEFAULT group default qlen 1000 DBGvpp# set interface mtu packet 9216 TenGigabitEthernet3/0/0 602: e0: mtu 9216 qdisc mq state DOWN mode DEFAULT group default qlen 1000 603: e0.10@e0: mtu 9000 qdisc noop state DOWN mode DEFAULT group default qlen 1000 DBGvpp# set interface mtu packet 9050 TenGigabitEthernet3/0/0 602: e0: mtu 9050 qdisc mq state DOWN mode DEFAULT group default qlen 1000 603: e0.10@e0: mtu 9000 qdisc noop state DOWN mode DEFAULT group default qlen 1000 DBGvpp# set interface mtu packet 9050 TenGigabitEthernet3/0/0.10 602: e0: mtu 9050 qdisc mq state DOWN mode DEFAULT group default qlen 1000 603: e0.10@e0: mtu 9050 qdisc noop state DOWN mode DEFAULT group default qlen 1000 DBGvpp# set interface mtu packet 1500 TenGigabitEthernet3/0/0.10 602: e0: mtu 9050 qdisc mq state DOWN mode DEFAULT group default qlen 1000 603: e0.10@e0: mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 DBGvpp# set interface mtu packet 1500 TenGigabitEthernet3/0/0 602: e0: mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000 603: e0.10@e0: mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 --- lcpng_if_sync.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lcpng_if_sync.c b/lcpng_if_sync.c index ff93c24..2f61c06 100644 --- a/lcpng_if_sync.c +++ b/lcpng_if_sync.c @@ -95,3 +95,30 @@ lcp_itf_admin_state_change (vnet_main_t * vnm, u32 sw_if_index, u32 flags) } VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION(lcp_itf_admin_state_change); + +static clib_error_t * +lcp_itf_mtu_change (vnet_main_t *vnm, u32 sw_if_index, u32 flags) +{ + const lcp_itf_pair_t *lip; + vnet_sw_interface_t *si; + + LCP_ITF_PAIR_DBG ("mtu_change: sw %U %u", format_vnet_sw_if_index_name, vnm, + sw_if_index, flags); + + // Sync interface state changes into host + lip = lcp_itf_pair_get (lcp_itf_pair_find_by_phy (sw_if_index)); + if (!lip) + return NULL; + + si = vnet_get_sw_interface_or_null (vnm, sw_if_index); + if (!si) + return NULL; + + LCP_ITF_PAIR_INFO ("mtu_change: %U mtu %u", format_lcp_itf_pair, lip, + si->mtu[VNET_MTU_L3]); + vnet_netlink_set_link_mtu (lip->lip_vif_index, si->mtu[VNET_MTU_L3]); + + return NULL; +} + +VNET_SW_INTERFACE_MTU_CHANGE_FUNCTION (lcp_itf_mtu_change);