提交 7948f6cc 编写于 作者: F Florian Westphal 提交者: David S. Miller

mptcp: allow partial cleaning of rtx head dfrag

After adding wmem accounting for the mptcp socket we could get
into a situation where the mptcp socket can't transmit more data,
and mptcp_clean_una doesn't reduce wmem even if snd_una has advanced
because it currently will only remove entire dfrags.

Allow advancing the dfrag head sequence and reduce wmem,
even though this isn't correct (as we can't release the page).

Because we will soon block on mptcp sk in case wmem is too large,
call sk_stream_write_space() in case we reduced the backlog so
userspace task blocked in sendmsg or poll will be woken up.

This isn't an issue if the send buffer is large, but it is when
SO_SNDBUF is used to reduce it to a lower value.

Note we can still get a deadlock for low SO_SNDBUF values in
case both sides of the connection write to the socket: both could
be blocked due to wmem being too small -- and current mptcp stack
will only increment mptcp ack_seq on recv.

This doesn't happen with the selftest as it uses poll() and
will always call recv if there is data to read.
Signed-off-by: NFlorian Westphal <fw@strlen.de>
Signed-off-by: NMat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 d027236c
...@@ -338,6 +338,7 @@ static bool mptcp_frag_can_collapse_to(const struct mptcp_sock *msk, ...@@ -338,6 +338,7 @@ static bool mptcp_frag_can_collapse_to(const struct mptcp_sock *msk,
static void dfrag_uncharge(struct sock *sk, int len) static void dfrag_uncharge(struct sock *sk, int len)
{ {
sk_mem_uncharge(sk, len); sk_mem_uncharge(sk, len);
sk_wmem_queued_add(sk, -len);
} }
static void dfrag_clear(struct sock *sk, struct mptcp_data_frag *dfrag) static void dfrag_clear(struct sock *sk, struct mptcp_data_frag *dfrag)
...@@ -364,8 +365,23 @@ static void mptcp_clean_una(struct sock *sk) ...@@ -364,8 +365,23 @@ static void mptcp_clean_una(struct sock *sk)
cleaned = true; cleaned = true;
} }
dfrag = mptcp_rtx_head(sk);
if (dfrag && after64(snd_una, dfrag->data_seq)) {
u64 delta = dfrag->data_seq + dfrag->data_len - snd_una;
dfrag->data_seq += delta;
dfrag->data_len -= delta;
dfrag_uncharge(sk, delta);
cleaned = true;
}
if (cleaned) { if (cleaned) {
sk_mem_reclaim_partial(sk); sk_mem_reclaim_partial(sk);
/* Only wake up writers if a subflow is ready */
if (test_bit(MPTCP_SEND_SPACE, &msk->flags))
sk_stream_write_space(sk);
} }
} }
......
...@@ -190,6 +190,16 @@ static inline struct mptcp_data_frag *mptcp_rtx_tail(const struct sock *sk) ...@@ -190,6 +190,16 @@ static inline struct mptcp_data_frag *mptcp_rtx_tail(const struct sock *sk)
return list_last_entry(&msk->rtx_queue, struct mptcp_data_frag, list); return list_last_entry(&msk->rtx_queue, struct mptcp_data_frag, list);
} }
static inline struct mptcp_data_frag *mptcp_rtx_head(const struct sock *sk)
{
struct mptcp_sock *msk = mptcp_sk(sk);
if (list_empty(&msk->rtx_queue))
return NULL;
return list_first_entry(&msk->rtx_queue, struct mptcp_data_frag, list);
}
struct mptcp_subflow_request_sock { struct mptcp_subflow_request_sock {
struct tcp_request_sock sk; struct tcp_request_sock sk;
u16 mp_capable : 1, u16 mp_capable : 1,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册