Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp158493pxx; Wed, 28 Oct 2020 01:04:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWUm2qyilQ5mxFABDZtZEVjQGJjHtbtHPPJYKw2DtOyLVm1PYeC89eeDRp2jwWLzzYYO2C X-Received: by 2002:a17:906:cb2:: with SMTP id k18mr1858422ejh.71.1603872242929; Wed, 28 Oct 2020 01:04:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603872242; cv=none; d=google.com; s=arc-20160816; b=LRzcpLnCSSc0VqoyvB5ghU3PwTPEmu62+ZerkdWWZvIxHNJedvW/hMpTSopsuAoawy XZcZyrACaeqG3gB9Zz/XGCeDKi5kwHS0ytDmbF53fgGBXqVaESWcSQ/oLk8U1qrL7qTz oyDrSmOFUe1Y0b96k+1gzNlO0p9aju1YBxvmFh4sVp+Za/q9OHwXxSXFFvT/sHs1NEbd 2COTcMYZgg/RIfbBNld6xoLRtdwuyrQrUVEZJ/bevU44cgELyz9u+k8jMME/EwFOouSE o/ldrpQf+5xMyvF4SnonX+YSnKEcnCVluhT2/ljw9IgJ9G8lxYboMuQNJUNjUI90zd0Z 3Suw== 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=HdZTXTvs0/Q+7cELvfssE/8HBt0K0ZL9v0LZVIXpPCc=; b=lUTw2cD83zYJ7q43DxS5a5ulOgW40D9ey5qDSlPr119p8aWa//8DcegNb5t5QaDjyX WFCHGac3TsoW8qNaOCQ7ZwPZRWXrcVUZ48xmQ72fflyWg4b9K+t9HUxrpKMzXmMICdVA 4uIesaqavqiAeTV2F6jKUwwSh2odZXNcY0eWKLfqpQpG/yYib0qD/2QM9qqkd25WMwh4 iubNSwdrcFZH7YZs9O7jUxyWncqJncdo6D42sIcMaRUeKvUpoQiAiN8cf/Z+XH/1hk7N G4VCn9/Ae7kMP8v+Ly9L8byCX9jmYwb1vP0wiQL29KuGHdKkksXVj6sAmAWRcKj7hcDe w01w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nESs2DbD; 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=fail (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 o10si2705925ejr.482.2020.10.28.01.03.39; Wed, 28 Oct 2020 01:04:02 -0700 (PDT) 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=@kernel.org header.s=default header.b=nESs2DbD; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752906AbgJ0N5g (ORCPT + 99 others); Tue, 27 Oct 2020 09:57:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:44436 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752895AbgJ0N5d (ORCPT ); Tue, 27 Oct 2020 09:57:33 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 84C6D206D4; Tue, 27 Oct 2020 13:57:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807053; bh=5Nrg9qNu3Torung5yikz1BNu29PkdABNgVSPZT+zAnY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nESs2DbD4u+C76TVGguTpzh1FjOmohPvT8QI6fErS5pLwgR+NI8faDdJS6rhSmofO 8DfN7cykmiUf48CzpYuz4w54gJRWljNN2mOStP9eVvSZjdDSBj3rrmeEa1XzXtgJJ2 rboPR6CwRPnVwKmwyHB1aXvMfNnFjUShYcz92M5U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Maciej=20=C5=BBenczykowski?= , Eric Dumazet , Willem de Bruijn , Lorenzo Colitti , "Sunmeet Gill (Sunny)" , Vinay Paradkar , Tyler Wear , David Ahern Subject: [PATCH 4.4 003/112] net/ipv4: always honour route mtu during forwarding Date: Tue, 27 Oct 2020 14:48:33 +0100 Message-Id: <20201027134900.696651369@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134900.532249571@linuxfoundation.org> References: <20201027134900.532249571@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: "Maciej Żenczykowski" [ Upstream commit 02a1b175b0e92d9e0fa5df3957ade8d733ceb6a0 ] Documentation/networking/ip-sysctl.txt:46 says: ip_forward_use_pmtu - BOOLEAN By default we don't trust protocol path MTUs while forwarding because they could be easily forged and can lead to unwanted fragmentation by the router. You only need to enable this if you have user-space software which tries to discover path mtus by itself and depends on the kernel honoring this information. This is normally not the case. Default: 0 (disabled) Possible values: 0 - disabled 1 - enabled Which makes it pretty clear that setting it to 1 is a potential security/safety/DoS issue, and yet it is entirely reasonable to want forwarded traffic to honour explicitly administrator configured route mtus (instead of defaulting to device mtu). Indeed, I can't think of a single reason why you wouldn't want to. Since you configured a route mtu you probably know better... It is pretty common to have a higher device mtu to allow receiving large (jumbo) frames, while having some routes via that interface (potentially including the default route to the internet) specify a lower mtu. Note that ipv6 forwarding uses device mtu unless the route is locked (in which case it will use the route mtu). This approach is not usable for IPv4 where an 'mtu lock' on a route also has the side effect of disabling TCP path mtu discovery via disabling the IPv4 DF (don't frag) bit on all outgoing frames. I'm not aware of a way to lock a route from an IPv6 RA, so that also potentially seems wrong. Signed-off-by: Maciej Żenczykowski Cc: Eric Dumazet Cc: Willem de Bruijn Cc: Lorenzo Colitti Cc: Sunmeet Gill (Sunny) Cc: Vinay Paradkar Cc: Tyler Wear Cc: David Ahern Reviewed-by: Eric Dumazet Signed-off-by: Greg Kroah-Hartman --- include/net/ip.h | 6 ++++++ 1 file changed, 6 insertions(+) --- a/include/net/ip.h +++ b/include/net/ip.h @@ -317,12 +317,18 @@ static inline unsigned int ip_dst_mtu_ma bool forwarding) { struct net *net = dev_net(dst->dev); + unsigned int mtu; if (net->ipv4.sysctl_ip_fwd_use_pmtu || ip_mtu_locked(dst) || !forwarding) return dst_mtu(dst); + /* 'forwarding = true' case should always honour route mtu */ + mtu = dst_metric_raw(dst, RTAX_MTU); + if (mtu) + return mtu; + return min(READ_ONCE(dst->dev->mtu), IP_MAX_MTU); }