diff options
author | Nicolas Dichtel <nicolas.dichtel@6wind.com> | 2015-07-24 06:28:36 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-07-27 04:02:49 -0400 |
commit | 5a6228a0b472062646434cd2536d109c102b606e (patch) | |
tree | 29b6d0958db33b1fc5980dbbcec192a7b1d20c19 | |
parent | d943659508a4fb883507fdd3f998329e70a8f922 (diff) |
lwtunnel: change prototype of lwtunnel_state_get()
It saves some lines and simplify a bit the code when the state is returning
by this function. It's also useful to handle a NULL entry.
To avoid too long lines, I've also renamed lwtunnel_state_get() and
lwtunnel_state_put() to lwtstate_get() and lwtstate_put().
CC: Thomas Graf <tgraf@suug.ch>
CC: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
Acked-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/lwtunnel.h | 16 | ||||
-rw-r--r-- | net/ipv4/fib_semantics.c | 9 | ||||
-rw-r--r-- | net/ipv4/route.c | 9 | ||||
-rw-r--r-- | net/ipv6/ip6_fib.c | 2 | ||||
-rw-r--r-- | net/ipv6/route.c | 8 |
5 files changed, 20 insertions, 24 deletions
diff --git a/include/net/lwtunnel.h b/include/net/lwtunnel.h index 918e03c1dafa..b02039081b04 100644 --- a/include/net/lwtunnel.h +++ b/include/net/lwtunnel.h | |||
@@ -35,12 +35,16 @@ extern const struct lwtunnel_encap_ops __rcu * | |||
35 | lwtun_encaps[LWTUNNEL_ENCAP_MAX+1]; | 35 | lwtun_encaps[LWTUNNEL_ENCAP_MAX+1]; |
36 | 36 | ||
37 | #ifdef CONFIG_LWTUNNEL | 37 | #ifdef CONFIG_LWTUNNEL |
38 | static inline void lwtunnel_state_get(struct lwtunnel_state *lws) | 38 | static inline struct lwtunnel_state * |
39 | lwtstate_get(struct lwtunnel_state *lws) | ||
39 | { | 40 | { |
40 | atomic_inc(&lws->refcnt); | 41 | if (lws) |
42 | atomic_inc(&lws->refcnt); | ||
43 | |||
44 | return lws; | ||
41 | } | 45 | } |
42 | 46 | ||
43 | static inline void lwtunnel_state_put(struct lwtunnel_state *lws) | 47 | static inline void lwtstate_put(struct lwtunnel_state *lws) |
44 | { | 48 | { |
45 | if (!lws) | 49 | if (!lws) |
46 | return; | 50 | return; |
@@ -74,11 +78,13 @@ int lwtunnel_output6(struct sock *sk, struct sk_buff *skb); | |||
74 | 78 | ||
75 | #else | 79 | #else |
76 | 80 | ||
77 | static inline void lwtunnel_state_get(struct lwtunnel_state *lws) | 81 | static inline struct lwtunnel_state * |
82 | lwtstate_get(struct lwtunnel_state *lws) | ||
78 | { | 83 | { |
84 | return lws; | ||
79 | } | 85 | } |
80 | 86 | ||
81 | static inline void lwtunnel_state_put(struct lwtunnel_state *lws) | 87 | static inline void lwtstate_put(struct lwtunnel_state *lws) |
82 | { | 88 | { |
83 | } | 89 | } |
84 | 90 | ||
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index d4c6732cfbfa..65e00399a9a6 100644 --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c | |||
@@ -209,7 +209,7 @@ static void free_fib_info_rcu(struct rcu_head *head) | |||
209 | change_nexthops(fi) { | 209 | change_nexthops(fi) { |
210 | if (nexthop_nh->nh_dev) | 210 | if (nexthop_nh->nh_dev) |
211 | dev_put(nexthop_nh->nh_dev); | 211 | dev_put(nexthop_nh->nh_dev); |
212 | lwtunnel_state_put(nexthop_nh->nh_lwtstate); | 212 | lwtstate_put(nexthop_nh->nh_lwtstate); |
213 | free_nh_exceptions(nexthop_nh); | 213 | free_nh_exceptions(nexthop_nh); |
214 | rt_fibinfo_free_cpus(nexthop_nh->nh_pcpu_rth_output); | 214 | rt_fibinfo_free_cpus(nexthop_nh->nh_pcpu_rth_output); |
215 | rt_fibinfo_free(&nexthop_nh->nh_rth_input); | 215 | rt_fibinfo_free(&nexthop_nh->nh_rth_input); |
@@ -514,8 +514,8 @@ static int fib_get_nhs(struct fib_info *fi, struct rtnexthop *rtnh, | |||
514 | nla, &lwtstate); | 514 | nla, &lwtstate); |
515 | if (ret) | 515 | if (ret) |
516 | goto errout; | 516 | goto errout; |
517 | lwtunnel_state_get(lwtstate); | 517 | nexthop_nh->nh_lwtstate = |
518 | nexthop_nh->nh_lwtstate = lwtstate; | 518 | lwtstate_get(lwtstate); |
519 | } | 519 | } |
520 | } | 520 | } |
521 | 521 | ||
@@ -971,8 +971,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg) | |||
971 | if (err) | 971 | if (err) |
972 | goto failure; | 972 | goto failure; |
973 | 973 | ||
974 | lwtunnel_state_get(lwtstate); | 974 | nh->nh_lwtstate = lwtstate_get(lwtstate); |
975 | nh->nh_lwtstate = lwtstate; | ||
976 | } | 975 | } |
977 | nh->nh_oif = cfg->fc_oif; | 976 | nh->nh_oif = cfg->fc_oif; |
978 | nh->nh_gw = cfg->fc_gw; | 977 | nh->nh_gw = cfg->fc_gw; |
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 519ec232818d..11096396ef4a 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -1358,7 +1358,7 @@ static void ipv4_dst_destroy(struct dst_entry *dst) | |||
1358 | list_del(&rt->rt_uncached); | 1358 | list_del(&rt->rt_uncached); |
1359 | spin_unlock_bh(&ul->lock); | 1359 | spin_unlock_bh(&ul->lock); |
1360 | } | 1360 | } |
1361 | lwtunnel_state_put(rt->rt_lwtstate); | 1361 | lwtstate_put(rt->rt_lwtstate); |
1362 | } | 1362 | } |
1363 | 1363 | ||
1364 | void rt_flush_dev(struct net_device *dev) | 1364 | void rt_flush_dev(struct net_device *dev) |
@@ -1407,12 +1407,7 @@ static void rt_set_nexthop(struct rtable *rt, __be32 daddr, | |||
1407 | #ifdef CONFIG_IP_ROUTE_CLASSID | 1407 | #ifdef CONFIG_IP_ROUTE_CLASSID |
1408 | rt->dst.tclassid = nh->nh_tclassid; | 1408 | rt->dst.tclassid = nh->nh_tclassid; |
1409 | #endif | 1409 | #endif |
1410 | if (nh->nh_lwtstate) { | 1410 | rt->rt_lwtstate = lwtstate_get(nh->nh_lwtstate); |
1411 | lwtunnel_state_get(nh->nh_lwtstate); | ||
1412 | rt->rt_lwtstate = nh->nh_lwtstate; | ||
1413 | } else { | ||
1414 | rt->rt_lwtstate = NULL; | ||
1415 | } | ||
1416 | if (unlikely(fnhe)) | 1411 | if (unlikely(fnhe)) |
1417 | cached = rt_bind_exception(rt, fnhe, daddr); | 1412 | cached = rt_bind_exception(rt, fnhe, daddr); |
1418 | else if (!(rt->dst.flags & DST_NOCACHE)) | 1413 | else if (!(rt->dst.flags & DST_NOCACHE)) |
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index d715f2e0c4e7..5693b5eb8482 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c | |||
@@ -178,7 +178,7 @@ static void rt6_free_pcpu(struct rt6_info *non_pcpu_rt) | |||
178 | static void rt6_release(struct rt6_info *rt) | 178 | static void rt6_release(struct rt6_info *rt) |
179 | { | 179 | { |
180 | if (atomic_dec_and_test(&rt->rt6i_ref)) { | 180 | if (atomic_dec_and_test(&rt->rt6i_ref)) { |
181 | lwtunnel_state_put(rt->rt6i_lwtstate); | 181 | lwtstate_put(rt->rt6i_lwtstate); |
182 | rt6_free_pcpu(rt); | 182 | rt6_free_pcpu(rt); |
183 | dst_free(&rt->dst); | 183 | dst_free(&rt->dst); |
184 | } | 184 | } |
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index fbe27fb6bd3f..c9b2b9fe83fc 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -1778,8 +1778,7 @@ int ip6_route_add(struct fib6_config *cfg) | |||
1778 | cfg->fc_encap, &lwtstate); | 1778 | cfg->fc_encap, &lwtstate); |
1779 | if (err) | 1779 | if (err) |
1780 | goto out; | 1780 | goto out; |
1781 | lwtunnel_state_get(lwtstate); | 1781 | rt->rt6i_lwtstate = lwtstate_get(lwtstate); |
1782 | rt->rt6i_lwtstate = lwtstate; | ||
1783 | if (lwtunnel_output_redirect(rt->rt6i_lwtstate)) | 1782 | if (lwtunnel_output_redirect(rt->rt6i_lwtstate)) |
1784 | rt->dst.output = lwtunnel_output6; | 1783 | rt->dst.output = lwtunnel_output6; |
1785 | } | 1784 | } |
@@ -2161,10 +2160,7 @@ static void ip6_rt_copy_init(struct rt6_info *rt, struct rt6_info *ort) | |||
2161 | #endif | 2160 | #endif |
2162 | rt->rt6i_prefsrc = ort->rt6i_prefsrc; | 2161 | rt->rt6i_prefsrc = ort->rt6i_prefsrc; |
2163 | rt->rt6i_table = ort->rt6i_table; | 2162 | rt->rt6i_table = ort->rt6i_table; |
2164 | if (ort->rt6i_lwtstate) { | 2163 | rt->rt6i_lwtstate = lwtstate_get(ort->rt6i_lwtstate); |
2165 | lwtunnel_state_get(ort->rt6i_lwtstate); | ||
2166 | rt->rt6i_lwtstate = ort->rt6i_lwtstate; | ||
2167 | } | ||
2168 | } | 2164 | } |
2169 | 2165 | ||
2170 | #ifdef CONFIG_IPV6_ROUTE_INFO | 2166 | #ifdef CONFIG_IPV6_ROUTE_INFO |