From c0de64fc596505ee884500300aea0039591d8991 Mon Sep 17 00:00:00 2001 From: Tomasz Bursztyka Date: Thu, 21 Mar 2019 14:29:11 +0100 Subject: [PATCH] net/ipv6: Take iface's MTU into account to decide fragmenting or not In case of Ethernet for instance, the MTU is larger than the minimal IPv6 MTU, so it is not required to fragment a packet that fits in Ethernet MTU. Fixes #14659 Signed-off-by: Tomasz Bursztyka --- subsys/net/ip/ipv6_nbr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/subsys/net/ip/ipv6_nbr.c b/subsys/net/ip/ipv6_nbr.c index d459a8a39b..96c851ef48 100644 --- a/subsys/net/ip/ipv6_nbr.c +++ b/subsys/net/ip/ipv6_nbr.c @@ -663,9 +663,11 @@ enum net_verdict net_ipv6_prepare_for_send(struct net_pkt *pkt) * contain a proper value and we can skip other checks. */ if (net_pkt_ipv6_fragment_id(pkt) == 0) { + u16_t mtu = net_if_get_mtu(net_pkt_iface(pkt)); size_t pkt_len = net_pkt_get_len(pkt); - if (pkt_len > NET_IPV6_MTU) { + mtu = MAX(NET_IPV6_MTU, mtu); + if (mtu < pkt_len) { ret = net_ipv6_send_fragmented_pkt(net_pkt_iface(pkt), pkt, pkt_len); if (ret < 0) {