Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: Preserve metadata on pskb_expand_head

pskb_expand_head() copies headroom, including skb metadata, into the newly
allocated head, but then clears the metadata. As a result, metadata is lost
when BPF helpers trigger an skb head reallocation.

Let the skb metadata remain in the newly created copy of head.

Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Link: https://patch.msgid.link/20251105-skb-meta-rx-path-v4-2-5ceb08a9b37b@cloudflare.com

authored by

Jakub Sitnicki and committed by
Martin KaFai Lau
290fc0be 8989d328

+4 -2
+4 -2
net/core/skbuff.c
··· 2234 2234 * 2235 2235 * All the pointers pointing into skb header may change and must be 2236 2236 * reloaded after call to this function. 2237 + * 2238 + * Note: If you skb_push() the start of the buffer after reallocating the 2239 + * header, call skb_postpush_data_move() first to move the metadata out of 2240 + * the way before writing to &sk_buff->data. 2237 2241 */ 2238 2242 2239 2243 int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail, ··· 2308 2304 skb->hdr_len = 0; 2309 2305 skb->nohdr = 0; 2310 2306 atomic_set(&skb_shinfo(skb)->dataref, 1); 2311 - 2312 - skb_metadata_clear(skb); 2313 2307 2314 2308 /* It is not generally safe to change skb->truesize. 2315 2309 * For the moment, we really care of rx path, or