net: tap: track dropped skb via kfree_skb_reason()

The TAP can be used as vhost-net backend. E.g., the tap_handle_frame() is
the interface to forward the skb from TAP to vhost-net/virtio-net.

However, there are many "goto drop" in the TAP driver. Therefore, the
kfree_skb_reason() is involved at each "goto drop" to help userspace
ftrace/ebpf to track the reason for the loss of packets.

The below reasons are introduced:

- SKB_DROP_REASON_SKB_CSUM
- SKB_DROP_REASON_SKB_GSO_SEG
- SKB_DROP_REASON_SKB_UCOPY_FAULT
- SKB_DROP_REASON_DEV_HDR
- SKB_DROP_REASON_FULL_RING

Cc: Joao Martins <joao.m.martins@oracle.com>
Cc: Joe Jin <joe.jin@oracle.com>
Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Dongli Zhang 2022-03-04 06:55:05 -08:00 committed by David S. Miller
parent 925a24213b
commit 736f16de75
3 changed files with 43 additions and 10 deletions

View file

@ -412,6 +412,19 @@ enum skb_drop_reason {
* this means that L3 protocol is
* not supported
*/
SKB_DROP_REASON_SKB_CSUM, /* sk_buff checksum computation
* error
*/
SKB_DROP_REASON_SKB_GSO_SEG, /* gso segmentation error */
SKB_DROP_REASON_SKB_UCOPY_FAULT, /* failed to copy data from
* user space, e.g., via
* zerocopy_sg_from_iter()
* or skb_orphan_frags_rx()
*/
SKB_DROP_REASON_DEV_HDR, /* device driver specific
* header/metadata is invalid
*/
SKB_DROP_REASON_FULL_RING, /* ring buffer is full */
SKB_DROP_REASON_MAX,
};