From a68d6f1a9a9e9b471085c5d0231d1e3a0fad92c8 Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Mon, 6 May 2019 12:37:19 +0200 Subject: [PATCH] Fix bug #56136: The netif->mtu6 was updated by Router Advertisement abnomally Using patch from Gao Quingahui plus improvement --- src/core/ipv6/nd6.c | 2 +- src/core/netif.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/ipv6/nd6.c b/src/core/ipv6/nd6.c index 1e7c94ce..d65ed4e1 100644 --- a/src/core/ipv6/nd6.c +++ b/src/core/ipv6/nd6.c @@ -697,7 +697,7 @@ nd6_input(struct pbuf *p, struct netif *inp) #if LWIP_ND6_ALLOW_RA_UPDATES if (inp->mtu) { /* don't set the mtu for IPv6 higher than the netif driver supports */ - inp->mtu6 = LWIP_MIN(inp->mtu, (u16_t)mtu32); + inp->mtu6 = LWIP_MIN(LWIP_MIN(inp->mtu, inp->mtu6), (u16_t)mtu32); } else { inp->mtu6 = (u16_t)mtu32; } diff --git a/src/core/netif.c b/src/core/netif.c index 15200a27..e95cb672 100644 --- a/src/core/netif.c +++ b/src/core/netif.c @@ -1031,6 +1031,10 @@ netif_set_link_down(struct netif *netif) if (netif->flags & NETIF_FLAG_LINK_UP) { netif_clear_flags(netif, NETIF_FLAG_LINK_UP); +#if LWIP_IPV6 && LWIP_ND6_ALLOW_RA_UPDATES + netif->mtu6 = netif->mtu; +#endif + NETIF_LINK_CALLBACK(netif); #if LWIP_NETIF_EXT_STATUS_CALLBACK {