Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2273426pxb; Mon, 11 Jan 2021 05:45:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJyZ/ytvOsKKxVA7sKG853+kVFgLPWOvKEuPbPEI/VgVoWghMOC5JJDCTDGug0RyEW4PJd8F X-Received: by 2002:a17:906:cf81:: with SMTP id um1mr11157254ejb.122.1610372757026; Mon, 11 Jan 2021 05:45:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610372757; cv=none; d=google.com; s=arc-20160816; b=d+owBkAdKp9Idwgo50VwDlFeuOE9/AZXGBNrL1deloy7OKatDDubkQKTYX0X3NH+bj AnCjNjQkHlSAwYJRNJObHLnVCrM5oXRiSnVdoVUAz7W8247/WCePHnKK9e6cDsy3WTNG 4SlQsqCjXPhassqRVOsVe9E58/MRyep76IZYgO2JteFPkgtHO97n07uRWt75sHjin7x4 tJocOU1yCoY5UNm0TMUSR1X+DyFR1/FGxrQbIgefN5Kacy4vRB26Hkg+90C4wmwUapoc fjvb0sKOlaB47Kf1bqUYBtYmUfl3QBIezUtuBt9RbTD10tH/m9OsLbvT2ac5RfYUlQjb 5n8Q== 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=FLPQtYg76aZt1H917leaLPnVf/dGJT/h6mXnVE7C6sY=; b=UjeqB+Mur6UKDxn9AN39YUCnTb3dq6ILQWm2dmmHAalyHOpiZakSv7OQ5GUFwRo8Ci 23ErwJGaX48MMOPIrFXTxUwDdZ69RfdDhA1XIEZJ8AELEdp76BrB7wxlOWnc8w4Cf/6C 6kRdU4SD8FHcRmmISyCMuLpg9QmJnfXd3uHMeJI+EOuondO4CUmE6j7D+L+qxQSk2+Ix wlNVnVtBkeTc3EMqziMWS5WT0gX8g+sc4DkZ8QIJzcJzTBqjC5elLoMVBbXiFgnStuhV ZtMMtmOLUSMm/JRlI1oNAmUoftVVHNIAIZpbL2LsiqpwfW6ewtsvqcVlWoT59ioIeui3 6v8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="SEObD/0m"; 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 g3si6457101ejf.612.2021.01.11.05.45.32; Mon, 11 Jan 2021 05:45:57 -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="SEObD/0m"; 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 S2387523AbhAKNmw (ORCPT + 99 others); Mon, 11 Jan 2021 08:42:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:58310 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730854AbhAKNME (ORCPT ); Mon, 11 Jan 2021 08:12:04 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3B3BB229C4; Mon, 11 Jan 2021 13:11:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610370708; bh=SoE5L+xLOHSO4s0H0GXXzM6KwEtcX67+LjFiMjJRfCo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SEObD/0mrukaIimr2gok7O/4F9D/ygLqJN9z+g5anZqTjImcX22Jpmo0QhzC4afT+ u2MTia7hZ/fz9uWoTzTizDtu/Hw1RyzCpjv9WZjBhHZnNGxYxmBVGydFxqvkC58ka/ 9UtFE7afH4/11Hun04Qw8zNSp2V9r4nXWnHomrOA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guillaume Nault , "David S. Miller" Subject: [PATCH 5.4 33/92] ipv4: Ignore ECN bits for fib lookups in fib_compute_spec_dst() Date: Mon, 11 Jan 2021 14:01:37 +0100 Message-Id: <20210111130040.742940184@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210111130039.165470698@linuxfoundation.org> References: <20210111130039.165470698@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: Guillaume Nault [ Upstream commit 21fdca22eb7df2a1e194b8adb812ce370748b733 ] RT_TOS() only clears one of the ECN bits. Therefore, when fib_compute_spec_dst() resorts to a fib lookup, it can return different results depending on the value of the second ECN bit. For example, ECT(0) and ECT(1) packets could be treated differently. $ ip netns add ns0 $ ip netns add ns1 $ ip link add name veth01 netns ns0 type veth peer name veth10 netns ns1 $ ip -netns ns0 link set dev lo up $ ip -netns ns1 link set dev lo up $ ip -netns ns0 link set dev veth01 up $ ip -netns ns1 link set dev veth10 up $ ip -netns ns0 address add 192.0.2.10/24 dev veth01 $ ip -netns ns1 address add 192.0.2.11/24 dev veth10 $ ip -netns ns1 address add 192.0.2.21/32 dev lo $ ip -netns ns1 route add 192.0.2.10/32 tos 4 dev veth10 src 192.0.2.21 $ ip netns exec ns1 sysctl -wq net.ipv4.icmp_echo_ignore_broadcasts=0 With TOS 4 and ECT(1), ns1 replies using source address 192.0.2.21 (ping uses -Q to set all TOS and ECN bits): $ ip netns exec ns0 ping -c 1 -b -Q 5 192.0.2.255 [...] 64 bytes from 192.0.2.21: icmp_seq=1 ttl=64 time=0.544 ms But with TOS 4 and ECT(0), ns1 replies using source address 192.0.2.11 because the "tos 4" route isn't matched: $ ip netns exec ns0 ping -c 1 -b -Q 6 192.0.2.255 [...] 64 bytes from 192.0.2.11: icmp_seq=1 ttl=64 time=0.597 ms After this patch the ECN bits don't affect the result anymore: $ ip netns exec ns0 ping -c 1 -b -Q 6 192.0.2.255 [...] 64 bytes from 192.0.2.21: icmp_seq=1 ttl=64 time=0.591 ms Fixes: 35ebf65e851c ("ipv4: Create and use fib_compute_spec_dst() helper.") Signed-off-by: Guillaume Nault Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/fib_frontend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c @@ -302,7 +302,7 @@ __be32 fib_compute_spec_dst(struct sk_bu .flowi4_iif = LOOPBACK_IFINDEX, .flowi4_oif = l3mdev_master_ifindex_rcu(dev), .daddr = ip_hdr(skb)->saddr, - .flowi4_tos = RT_TOS(ip_hdr(skb)->tos), + .flowi4_tos = ip_hdr(skb)->tos & IPTOS_RT_MASK, .flowi4_scope = scope, .flowi4_mark = vmark ? skb->mark : 0, };