History

net: tun: track dropped skb via kfree_skb_reason()

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_DEV_READY - SKB_DROP_REASON_NOMEM - SKB_DROP_REASON_HDR_TRUNC - SKB_DROP_REASON_TAP_FILTER - SKB_DROP_REASON_TAP_TXFILTER

Dongli Zhang committed 4 years ago

Commit 4b4f0521 parent 45a15d83 files · +51 −9Browse files

Showing the changes to include (2 of 3 files). Show all

Unified · Split

2 files
  1. include/linux/skbuff.h +18 −0
  2. include/trace/events/skb.h +5 −0
include/linux/skbuff.h+18−0
@@ -424,7 +424,25 @@ enum skb_drop_reason { · 423 unmodified lines
424 SKB_DROP_REASON_DEV_HDR, /* device driver specific424 SKB_DROP_REASON_DEV_HDR, /* device driver specific
425 * header/metadata is invalid425 * header/metadata is invalid
426 */426 */
427 /* the device is not ready to xmit/recv due to any of its data
428 * structure that is not up/ready/initialized, e.g., the IFF_UP is
429 * not set, or driver specific tun->tfiles[txq] is not initialized
430 */
431 SKB_DROP_REASON_DEV_READY,
427 SKB_DROP_REASON_FULL_RING, /* ring buffer is full */432 SKB_DROP_REASON_FULL_RING, /* ring buffer is full */
433 SKB_DROP_REASON_NOMEM, /* error due to OOM */
434 SKB_DROP_REASON_HDR_TRUNC, /* failed to trunc/extract the header
435 * from networking data, e.g., failed
436 * to pull the protocol header from
437 * frags via pskb_may_pull()
438 */
439 SKB_DROP_REASON_TAP_FILTER, /* dropped by (ebpf) filter directly
440 * attached to tun/tap, e.g., via
441 * TUNSETFILTEREBPF
442 */
443 SKB_DROP_REASON_TAP_TXFILTER, /* dropped by tx filter implemented
444 * at tun/tap, e.g., check_filter()
445 */
428 SKB_DROP_REASON_MAX,446 SKB_DROP_REASON_MAX,
429};447};
430 448
include/trace/events/skb.h+5−0
@@ -55,7 +55,12 @@ · 54 unmodified lines
55 EM(SKB_DROP_REASON_SKB_GSO_SEG, SKB_GSO_SEG) \55 EM(SKB_DROP_REASON_SKB_GSO_SEG, SKB_GSO_SEG) \
56 EM(SKB_DROP_REASON_SKB_UCOPY_FAULT, SKB_UCOPY_FAULT) \56 EM(SKB_DROP_REASON_SKB_UCOPY_FAULT, SKB_UCOPY_FAULT) \
57 EM(SKB_DROP_REASON_DEV_HDR, DEV_HDR) \57 EM(SKB_DROP_REASON_DEV_HDR, DEV_HDR) \
58 EM(SKB_DROP_REASON_DEV_READY, DEV_READY) \
58 EM(SKB_DROP_REASON_FULL_RING, FULL_RING) \59 EM(SKB_DROP_REASON_FULL_RING, FULL_RING) \
60 EM(SKB_DROP_REASON_NOMEM, NOMEM) \
61 EM(SKB_DROP_REASON_HDR_TRUNC, HDR_TRUNC) \
62 EM(SKB_DROP_REASON_TAP_FILTER, TAP_FILTER) \
63 EM(SKB_DROP_REASON_TAP_TXFILTER, TAP_TXFILTER) \
59 EMe(SKB_DROP_REASON_MAX, MAX)64 EMe(SKB_DROP_REASON_MAX, MAX)
60 65
61#undef EM66#undef EM

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t