Re: [PATCH net-next v6 04/19] tcp: add datapath logic for PSP with inline key exchange
From: Daniel Zahka <daniel.zahka@gmail.com>
Date: 2025-08-14 14:43:37
On 8/14/25 9:18 AM, Paolo Abeni wrote:
On 8/12/25 2:29 AM, Daniel Zahka wrote:quoted
@@ -2070,7 +2076,9 @@ bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb, (TCPHDR_ECE | TCPHDR_CWR | TCPHDR_AE)) || !tcp_skb_can_collapse_rx(tail, skb) || thtail->doff != th->doff || - memcmp(thtail + 1, th + 1, hdrlen - sizeof(*th))) + memcmp(thtail + 1, th + 1, hdrlen - sizeof(*th)) || + /* prior to PSP Rx policy check, retain exact PSP metadata */ + psp_skb_coalesce_diff(tail, skb)) goto no_coalesce;The TCP stack will try to coalesce skbs in other places, too (i.e. tcp_try_coalesce(), tcp_collapse()...) Why a similar check is not needed there?
We handle coalescing of skb's in various places. On the tx path, we place a call to tcp_write_collapse_fence() in psp_sock_assoc_set_tx(), to prevent data written into the socket as cleartext from being merged with data written after the tx-assoc netlink operation has been performed. On the rx path, for dealing with coalescing before the skb is in the socket receive queue we call psp_skb_coalesce_diff() from tcp_add_backlog() and gro_list_prepare(). For skb's that are already on the socket receive queue, we rely on the fact that psp skb's will have skb->decrypted set, and all tcp functions that try to collapse skb's on the receive queue should call skb_cmp_decrypted() at some point. If we have missed a case, than that would be a bug.