From: Duan Jiong <duanj.fnst@cn.fujitsu.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: [PATCH] ipv6: match those routes that have different metirc
Date: Mon, 11 Nov 2013 11:00:53 +0800 [thread overview]
Message-ID: <52804865.8090206@cn.fujitsu.com> (raw)
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 <duanj.fnst@cn.fujitsu.com>
---
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)
--
1.8.3.1
next reply other threads:[~2013-11-11 3:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-11 3:00 Duan Jiong [this message]
2013-11-11 6:07 ` [PATCH] ipv6: match those routes that have different metirc Hannes Frederic Sowa
2013-11-11 7:16 ` Duan Jiong
2013-11-11 7:39 ` Hannes Frederic Sowa
2013-11-11 8:29 ` Duan Jiong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52804865.8090206@cn.fujitsu.com \
--to=duanj.fnst@cn.fujitsu.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).