mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 09:20:13 -04:00
mptcp: enforce hard limit on backlog flushing
Currently a wild producer could keep the backlog flushing operation spinning for an unbound time. Since the previous patch, the amount of data present in the backlog is hard-limited. Move the backlog len update at the end of the flush loop to prevent it spinning forever. Also, no need to splice back the remaining skbs list into the backlog, as such list is always empty after each backlog processing loop. Signed-off-by: Paolo Abeni <pabeni@redhat.com> Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Link: https://patch.msgid.link/20260807-net-next-mptcp-oooq-pruning-v3-5-dbc1eb853cc3@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
e0e4d56b05
commit
b1224c4b40
@@ -2229,7 +2229,6 @@ static bool __mptcp_move_skbs(struct sock *sk, struct list_head *skbs, u32 *delt
|
||||
struct mptcp_sock *msk = mptcp_sk(sk);
|
||||
bool moved = false;
|
||||
|
||||
*delta = 0;
|
||||
while (1) {
|
||||
prefetch(skb->next);
|
||||
list_del(&skb->list);
|
||||
@@ -2266,20 +2265,12 @@ static bool mptcp_can_spool_backlog(struct sock *sk, struct list_head *skbs)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void mptcp_backlog_spooled(struct sock *sk, u32 moved,
|
||||
struct list_head *skbs)
|
||||
{
|
||||
struct mptcp_sock *msk = mptcp_sk(sk);
|
||||
|
||||
WRITE_ONCE(msk->backlog_len, msk->backlog_len - moved);
|
||||
list_splice(skbs, &msk->backlog_list);
|
||||
}
|
||||
|
||||
static bool mptcp_move_skbs(struct sock *sk)
|
||||
{
|
||||
struct mptcp_sock *msk = mptcp_sk(sk);
|
||||
struct list_head skbs;
|
||||
bool enqueued = false;
|
||||
u32 moved;
|
||||
u32 moved = 0;
|
||||
|
||||
mptcp_data_lock(sk);
|
||||
while (mptcp_can_spool_backlog(sk, &skbs)) {
|
||||
@@ -2287,8 +2278,8 @@ static bool mptcp_move_skbs(struct sock *sk)
|
||||
enqueued |= __mptcp_move_skbs(sk, &skbs, &moved);
|
||||
|
||||
mptcp_data_lock(sk);
|
||||
mptcp_backlog_spooled(sk, moved, &skbs);
|
||||
}
|
||||
WRITE_ONCE(msk->backlog_len, msk->backlog_len - moved);
|
||||
mptcp_data_unlock(sk);
|
||||
|
||||
if (enqueued && mptcp_epollin_ready(sk))
|
||||
@@ -3747,12 +3738,12 @@ static void mptcp_release_cb(struct sock *sk)
|
||||
__must_hold(&sk->sk_lock.slock)
|
||||
{
|
||||
struct mptcp_sock *msk = mptcp_sk(sk);
|
||||
u32 moved = 0;
|
||||
|
||||
for (;;) {
|
||||
unsigned long flags = (msk->cb_flags & MPTCP_FLAGS_PROCESS_CTX_NEED);
|
||||
struct list_head join_list, skbs;
|
||||
bool spool_bl;
|
||||
u32 moved;
|
||||
|
||||
spool_bl = mptcp_can_spool_backlog(sk, &skbs);
|
||||
if (!flags && !spool_bl)
|
||||
@@ -3785,9 +3776,9 @@ static void mptcp_release_cb(struct sock *sk)
|
||||
|
||||
cond_resched();
|
||||
spin_lock_bh(&sk->sk_lock.slock);
|
||||
if (spool_bl)
|
||||
mptcp_backlog_spooled(sk, moved, &skbs);
|
||||
}
|
||||
if (moved)
|
||||
WRITE_ONCE(msk->backlog_len, msk->backlog_len - moved);
|
||||
|
||||
if (__test_and_clear_bit(MPTCP_CLEAN_UNA, &msk->cb_flags))
|
||||
__mptcp_clean_una_wakeup(sk);
|
||||
|
||||
Reference in New Issue
Block a user