Re: [PATCH net-next v2] tun: use pskb_may_pull_reason() and remove SKB_DROP_REASON_HDR_TRUNC

From: Willem de Bruijn

Date: Sat Oct 03 2026 - 14:40:07 EST


Anton Danilov wrote:
> tun_get_user() is the only user of SKB_DROP_REASON_HDR_TRUNC. It sets
> it when pskb_may_pull() fails to pull the Ethernet header of a frame
> written to a TAP device.
>
> pskb_may_pull_reason() reports why the pull failed: PKT_TOO_SMALL if
> the packet is shorter than requested, NOMEM if pulling the data into
> the linear area fails. Use it for both header pulls in tun_get_user(),
> on TAP and on TUN devices, and remove the now unused
> SKB_DROP_REASON_HDR_TRUNC. The pull of the IP version byte on a TUN
> device with IFF_NO_PI was reported as NOT_SPECIFIED and now reports
> PKT_TOO_SMALL, for example when only the virtio-net header is written.
>
> After a successful pull drop_reason is SKB_NOT_DROPPED_YET. The later
> error paths without a reason of their own, the unknown IP version on
> TUN and the path that finds the queue detached, relied on the
> SKB_DROP_REASON_NOT_SPECIFIED initializer. Fall back to
> SKB_DROP_REASON_NOT_SPECIFIED at the free_skb label, as vxlan_rcv()
> does, so that these paths, and any later one without a reason of its
> own, keep reporting it.
>
> The errors returned to user space do not change.
>
> Suggested-by: Ido Schimmel <idosch@xxxxxxxxxx>
> Link: https://lore.kernel.org/netdev/20260923145931.GA2859441@shredder/
> Assisted-by: LLM
> Signed-off-by: Anton Danilov <littlesmilingcloud@xxxxxxxxx>

Reviewed-by: Willem de Bruijn <willemb@xxxxxxxxxx>