| @@ -322,6 +322,7 @@ rx_handler_result_t tap_handle_frame(struct sk_buff **pskb) · 321 unmodified lines |
| 322 | 322 | struct tap_dev *tap; |
| 323 | 323 | struct tap_queue *q; |
| 324 | 324 | netdev_features_t features = TAP_FEATURES; |
| 325 | + enum skb_drop_reason drop_reason; |
| 325 | 326 | |
| 326 | 327 | tap = tap_dev_get_rcu(dev); |
| 327 | 328 | if (!tap) |
| @@ -343,12 +344,16 @@ rx_handler_result_t tap_handle_frame(struct sk_buff **pskb) · 15 unmodified lines |
| 343 | 344 | struct sk_buff *segs = __skb_gso_segment(skb, features, false); |
| 344 | 345 | struct sk_buff *next; |
| 345 | 346 | |
| 346 | | − if (IS_ERR(segs)) |
| 347 | + if (IS_ERR(segs)) { |
| 348 | + drop_reason = SKB_DROP_REASON_SKB_GSO_SEG; |
| 347 | 349 | goto drop; |
| 350 | + } |
| 348 | 351 | |
| 349 | 352 | if (!segs) { |
| 350 | | − if (ptr_ring_produce(&q->ring, skb)) |
| 353 | + if (ptr_ring_produce(&q->ring, skb)) { |
| 354 | + drop_reason = SKB_DROP_REASON_FULL_RING; |
| 351 | 355 | goto drop; |
| 356 | + } |
| 352 | 357 | goto wake_up; |
| 353 | 358 | } |
| 354 | 359 | |
| @@ -356,8 +361,9 @@ rx_handler_result_t tap_handle_frame(struct sk_buff **pskb) · 1 unmodified line |
| 356 | 361 | skb_list_walk_safe(segs, skb, next) { |
| 357 | 362 | skb_mark_not_on_list(skb); |
| 358 | 363 | if (ptr_ring_produce(&q->ring, skb)) { |
| 359 | | − kfree_skb(skb); |
| 360 | | − kfree_skb_list(next); |
| 364 | + drop_reason = SKB_DROP_REASON_FULL_RING; |
| 365 | + kfree_skb_reason(skb, drop_reason); |
| 366 | + kfree_skb_list_reason(next, drop_reason); |
| 361 | 367 | break; |
| 362 | 368 | } |
| 363 | 369 | } |
| @@ -369,10 +375,14 @@ rx_handler_result_t tap_handle_frame(struct sk_buff **pskb) · 5 unmodified lines |
| 369 | 375 | */ |
| 370 | 376 | if (skb->ip_summed == CHECKSUM_PARTIAL && |
| 371 | 377 | !(features & NETIF_F_CSUM_MASK) && |
| 372 | | − skb_checksum_help(skb)) |
| 378 | + skb_checksum_help(skb)) { |
| 379 | + drop_reason = SKB_DROP_REASON_SKB_CSUM; |
| 373 | 380 | goto drop; |
| 374 | | − if (ptr_ring_produce(&q->ring, skb)) |
| 381 | + } |
| 382 | + if (ptr_ring_produce(&q->ring, skb)) { |
| 383 | + drop_reason = SKB_DROP_REASON_FULL_RING; |
| 375 | 384 | goto drop; |
| 385 | + } |
| 376 | 386 | } |
| 377 | 387 | |
| 378 | 388 | wake_up: |
| @@ -383,7 +393,7 @@ drop: · 4 unmodified lines |
| 383 | 393 | /* Count errors/drops only here, thus don't care about args. */ |
| 384 | 394 | if (tap->count_rx_dropped) |
| 385 | 395 | tap->count_rx_dropped(tap); |
| 386 | | − kfree_skb(skb); |
| 396 | + kfree_skb_reason(skb, drop_reason); |
| 387 | 397 | return RX_HANDLER_CONSUMED; |
| 388 | 398 | } |
| 389 | 399 | EXPORT_SYMBOL_GPL(tap_handle_frame); |
| @@ -632,6 +642,7 @@ static ssize_t tap_get_user(struct tap_queue *q, void *msg_control, · 242 unmodified lines |
| 632 | 642 | int depth; |
| 633 | 643 | bool zerocopy = false; |
| 634 | 644 | size_t linear; |
| 645 | + enum skb_drop_reason drop_reason; |
| 635 | 646 | |
| 636 | 647 | if (q->flags & IFF_VNET_HDR) { |
| 637 | 648 | vnet_hdr_len = READ_ONCE(q->vnet_hdr_sz); |
| @@ -696,8 +707,10 @@ static ssize_t tap_get_user(struct tap_queue *q, void *msg_control, · 58 unmodified lines |
| 696 | 707 | else |
| 697 | 708 | err = skb_copy_datagram_from_iter(skb, 0, from, len); |
| 698 | 709 | |
| 699 | | − if (err) |
| 710 | + if (err) { |
| 711 | + drop_reason = SKB_DROP_REASON_SKB_UCOPY_FAULT; |
| 700 | 712 | goto err_kfree; |
| 713 | + } |
| 701 | 714 | |
| 702 | 715 | skb_set_network_header(skb, ETH_HLEN); |
| 703 | 716 | skb_reset_mac_header(skb); |
| @@ -706,8 +719,10 @@ static ssize_t tap_get_user(struct tap_queue *q, void *msg_control, · 2 unmodified lines |
| 706 | 719 | if (vnet_hdr_len) { |
| 707 | 720 | err = virtio_net_hdr_to_skb(skb, &vnet_hdr, |
| 708 | 721 | tap_is_little_endian(q)); |
| 709 | | − if (err) |
| 722 | + if (err) { |
| 723 | + drop_reason = SKB_DROP_REASON_DEV_HDR; |
| 710 | 724 | goto err_kfree; |
| 725 | + } |
| 711 | 726 | } |
| 712 | 727 | |
| 713 | 728 | skb_probe_transport_header(skb); |
| @@ -738,7 +753,7 @@ static ssize_t tap_get_user(struct tap_queue *q, void *msg_control, · 24 unmodified lines |
| 738 | 753 | return total_len; |
| 739 | 754 | |
| 740 | 755 | err_kfree: |
| 741 | | − kfree_skb(skb); |
| 756 | + kfree_skb_reason(skb, drop_reason); |
| 742 | 757 | |
| 743 | 758 | err: |
| 744 | 759 | rcu_read_lock(); |