mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-04-02 12:34:06 +00:00
ipv4: Add FLOWI_FLAG_KNOWN_NH
Add flag to request that output route should be returned with known rt_gateway, in case we want to use it as nexthop for neighbour resolving. The returned route can be cached as follows: - in NH exception: because the cached routes are not shared with other destinations - in FIB NH: when using gateway because all destinations for NH share same gateway As last option, to return rt_gateway!=0 we have to set DST_NOCACHE. Signed-off-by: Julian Anastasov <ja@ssi.bg> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
155e8336c3
commit
c92b96553a
2 changed files with 18 additions and 4 deletions
|
@ -21,6 +21,7 @@ struct flowi_common {
|
||||||
__u8 flowic_flags;
|
__u8 flowic_flags;
|
||||||
#define FLOWI_FLAG_ANYSRC 0x01
|
#define FLOWI_FLAG_ANYSRC 0x01
|
||||||
#define FLOWI_FLAG_CAN_SLEEP 0x02
|
#define FLOWI_FLAG_CAN_SLEEP 0x02
|
||||||
|
#define FLOWI_FLAG_KNOWN_NH 0x04
|
||||||
__u32 flowic_secid;
|
__u32 flowic_secid;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1762,6 +1762,7 @@ static struct rtable *__mkroute_output(const struct fib_result *res,
|
||||||
struct in_device *in_dev;
|
struct in_device *in_dev;
|
||||||
u16 type = res->type;
|
u16 type = res->type;
|
||||||
struct rtable *rth;
|
struct rtable *rth;
|
||||||
|
bool do_cache;
|
||||||
|
|
||||||
in_dev = __in_dev_get_rcu(dev_out);
|
in_dev = __in_dev_get_rcu(dev_out);
|
||||||
if (!in_dev)
|
if (!in_dev)
|
||||||
|
@ -1798,24 +1799,36 @@ static struct rtable *__mkroute_output(const struct fib_result *res,
|
||||||
}
|
}
|
||||||
|
|
||||||
fnhe = NULL;
|
fnhe = NULL;
|
||||||
|
do_cache = fi != NULL;
|
||||||
if (fi) {
|
if (fi) {
|
||||||
struct rtable __rcu **prth;
|
struct rtable __rcu **prth;
|
||||||
|
struct fib_nh *nh = &FIB_RES_NH(*res);
|
||||||
|
|
||||||
fnhe = find_exception(&FIB_RES_NH(*res), fl4->daddr);
|
fnhe = find_exception(nh, fl4->daddr);
|
||||||
if (fnhe)
|
if (fnhe)
|
||||||
prth = &fnhe->fnhe_rth;
|
prth = &fnhe->fnhe_rth;
|
||||||
else
|
else {
|
||||||
prth = __this_cpu_ptr(FIB_RES_NH(*res).nh_pcpu_rth_output);
|
if (unlikely(fl4->flowi4_flags &
|
||||||
|
FLOWI_FLAG_KNOWN_NH &&
|
||||||
|
!(nh->nh_gw &&
|
||||||
|
nh->nh_scope == RT_SCOPE_LINK))) {
|
||||||
|
do_cache = false;
|
||||||
|
goto add;
|
||||||
|
}
|
||||||
|
prth = __this_cpu_ptr(nh->nh_pcpu_rth_output);
|
||||||
|
}
|
||||||
rth = rcu_dereference(*prth);
|
rth = rcu_dereference(*prth);
|
||||||
if (rt_cache_valid(rth)) {
|
if (rt_cache_valid(rth)) {
|
||||||
dst_hold(&rth->dst);
|
dst_hold(&rth->dst);
|
||||||
return rth;
|
return rth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add:
|
||||||
rth = rt_dst_alloc(dev_out,
|
rth = rt_dst_alloc(dev_out,
|
||||||
IN_DEV_CONF_GET(in_dev, NOPOLICY),
|
IN_DEV_CONF_GET(in_dev, NOPOLICY),
|
||||||
IN_DEV_CONF_GET(in_dev, NOXFRM),
|
IN_DEV_CONF_GET(in_dev, NOXFRM),
|
||||||
fi);
|
do_cache);
|
||||||
if (!rth)
|
if (!rth)
|
||||||
return ERR_PTR(-ENOBUFS);
|
return ERR_PTR(-ENOBUFS);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue