diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 8b82a7fe6ec7..d4152c9ba8df 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1903,7 +1903,8 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, if (tun->flags & IFF_NO_PI) { u8 ip_version; - if (!pskb_may_pull(skb, 1)) { + drop_reason = pskb_may_pull_reason(skb, 1); + if (drop_reason) { err = -EINVAL; goto drop; } @@ -1926,9 +1927,9 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, skb->protocol = pi.proto; break; case IFF_TAP: - if (!pskb_may_pull(skb, ETH_HLEN)) { + drop_reason = pskb_may_pull_reason(skb, ETH_HLEN); + if (drop_reason) { err = -ENOMEM; - drop_reason = SKB_DROP_REASON_HDR_TRUNC; goto drop; } skb_set_network_header(skb, ETH_HLEN); @@ -2065,6 +2066,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, dev_core_stats_rx_dropped_inc(tun->dev); free_skb: + drop_reason = drop_reason ?: SKB_DROP_REASON_NOT_SPECIFIED; if (!IS_ERR_OR_NULL(skb)) kfree_skb_reason(skb, drop_reason); diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h index 664249924219..fa2fe8990557 100644 --- a/include/net/dropreason-core.h +++ b/include/net/dropreason-core.h @@ -82,7 +82,6 @@ FN(DEV_READY) \ FN(FULL_RING) \ FN(NOMEM) \ - FN(HDR_TRUNC) \ FN(TAP_FILTER) \ FN(TAP_TXFILTER) \ FN(ICMP_CSUM) \ @@ -427,12 +426,6 @@ enum skb_drop_reason { SKB_DROP_REASON_FULL_RING, /** @SKB_DROP_REASON_NOMEM: error due to OOM */ SKB_DROP_REASON_NOMEM, - /** - * @SKB_DROP_REASON_HDR_TRUNC: failed to trunc/extract the header from - * networking data, e.g., failed to pull the protocol header from - * frags via pskb_may_pull() - */ - SKB_DROP_REASON_HDR_TRUNC, /** * @SKB_DROP_REASON_TAP_FILTER: dropped by (ebpf) filter directly attached * to tun/tap, e.g., via TUNSETFILTEREBPF