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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 28 Oct 2012 17:56:17 +0000 (10:56 -0700)
[ Upstream commit f8a17175c63fd3e8b573719f7538816f8c96abf4 ]

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/ipv4/fib_semantics.c
net/ipv4/route.c

index a74710048b13e3644b783f143e504767d7482a19..9633661fe3113b518191ecf73407ad4a1e23bf51 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 7a99968df9e5b274468af90c8bd6b5d5ceacd816..079f0ba77f0d68bd5f1f418b2b141fb9e3e90147 100644 (file)
@@ -1210,8 +1210,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;
@@ -1226,7 +1224,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;
        }