All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH mptcp-net v2 0/3] mptcp: fix request sock for subflow in v6
@ 2022-11-30  9:44 Matthieu Baerts
  2022-11-30  9:44 ` [PATCH mptcp-net v2 1/3] mptcp: remove MPTCP 'ifdef' in TCP SYN cookies Matthieu Baerts
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Matthieu Baerts @ 2022-11-30  9:44 UTC (permalink / raw)
  To: mptcp; +Cc: Matthieu Baerts

ChangeLog:
- v2:
  The CI reported the structure I moved from mptcp.h to subflow.c only can be
  static (from 'make C=1'). While at it, I also marked it as __ro_after_init.
  See patch 1/3 (also in 2/3 for the v6 part).

When working on validating the listener part of TCP FastOpen with Packetdrill, I
noticed the cookie in IPv6 was not the expected one.

The root cause was that req->rsk_ops->family was set to AF_INET while the
subflow was in v6. Patch 2/3 solves that.

While looking around, I noticed we were always calling the destructor from TCP
in v4 and I changed that in patch 3/3. I don't think there is a memory leaks in
usual cases.

Paolo did a pre-review (thanks again for that!) and suggested the patch 1/3.


Matthieu Baerts (3):
  mptcp: remove MPTCP 'ifdef' in TCP SYN cookies
  mptcp: dedicated request sock for subflow in v6
  mptcp: use proper req destructor for IPv6

 include/net/mptcp.h   | 12 +++++++--
 net/ipv4/syncookies.c |  7 +++--
 net/mptcp/subflow.c   | 61 ++++++++++++++++++++++++++++++++++++-------
 3 files changed, 64 insertions(+), 16 deletions(-)


base-commit: 8de87563b5eb14ed009c26cae1e6afbff35c93e0
-- 
2.37.2


^ permalink raw reply	[flat|nested] 14+ messages in thread
* [PATCH mptcp-net 3/3] mptcp: use proper req destructor for IPv6
@ 2022-11-29 21:08 Matthieu Baerts
  2022-11-29 22:52 ` mptcp: use proper req destructor for IPv6: Tests Results MPTCP CI
  0 siblings, 1 reply; 14+ messages in thread
From: Matthieu Baerts @ 2022-11-29 21:08 UTC (permalink / raw)
  To: mptcp; +Cc: Matthieu Baerts

Before, only the destructor from TCP request sock in IPv4 was called
even if the subflow was in v4.

It is important to use the right destructor to avoid memory leaks with
some advanced IPv6 features, e.g. when the request socks contain
specific IPv6 options.

Fixes: 79c0949e9a09 ("mptcp: Add key generation and token tree")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 net/mptcp/subflow.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index 16498dd9e0a1..2e1d70e2272b 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -45,7 +45,6 @@ static void subflow_req_destructor(struct request_sock *req)
 		sock_put((struct sock *)subflow_req->msk);
 
 	mptcp_token_destroy_request(req);
-	tcp_request_sock_ops.destructor(req);
 }
 
 static void subflow_generate_hmac(u64 key1, u64 key2, u32 nonce1, u32 nonce2,
@@ -550,6 +549,12 @@ static int subflow_v4_conn_request(struct sock *sk, struct sk_buff *skb)
 	return 0;
 }
 
+static void subflow_v4_req_destructor(struct request_sock *req)
+{
+	subflow_req_destructor(req);
+	tcp_request_sock_ops.destructor(req);
+}
+
 #if IS_ENABLED(CONFIG_MPTCP_IPV6)
 struct request_sock_ops mptcp_subflow_v6_request_sock_ops;
 static struct tcp_request_sock_ops subflow_request_sock_ipv6_ops __ro_after_init;
@@ -581,6 +586,12 @@ static int subflow_v6_conn_request(struct sock *sk, struct sk_buff *skb)
 	tcp_listendrop(sk);
 	return 0; /* don't send reset */
 }
+
+static void subflow_v6_req_destructor(struct request_sock *req)
+{
+	subflow_req_destructor(req);
+	tcp6_request_sock_ops.destructor(req);
+}
 #endif
 
 struct request_sock *mptcp_subflow_reqsk_alloc(const struct request_sock_ops *ops,
@@ -1929,8 +1940,6 @@ static int subflow_ops_init(struct request_sock_ops *subflow_ops)
 	if (!subflow_ops->slab)
 		return -ENOMEM;
 
-	subflow_ops->destructor = subflow_req_destructor;
-
 	return 0;
 }
 
@@ -1938,6 +1947,8 @@ void __init mptcp_subflow_init(void)
 {
 	mptcp_subflow_v4_request_sock_ops = tcp_request_sock_ops;
 	mptcp_subflow_v4_request_sock_ops.slab_name = "request_sock_subflow_v4";
+	mptcp_subflow_v4_request_sock_ops.destructor = subflow_v4_req_destructor;
+
 	if (subflow_ops_init(&mptcp_subflow_v4_request_sock_ops) != 0)
 		panic("MPTCP: failed to init subflow v4 request sock ops\n");
 
@@ -1963,6 +1974,8 @@ void __init mptcp_subflow_init(void)
 
 	mptcp_subflow_v6_request_sock_ops = tcp6_request_sock_ops;
 	mptcp_subflow_v6_request_sock_ops.slab_name = "request_sock_subflow_v6";
+	mptcp_subflow_v6_request_sock_ops.destructor = subflow_v6_req_destructor;
+
 	if (subflow_ops_init(&mptcp_subflow_v6_request_sock_ops) != 0)
 		panic("MPTCP: failed to init subflow v6 request sock ops\n");
 
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-12-06 17:37 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-30  9:44 [PATCH mptcp-net v2 0/3] mptcp: fix request sock for subflow in v6 Matthieu Baerts
2022-11-30  9:44 ` [PATCH mptcp-net v2 1/3] mptcp: remove MPTCP 'ifdef' in TCP SYN cookies Matthieu Baerts
2022-12-05 21:52   ` Mat Martineau
2022-12-06  9:55     ` Matthieu Baerts
2022-12-06 17:20       ` Mat Martineau
2022-12-06 17:37         ` Matthieu Baerts
2022-11-30  9:44 ` [PATCH mptcp-net v2 2/3] mptcp: dedicated request sock for subflow in v6 Matthieu Baerts
2022-11-30  9:44 ` [PATCH mptcp-net v2 3/3] mptcp: use proper req destructor for IPv6 Matthieu Baerts
2022-11-30 11:49   ` mptcp: use proper req destructor for IPv6: Tests Results MPTCP CI
2022-11-30 13:48   ` MPTCP CI
2022-12-02 22:56   ` [PATCH mptcp-net v2 3/3] mptcp: use proper req destructor for IPv6 Mat Martineau
2022-12-05 10:24     ` Matthieu Baerts
2022-12-03  0:16   ` mptcp: use proper req destructor for IPv6: Tests Results MPTCP CI
  -- strict thread matches above, loose matches on Subject: below --
2022-11-29 21:08 [PATCH mptcp-net 3/3] mptcp: use proper req destructor for IPv6 Matthieu Baerts
2022-11-29 22:52 ` mptcp: use proper req destructor for IPv6: Tests Results MPTCP CI

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.