Skip to contentSkip to conversation

mptcp: Make mptcp initialization part of tcp initialization

PATCH Superseded Peter Krystad 2 participants 3 messages May 24, 2019 – May 28, 2019

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Peter Krystad

author
#0 lore raw

PATCH 1/1 mptcp: Make mptcp initialization part of tcp initialization

Remove remnant module initialization of MPTCP and make it part of the inet/tcp initialization sequence.

OK to squash but needs to be split up to do so.

Signed-off-by Peter Krystad <peter.krystad(a)linux.intel.com>
---
 include/net/mptcp.h  |  6 ++++++
 net/ipv4/tcp.c       |  2 ++
 net/mptcp/protocol.c | 22 +++-------------------
 net/mptcp/subflow.c  | 15 ++++++++++++---
 4 files changed, 23 insertions(+), 22 deletions(-)
include/net/mptcp.h +6 -0
index ed67b140af33..a927e65d5027 100644
@@ -49,6 +49,8 @@ struct mptcp_out_options {
 
 #ifdef CONFIG_MPTCP
 
+void mptcp_init(void);
+
 static inline bool sk_is_mptcp(const struct sock *sk)
 {
 	return tcp_sk(sk)->is_mptcp;
@@ -84,6 +86,10 @@ void mptcp_write_options(__be32 *ptr, struct mptcp_out_options *opts);
 
 #else
 
+void mptcp_init(void)
+{
+}
+
 static inline bool sk_is_mptcp(const struct sock *sk)
 {
 	return false;
net/ipv4/tcp.c +2 -0
index cb072dce81a7..ab242851da3f 100644
@@ -275,6 +275,7 @@
 #include <net/icmp.h>
 #include <net/inet_common.h>
 #include <net/tcp.h>
+#include <net/mptcp.h>
 #include <net/xfrm.h>
 #include <net/ip.h>
 #include <net/sock.h>
@@ -3947,4 +3948,5 @@ void __init tcp_init(void)
 	tcp_metrics_init();
 	BUG_ON(tcp_register_congestion_control(&tcp_reno) != 0);
 	tcp_tasklet_init();
+	mptcp_init();
 }
net/mptcp/protocol.c +3 -19
index 06312efc0b90..d1c617852e0f 100644
@@ -1009,7 +1009,7 @@ static struct inet_protosw mptcp_protosw = {
 	.flags		= INET_PROTOSW_ICSK,
 };
 
-static int __init mptcp_init(void)
+void mptcp_init(void)
 {
 	int err;
 
@@ -1036,26 +1036,10 @@ static int __init mptcp_init(void)
 
 	inet_register_protosw(&mptcp_protosw);
 
-	return 0;
-
+	return;
 proto_failed:
 	subflow_exit();
 
 subflow_failed:
-	return err;
-}
-
-static void __exit mptcp_exit(void)
-{
-	inet_unregister_protosw(&mptcp_protosw);
-	proto_unregister(&mptcp_prot);
-
-	subflow_exit();
+	return;
 }
-
-module_init(mptcp_init);
-module_exit(mptcp_exit);
-
-MODULE_LICENSE("GPL");
-MODULE_ALIAS_NET_PF_PROTO(PF_INET, IPPROTO_MPTCP);
-MODULE_ALIAS_NET_PF_PROTO(PF_INET6, IPPROTO_MPTCP);
net/mptcp/subflow.c +12 -3
index bc8e1a0658ec..e4ae5c5d177d 100644
@@ -294,6 +294,12 @@ static int subflow_ops_init(struct request_sock_ops *subflow_ops)
 	return 0;
 }
 
+static void subflow_ops_exit(void)
+{
+	kfree(subflow_request_sock_ops.slab_name);
+	kmem_cache_destroy(subflow_request_sock_ops.slab);
+}
+
 int subflow_init(void)
 {
 	int ret;
@@ -312,12 +318,15 @@ int subflow_init(void)
 	subflow_specific.sk_rx_dst_set = subflow_finish_connect;
 	subflow_specific.rebuild_header = subflow_rebuild_header;
 
-	return tcp_register_ulp(&subflow_ulp_ops);
+	ret = tcp_register_ulp(&subflow_ulp_ops);
+	if (ret != 0)
+		subflow_ops_exit();
+
+	return ret;
 }
 
 void subflow_exit(void)
 {
 	tcp_unregister_ulp(&subflow_ulp_ops);
+	subflow_ops_exit();
 }
-
-MODULE_LICENSE("GPL");
Signature · 1 line
2.17.2
#1 lore raw

include/net/mptcp.h void mptcp_write_options(__be32 *ptr, struct mptcp_out_options *opts); · line 92

Quoted 11 lines · Peter Krystad

static inline bool sk_is_mptcp(const struct sock *sk) {

include/net/mptcp.h +4 -0
 	return tcp_sk(sk)->is_mptcp;
@@ -84,6 +86,10 @@ void mptcp_write_options(__be32 *ptr, struct mptcp_out_options *opts);
 
 #else
 
+void mptcp_init(void)
+{
+}
+

ITYM 'static inline void mptcp_init(void) {}'.

author
#2 lore raw
Quoted 6 lines · Florian Westphal
Quoted 5 lines · Peter Krystad

static inline bool sk_is_mptcp(const struct sock *sk) {

include/net/mptcp.h +0 -0
 	return tcp_sk(sk)->is_mptcp;
@@ -84,6 +86,10 @@ void mptcp_write_options(__be32 *ptr, struct mptcp_out_options *opts);
 
Quoted 8 lines

include/net/mptcp.h void mptcp_write_options(__be32 *ptr, struct mptcp_out_options *opts); · line 92

Quoted 6 lines
include/net/mptcp.h +4 -0
 #else
 
+void mptcp_init(void)
+{
+}
+

ITYM 'static inline void mptcp_init(void) {}'.

Indeed I did.