mptcp: reset 'first' and ack_hint on subflow close
Subsystems (2)
Florian Westphal
PATCH 1/1 mptcp: reset 'first' and ack_hint on subflow close
Just like with last_snd, we have to NULL 'first' on subflow close.
ack_hint isn't strictly required (its never dereferenced), but better to clear this as well.
msk->first is dereferenced unconditionally at accept time, but at that point the ssk is not on the conn_list yet -- this means worker can't see it when iterating the conn_list.
--- net/mptcp/protocol.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/mptcp/protocol.c +6 -0
@@ -2161,6 +2161,12 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,if (ssk == msk->last_snd) msk->last_snd =NULL ; +if (ssk == msk->ack_hint) + msk->ack_hint =NULL ; + +if (ssk == msk->first) + msk->first =NULL ; +if (msk->subflow && ssk == msk->subflow->sk)mptcp_dispose_initial_subflow (msk); }
Signature · 1 line
2.26.2
Paolo Abeni
Quoted 8 lines · Florian Westphal
Just like with
last_snd, we have to NULL 'first' on subflow close.
ack_hintisn't strictly required (its never dereferenced), but better to clear this as well.
msk->firstis dereferenced unconditionally at accept time, but at that point the ssk is not on theconn_listyet -- this means worker can't see it when iterating theconn_list.
There is a __mptcp_flush_join_list() before __mptcp_close_subflow(), could that matter? IIRC even the PM can move the subflow from join_list to conn_list to take some actions.
not 110% related, we have a couple of !msk->first in mptcp_update_rcv_data_fin() and mptcp_check_data_fin() which are likely obsoleted/to be removed.
Thanks!
Paolo
Florian Westphal
Quoted 10 lines · Paolo Abeni
Quoted 8 lines · Florian Westphal
Just like with
last_snd, we have to NULL 'first' on subflow close.
ack_hintisn't strictly required (its never dereferenced), but better to clear this as well.
msk->firstis dereferenced unconditionally at accept time, but at that point the ssk is not on theconn_listyet -- this means worker can't see it when iterating theconn_list.
Quoted 7 lines
There is a
__mptcp_flush_join_list()before__mptcp_close_subflow(), could that matter? IIRC even the PM can move the subflow fromjoin_listtoconn_listto take some actions.not 110% related, we have a couple of !msk->first in
mptcp_update_rcv_data_fin()andmptcp_check_data_fin()which are likely obsoleted/to be removed.
Hmm, if those are redunant, what exactly do we need msk->first for? Fallback mode could just fetch the subflow off conn_list.
Matthieu, please ignore this patch for now, I'd prefer to remove msk->first completely if possible.
Paolo Abeni
Quoted 15 lines · Florian Westphal
Quoted 14 lines · Paolo Abeni
Quoted 8 lines · Florian Westphal
Just like with
last_snd, we have to NULL 'first' on subflow close.
ack_hintisn't strictly required (its never dereferenced), but better to clear this as well.
msk->firstis dereferenced unconditionally at accept time, but at that point the ssk is not on theconn_listyet -- this means worker can't see it when iterating theconn_list.There is a
__mptcp_flush_join_list()before__mptcp_close_subflow(), could that matter? IIRC even the PM can move the subflow fromjoin_listtoconn_listto take some actions.
Quoted 6 lines
Quoted 3 lines
not 110% related, we have a couple of !msk->first in
mptcp_update_rcv_data_fin()andmptcp_check_data_fin()which are likely obsoleted/to be removed.Hmm, if those are redunant, what exactly do we need
msk->firstfor? Fallback mode could just fetch the subflow offconn_list.
AFAICS it mostly avoids traversing the conn_list in some scenarios ;) IIRC I added that thing as early optimization (== root of all evil)
Quoted 3 lines
Matthieu, please ignore this patch for now, I'd prefer to remove
msk->firstcompletely if possible.
I would love this latter option!
(in the long term I think it would be nice also remote ->subflow)
Thanks!
Paolo
Florian Westphal
Quoted 6 lines · Paolo Abeni
Quoted 5 lines · Florian Westphal
Just like with
last_snd, we have to NULL 'first' on subflow close.
ack_hintisn't strictly required (its never dereferenced), but better to clear this as well.
Quoted 7 lines
Quoted 3 lines
msk->firstis dereferenced unconditionally at accept time, but at that point the ssk is not on theconn_listyet -- this means worker can't see it when iterating theconn_list.There is a
__mptcp_flush_join_list()before__mptcp_close_subflow(), could that matter? IIRC even the PM can move the subflow fromjoin_listtoconn_listto take some actions.
AFAICS msk->first gets set/used to avoid use of join_list. The latter is only used for incoming mp_join, not mp_capable.
I guess we can use the join_list but we whould have to stop splicing it to the conn_list unconditionally -- we would need to keep mp_capable one on the join_list until accept() time.
I think its better to apply this as-is at the moment, removing of ->first seems possible but the naive approach un-does several fixes you made to avoid exposure of the first subflow to the work queue.
Paolo Abeni
Acked-byQuoted 11 lines · Florian Westphal
Quoted 10 lines · Paolo Abeni
Quoted 8 lines · Florian Westphal
Just like with
last_snd, we have to NULL 'first' on subflow close.
ack_hintisn't strictly required (its never dereferenced), but better to clear this as well.
msk->firstis dereferenced unconditionally at accept time, but at that point the ssk is not on theconn_listyet -- this means worker can't see it when iterating theconn_list.
Quoted 6 lines
Quoted 3 lines
There is a
__mptcp_flush_join_list()before__mptcp_close_subflow(), could that matter? IIRC even the PM can move the subflow fromjoin_listtoconn_listto take some actions.AFAICS
msk->firstgets set/used to avoid use ofjoin_list. The latter is only used for incomingmp_join, notmp_capable.
Sharing here private conversation.
If msk->first is closed before accept, accept will still return an established msk socket, with msk->first still valid and pointing to the original subflow, in TCP_CLOSE status (and still with a valid refcnt [==1])
TL;DR: the patch looks safe, no need for a complex codying to remove msk->first field.