Skip to content

Commit 68c7af9

Browse files
Paolo Abenikuba-moo
authored andcommitted
mptcp: factor out a basic skb coalesce helper
The upcoming patch will introduced backlog processing for MPTCP socket, and we want to leverage coalescing in such data path. Factor out the relevant bits not touching memory accounting to deal with such use-case. Co-developed-by: Geliang Tang <geliang@kernel.org> Signed-off-by: Geliang Tang <geliang@kernel.org> Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Link: https://patch.msgid.link/20250927-net-next-mptcp-rcv-path-imp-v1-6-5da266aa9c1a@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent c4ebc4e commit 68c7af9

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

net/mptcp/protocol.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,22 +142,33 @@ static void mptcp_drop(struct sock *sk, struct sk_buff *skb)
142142
__kfree_skb(skb);
143143
}
144144

145-
static bool mptcp_try_coalesce(struct sock *sk, struct sk_buff *to,
146-
struct sk_buff *from)
145+
static bool __mptcp_try_coalesce(struct sock *sk, struct sk_buff *to,
146+
struct sk_buff *from, bool *fragstolen,
147+
int *delta)
147148
{
148-
bool fragstolen;
149-
int delta;
149+
int limit = READ_ONCE(sk->sk_rcvbuf);
150150

151151
if (unlikely(MPTCP_SKB_CB(to)->cant_coalesce) ||
152152
MPTCP_SKB_CB(from)->offset ||
153-
((to->len + from->len) > (sk->sk_rcvbuf >> 3)) ||
154-
!skb_try_coalesce(to, from, &fragstolen, &delta))
153+
((to->len + from->len) > (limit >> 3)) ||
154+
!skb_try_coalesce(to, from, fragstolen, delta))
155155
return false;
156156

157157
pr_debug("colesced seq %llx into %llx new len %d new end seq %llx\n",
158158
MPTCP_SKB_CB(from)->map_seq, MPTCP_SKB_CB(to)->map_seq,
159159
to->len, MPTCP_SKB_CB(from)->end_seq);
160160
MPTCP_SKB_CB(to)->end_seq = MPTCP_SKB_CB(from)->end_seq;
161+
return true;
162+
}
163+
164+
static bool mptcp_try_coalesce(struct sock *sk, struct sk_buff *to,
165+
struct sk_buff *from)
166+
{
167+
bool fragstolen;
168+
int delta;
169+
170+
if (!__mptcp_try_coalesce(sk, to, from, &fragstolen, &delta))
171+
return false;
161172

162173
/* note the fwd memory can reach a negative value after accounting
163174
* for the delta, but the later skb free will restore a non

0 commit comments

Comments
 (0)