From e29d5c16e0567e5edb9c51f44d5e926d67a9a02c Mon Sep 17 00:00:00 2001 From: Paolo Abeni Date: Wed, 22 Nov 2023 17:21:26 +0100 Subject: [PATCH] mptcp: cleanup state propagation. When propagating the first subflow state via the release_cb, the msk must actually take to 2 separate actions: state sync-up and send buffer sync-up. Relaying on the specific flags instead of bounding both in __mptcp_sync_state(), allows cleaning up a bit the code. Signed-off-by: Paolo Abeni Message-Id: <240a97d522887a938faeb24a6a3e3a9ed24570b1.1700667908.git.pabeni@redhat.com> --- net/mptcp/protocol.c | 3 +-- net/mptcp/subflow.c | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 199b2e09f1acd..4fc038d29623a 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3404,9 +3404,8 @@ static void mptcp_release_cb(struct sock *sk) if (unlikely(msk->cb_flags)) { /* be sure to sync the msk state before taking actions * depending on sk_state (MPTCP_ERROR_REPORT) - * On sk release avoid actions depending on the first subflow */ - if (__test_and_clear_bit(MPTCP_SYNC_STATE, &msk->cb_flags) && msk->first) + if (__test_and_clear_bit(MPTCP_SYNC_STATE, &msk->cb_flags)) __mptcp_sync_state(sk, msk->pending_state); if (__test_and_clear_bit(MPTCP_ERROR_REPORT, &msk->cb_flags)) __mptcp_error_report(sk); diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 6d7684c35e933..64302a1ac3063 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -421,9 +421,6 @@ static bool subflow_use_different_dport(struct mptcp_sock *msk, const struct soc void __mptcp_sync_state(struct sock *sk, int state) { - struct mptcp_sock *msk = mptcp_sk(sk); - - __mptcp_propagate_sndbuf(sk, msk->first); if (sk->sk_state == TCP_SYN_SENT) { inet_sk_state_store(sk, state); sk->sk_state_change(sk); @@ -436,10 +433,12 @@ static void mptcp_propagate_state(struct sock *sk, struct sock *ssk) mptcp_data_lock(sk); if (!sock_owned_by_user(sk)) { + __mptcp_propagate_sndbuf(sk, msk->first); __mptcp_sync_state(sk, ssk->sk_state); } else { msk->pending_state = ssk->sk_state; __set_bit(MPTCP_SYNC_STATE, &msk->cb_flags); + __set_bit(MPTCP_SYNC_SNDBUF, &msk->cb_flags); } mptcp_data_unlock(sk); }