diff mbox series

[1/8] mptcp: Add IPv6 support for MPTCP socket stubs

Message ID 20191113064518.4823-2-peter.krystad@linux.intel.com
State Accepted, archived
Delegated to: Matthieu Baerts
Headers show
Series [1/8] mptcp: Add IPv6 support for MPTCP socket stubs | expand

Commit Message

Peter Krystad Nov. 13, 2019, 6:45 a.m. UTC
squashto: Add MPTCP socket stubs

Signed-off-by: Peter Krystad <peter.krystad@linux.intel.com>
---
 include/net/mptcp.h  | 10 ++++++++++
 net/ipv6/tcp_ipv6.c  |  7 +++++++
 net/mptcp/protocol.c | 19 +++++++++++++++++++
 3 files changed, 36 insertions(+)
diff mbox series

Patch

diff --git a/include/net/mptcp.h b/include/net/mptcp.h
index 535b27f6ba03..cc173e5f7900 100644
--- a/include/net/mptcp.h
+++ b/include/net/mptcp.h
@@ -146,4 +146,14 @@  static inline bool mptcp_sk_is_subflow(const struct sock *sk)
 }
 
 #endif /* CONFIG_MPTCP */
+
+#if IS_ENABLED(CONFIG_MPTCP_IPV6)
+int mptcpv6_init(void);
+#elif IS_ENABLED(CONFIG_IPV6)
+static inline int mptcpv6_init(void)
+{
+	return 0;
+}
+#endif
+
 #endif /* __NET_MPTCP_H */
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index bae175b57e0f..bcc3bb89938d 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -2108,9 +2108,16 @@  int __init tcpv6_init(void)
 	ret = register_pernet_subsys(&tcpv6_net_ops);
 	if (ret)
 		goto out_tcpv6_protosw;
+
+	ret = mptcpv6_init();
+	if (ret)
+		goto out_tcpv6_pernet_subsys;
+
 out:
 	return ret;
 
+out_tcpv6_pernet_subsys:
+	unregister_pernet_subsys(&tcpv6_net_ops);
 out_tcpv6_protosw:
 	inet6_unregister_protosw(&tcpv6_protosw);
 out_tcpv6_protocol:
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 42b33ed6b870..aa8444c2dd71 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -963,3 +963,22 @@  void mptcp_proto_init(void)
 
 	inet_register_protosw(&mptcp_protosw);
 }
+
+#if IS_ENABLED(CONFIG_MPTCP_IPV6)
+static struct inet_protosw mptcp_v6_protosw = {
+	.type		= SOCK_STREAM,
+	.protocol	= IPPROTO_MPTCP,
+	.prot		= &mptcp_prot,
+	.ops		= &inet6_stream_ops,
+	.flags		= INET_PROTOSW_ICSK,
+};
+
+int mptcpv6_init(void)
+{
+	int err;
+
+	err = inet6_register_protosw(&mptcp_v6_protosw);
+
+	return err;
+}
+#endif