From patchwork Mon Nov 11 03:00:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Duan Jiong X-Patchwork-Id: 290118 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 7883A2C00AA for ; Mon, 11 Nov 2013 14:03:24 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751309Ab3KKDDV (ORCPT ); Sun, 10 Nov 2013 22:03:21 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:7212 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751003Ab3KKDDT (ORCPT ); Sun, 10 Nov 2013 22:03:19 -0500 X-IronPort-AV: E=Sophos;i="4.93,675,1378828800"; d="scan'208";a="8996273" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 11 Nov 2013 10:59:35 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id rAB32wrk017321; Mon, 11 Nov 2013 11:02:58 +0800 Received: from [10.167.225.86] ([10.167.225.86]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013111111011528-14792 ; Mon, 11 Nov 2013 11:01:15 +0800 Message-ID: <52804865.8090206@cn.fujitsu.com> Date: Mon, 11 Nov 2013 11:00:53 +0800 From: Duan Jiong User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: David Miller CC: netdev@vger.kernel.org Subject: [PATCH] ipv6: match those routes that have different metirc X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/11/11 11:01:15, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/11/11 11:01:18, Serialize complete at 2013/11/11 11:01:18 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Now the kernel only match those routes that have the same metirc, so if those routes are non-reachable, then the packets can't be sent out. But according to the rfc 4191 section 3.2, if the best route points to a non-reachable route, the next best route should be consulted. So the kernel should not only match those routes that have minimum metric, and should also match others. Signed-off-by: Duan Jiong --- net/ipv6/route.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 7faa9d5..96cd22a 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -629,7 +629,7 @@ static struct rt6_info *find_match(struct rt6_info *rt, int oif, int strict, if (strict & RT6_LOOKUP_F_REACHABLE) rt6_probe(rt); - if (m > *mpri) { + if (m > *mpri && (!match || rt->rt6i_metric == match->rt6i_metric)) { *do_rr = match_do_rr; *mpri = m; match = rt; @@ -639,19 +639,13 @@ out: } static struct rt6_info *find_rr_leaf(struct fib6_node *fn, - struct rt6_info *rr_head, - u32 metric, int oif, int strict, - bool *do_rr) + int oif, int strict, bool *do_rr) { struct rt6_info *rt, *match; int mpri = -1; match = NULL; - for (rt = rr_head; rt && rt->rt6i_metric == metric; - rt = rt->dst.rt6_next) - match = find_match(rt, oif, strict, &mpri, match, do_rr); - for (rt = fn->leaf; rt && rt != rr_head && rt->rt6i_metric == metric; - rt = rt->dst.rt6_next) + for (rt = fn->leaf; rt; rt = rt->dst.rt6_next) match = find_match(rt, oif, strict, &mpri, match, do_rr); return match; @@ -667,14 +661,13 @@ static struct rt6_info *rt6_select(struct fib6_node *fn, int oif, int strict) if (!rt0) fn->rr_ptr = rt0 = fn->leaf; - match = find_rr_leaf(fn, rt0, rt0->rt6i_metric, oif, strict, - &do_rr); + match = find_rr_leaf(fn, oif, strict, &do_rr); if (do_rr) { struct rt6_info *next = rt0->dst.rt6_next; /* no entries matched; do round-robin */ - if (!next || next->rt6i_metric != rt0->rt6i_metric) + if (!next) next = fn->leaf; if (next != rt0)