Received: by 10.223.185.111 with SMTP id b44csp916679wrg; Fri, 9 Mar 2018 16:48:17 -0800 (PST) X-Google-Smtp-Source: AG47ELv0iGKXIPYCR++1r17oO2bPM+JV0gHQMtGVymq3DvmCrM1vdgGHnqBGN7weOO71I1fYisvi X-Received: by 10.99.108.129 with SMTP id h123mr350531pgc.30.1520642897341; Fri, 09 Mar 2018 16:48:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520642897; cv=none; d=google.com; s=arc-20160816; b=Cv9Wphul/CspwrX6RFGbYa87R7TUvsXLvNrgMmf3bZvXTvL9VRETbOycK5zdigRgsv v1let3vMsRPgyCD5rrG2kFZl6hyioisjO7/394Nhrwne7Dv8or5laG3gYkY9Skqwx9Pn pLOxlXwP+Exuy8OMAB14TE1S5M6bI1sgWKZTO1aTNXVMcycjHo7dTpFDP85z8Og/A/NA Zwvr8V1iz/TRuffv+0ZRmMvwTDKHdAfDxTUbIncEd/3SRrNaXKkc45qcnUoDqHIRD2EF i6t1Ml8SY9DNMCvDqZ9/MbR59+3er5Mi63Z0iaxA2dcaNw3wKlba0tWJ8zsOmRFRReH7 CMZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=hMt67OoY3p5lhBhgqdDI/Su9q4985d08R6K9VNYHOMQ=; b=LqEwH0JNhcLKOQCdEg93WZ2Y8BXUrZwsLMPrNL5YWd5NzeBDwWI2a31h9kXsgEbZKB 4V0ecm+cKJu36ve5P9zv8AbVa8537rHobkr3JF4GWL5gCD47XdWlHnsNXHH3LEO3O4f2 rS5qRgQLM4kuRKjmtMtOXlncD7s0RJO3UVbomchGnFoV2vTZTnpekbh7U6QLNAQJ+etg WIUXgmcMzxOQP7y4tp3VDT4rAWIzkhpeqHQIb4SobhF44DyE30HMb2jIetHWWR+tMRC8 gOz77eZzFxibIM8wtyJSi5R8Sf6qOVKyPZWK+n+LyqP5qNUHXmk+u9Yve6XVqPqcWpXj mszQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33-v6si1785935plf.98.2018.03.09.16.48.03; Fri, 09 Mar 2018 16:48:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933232AbeCJAUA (ORCPT + 99 others); Fri, 9 Mar 2018 19:20:00 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:38940 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933141AbeCJAT6 (ORCPT ); Fri, 9 Mar 2018 19:19:58 -0500 Received: from localhost (unknown [185.236.200.248]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 29E1EF4D; Sat, 10 Mar 2018 00:19:58 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jianlin Shi , Stefano Brivio , David Ahern , "David S. Miller" Subject: [PATCH 4.4 19/36] fib_semantics: Dont match route with mismatching tclassid Date: Fri, 9 Mar 2018 16:18:35 -0800 Message-Id: <20180310001808.398098537@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180310001807.213987241@linuxfoundation.org> References: <20180310001807.213987241@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stefano Brivio [ Upstream commit a8c6db1dfd1b1d18359241372bb204054f2c3174 ] In fib_nh_match(), if output interface or gateway are passed in the FIB configuration, we don't have to check next hops of multipath routes to conclude whether we have a match or not. However, we might still have routes with different realms matching the same output interface and gateway configuration, and this needs to cause the match to fail. Otherwise the first route inserted in the FIB will match, regardless of the realms: # ip route add 1.1.1.1 dev eth0 table 1234 realms 1/2 # ip route append 1.1.1.1 dev eth0 table 1234 realms 3/4 # ip route list table 1234 1.1.1.1 dev eth0 scope link realms 1/2 1.1.1.1 dev eth0 scope link realms 3/4 # ip route del 1.1.1.1 dev ens3 table 1234 realms 3/4 # ip route list table 1234 1.1.1.1 dev ens3 scope link realms 3/4 whereas route with realms 3/4 should have been deleted instead. Explicitly check for fc_flow passed in the FIB configuration (this comes from RTA_FLOW extracted by rtm_to_fib_config()) and fail matching if it differs from nh_tclassid. The handling of RTA_FLOW for multipath routes later in fib_nh_match() is still needed, as we can have multiple RTA_FLOW attributes that need to be matched against the tclassid of each next hop. v2: Check that fc_flow is set before discarding the match, so that the user can still select the first matching rule by not specifying any realm, as suggested by David Ahern. Reported-by: Jianlin Shi Signed-off-by: Stefano Brivio Acked-by: David Ahern Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/fib_semantics.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c @@ -640,6 +640,11 @@ int fib_nh_match(struct fib_config *cfg, fi->fib_nh, cfg)) return 1; } +#ifdef CONFIG_IP_ROUTE_CLASSID + if (cfg->fc_flow && + cfg->fc_flow != fi->fib_nh->nh_tclassid) + return 1; +#endif if ((!cfg->fc_oif || cfg->fc_oif == fi->fib_nh->nh_oif) && (!cfg->fc_gw || cfg->fc_gw == fi->fib_nh->nh_gw)) return 0;