Received: by 10.192.165.156 with SMTP id m28csp54499imm; Tue, 10 Apr 2018 16:15:31 -0700 (PDT) X-Google-Smtp-Source: AIpwx48m1Fi1mCDJHv+34o83HrvjHtRvK+/gbwqU6U/ov+zol5AuHeJ+LtszvMJ+H6qm1fI2+YDt X-Received: by 10.98.236.4 with SMTP id k4mr1930242pfh.240.1523402131123; Tue, 10 Apr 2018 16:15:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523402131; cv=none; d=google.com; s=arc-20160816; b=dBSKuLmWZI0dqPTw2jNSfVP2M6HEWMp8CHR8/ODREez+UaE3uuCukt8lDopQ8m88o8 Qqdwp0a4ZNx44RtEQjwlxiRNeGTbDv1ZvJE1NRmmyCD7VdeSUqRig1w3S4qYFwX/6lnW JL8BgF9+UDr6JNjWXplq/Ks2SjSk1NyciYwITmwkElU/kXjnrYIR77NKeqV2phJLhAba 8dzTHU0phm4Gc3evBpkvXQrWWVHT/MuOKf3Xwdcq/UZt9NE38nwyittpFkmCsEU6ddNz ymjCXhPotKkLkarOtytxLKMPLzmNuCC/WjdC+nr5bOf0BGN9yojMDIeZHN3o882YwOQa EqFw== 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=/Bb1c+m3WbOvdTpYMqgjy8FP6fNzBq71s1v2ab+GIYA=; b=fe2ezK02JeHqn9wWNQ9aPcTuupDiyOCBYSIXHkqYtqXip683HmocAvFiWk7x/W5KEH lnbcIt3lSRU28PAtuu8W0hPOimkbPuvwUGZL2cLGI9DzcLnGCNcQkicCeph+EAlmCNZb Q6W/vSXyo8YqMBY3R8ugXT4koD8cBMHECwXlYXKeTRoHrEWCuXSWvnS61hvHEzKUnuvS skvGj2Gg9U/BRzhjHPAaKNU0JZ9CbGzcuN7GBbGoYgkJiguM8bT0ZVY8cM7Mp/WEKL6j IzeTOovkuleApchqw7zRLFNdKMH00VfyqE/mXeZhNBOB5zW66A8fPpsePuYZaZA5LghG cJcg== 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 k64si2834373pfj.262.2018.04.10.16.14.54; Tue, 10 Apr 2018 16:15:31 -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 S1755558AbeDJXKB (ORCPT + 99 others); Tue, 10 Apr 2018 19:10:01 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:41212 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755178AbeDJWdO (ORCPT ); Tue, 10 Apr 2018 18:33:14 -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 557F9BCF; Tue, 10 Apr 2018 22:33:13 +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.15 165/168] route: check sysctl_fib_multipath_use_neigh earlier than hash Date: Wed, 11 Apr 2018 00:25:07 +0200 Message-Id: <20180410212808.247986797@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212800.144079021@linuxfoundation.org> References: <20180410212800.144079021@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.15-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 @@ -1746,18 +1746,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