On 2/26/22 1:49 AM, Dongli Zhang wrote: > The TUN can be used as vhost-net backend. E.g, the tun_net_xmit() is the > interface to forward the skb from TUN to vhost-net/virtio-net. > > However, there are many "goto drop" in the TUN 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_PULL > - SKB_DROP_REASON_SKB_TRIM > - SKB_DROP_REASON_DEV_READY > - SKB_DROP_REASON_TAP_FILTER > - SKB_DROP_REASON_TAP_TXFILTER > > Cc: Joao Martins <joao.m.martins@xxxxxxxxxx> > Cc: Joe Jin <joe.jin@xxxxxxxxxx> > Signed-off-by: Dongli Zhang <dongli.zhang@xxxxxxxxxx> > --- > Changed since v1: > - revise the reason name > Changed since v2: > - declare drop_reason as type "enum skb_drop_reason" > Changed since v3: > - rename to TAP_FILTER and TAP_TXFILTER > - honor reverse xmas tree style declaration for 'drop_reason' in > tun_net_xmit() > > drivers/net/tun.c | 37 ++++++++++++++++++++++++++++--------- > include/linux/skbuff.h | 10 ++++++++++ > include/trace/events/skb.h | 5 +++++ > 3 files changed, 43 insertions(+), 9 deletions(-) > Reviewed-by: David Ahern <dsahern@xxxxxxxxxx>