Received: by 10.192.165.156 with SMTP id m28csp30317imm; Tue, 10 Apr 2018 15:45:10 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+5oGuBTpGKu/rVE8zipVULU42SqLKwCfjEw5ObvvdlPWN9vkVvf4br8vyduzBv2mfjUx7I X-Received: by 2002:a17:902:7441:: with SMTP id e1-v6mr2297845plt.169.1523400310469; Tue, 10 Apr 2018 15:45:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523400310; cv=none; d=google.com; s=arc-20160816; b=vC9ms22ZElZLGJP9MGULUHRrLWLtgrvXwKZHucoDey3kuhemryQwdINC1K9e3atlyi hC5/VtTvchuKU3d0E2GASVxsKQXe9MKdF2Kf0XDNKRVpH2AQiEtcLgr2zkLx1zdF/xOf uYChS4eTjQr8xTPkv4biG0sq8yYRyYqXbzy1XCd59wAfYO8QqHhnxUAiDTkYddxva/L1 91bse8HP0P2OUcnFfqyTLLoJRxJ2VlhYW1ijvzCZ6GojSCFkicD546JH7tcrYjKheMqf lqkfI2eBch+mxbRGC28QfQPaCFg9cmZSAQwdFczSBwl6Z7KDEoHccF0k9lN6+7L8ge4o HaSA== 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=293TuL66H7nRjWKTA/nNS9gC/CvNMQxoaMCDEt6l6b4=; b=nOfwvMZzrcqmQgu1fce5VI7yXMwH4PQHpId5pDOzi7xB0pKogxp5knXD3UKA1kBGSJ OYQnEP6XapommyAFDC9sQfilrC2ppinnVJe7dMN6E/colZMtRUBCg0qUbGH+CBvLzLbV Xzy0drPVvcXp8EYkmpJUMVdw6+WWlcfojjHzDS+i32irgVlee6yjkEh93N8Ecs1UqapZ IeyCi0Kw0n6+yAItP9ZJu0YSs/2LPZ4I5MOsCj0qiQTN6RJcq84Er60wYr6QuK6+sxKX g89ydXq5/FDuh2CtwUc2C1APzp2YnFWDY+c+ZWyYfpQAcUcCp0nQwoobb9jbjQp1ao9m MOTw== 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 c6si2869903pfl.136.2018.04.10.15.44.31; Tue, 10 Apr 2018 15:45:10 -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 S932798AbeDJWlC (ORCPT + 99 others); Tue, 10 Apr 2018 18:41:02 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46766 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932691AbeDJWkX (ORCPT ); Tue, 10 Apr 2018 18:40:23 -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 18F4ADE8; Tue, 10 Apr 2018 22:40:22 +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.14 135/138] route: check sysctl_fib_multipath_use_neigh earlier than hash Date: Wed, 11 Apr 2018 00:25:25 +0200 Message-Id: <20180410212917.938793265@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212902.121524696@linuxfoundation.org> References: <20180410212902.121524696@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.14-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 @@ -1755,18 +1755,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