Skip to contentSkip to conversation

l2tp: trivial cleanups

PATCH In review Guillaume Nault 2 participants 9 messages Jun 25, 2018 – Jun 26, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover l2tp: trivial cleanups

Just a set of unrelated trivial cleanups (remove unused code, make local functions static, etc.).

Guillaume Nault (7):
l2tp: remove pppol2tp_session_close()
l2tp: remove .show from struct l2tp_tunnel
l2tp: remove l2tp_tunnel_priv()
l2tp: don't export l2tp_session_queue_purge()
l2tp: don't export l2tp_tunnel_closeall()
l2tp: avoid duplicate l2tp_pernet() calls
l2tp: make l2tp_xmit_core() return void

 net/l2tp/l2tp_core.c    | 15 +++++----------
 net/l2tp/l2tp_core.h    | 12 ------------
 net/l2tp/l2tp_debugfs.c |  3 ---
 net/l2tp/l2tp_ppp.c     |  7 -------
 4 files changed, 5 insertions(+), 32 deletions(-)
Signature · 1 line
2.18.0
#1 lore raw

PATCH 1/7 l2tp: remove pppol2tp_session_close()

l2tp_core.c verifies that ->session_close() is defined before calling it. There's no need for a stub.

---
 net/l2tp/l2tp_ppp.c | 7 -------
 1 file changed, 7 deletions(-)
net/l2tp/l2tp_ppp.c +0 -7
index 55188382845c..eea5d7844473 100644
@@ -424,12 +424,6 @@ static void pppol2tp_put_sk(struct rcu_head *head)
 	sock_put(ps->__sk);
 }
 
-/* Called by l2tp_core when a session socket is being closed.
- */
-static void pppol2tp_session_close(struct l2tp_session *session)
-{
-}
-
 /* Really kill the session socket. (Called from sock_put() if
  * refcnt == 0.)
  */
@@ -573,7 +567,6 @@ static void pppol2tp_session_init(struct l2tp_session *session)
 	struct dst_entry *dst;
 
 	session->recv_skb = pppol2tp_recv;
-	session->session_close = pppol2tp_session_close;
 #if IS_ENABLED(CONFIG_L2TP_DEBUGFS)
 	session->show = pppol2tp_show;
 #endif
Signature · 1 line
2.18.0
#2 lore raw

PATCH 2/7 l2tp: remove .show from struct l2tp_tunnel

In reply to Guillaume Nault

This callback has never been implemented.

---
 net/l2tp/l2tp_core.h    | 3 ---
 net/l2tp/l2tp_debugfs.c | 3 ---
 2 files changed, 6 deletions(-)
net/l2tp/l2tp_core.h +0 -3
index c199020f8a8a..b21c20a4e08f 100644
@@ -180,9 +180,6 @@ struct l2tp_tunnel {
 	struct net		*l2tp_net;	/* the net we belong to */
 
 	refcount_t		ref_count;
-#ifdef CONFIG_DEBUG_FS
-	void (*show)(struct seq_file *m, void *arg);
-#endif
 	int (*recv_payload_hook)(struct sk_buff *skb);
 	void (*old_sk_destruct)(struct sock *);
 	struct sock		*sock;		/* Parent socket */
net/l2tp/l2tp_debugfs.c +0 -3
index e87686f7d63c..b5d7dde003ef 100644
@@ -177,9 +177,6 @@ static void l2tp_dfs_seq_tunnel_show(struct seq_file *m, void *v)
 		   atomic_long_read(&tunnel->stats.rx_packets),
 		   atomic_long_read(&tunnel->stats.rx_bytes),
 		   atomic_long_read(&tunnel->stats.rx_errors));
-
-	if (tunnel->show != NULL)
-		tunnel->show(m, tunnel);
 }
 
 static void l2tp_dfs_seq_session_show(struct seq_file *m, void *v)
Signature · 1 line
2.18.0
#3 lore raw

PATCH 3/7 l2tp: remove l2tp_tunnel_priv()

In reply to Guillaume Nault

This function, and the associated .priv field, are unused.

---
 net/l2tp/l2tp_core.h | 7 -------
 1 file changed, 7 deletions(-)
net/l2tp/l2tp_core.h +0 -7
index b21c20a4e08f..15e1171ecf7b 100644
@@ -187,8 +187,6 @@ struct l2tp_tunnel {
 						 * was created by userspace */
 
 	struct work_struct	del_work;
-
-	uint8_t			priv[0];	/* private data */
 };
 
 struct l2tp_nl_cmd_ops {
@@ -198,11 +196,6 @@ struct l2tp_nl_cmd_ops {
 	int (*session_delete)(struct l2tp_session *session);
 };
 
-static inline void *l2tp_tunnel_priv(struct l2tp_tunnel *tunnel)
-{
-	return &tunnel->priv[0];
-}
-
 static inline void *l2tp_session_priv(struct l2tp_session *session)
 {
 	return &session->priv[0];
Signature · 1 line
2.18.0
#4 lore raw

PATCH 4/7 l2tp: don't export l2tp_session_queue_purge()

In reply to Guillaume Nault

This function is only used in l2tp_core.c.

---
 net/l2tp/l2tp_core.c | 3 +--
 net/l2tp/l2tp_core.h | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)
net/l2tp/l2tp_core.c +1 -2
index 40261cb68e83..3adef4c35a3a 100644
@@ -783,7 +783,7 @@ EXPORT_SYMBOL(l2tp_recv_common);
 
 /* Drop skbs from the session's reorder_q
  */
-int l2tp_session_queue_purge(struct l2tp_session *session)
+static int l2tp_session_queue_purge(struct l2tp_session *session)
 {
 	struct sk_buff *skb = NULL;
 	BUG_ON(!session);
@@ -794,7 +794,6 @@ int l2tp_session_queue_purge(struct l2tp_session *session)
 	}
 	return 0;
 }
