Skip to content

Commit

Permalink
[IPV6]: ROUTE: Try selecting better route for non-default routes as w…
Browse files Browse the repository at this point in the history
…ell.

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
YOSHIFUJI Hideaki authored and David S. Miller committed Mar 21, 2006
1 parent 045927f commit 118f8c1
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions net/ipv6/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ void ip6_route_input(struct sk_buff *skb)
int attempts = 3;
int err;

strict = ipv6_addr_type(&skb->nh.ipv6h->daddr) & (IPV6_ADDR_MULTICAST|IPV6_ADDR_LINKLOCAL);
strict = ipv6_addr_type(&skb->nh.ipv6h->daddr) & (IPV6_ADDR_MULTICAST|IPV6_ADDR_LINKLOCAL) ? RT6_SELECT_F_IFACE : 0;

relookup:
read_lock_bh(&rt6_lock);
Expand All @@ -427,12 +427,16 @@ void ip6_route_input(struct sk_buff *skb)
rt = fn->leaf;

if ((rt->rt6i_flags & RTF_CACHE)) {
rt = rt6_device_match(rt, skb->dev->ifindex, strict);
rt = rt6_select(&fn->leaf, skb->dev->ifindex, strict | RT6_SELECT_F_REACHABLE);
if (rt == &ip6_null_entry)
rt = rt6_select(&fn->leaf, skb->dev->ifindex, strict);
BACKTRACK();
goto out;
}

rt = rt6_device_match(rt, skb->dev->ifindex, strict);
rt = rt6_select(&fn->leaf, skb->dev->ifindex, strict | RT6_SELECT_F_REACHABLE);
if (rt == &ip6_null_entry)
rt = rt6_select(&fn->leaf, skb->dev->ifindex, strict);
BACKTRACK();

dst_hold(&rt->u.dst);
Expand Down Expand Up @@ -497,7 +501,9 @@ struct dst_entry * ip6_route_output(struct sock *sk, struct flowi *fl)
rt = fn->leaf;

if ((rt->rt6i_flags & RTF_CACHE)) {
rt = rt6_device_match(rt, fl->oif, strict);
rt = rt6_select(&fn->leaf, fl->oif, strict | RT6_SELECT_F_REACHABLE);
if (rt == &ip6_null_entry)
rt = rt6_select(&fn->leaf, fl->oif, strict);
BACKTRACK();
goto out;
}
Expand All @@ -506,7 +512,9 @@ struct dst_entry * ip6_route_output(struct sock *sk, struct flowi *fl)
if (rt == &ip6_null_entry)
rt = rt6_select(&fn->leaf, fl->oif, strict);
} else {
rt = rt6_device_match(rt, fl->oif, strict);
rt = rt6_select(&fn->leaf, fl->oif, strict | RT6_SELECT_F_REACHABLE);
if (rt == &ip6_null_entry)
rt = rt6_select(&fn->leaf, fl->oif, strict);
BACKTRACK();
}

Expand Down

0 comments on commit 118f8c1

Please sign in to comment.