forked from Minki/linux
ipv6 route: Prefer outgoing interface with source address assigned.
Outgoing interface is selected by the route decision if unspecified. Let's prefer routes via interface(s) with the address assigned if we have multiple routes with same cost. With help from Naohiro Ooiwa <nooiwa@miraclelinux.com>. Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
This commit is contained in:
parent
1b34be74cb
commit
dd3abc4ef5
@ -237,15 +237,20 @@ static inline int rt6_need_strict(struct in6_addr *daddr)
|
|||||||
|
|
||||||
static inline struct rt6_info *rt6_device_match(struct net *net,
|
static inline struct rt6_info *rt6_device_match(struct net *net,
|
||||||
struct rt6_info *rt,
|
struct rt6_info *rt,
|
||||||
|
struct in6_addr *saddr,
|
||||||
int oif,
|
int oif,
|
||||||
int flags)
|
int flags)
|
||||||
{
|
{
|
||||||
struct rt6_info *local = NULL;
|
struct rt6_info *local = NULL;
|
||||||
struct rt6_info *sprt;
|
struct rt6_info *sprt;
|
||||||
|
|
||||||
if (oif) {
|
if (!oif && ipv6_addr_any(saddr))
|
||||||
for (sprt = rt; sprt; sprt = sprt->u.dst.rt6_next) {
|
goto out;
|
||||||
struct net_device *dev = sprt->rt6i_dev;
|
|
||||||
|
for (sprt = rt; sprt; sprt = sprt->u.dst.rt6_next) {
|
||||||
|
struct net_device *dev = sprt->rt6i_dev;
|
||||||
|
|
||||||
|
if (oif) {
|
||||||
if (dev->ifindex == oif)
|
if (dev->ifindex == oif)
|
||||||
return sprt;
|
return sprt;
|
||||||
if (dev->flags & IFF_LOOPBACK) {
|
if (dev->flags & IFF_LOOPBACK) {
|
||||||
@ -259,14 +264,21 @@ static inline struct rt6_info *rt6_device_match(struct net *net,
|
|||||||
}
|
}
|
||||||
local = sprt;
|
local = sprt;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (ipv6_chk_addr(net, saddr, dev,
|
||||||
|
flags & RT6_LOOKUP_F_IFACE))
|
||||||
|
return sprt;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oif) {
|
||||||
if (local)
|
if (local)
|
||||||
return local;
|
return local;
|
||||||
|
|
||||||
if (flags & RT6_LOOKUP_F_IFACE)
|
if (flags & RT6_LOOKUP_F_IFACE)
|
||||||
return net->ipv6.ip6_null_entry;
|
return net->ipv6.ip6_null_entry;
|
||||||
}
|
}
|
||||||
|
out:
|
||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,7 +551,7 @@ static struct rt6_info *ip6_pol_route_lookup(struct net *net,
|
|||||||
fn = fib6_lookup(&table->tb6_root, &fl->fl6_dst, &fl->fl6_src);
|
fn = fib6_lookup(&table->tb6_root, &fl->fl6_dst, &fl->fl6_src);
|
||||||
restart:
|
restart:
|
||||||
rt = fn->leaf;
|
rt = fn->leaf;
|
||||||
rt = rt6_device_match(net, rt, fl->oif, flags);
|
rt = rt6_device_match(net, rt, &fl->fl6_src, fl->oif, flags);
|
||||||
BACKTRACK(net, &fl->fl6_src);
|
BACKTRACK(net, &fl->fl6_src);
|
||||||
out:
|
out:
|
||||||
dst_use(&rt->u.dst, jiffies);
|
dst_use(&rt->u.dst, jiffies);
|
||||||
|
Loading…
Reference in New Issue
Block a user