Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4183816pxb; Mon, 8 Feb 2021 09:51:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJz1w2fT1jct6vRIC+AHeI3UUiRh3kxpXAg8uDhWGKvayUz8FtgBAb6GytoATSu9ARkWTBWB X-Received: by 2002:a50:8a90:: with SMTP id j16mr17845881edj.334.1612806691624; Mon, 08 Feb 2021 09:51:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612806691; cv=none; d=google.com; s=arc-20160816; b=bxX1+aiHbJCwulP6fICv7/aNb0oa4ga5983D1JKNoF9Ia7Z2mrKb+aKmDDKHKlNt7e q53Q8ZxE/Bq7IT+oB/0QPlkAsZlikltRcZ54VKiGhYnh42E9tthVMykoMnNpgqKt0vgY Vc2jlS5aHADhYw3T9QwUpH4dCzo+VM0IywcMCWE6PUUgPH9QKrxh1ff0bIIL5V4A7Ka8 UuJN2ZG4ZRm9LV1yHSbgOBHWo61xu35gML4Z2DkH2CuOQv8xJXNRdZNWqgvAJJf1ORqs gNDoQsfgjOFVWng09kNOM2Z9ONi3KcVDukXiXKSgmBWm7N2ZJYe8fwXfeLFfy9dmFH9s +XmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gDwES1V/LsMl+6ikWbSYI3kCm58l00xJ4Jft+oFFo7o=; b=wFF6G0qnWeia0erTp80hnHofir1xP0OYVb0dQfpKW513dAzniUhhtuT6qzJ78AbFaL 7hhNrvHP+bSgZ/uq+6vqYnRkT5gXn/v7Ao3TeaiNsOcre7ihFQCwENVBBlZ8hphDPnTs KxeU+577YT5uANsulSj71px2WkdU9b3Os0nSiUQ44ubkl7wHypUIwymtVZrrQrzhTw18 ir/bOTXlN6UoMP3oVpeaQhprzqpa5HcBrOLDBrhvX8vq4HiWKCBGalwahfv4JF1MMH4T Qc3vL1WNkb25a7pGZxs5toviVydicomTgDPI5kgk7UoWkERBQQVHQYo2c1/YEQ9OHmdF 20XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=n5qazUw9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si11496549ejr.403.2021.02.08.09.50.53; Mon, 08 Feb 2021 09:51:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=n5qazUw9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235059AbhBHRrv (ORCPT + 99 others); Mon, 8 Feb 2021 12:47:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:37472 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233914AbhBHPbi (ORCPT ); Mon, 8 Feb 2021 10:31:38 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 81A7564F3A; Mon, 8 Feb 2021 15:17:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612797459; bh=vMWd2lQQiMZKvbzsS4XGw8xLwCAi604h9mQ2hsjrLng=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n5qazUw9ZqVfsdFS4MKAxJBAlp2W01K2683pfhdTo9aXXAJop6/FO5KsvxxqOsTCm 2sqPPvdQF9+hLNBu3XEHrlJoGAmwwcjeTxmqM39jowcbCLDKTT02fLX0TLwQJP/j0r s7ryxpJEpn0wVYVKJT+A3h3fwC+rQxQKW8l/hl4c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Slava Bacherikov , Vadim Fedorenko , Jakub Kicinski Subject: [PATCH 5.10 117/120] net: ip_tunnel: fix mtu calculation Date: Mon, 8 Feb 2021 16:01:44 +0100 Message-Id: <20210208145823.036421817@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208145818.395353822@linuxfoundation.org> References: <20210208145818.395353822@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vadim Fedorenko commit 28e104d00281ade30250b24e098bf50887671ea4 upstream. dev->hard_header_len for tunnel interface is set only when header_ops are set too and already contains full overhead of any tunnel encapsulation. That's why there is not need to use this overhead twice in mtu calc. Fixes: fdafed459998 ("ip_gre: set dev->hard_header_len and dev->needed_headroom properly") Reported-by: Slava Bacherikov Signed-off-by: Vadim Fedorenko Link: https://lore.kernel.org/r/1611959267-20536-1-git-send-email-vfedorenko@novek.ru Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/ipv4/ip_tunnel.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) --- a/net/ipv4/ip_tunnel.c +++ b/net/ipv4/ip_tunnel.c @@ -317,7 +317,7 @@ static int ip_tunnel_bind_dev(struct net } dev->needed_headroom = t_hlen + hlen; - mtu -= (dev->hard_header_len + t_hlen); + mtu -= t_hlen; if (mtu < IPV4_MIN_MTU) mtu = IPV4_MIN_MTU; @@ -347,7 +347,7 @@ static struct ip_tunnel *ip_tunnel_creat nt = netdev_priv(dev); t_hlen = nt->hlen + sizeof(struct iphdr); dev->min_mtu = ETH_MIN_MTU; - dev->max_mtu = IP_MAX_MTU - dev->hard_header_len - t_hlen; + dev->max_mtu = IP_MAX_MTU - t_hlen; ip_tunnel_add(itn, nt); return nt; @@ -488,11 +488,10 @@ static int tnl_update_pmtu(struct net_de int mtu; tunnel_hlen = md ? tunnel_hlen : tunnel->hlen; - pkt_size = skb->len - tunnel_hlen - dev->hard_header_len; + pkt_size = skb->len - tunnel_hlen; if (df) - mtu = dst_mtu(&rt->dst) - dev->hard_header_len - - sizeof(struct iphdr) - tunnel_hlen; + mtu = dst_mtu(&rt->dst) - (sizeof(struct iphdr) + tunnel_hlen); else mtu = skb_valid_dst(skb) ? dst_mtu(skb_dst(skb)) : dev->mtu; @@ -972,7 +971,7 @@ int __ip_tunnel_change_mtu(struct net_de { struct ip_tunnel *tunnel = netdev_priv(dev); int t_hlen = tunnel->hlen + sizeof(struct iphdr); - int max_mtu = IP_MAX_MTU - dev->hard_header_len - t_hlen; + int max_mtu = IP_MAX_MTU - t_hlen; if (new_mtu < ETH_MIN_MTU) return -EINVAL; @@ -1149,10 +1148,9 @@ int ip_tunnel_newlink(struct net_device mtu = ip_tunnel_bind_dev(dev); if (tb[IFLA_MTU]) { - unsigned int max = IP_MAX_MTU - dev->hard_header_len - nt->hlen; + unsigned int max = IP_MAX_MTU - (nt->hlen + sizeof(struct iphdr)); - mtu = clamp(dev->mtu, (unsigned int)ETH_MIN_MTU, - (unsigned int)(max - sizeof(struct iphdr))); + mtu = clamp(dev->mtu, (unsigned int)ETH_MIN_MTU, max); } err = dev_set_mtu(dev, mtu);