Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2674382pxb; Mon, 11 Jan 2021 16:50:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJxHySzj7SnztAYYAry5/9bmQix0/jN/ve0q6wvUVXN+Q0We2Gt/RKq8XRcl36sjxGxK7o3o X-Received: by 2002:a17:906:1393:: with SMTP id f19mr1332537ejc.431.1610412625874; Mon, 11 Jan 2021 16:50:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610412625; cv=none; d=google.com; s=arc-20160816; b=kUeXIcg/ZItVplRuSChqmk4ZuSjRP/4m4aeLK2CKwnC8f9uF0q1zOM3hy/HMZBcP1v dPcQBaZlebTNwi8b5ntCgueTQ+Ah1Yi17ygJMK9wX8twjSHUFwbaTPjFzxTZq7qkee6m OjN1n/+CTvkn7bD5ep1DBpUif1jfuUpRKQjPRvjRKOkxjXBfTxlq6ga6b81+7rxg8fZN IKY0I6kN2smQZrlPT2tb47HOnzzLa0Bnb/4gbZ3GBUzvafmthxreoWb3cLq7SM8W9ibk QZZKLhC5Q6lg2wPp+jOuuJVA6HEGnSBKsmxU/Gi4cwAIvIt2qInTOALiKQky6lS//CAl syUA== 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=/WWxG8A7mRm7ND+WYv0t18xPdCEDqAxMBLh1hrtA/pI=; b=Qov1ymrZLMJ20Vp38jyq02ZQLRIDozbuknCEMZ0U2qNqUwPxHfDqk39CLu+2RnZAJ+ i/agHmPtkbqxVDNP7/WX96F39oDy9OQPbvuNpCByMl3oQJenDOM10MEmIpNngIu/96Pg rVNAZPW2mXj9dCDDfhNXDBYlqwXGJMDQp9Nruhs8PZUx6Ac2YbYuwI1ObDUQqmTgvYD5 j3M3/CK79AW4tzAl9LuYt27wIVacU5lyXk5cCcISQv8wyeHZeiYRGTVdVR0aQj6ajMaI 3VMhir2lY+bkE7MG70UBiJkY5u+buoSStFmh5+nkrMNJ/NMbkmabVxSC2g3iJj7dkkAg es4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mcfchUbi; 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 cx27si535187edb.264.2021.01.11.16.50.01; Mon, 11 Jan 2021 16:50:25 -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=mcfchUbi; 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 S1730459AbhAKNGb (ORCPT + 99 others); Mon, 11 Jan 2021 08:06:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:52892 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730327AbhAKNFg (ORCPT ); Mon, 11 Jan 2021 08:05:36 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id EE7AD22ADF; Mon, 11 Jan 2021 13:04:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610370295; bh=c0KachQ6QPtQ2YGOd7GrCsXbBmZMFNbVkZPOBmcsxXo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mcfchUbiWGVaGwa9W3hAFiaAEGlmMgDLXQm+cVbndvoL0xF/LHLiaIdV7m00HDw3z O4aFjB53PW/Jf+jnGyFZS9Lmkkx1XVaRDBemNuARm/fiXKYScUJ9cg4XwdUlbBy61t 3H2Y2aYZyTj5JxhbX+ejuag7aRbWEmLO0Y1AB+8Y= 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 4.14 17/57] ipv4: Ignore ECN bits for fib lookups in fib_compute_spec_dst() Date: Mon, 11 Jan 2021 14:01:36 +0100 Message-Id: <20210111130034.557090256@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210111130033.715773309@linuxfoundation.org> References: <20210111130033.715773309@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 @@ -292,7 +292,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, };