Linux Kernel Network Programming - struct sk_buff data-structure - skb_trim() API
Linux Kernel Network Programming - struct sk_buff data-structure - skb_trim() API

Refer:
skb_trim() – remove end from a buffer ↗

And here is the copy paste of skb_trim() API (/net/core/skbuff.c) from the Kernel-source version 6.5.8 for quick reference:

/**
 *	skb_trim - remove end from a buffer
 *	@skb: buffer to alter
 *	@len: new length
 *
 *	Cut the length of a buffer down by removing data from the tail. If
 *	the buffer is already under the length specified it is not modified.
 *	The skb must be linear.
 */
void skb_trim(struct sk_buff *skb, unsigned int len)
{
	if (skb->len > len)
		__skb_trim(skb, len);
}
EXPORT_SYMBOL(skb_trim);

Which points to __skb_trim() wrapper API as you can see above, and if we trace, we get the implementation in /include/linux/skbuff.h. __skb_trim() internally calls __skb_set_length() API which has most of the core implementation of the same. And just below the same you can also see the skb_trim() function prototype.

static inline void __skb_set_length(struct sk_buff *skb, unsigned int len)
{
	if (WARN_ON(skb_is_nonlinear(skb)))
		return;
	skb->len = len;
	skb_set_tail_pointer(skb, len);
}

static inline void __skb_trim(struct sk_buff *skb, unsigned int len)
{
	__skb_set_length(skb, len);
}

void skb_trim(struct sk_buff *skb, unsigned int len);