Commit fc130840d75d42c5a360fd1d8b72489eec09cad3
Committed by
David S. Miller
1 parent
9740d78604
Exists in
master
and in
4 other branches
l2tp: make local function static
Also moved the refcound inlines from l2tp_core.h to l2tp_core.c since only used in that one file. Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Acked-by: James Chapman <jchapman@katalix.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 3 changed files with 41 additions and 44 deletions Side-by-side Diff
net/l2tp/l2tp_core.c
... | ... | @@ -111,6 +111,10 @@ |
111 | 111 | spinlock_t l2tp_session_hlist_lock; |
112 | 112 | }; |
113 | 113 | |
114 | +static void l2tp_session_set_header_len(struct l2tp_session *session, int version); | |
115 | +static void l2tp_tunnel_free(struct l2tp_tunnel *tunnel); | |
116 | +static void l2tp_tunnel_closeall(struct l2tp_tunnel *tunnel); | |
117 | + | |
114 | 118 | static inline struct l2tp_net *l2tp_pernet(struct net *net) |
115 | 119 | { |
116 | 120 | BUG_ON(!net); |
... | ... | @@ -118,6 +122,34 @@ |
118 | 122 | return net_generic(net, l2tp_net_id); |
119 | 123 | } |
120 | 124 | |
125 | + | |
126 | +/* Tunnel reference counts. Incremented per session that is added to | |
127 | + * the tunnel. | |
128 | + */ | |
129 | +static inline void l2tp_tunnel_inc_refcount_1(struct l2tp_tunnel *tunnel) | |
130 | +{ | |
131 | + atomic_inc(&tunnel->ref_count); | |
132 | +} | |
133 | + | |
134 | +static inline void l2tp_tunnel_dec_refcount_1(struct l2tp_tunnel *tunnel) | |
135 | +{ | |
136 | + if (atomic_dec_and_test(&tunnel->ref_count)) | |
137 | + l2tp_tunnel_free(tunnel); | |
138 | +} | |
139 | +#ifdef L2TP_REFCNT_DEBUG | |
140 | +#define l2tp_tunnel_inc_refcount(_t) do { \ | |
141 | + printk(KERN_DEBUG "l2tp_tunnel_inc_refcount: %s:%d %s: cnt=%d\n", __func__, __LINE__, (_t)->name, atomic_read(&_t->ref_count)); \ | |
142 | + l2tp_tunnel_inc_refcount_1(_t); \ | |
143 | + } while (0) | |
144 | +#define l2tp_tunnel_dec_refcount(_t) do { \ | |
145 | + printk(KERN_DEBUG "l2tp_tunnel_dec_refcount: %s:%d %s: cnt=%d\n", __func__, __LINE__, (_t)->name, atomic_read(&_t->ref_count)); \ | |
146 | + l2tp_tunnel_dec_refcount_1(_t); \ | |
147 | + } while (0) | |
148 | +#else | |
149 | +#define l2tp_tunnel_inc_refcount(t) l2tp_tunnel_inc_refcount_1(t) | |
150 | +#define l2tp_tunnel_dec_refcount(t) l2tp_tunnel_dec_refcount_1(t) | |
151 | +#endif | |
152 | + | |
121 | 153 | /* Session hash global list for L2TPv3. |
122 | 154 | * The session_id SHOULD be random according to RFC3931, but several |
123 | 155 | * L2TP implementations use incrementing session_ids. So we do a real |
... | ... | @@ -699,8 +731,8 @@ |
699 | 731 | * Returns 1 if the packet was not a good data packet and could not be |
700 | 732 | * forwarded. All such packets are passed up to userspace to deal with. |
701 | 733 | */ |
702 | -int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb, | |
703 | - int (*payload_hook)(struct sk_buff *skb)) | |
734 | +static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb, | |
735 | + int (*payload_hook)(struct sk_buff *skb)) | |
704 | 736 | { |
705 | 737 | struct l2tp_session *session = NULL; |
706 | 738 | unsigned char *ptr, *optr; |
... | ... | @@ -922,7 +954,8 @@ |
922 | 954 | return bufp - optr; |
923 | 955 | } |
924 | 956 | |
925 | -int l2tp_xmit_core(struct l2tp_session *session, struct sk_buff *skb, size_t data_len) | |
957 | +static int l2tp_xmit_core(struct l2tp_session *session, struct sk_buff *skb, | |
958 | + size_t data_len) | |
926 | 959 | { |
927 | 960 | struct l2tp_tunnel *tunnel = session->tunnel; |
928 | 961 | unsigned int len = skb->len; |
... | ... | @@ -1089,7 +1122,7 @@ |
1089 | 1122 | * The tunnel context is deleted only when all session sockets have been |
1090 | 1123 | * closed. |
1091 | 1124 | */ |
1092 | -void l2tp_tunnel_destruct(struct sock *sk) | |
1125 | +static void l2tp_tunnel_destruct(struct sock *sk) | |
1093 | 1126 | { |
1094 | 1127 | struct l2tp_tunnel *tunnel; |
1095 | 1128 | |
1096 | 1129 | |
... | ... | @@ -1128,11 +1161,10 @@ |
1128 | 1161 | end: |
1129 | 1162 | return; |
1130 | 1163 | } |
1131 | -EXPORT_SYMBOL(l2tp_tunnel_destruct); | |
1132 | 1164 | |
1133 | 1165 | /* When the tunnel is closed, all the attached sessions need to go too. |
1134 | 1166 | */ |
1135 | -void l2tp_tunnel_closeall(struct l2tp_tunnel *tunnel) | |
1167 | +static void l2tp_tunnel_closeall(struct l2tp_tunnel *tunnel) | |
1136 | 1168 | { |
1137 | 1169 | int hash; |
1138 | 1170 | struct hlist_node *walk; |
... | ... | @@ -1198,7 +1230,7 @@ |
1198 | 1230 | /* Really kill the tunnel. |
1199 | 1231 | * Come here only when all sessions have been cleared from the tunnel. |
1200 | 1232 | */ |
1201 | -void l2tp_tunnel_free(struct l2tp_tunnel *tunnel) | |
1233 | +static void l2tp_tunnel_free(struct l2tp_tunnel *tunnel) | |
1202 | 1234 | { |
1203 | 1235 | struct l2tp_net *pn = l2tp_pernet(tunnel->l2tp_net); |
1204 | 1236 | |
... | ... | @@ -1217,7 +1249,6 @@ |
1217 | 1249 | atomic_dec(&l2tp_tunnel_count); |
1218 | 1250 | kfree(tunnel); |
1219 | 1251 | } |
1220 | -EXPORT_SYMBOL_GPL(l2tp_tunnel_free); | |
1221 | 1252 | |
1222 | 1253 | /* Create a socket for the tunnel, if one isn't set up by |
1223 | 1254 | * userspace. This is used for static tunnels where there is no |
... | ... | @@ -1512,7 +1543,7 @@ |
1512 | 1543 | /* We come here whenever a session's send_seq, cookie_len or |
1513 | 1544 | * l2specific_len parameters are set. |
1514 | 1545 | */ |
1515 | -void l2tp_session_set_header_len(struct l2tp_session *session, int version) | |
1546 | +static void l2tp_session_set_header_len(struct l2tp_session *session, int version) | |
1516 | 1547 | { |
1517 | 1548 | if (version == L2TP_HDR_VER_2) { |
1518 | 1549 | session->hdr_len = 6; |
... | ... | @@ -1525,7 +1556,6 @@ |
1525 | 1556 | } |
1526 | 1557 | |
1527 | 1558 | } |
1528 | -EXPORT_SYMBOL_GPL(l2tp_session_set_header_len); | |
1529 | 1559 | |
1530 | 1560 | struct l2tp_session *l2tp_session_create(int priv_size, struct l2tp_tunnel *tunnel, u32 session_id, u32 peer_session_id, struct l2tp_session_cfg *cfg) |
1531 | 1561 | { |
net/l2tp/l2tp_core.h
... | ... | @@ -231,47 +231,14 @@ |
231 | 231 | extern int l2tp_tunnel_delete(struct l2tp_tunnel *tunnel); |
232 | 232 | extern struct l2tp_session *l2tp_session_create(int priv_size, struct l2tp_tunnel *tunnel, u32 session_id, u32 peer_session_id, struct l2tp_session_cfg *cfg); |
233 | 233 | extern int l2tp_session_delete(struct l2tp_session *session); |
234 | -extern void l2tp_tunnel_free(struct l2tp_tunnel *tunnel); | |
235 | 234 | extern void l2tp_session_free(struct l2tp_session *session); |
236 | 235 | extern void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb, unsigned char *ptr, unsigned char *optr, u16 hdrflags, int length, int (*payload_hook)(struct sk_buff *skb)); |
237 | -extern int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb, int (*payload_hook)(struct sk_buff *skb)); | |
238 | 236 | extern int l2tp_udp_encap_recv(struct sock *sk, struct sk_buff *skb); |
239 | 237 | |
240 | -extern int l2tp_xmit_core(struct l2tp_session *session, struct sk_buff *skb, size_t data_len); | |
241 | 238 | extern int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len); |
242 | -extern void l2tp_tunnel_destruct(struct sock *sk); | |
243 | -extern void l2tp_tunnel_closeall(struct l2tp_tunnel *tunnel); | |
244 | -extern void l2tp_session_set_header_len(struct l2tp_session *session, int version); | |
245 | 239 | |
246 | 240 | extern int l2tp_nl_register_ops(enum l2tp_pwtype pw_type, const struct l2tp_nl_cmd_ops *ops); |
247 | 241 | extern void l2tp_nl_unregister_ops(enum l2tp_pwtype pw_type); |
248 | - | |
249 | -/* Tunnel reference counts. Incremented per session that is added to | |
250 | - * the tunnel. | |
251 | - */ | |
252 | -static inline void l2tp_tunnel_inc_refcount_1(struct l2tp_tunnel *tunnel) | |
253 | -{ | |
254 | - atomic_inc(&tunnel->ref_count); | |
255 | -} | |
256 | - | |
257 | -static inline void l2tp_tunnel_dec_refcount_1(struct l2tp_tunnel *tunnel) | |
258 | -{ | |
259 | - if (atomic_dec_and_test(&tunnel->ref_count)) | |
260 | - l2tp_tunnel_free(tunnel); | |
261 | -} | |
262 | -#ifdef L2TP_REFCNT_DEBUG | |
263 | -#define l2tp_tunnel_inc_refcount(_t) do { \ | |
264 | - printk(KERN_DEBUG "l2tp_tunnel_inc_refcount: %s:%d %s: cnt=%d\n", __func__, __LINE__, (_t)->name, atomic_read(&_t->ref_count)); \ | |
265 | - l2tp_tunnel_inc_refcount_1(_t); \ | |
266 | - } while (0) | |
267 | -#define l2tp_tunnel_dec_refcount(_t) do { \ | |
268 | - printk(KERN_DEBUG "l2tp_tunnel_dec_refcount: %s:%d %s: cnt=%d\n", __func__, __LINE__, (_t)->name, atomic_read(&_t->ref_count)); \ | |
269 | - l2tp_tunnel_dec_refcount_1(_t); \ | |
270 | - } while (0) | |
271 | -#else | |
272 | -#define l2tp_tunnel_inc_refcount(t) l2tp_tunnel_inc_refcount_1(t) | |
273 | -#define l2tp_tunnel_dec_refcount(t) l2tp_tunnel_dec_refcount_1(t) | |
274 | -#endif | |
275 | 242 | |
276 | 243 | /* Session reference counts. Incremented when code obtains a reference |
277 | 244 | * to a session. |