lwtun_encaps[LWTUNNEL_ENCAP_MAX+1];
#ifdef CONFIG_LWTUNNEL
-static inline void lwtunnel_state_get(struct lwtunnel_state *lws)
+static inline struct lwtunnel_state *
+lwtstate_get(struct lwtunnel_state *lws)
{
- atomic_inc(&lws->refcnt);
+ if (lws)
+ atomic_inc(&lws->refcnt);
+
+ return lws;
}
-static inline void lwtunnel_state_put(struct lwtunnel_state *lws)
+static inline void lwtstate_put(struct lwtunnel_state *lws)
{
if (!lws)
return;
#else
-static inline void lwtunnel_state_get(struct lwtunnel_state *lws)
+static inline struct lwtunnel_state *
+lwtstate_get(struct lwtunnel_state *lws)
{
+ return lws;
}
-static inline void lwtunnel_state_put(struct lwtunnel_state *lws)
+static inline void lwtstate_put(struct lwtunnel_state *lws)
{
}
change_nexthops(fi) {
if (nexthop_nh->nh_dev)
dev_put(nexthop_nh->nh_dev);
- lwtunnel_state_put(nexthop_nh->nh_lwtstate);
+ lwtstate_put(nexthop_nh->nh_lwtstate);
free_nh_exceptions(nexthop_nh);
rt_fibinfo_free_cpus(nexthop_nh->nh_pcpu_rth_output);
rt_fibinfo_free(&nexthop_nh->nh_rth_input);
nla, &lwtstate);
if (ret)
goto errout;
- lwtunnel_state_get(lwtstate);
- nexthop_nh->nh_lwtstate = lwtstate;
+ nexthop_nh->nh_lwtstate =
+ lwtstate_get(lwtstate);
}
}
if (err)
goto failure;
- lwtunnel_state_get(lwtstate);
- nh->nh_lwtstate = lwtstate;
+ nh->nh_lwtstate = lwtstate_get(lwtstate);
}
nh->nh_oif = cfg->fc_oif;
nh->nh_gw = cfg->fc_gw;
list_del(&rt->rt_uncached);
spin_unlock_bh(&ul->lock);
}
- lwtunnel_state_put(rt->rt_lwtstate);
+ lwtstate_put(rt->rt_lwtstate);
}
void rt_flush_dev(struct net_device *dev)
#ifdef CONFIG_IP_ROUTE_CLASSID
rt->dst.tclassid = nh->nh_tclassid;
#endif
- if (nh->nh_lwtstate) {
- lwtunnel_state_get(nh->nh_lwtstate);
- rt->rt_lwtstate = nh->nh_lwtstate;
- } else {
- rt->rt_lwtstate = NULL;
- }
+ rt->rt_lwtstate = lwtstate_get(nh->nh_lwtstate);
if (unlikely(fnhe))
cached = rt_bind_exception(rt, fnhe, daddr);
else if (!(rt->dst.flags & DST_NOCACHE))
static void rt6_release(struct rt6_info *rt)
{
if (atomic_dec_and_test(&rt->rt6i_ref)) {
- lwtunnel_state_put(rt->rt6i_lwtstate);
+ lwtstate_put(rt->rt6i_lwtstate);
rt6_free_pcpu(rt);
dst_free(&rt->dst);
}
cfg->fc_encap, &lwtstate);
if (err)
goto out;
- lwtunnel_state_get(lwtstate);
- rt->rt6i_lwtstate = lwtstate;
+ rt->rt6i_lwtstate = lwtstate_get(lwtstate);
if (lwtunnel_output_redirect(rt->rt6i_lwtstate))
rt->dst.output = lwtunnel_output6;
}
#endif
rt->rt6i_prefsrc = ort->rt6i_prefsrc;
rt->rt6i_table = ort->rt6i_table;
- if (ort->rt6i_lwtstate) {
- lwtunnel_state_get(ort->rt6i_lwtstate);
- rt->rt6i_lwtstate = ort->rt6i_lwtstate;
- }
+ rt->rt6i_lwtstate = lwtstate_get(ort->rt6i_lwtstate);
}
#ifdef CONFIG_IPV6_ROUTE_INFO