-EXPORT_SYMBOL_GPL(l2tp_session_queue_purge);
 
 /* Internal UDP receive frame. Do the real work of receiving an L2TP data frame
  * here. The skb is not on a list when we get here.
net/l2tp/l2tp_core.h +0 -1
index 15e1171ecf7b..0a6e582f84d3 100644
@@ -234,7 +234,6 @@ void l2tp_session_free(struct l2tp_session *session);
 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));
-int l2tp_session_queue_purge(struct l2tp_session *session);
 int l2tp_udp_encap_recv(struct sock *sk, struct sk_buff *skb);
 void l2tp_session_set_header_len(struct l2tp_session *session, int version);
 
Signature · 1 line
2.18.0
#5 lore raw

PATCH 5/7 l2tp: don't export l2tp_tunnel_closeall()

In reply to Guillaume Nault

This function is only used in l2tp_core.c.

---
 net/l2tp/l2tp_core.c | 3 +--
 net/l2tp/l2tp_core.h | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)
net/l2tp/l2tp_core.c +1 -2
index 3adef4c35a3a..96e31f2ae7cd 100644
@@ -1192,7 +1192,7 @@ static void l2tp_tunnel_destruct(struct sock *sk)
 
 /* When the tunnel is closed, all the attached sessions need to go too.
  */
-void l2tp_tunnel_closeall(struct l2tp_tunnel *tunnel)
+static void l2tp_tunnel_closeall(struct l2tp_tunnel *tunnel)
 {
 	int hash;
 	struct hlist_node *walk;
@@ -1241,7 +1241,6 @@ void l2tp_tunnel_closeall(struct l2tp_tunnel *tunnel)
 	}
 	write_unlock_bh(&tunnel->hlist_lock);
 }
-EXPORT_SYMBOL_GPL(l2tp_tunnel_closeall);
 
 /* Tunnel socket destroy hook for UDP encapsulation */
 static void l2tp_udp_encap_destroy(struct sock *sk)
net/l2tp/l2tp_core.h +0 -1
index 0a6e582f84d3..a5c09d3a5698 100644
@@ -219,7 +219,6 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id,
 int l2tp_tunnel_register(struct l2tp_tunnel *tunnel, struct net *net,
 			 struct l2tp_tunnel_cfg *cfg);
 
-void l2tp_tunnel_closeall(struct l2tp_tunnel *tunnel);
 void l2tp_tunnel_delete(struct l2tp_tunnel *tunnel);
 struct l2tp_session *l2tp_session_create(int priv_size,
 					 struct l2tp_tunnel *tunnel,
Signature · 1 line
2.18.0
#6 lore raw

PATCH 6/7 l2tp: avoid duplicate l2tp_pernet() calls

In reply to Guillaume Nault

Replace 'l2tp_pernet(tunnel->l2tp_net)' with 'pn', which has been set on the preceding line.

---
 net/l2tp/l2tp_core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/l2tp/l2tp_core.c +1 -2
index 96e31f2ae7cd..88c3001531b4 100644
@@ -322,8 +322,7 @@ int l2tp_session_register(struct l2tp_session *session,
 
 	if (tunnel->version == L2TP_HDR_VER_3) {
 		pn = l2tp_pernet(tunnel->l2tp_net);
-		g_head = l2tp_session_id_hash_2(l2tp_pernet(tunnel->l2tp_net),
-						session->session_id);
+		g_head = l2tp_session_id_hash_2(pn, session->session_id);
 
 		spin_lock_bh(&pn->l2tp_session_hlist_lock);
 
Signature · 1 line
2.18.0
#7 lore raw

PATCH 7/7 l2tp: make l2tp_xmit_core() return void

In reply to Guillaume Nault

It always returns 0, and nobody reads the return value anyway.

---
 net/l2tp/l2tp_core.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
net/l2tp/l2tp_core.c +2 -4
index 88c3001531b4..1ea285bad84b 100644
@@ -1007,8 +1007,8 @@ static int l2tp_build_l2tpv3_header(struct l2tp_session *session, void *buf)
 	return bufp - optr;
 }
 
-static int l2tp_xmit_core(struct l2tp_session *session, struct sk_buff *skb,
-			  struct flowi *fl, size_t data_len)
+static void l2tp_xmit_core(struct l2tp_session *session, struct sk_buff *skb,
+			   struct flowi *fl, size_t data_len)
 {
 	struct l2tp_tunnel *tunnel = session->tunnel;
 	unsigned int len = skb->len;
@@ -1050,8 +1050,6 @@ static int l2tp_xmit_core(struct l2tp_session *session, struct sk_buff *skb,
 		atomic_long_inc(&tunnel->stats.tx_errors);
 		atomic_long_inc(&session->stats.tx_errors);
 	}
-
-	return 0;
 }
 
 /* If caller requires the skb to have a ppp header, the header must be
Signature · 1 line
2.18.0