@@ -165,7 +165,7 @@ static void l2tp_session_free(struct l2tp_session *session)
165165{
166166 trace_free_session (session );
167167 if (session -> tunnel )
168- l2tp_tunnel_dec_refcount (session -> tunnel );
168+ l2tp_tunnel_put (session -> tunnel );
169169 kfree_rcu (session , rcu );
170170}
171171
@@ -192,31 +192,19 @@ struct l2tp_tunnel *l2tp_sk_to_tunnel(const struct sock *sk)
192192}
193193EXPORT_SYMBOL_GPL (l2tp_sk_to_tunnel );
194194
195- void l2tp_tunnel_inc_refcount (struct l2tp_tunnel * tunnel )
196- {
197- refcount_inc (& tunnel -> ref_count );
198- }
199- EXPORT_SYMBOL_GPL (l2tp_tunnel_inc_refcount );
200-
201- void l2tp_tunnel_dec_refcount (struct l2tp_tunnel * tunnel )
195+ void l2tp_tunnel_put (struct l2tp_tunnel * tunnel )
202196{
203197 if (refcount_dec_and_test (& tunnel -> ref_count ))
204198 l2tp_tunnel_free (tunnel );
205199}
206- EXPORT_SYMBOL_GPL (l2tp_tunnel_dec_refcount );
207-
208- void l2tp_session_inc_refcount (struct l2tp_session * session )
209- {
210- refcount_inc (& session -> ref_count );
211- }
212- EXPORT_SYMBOL_GPL (l2tp_session_inc_refcount );
200+ EXPORT_SYMBOL_GPL (l2tp_tunnel_put );
213201
214- void l2tp_session_dec_refcount (struct l2tp_session * session )
202+ void l2tp_session_put (struct l2tp_session * session )
215203{
216204 if (refcount_dec_and_test (& session -> ref_count ))
217205 l2tp_session_free (session );
218206}
219- EXPORT_SYMBOL_GPL (l2tp_session_dec_refcount );
207+ EXPORT_SYMBOL_GPL (l2tp_session_put );
220208
221209/* Lookup a tunnel. A new reference is held on the returned tunnel. */
222210struct l2tp_tunnel * l2tp_tunnel_get (const struct net * net , u32 tunnel_id )
@@ -445,7 +433,7 @@ struct l2tp_session *l2tp_session_get_by_ifname(const struct net *net,
445433 if (tunnel ) {
446434 list_for_each_entry_rcu (session , & tunnel -> session_list , list ) {
447435 if (!strcmp (session -> ifname , ifname )) {
448- l2tp_session_inc_refcount ( session );
436+ refcount_inc ( & session -> ref_count );
449437 rcu_read_unlock_bh ();
450438
451439 return session ;
@@ -462,7 +450,7 @@ EXPORT_SYMBOL_GPL(l2tp_session_get_by_ifname);
462450static void l2tp_session_coll_list_add (struct l2tp_session_coll_list * clist ,
463451 struct l2tp_session * session )
464452{
465- l2tp_session_inc_refcount ( session );
453+ refcount_inc ( & session -> ref_count );
466454 WARN_ON_ONCE (session -> coll_list );
467455 session -> coll_list = clist ;
468456 spin_lock (& clist -> lock );
@@ -548,7 +536,7 @@ static void l2tp_session_collision_del(struct l2tp_net *pn,
548536 spin_unlock (& clist -> lock );
549537 if (refcount_dec_and_test (& clist -> ref_count ))
550538 kfree (clist );
551- l2tp_session_dec_refcount (session );
539+ l2tp_session_put (session );
552540 }
553541}
554542
@@ -597,7 +585,7 @@ int l2tp_session_register(struct l2tp_session *session,
597585 goto out ;
598586 }
599587
600- l2tp_tunnel_inc_refcount ( tunnel );
588+ refcount_inc ( & tunnel -> ref_count );
601589 WRITE_ONCE (session -> tunnel , tunnel );
602590 list_add_rcu (& session -> list , & tunnel -> session_list );
603591
@@ -1080,7 +1068,7 @@ int l2tp_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
10801068
10811069 if (!session || !session -> recv_skb ) {
10821070 if (session )
1083- l2tp_session_dec_refcount (session );
1071+ l2tp_session_put (session );
10841072
10851073 /* Not found? Pass to userspace to deal with */
10861074 goto pass ;
@@ -1094,12 +1082,12 @@ int l2tp_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
10941082
10951083 if (version == L2TP_HDR_VER_3 &&
10961084 l2tp_v3_ensure_opt_in_linear (session , skb , & ptr , & optr )) {
1097- l2tp_session_dec_refcount (session );
1085+ l2tp_session_put (session );
10981086 goto invalid ;
10991087 }
11001088
11011089 l2tp_recv_common (session , skb , ptr , optr , hdrflags , length );
1102- l2tp_session_dec_refcount (session );
1090+ l2tp_session_put (session );
11031091
11041092 return 0 ;
11051093
@@ -1393,7 +1381,7 @@ static void l2tp_udp_encap_destroy(struct sock *sk)
13931381 tunnel = l2tp_sk_to_tunnel (sk );
13941382 if (tunnel ) {
13951383 l2tp_tunnel_delete (tunnel );
1396- l2tp_tunnel_dec_refcount (tunnel );
1384+ l2tp_tunnel_put (tunnel );
13971385 }
13981386}
13991387
@@ -1428,10 +1416,10 @@ static void l2tp_tunnel_del_work(struct work_struct *work)
14281416
14291417 l2tp_tunnel_remove (tunnel -> l2tp_net , tunnel );
14301418 /* drop initial ref */
1431- l2tp_tunnel_dec_refcount (tunnel );
1419+ l2tp_tunnel_put (tunnel );
14321420
14331421 /* drop workqueue ref */
1434- l2tp_tunnel_dec_refcount (tunnel );
1422+ l2tp_tunnel_put (tunnel );
14351423}
14361424
14371425/* Create a socket for the tunnel, if one isn't set up by
@@ -1619,7 +1607,7 @@ static int l2tp_validate_socket(const struct sock *sk, const struct net *net,
16191607
16201608 tunnel = l2tp_sk_to_tunnel (sk );
16211609 if (tunnel ) {
1622- l2tp_tunnel_dec_refcount (tunnel );
1610+ l2tp_tunnel_put (tunnel );
16231611 return - EBUSY ;
16241612 }
16251613
@@ -1711,7 +1699,7 @@ void l2tp_tunnel_delete(struct l2tp_tunnel *tunnel)
17111699{
17121700 if (!test_and_set_bit (0 , & tunnel -> dead )) {
17131701 trace_delete_tunnel (tunnel );
1714- l2tp_tunnel_inc_refcount ( tunnel );
1702+ refcount_inc ( & tunnel -> ref_count );
17151703 queue_work (l2tp_wq , & tunnel -> del_work );
17161704 }
17171705}
@@ -1721,7 +1709,7 @@ void l2tp_session_delete(struct l2tp_session *session)
17211709{
17221710 if (!test_and_set_bit (0 , & session -> dead )) {
17231711 trace_delete_session (session );
1724- l2tp_session_inc_refcount ( session );
1712+ refcount_inc ( & session -> ref_count );
17251713 queue_work (l2tp_wq , & session -> del_work );
17261714 }
17271715}
@@ -1739,10 +1727,10 @@ static void l2tp_session_del_work(struct work_struct *work)
17391727 (* session -> session_close )(session );
17401728
17411729 /* drop initial ref */
1742- l2tp_session_dec_refcount (session );
1730+ l2tp_session_put (session );
17431731
17441732 /* drop workqueue ref */
1745- l2tp_session_dec_refcount (session );
1733+ l2tp_session_put (session );
17461734}
17471735
17481736/* We come here whenever a session's send_seq, cookie_len or
0 commit comments