[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1349616863.21172.2376.camel@edumazet-glaptop>
Date: Sun, 07 Oct 2012 15:34:23 +0200
From: Eric Dumazet <eric.dumazet@...il.com>
To: Julian Anastasov <ja@....bg>
Cc: netdev@...r.kernel.org
Subject: Re: [PATCH net 3/6] ipv4: add check if nh_pcpu_rth_output is
allocated
On Sun, 2012-10-07 at 14:26 +0300, Julian Anastasov wrote:
> Avoid NULL ptr dereference and caching if
> nh_pcpu_rth_output is not allocated.
>
> Signed-off-by: Julian Anastasov <ja@....bg>
> ---
> net/ipv4/route.c | 12 +++++++++---
> 1 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/net/ipv4/route.c b/net/ipv4/route.c
> index 488a8bb..0a600cc 100644
> --- a/net/ipv4/route.c
> +++ b/net/ipv4/route.c
> @@ -1798,18 +1798,24 @@ static struct rtable *__mkroute_output(const struct fib_result *res,
> fnhe = NULL;
> if (fi) {
> 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)
> prth = &fnhe->fnhe_rth;
> - else
> - prth = __this_cpu_ptr(FIB_RES_NH(*res).nh_pcpu_rth_output);
> + else {
> + if (!nh->nh_pcpu_rth_output)
> + goto add;
> + prth = __this_cpu_ptr(nh->nh_pcpu_rth_output);
> + }
> rth = rcu_dereference(*prth);
> if (rt_cache_valid(rth)) {
> dst_hold(&rth->dst);
> return rth;
> }
> }
> +
> +add:
> rth = rt_dst_alloc(dev_out,
> IN_DEV_CONF_GET(in_dev, NOPOLICY),
> IN_DEV_CONF_GET(in_dev, NOXFRM),
Alternative would be to make sure the allocation succeeded in
fib_create_info(), but I have no idea on the maximal number of fib_info
a complex routing setup might need ?
I guess a typical machine needs less than 30 fib_info...
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists