Received: by 10.192.165.156 with SMTP id m28csp1092955imm; Wed, 11 Apr 2018 12:16:20 -0700 (PDT) X-Google-Smtp-Source: AIpwx49xST5kkR/HDAm+ng98nZUHDCdY9ZyrbkaX5rSuavF09v9ppLSNoXg9u5tj/YUFsr/sLY06 X-Received: by 10.99.120.138 with SMTP id t132mr4393909pgc.280.1523474179926; Wed, 11 Apr 2018 12:16:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523474179; cv=none; d=google.com; s=arc-20160816; b=gjMVtD9/qs+1pObWf4BReixEeNXVmmcP+qPS0kAkiFBgi+nL8FLKmzRImkKk10fXba /cty46WJZpQ2KAaBvn/skK8XgpEFOWfy/3SeKe7+3RLOI4uITD1msUGM412ZIsJg8Je4 hJgItvG/lzvQbdGvP9thKcHcD37gJMc87fMC4LoO0AnxEf/0B382htpUKxatXJZDmfBt DU6RVYtPJ+F05IhwTSSCWXBC2QqHPUxcpIgzhIBgEf9MwYmwAikcPFUuxh9VyAO3f/ng vTvOBXDrBiPNG4OuPtdrcvZf5bz/nzXYtiYT9+Qhrcny72itJ/rLUYxQ06a8IO61Jo69 6luw== 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=AYk/lyYjItmqq1d87gRMCLB2FmmvqlJ7/tt9wnkUu0M=; b=bgcwiwSGDgJX1/n0hYmbolz48Fwg4qfKLF2lyuJqtE1+u643fXc2IeDK7FBSMP0EeX 5cxT2I7spRQBT5jLGYdSKjSPvuYeV2iOt9FkEWfTyV4z3343I4bx/+2cAOQK2tXQILxZ gPdtloH5TN1+enlzzg0RFY9YiK5gT4l4buE2m/RAunMPz77uj13/EXDIr8EKNkcQ4G0l aZYK7FpEXjtf31yWzBpOAl8TOsIMnNkVfNmk06wb5VR1ostBmcCEhPP/jiY+RoC6r3dg 4dEt8+3AiH1vggXZuTgKXnBLvz4ChrYbavWut886RfmyPHf9KaWBEN7W6qT6KOp14OCs gYuw== 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 z12si1137361pgc.708.2018.04.11.12.15.43; Wed, 11 Apr 2018 12:16:19 -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; 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 S935268AbeDKTGk (ORCPT + 99 others); Wed, 11 Apr 2018 15:06:40 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:40846 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935193AbeDKTGd (ORCPT ); Wed, 11 Apr 2018 15:06:33 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id EFFB9D3F; Wed, 11 Apr 2018 19:06:32 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jianlin Shi , Xin Long , David Ahern , "David S. Miller" Subject: [PATCH 4.9 304/310] route: check sysctl_fib_multipath_use_neigh earlier than hash Date: Wed, 11 Apr 2018 20:37:23 +0200 Message-Id: <20180411183635.624189163@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183622.305902791@linuxfoundation.org> References: <20180411183622.305902791@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: Xin Long [ Upstream commit 6174a30df1b902e1fedbd728f5343937e83e64e6 ] Prior to this patch, when one packet is hashed into path [1] (hash <= nh_upper_bound) and it's neigh is dead, it will try path [2]. However, if path [2]'s neigh is alive but it's hash > nh_upper_bound, it will not return this alive path. This packet will never be sent even if path [2] is alive. 3.3.3.1/24: nexthop via 1.1.1.254 dev eth1 weight 1 <--[1] (dead neigh) nexthop via 2.2.2.254 dev eth2 weight 1 <--[2] With sysctl_fib_multipath_use_neigh set is supposed to find an available path respecting to the l3/l4 hash. But if there is no available route with this hash, it should at least return an alive route even with other hash. This patch is to fix it by processing fib_multipath_use_neigh earlier than the hash check, so that it will at least return an alive route if there is when fib_multipath_use_neigh is enabled. It's also compatible with before when there are alive routes with the l3/l4 hash. Fixes: a6db4494d218 ("net: ipv4: Consider failed nexthops in multipath routes") Reported-by: Jianlin Shi Signed-off-by: Xin Long Acked-by: David Ahern Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/fib_semantics.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c @@ -1611,18 +1611,20 @@ void fib_select_multipath(struct fib_res bool first = false; for_nexthops(fi) { + if (net->ipv4.sysctl_fib_multipath_use_neigh) { + if (!fib_good_nh(nh)) + continue; + if (!first) { + res->nh_sel = nhsel; + first = true; + } + } + if (hash > atomic_read(&nh->nh_upper_bound)) continue; - if (!net->ipv4.sysctl_fib_multipath_use_neigh || - fib_good_nh(nh)) { - res->nh_sel = nhsel; - return; - } - if (!first) { - res->nh_sel = nhsel; - first = true; - } + res->nh_sel = nhsel; + return; } endfor_nexthops(fi); } #endif