Received: by 10.223.185.111 with SMTP id b44csp910731wrg; Fri, 9 Mar 2018 16:38:24 -0800 (PST) X-Google-Smtp-Source: AG47ELvfRJTfpk8yojjMiG10SkfKdn+ZuuXqVYCU02tmGVDV7LBVjSre8edREgRsF0SHMUXLC+vx X-Received: by 2002:a17:902:9306:: with SMTP id bc6-v6mr344295plb.133.1520642304680; Fri, 09 Mar 2018 16:38:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520642304; cv=none; d=google.com; s=arc-20160816; b=c60t20K1ZcKUrB2YgtLYZ59BzCZu/z9Oc3zUENYAC+QG1AApOUdJCc8IYhmdk5jPGE 4pgwtbuekO+AlN3HTbvV54ESX5CJhgbTj/Dzkkp97yfj6s1t27U/iToqToZT9YHj7OVi nk14mDEGz/oIucmNXk6KK3SxkZGemi+gGzeyNRQeCOK5ZsCIrAkOgV7wcR3QdZTImPOP AbZ9ZcF5DV0+q6QFMnmNO7+gJBPAcDbfw39aJnIwzYzpHLkYAp4mqukQT9IIuuBH8nFj jCrYU445r1cszGz1HtmlEre84BkIfYV2OfWrsSqSg9AjU1yKw/nzc7VzcBW+T6almOy7 fdNA== 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=NZhu3MuHcRLtQOFp4KfbpCediTvVSxq4Varm3hob34U=; b=ziGKweW7oFalwLUfa03/NBBPFRTwY6yUbOIoWiuqnfCJPWGCMk40OksV246d3a2PXP URbyCxfTdOakFI5ktqL9kEwejlPg1l+fevjDe6wMZkYhYzFwzKj/a/i9hws8K7nUB1B/ fANquxYpxuoEExOaKubCxHHhompRePxw/axDPV0C0e75Vj4xGL633uY8yBjW1/m/93iD eUGjRtGWxAKDzoz6yePhdkZ0YEogD88GEuhP8mOo99hEsXJ77V8Y7c5UfLEbTUuI5zQa WX4cq/rQhqyymYQljkyCBOjC2zDPCBLTormIvbRZjojdlEqe57qdXr9aiCw8L2XR5zxw mLrQ== 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 q13si1494896pgt.303.2018.03.09.16.38.10; Fri, 09 Mar 2018 16:38:24 -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 S933859AbeCJAhW (ORCPT + 99 others); Fri, 9 Mar 2018 19:37:22 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:39778 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933718AbeCJAVu (ORCPT ); Fri, 9 Mar 2018 19:21:50 -0500 Received: from localhost (unknown [185.236.200.248]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id BB2F8116E; Sat, 10 Mar 2018 00:21:49 +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.9 34/65] fib_semantics: Dont match route with mismatching tclassid Date: Fri, 9 Mar 2018 16:18:34 -0800 Message-Id: <20180310001827.701835041@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180310001824.927996722@linuxfoundation.org> References: <20180310001824.927996722@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.9-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;