mptcp: Make mptcp initialization part of tcp initialization
Subsystems (3)
Peter Krystad
PATCH v3 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 between "mptcp: Add MPTCP socket stubs" and
"mptcp: Associate MPTCP context with TCP socket"
v2 - ignore
v3 - fix function declaration
--- 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
@@ -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 +static inline void mptcp_init (void ) +{ +} +static inline bool sk_is_mptcp (const struct sock *sk) {return false;
net/ipv4/tcp.c +2 -0
@@ -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
@@ -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
@@ -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
Matthieu Baerts
Hi Peter, Florian,
Quoted 9 lines · Peter Krystad
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 between "mptcp: Add MPTCP socket stubs" and
"mptcp: Associate MPTCP context with TCP socket"v2 - ignore
v3 - fix function declaration
Thank you for the patch, the new version and the review.
Florian: is this new version OK for you?
Speak to you later,
Matt
Signature · 5 lines
Matthieu Baerts | R&D Engineer matthieu.baerts(a)tessares.net Tessares SA | Hybrid Access Solutions www.tessares.net 1 Avenue Jean Monnet, 1348 Louvain-la-Neuve, Belgium
Florian Westphal
Quoted 1 line · Matthieu Baerts
Florian: is this new version OK for you?
Sure.
Matthieu Baerts
Quoted 5 lines · Florian Westphal
Quoted 1 line · Matthieu Baerts
Florian: is this new version OK for you?
Sure.
Thank you!
Applying it right now. I have a few comments, I will quote the original email with the patch v3.
Cheers,
Matt
Signature · 5 lines
Matthieu Baerts | R&D Engineer matthieu.baerts(a)tessares.net Tessares SA | Hybrid Access Solutions www.tessares.net 1 Avenue Jean Monnet, 1348 Louvain-la-Neuve, Belgium
Matthieu Baerts
Hi Peter,
Quoted 9 lines · Peter Krystad
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 between "mptcp: Add MPTCP socket stubs" and
"mptcp: Associate MPTCP context with TCP socket"v2 - ignore
v3 - fix function declaration
(note: I have 3 extra comments inline below)
Thank you for the new version!
- 9499dac1f027: "squash" part 1 in "mptcp: Add MPTCP socket stubs"
- efdab8bae260: add signed-off
- c9810d1865f6: conflict 1
- f2d604e96056: conflict 2
- 00074d55450c: "squash" part 2 in "mptcp: Associate MPTCP context with TCP socket" (also removed an extra new line from this patch)
- 058d81e14f71: conflict 3
- 4757d74e2865: "squash" part 3 in "mptcp: Create SUBFLOW socket for incoming connections" (with a small fix, see below)
- result: 035b1eddfc37..f986a2c1c4e0
Note: it is not in "export" branch because net-next doesn't compile for the moment. Waiting for this patch to be applied:
https://patchwork.ozlabs.org/patch/1108255/
When applying your patch, I also found two parts of it that made me adding these three comments here below:
Quoted 45 lines
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@@ -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 +static inline void mptcp_init (void ) +{ +} +static inline bool sk_is_mptcp (const struct sock *sk) {return false;net/ipv4/tcp.c +1
-0@@ -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>
net/ipv4/tcp.c void __init tcp_init(void) · line 3951
Quoted 4 lines
net/ipv4/tcp.c +1
-0@@ -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 ();
I see that the other "_init" functions above either use "panic" inside or BUG_ON() here to deal with errors at startup. I can have a look at doing the same in mptcp_init() before this evening (morning) meeting to cleanly manage errors in this init part and avoid other problems later.
Quoted 48 lines
net/ipv4/tcp.c +0
-0}net/mptcp/protocol.c +3
-19@@ -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 +0
-0
net/mptcp/subflow.c static int subflow_ops_init(struct request_sock_ops *subflow_ops) · line 299
Quoted 6 lines
net/mptcp/subflow.c +3
-0@@ -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);
This kfree() is no longer needed. See 9b5faeebe499 (net: mptcp: don't leak 'slab' and 'slab_name' on exit).
Quoted 12 lines
net/mptcp/subflow.c +4
-1+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);
net/mptcp/subflow.c int subflow_init(void) · line 331
Quoted 10 lines
net/mptcp/subflow.c +5
-0+if (ret !=0 ) +subflow_ops_exit (); + +return ret; }void subflow_exit (void ) {tcp_unregister_ulp (&subflow_ulp_ops); +subflow_ops_exit ();
It seems that you were not on top of the latest "for-review" branch (or "export" one) because kmem_cache_destroy() was called here.
Cheers,
Matt
Quoted 4 lines
net/mptcp/subflow.c +0
-2} - -MODULE_LICENSE ("GPL" );
Signature · 5 lines
Matthieu Baerts | R&D Engineer matthieu.baerts(a)tessares.net Tessares SA | Hybrid Access Solutions www.tessares.net 1 Avenue Jean Monnet, 1348 Louvain-la-Neuve, Belgium