ipv4: make sure nh_pcpu_rth_output is always allocated
authorJulian Anastasov <ja@ssi.bg>
Mon, 8 Oct 2012 11:41:17 +0000 (11:41 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 8 Oct 2012 21:42:35 +0000 (17:42 -0400)
Avoid checking nh_pcpu_rth_output in fast path,
abort fib_info creation on alloc_percpu failure.

Signed-off-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/fib_semantics.c
net/ipv4/route.c

index 267753060ffc5c7efe6a3e183113d8dc3fbb49e6..71b125cd5db18a3af37d124d4eb3495f3e03fdea 100644 (file)
@@ -840,6 +840,8 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
        change_nexthops(fi) {
                nexthop_nh->nh_parent = fi;
                nexthop_nh->nh_pcpu_rth_output = alloc_percpu(struct rtable __rcu *);
+               if (!nexthop_nh->nh_pcpu_rth_output)
+                       goto failure;
        } endfor_nexthops(fi)
 
        if (cfg->fc_mx) {
index b90da1bc27043b43108de4e1be23a1d75ddf5381..5b0180f11b20f0dc44bc0a1c528d2ad683b666be 100644 (file)
@@ -1207,8 +1207,6 @@ static bool rt_cache_route(struct fib_nh *nh, struct rtable *rt)
        if (rt_is_input_route(rt)) {
                p = (struct rtable **)&nh->nh_rth_input;
        } else {
-               if (!nh->nh_pcpu_rth_output)
-                       goto nocache;
                p = (struct rtable **)__this_cpu_ptr(nh->nh_pcpu_rth_output);
        }
        orig = *p;
@@ -1223,7 +1221,6 @@ static bool rt_cache_route(struct fib_nh *nh, struct rtable *rt)
                 * unsuccessful at storing this route into the cache
                 * we really need to set it.
                 */
-nocache:
                rt->dst.flags |= DST_NOCACHE;
                ret = false;
        }