From ffd78d1ef8fe80d1b756a71d42d5eadda60ae996 Mon Sep 17 00:00:00 2001 From: Neale Ranns Date: Fri, 9 Feb 2018 06:05:16 -0800 Subject: Improve MTU handling - setting MTU on an interface updates the L3 max bytes too - value cached in the adjacency is also updated - MTU exceeded generates ICMP to sender Change-Id: I343ec71d8e903b529594c4bd0543f04bc7f370b3 Signed-off-by: Neale Ranns --- src/vnet/adj/adj.c | 37 +++++++++++++++++++++++++++++++++++++ src/vnet/adj/adj.h | 6 ++++++ src/vnet/adj/rewrite.c | 12 +++++++++--- src/vnet/adj/rewrite.h | 3 +++ 4 files changed, 55 insertions(+), 3 deletions(-) (limited to 'src/vnet/adj') diff --git a/src/vnet/adj/adj.c b/src/vnet/adj/adj.c index 5f7fe74cd43..d28d5195330 100644 --- a/src/vnet/adj/adj.c +++ b/src/vnet/adj/adj.c @@ -338,6 +338,43 @@ adj_feature_update (u32 sw_if_index, adj_walk (sw_if_index, adj_feature_update_walk_cb, &ctx); } +static adj_walk_rc_t +adj_mtu_update_walk_cb (adj_index_t ai, + void *arg) +{ + ip_adjacency_t *adj; + + adj = adj_get(ai); + + vnet_rewrite_update_mtu (vnet_get_main(), + &adj->rewrite_header); + + return (ADJ_WALK_RC_CONTINUE); +} + +static void +adj_sw_mtu_update (vnet_main_t * vnm, + u32 sw_if_index, + void *ctx) +{ + /* + * Walk all the adjacencies on the interface to update the cached MTU + */ + adj_walk (sw_if_index, adj_mtu_update_walk_cb, NULL); +} + +void +adj_mtu_update (u32 hw_if_index) +{ + /* + * Walk all the SW interfaces on the HW interface to update the cached MTU + */ + vnet_hw_interface_walk_sw(vnet_get_main(), + hw_if_index, + adj_sw_mtu_update, + NULL); +} + /** * @brief Walk the Adjacencies on a given interface */ diff --git a/src/vnet/adj/adj.h b/src/vnet/adj/adj.h index fe77d1634e0..bcf6c041209 100644 --- a/src/vnet/adj/adj.h +++ b/src/vnet/adj/adj.h @@ -344,6 +344,12 @@ extern const u8* adj_get_rewrite (adj_index_t ai); */ extern void adj_feature_update (u32 sw_if_index, u8 arc_index, u8 is_enable); +/** + * @brief Notify the adjacency subsystem that the MTU settings for + * an HW interface have changed + */ +extern void adj_mtu_update (u32 hw_if_index); + /** * @brief * The global adjacnecy pool. Exposed for fast/inline data-plane access diff --git a/src/vnet/adj/rewrite.c b/src/vnet/adj/rewrite.c index 9150f2c6c37..c21495a9644 100644 --- a/src/vnet/adj/rewrite.c +++ b/src/vnet/adj/rewrite.c @@ -77,15 +77,14 @@ format_vnet_rewrite (u8 * s, va_list * args) vnet_sw_interface_t *si; si = vnet_get_sw_interface_safe (vnm, rw->sw_if_index); if (NULL != si) - s = format (s, "%U: ", format_vnet_sw_interface_name, vnm, si); + s = format (s, "%U:", format_vnet_sw_interface_name, vnm, si); else s = format (s, "DELETED:%d", rw->sw_if_index); } /* Format rewrite string. */ if (rw->data_bytes > 0) - - s = format (s, "%U", + s = format (s, " %U", format_hex_bytes, rw->data + max_data_bytes - rw->data_bytes, rw->data_bytes); @@ -110,6 +109,13 @@ vnet_rewrite_init (vnet_main_t * vnm, vnet_sw_interface_get_mtu (vnm, sw_if_index, VLIB_TX); } +void +vnet_rewrite_update_mtu (vnet_main_t * vnm, vnet_rewrite_header_t * rw) +{ + rw->max_l3_packet_bytes = + vnet_sw_interface_get_mtu (vnm, rw->sw_if_index, VLIB_TX); +} + void vnet_rewrite_for_sw_interface (vnet_main_t * vnm, vnet_link_t link_type, diff --git a/src/vnet/adj/rewrite.h b/src/vnet/adj/rewrite.h index 1dea72f5ed8..005ac41fe72 100644 --- a/src/vnet/adj/rewrite.h +++ b/src/vnet/adj/rewrite.h @@ -328,6 +328,9 @@ void vnet_rewrite_init (struct vnet_main_t *vnm, u32 this_node, u32 next_node, vnet_rewrite_header_t * rw); +void vnet_rewrite_update_mtu (struct vnet_main_t *vnm, + vnet_rewrite_header_t * rw); + u8 *vnet_build_rewrite_for_sw_interface (struct vnet_main_t *vnm, u32 sw_if_index, vnet_link_t packet_type, -- cgit 1.2.3-korg