Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f8a17175 authored by Julian Anastasov's avatar Julian Anastasov Committed by David S. Miller
Browse files

ipv4: make sure nh_pcpu_rth_output is always allocated



Avoid checking nh_pcpu_rth_output in fast path,
abort fib_info creation on alloc_percpu failure.

Signed-off-by: default avatarJulian Anastasov <ja@ssi.bg>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e0adef0f
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -840,6 +840,8 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
	change_nexthops(fi) {
	change_nexthops(fi) {
		nexthop_nh->nh_parent = fi;
		nexthop_nh->nh_parent = fi;
		nexthop_nh->nh_pcpu_rth_output = alloc_percpu(struct rtable __rcu *);
		nexthop_nh->nh_pcpu_rth_output = alloc_percpu(struct rtable __rcu *);
		if (!nexthop_nh->nh_pcpu_rth_output)
			goto failure;
	} endfor_nexthops(fi)
	} endfor_nexthops(fi)


	if (cfg->fc_mx) {
	if (cfg->fc_mx) {
+0 −3
Original line number Original line Diff line number Diff line
@@ -1207,8 +1207,6 @@ static bool rt_cache_route(struct fib_nh *nh, struct rtable *rt)
	if (rt_is_input_route(rt)) {
	if (rt_is_input_route(rt)) {
		p = (struct rtable **)&nh->nh_rth_input;
		p = (struct rtable **)&nh->nh_rth_input;
	} else {
	} else {
		if (!nh->nh_pcpu_rth_output)
			goto nocache;
		p = (struct rtable **)__this_cpu_ptr(nh->nh_pcpu_rth_output);
		p = (struct rtable **)__this_cpu_ptr(nh->nh_pcpu_rth_output);
	}
	}
	orig = *p;
	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
		 * unsuccessful at storing this route into the cache
		 * we really need to set it.
		 * we really need to set it.
		 */
		 */
nocache:
		rt->dst.flags |= DST_NOCACHE;
		rt->dst.flags |= DST_NOCACHE;
		ret = false;
		ret = false;
	}
	}