Commit a0e17064 authored by Florian Westphal's avatar Florian Westphal Committed by David S. Miller

mptcp: move common nospace-pattern to a helper

Paolo noticed that ssk_check_wmem() has same pattern, so add/use
common helper for both places.
Suggested-by: default avatarPaolo Abeni <pabeni@redhat.com>
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent eb682677
...@@ -653,6 +653,15 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk, ...@@ -653,6 +653,15 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,
return ret; return ret;
} }
static void mptcp_nospace(struct mptcp_sock *msk, struct socket *sock)
{
clear_bit(MPTCP_SEND_SPACE, &msk->flags);
smp_mb__after_atomic(); /* msk->flags is changed by write_space cb */
/* enables sk->write_space() callbacks */
set_bit(SOCK_NOSPACE, &sock->flags);
}
static struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk) static struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk)
{ {
struct mptcp_subflow_context *subflow; struct mptcp_subflow_context *subflow;
...@@ -666,13 +675,8 @@ static struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk) ...@@ -666,13 +675,8 @@ static struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk)
if (!sk_stream_memory_free(ssk)) { if (!sk_stream_memory_free(ssk)) {
struct socket *sock = ssk->sk_socket; struct socket *sock = ssk->sk_socket;
if (sock) { if (sock)
clear_bit(MPTCP_SEND_SPACE, &msk->flags); mptcp_nospace(msk, sock);
smp_mb__after_atomic();
/* enables sk->write_space() callbacks */
set_bit(SOCK_NOSPACE, &sock->flags);
}
return NULL; return NULL;
} }
...@@ -698,13 +702,8 @@ static void ssk_check_wmem(struct mptcp_sock *msk, struct sock *ssk) ...@@ -698,13 +702,8 @@ static void ssk_check_wmem(struct mptcp_sock *msk, struct sock *ssk)
return; return;
sock = READ_ONCE(ssk->sk_socket); sock = READ_ONCE(ssk->sk_socket);
if (sock)
if (sock) { mptcp_nospace(msk, sock);
clear_bit(MPTCP_SEND_SPACE, &msk->flags);
smp_mb__after_atomic();
/* set NOSPACE only after clearing SEND_SPACE flag */
set_bit(SOCK_NOSPACE, &sock->flags);
}
} }
static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment