Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp680455ybh; Tue, 10 Mar 2020 06:22:13 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvRIWipJoyidbDOkwOthoLBH64u24cMHbFlkCs7+Tw2fHXWaAhJAOwy24ZZfvP94lLSvoRL X-Received: by 2002:aca:918:: with SMTP id 24mr1112840oij.35.1583846533236; Tue, 10 Mar 2020 06:22:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583846533; cv=none; d=google.com; s=arc-20160816; b=gYw+f+/J7EWcdtgfprb3vcYxphOdpyY8VwBKaAYa3G1icxX3pKX+wVXXvmcykarf6F qCflrc/20y8tOTPNE7YYyC3r1xLPpgel1xeU2FS2H4UvZ09Pr5to2yPCMMNoX/1SQSzL OgW5zTZ7RiggOeeD8X7Flx5e5py/XP3TC0be41hvR//Q3wz/LRBkRApLDEUUFXfBD6M/ mXlNsfTDoP82zSWa+19bBUfkhVHRs2geGNFJ+U4ZiT2UUCfKyCz/e1HAHCzuIcmnYvP7 KIP1j7UisdOmNdgWF2B7CA7wUsVDLgTLHEtezhcKCgFeMOPtzkyJO7gqBL2Qp/YNf2am XWEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hmPvaRYT8Frqs8fQ34WpnfphGV/Oq96FsAEhL/SG8xY=; b=ffg0+CqaOvkMUzuWhDVbuIy+er8vOms8UnsQpWb78pksFxGv/l9XZw0UyxAttolBsh MW2ekZQ6qn/A0w0T4pgE5T5tovtcTook60HB+mpfJUe8UuLNpMMP556X0BuAe8YkEMWT dU8pf61k1ERDR5R1EBToYThlaxpRV40U4Kly47W71CrTy3bOqTEXLQ14T6gcPXizc18L Tp33TrJfus/5HUyFO+MzVKLUE4BhI7JV2QuDWYxtFjklq/ARriVp7TOkbDERyiw8dCtw uZ6oBIyaQLRyTMOo4bMwqlJlBMF+FUt1Lx6lQXhrTkrYoWDlG6L/wonTlZJdxiLCXIjk yOyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cua6HE9G; 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 m9si5918374otq.87.2020.03.10.06.22.01; Tue, 10 Mar 2020 06:22:13 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=cua6HE9G; 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 S1730794AbgCJNU6 (ORCPT + 99 others); Tue, 10 Mar 2020 09:20:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:52184 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728891AbgCJNGe (ORCPT ); Tue, 10 Mar 2020 09:06:34 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 EC96D20409; Tue, 10 Mar 2020 13:06:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583845594; bh=tXedHrave03/djjKK4IkV0L4IAg1gcrgsCOHOyc8TsY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cua6HE9G8853Jlf7H/kejj+CpSCTNvhWcRTeh1VmjTMgG4pqDPnRTEDkaaxuA0RxH ghzycMKkg/lxN+FeBq7iQf4yGEzHCSHDEm/YUA86UoB4w92OBwv87YQFb47+ETCw0R YlUNbTNrucn3WYxLFQwEzH7FBbwMD2D3RkpZZUp4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Benjamin Poirier , Michal Kubecek , "David S. Miller" Subject: [PATCH 4.14 031/126] ipv6: Fix route replacement with dev-only route Date: Tue, 10 Mar 2020 13:40:52 +0100 Message-Id: <20200310124206.419779637@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200310124203.704193207@linuxfoundation.org> References: <20200310124203.704193207@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Benjamin Poirier [ Upstream commit e404b8c7cfb31654c9024d497cec58a501501692 ] After commit 27596472473a ("ipv6: fix ECMP route replacement") it is no longer possible to replace an ECMP-able route by a non ECMP-able route. For example, ip route add 2001:db8::1/128 via fe80::1 dev dummy0 ip route replace 2001:db8::1/128 dev dummy0 does not work as expected. Tweak the replacement logic so that point 3 in the log of the above commit becomes: 3. If the new route is not ECMP-able, and no matching non-ECMP-able route exists, replace matching ECMP-able route (if any) or add the new route. We can now summarize the entire replace semantics to: When doing a replace, prefer replacing a matching route of the same "ECMP-able-ness" as the replace argument. If there is no such candidate, fallback to the first route found. Fixes: 27596472473a ("ipv6: fix ECMP route replacement") Signed-off-by: Benjamin Poirier Reviewed-by: Michal Kubecek Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv6/ip6_fib.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c @@ -893,8 +893,7 @@ static int fib6_add_rt2node(struct fib6_ found++; break; } - if (rt_can_ecmp) - fallback_ins = fallback_ins ?: ins; + fallback_ins = fallback_ins ?: ins; goto next_iter; } @@ -934,7 +933,9 @@ next_iter: } if (fallback_ins && !found) { - /* No ECMP-able route found, replace first non-ECMP one */ + /* No matching route with same ecmp-able-ness found, replace + * first matching route + */ ins = fallback_ins; iter = *ins; found++;