| @@ -322,6 +322,7 @@ rx_handler_result_t tap_handle_frame(struct sk_buff **pskb) · 321 unmodified lines |
| 322 | struct tap_dev *tap; | 322 | struct tap_dev *tap; |
| 323 | struct tap_queue *q; | 323 | struct tap_queue *q; |
| 324 | netdev_features_t features = TAP_FEATURES; | 324 | netdev_features_t features = TAP_FEATURES; |
| | 325 | enum skb_drop_reason drop_reason; |
| 325 | | 326 | |
| 326 | tap = tap_dev_get_rcu(dev); | 327 | tap = tap_dev_get_rcu(dev); |
| 327 | if (!tap) | 328 | if (!tap) |
| @@ -343,12 +344,16 @@ rx_handler_result_t tap_handle_frame(struct sk_buff **pskb) · 15 unmodified lines |
| 343 | struct sk_buff *segs = __skb_gso_segment(skb, features, false); | 344 | struct sk_buff *segs = __skb_gso_segment(skb, features, false); |
| 344 | struct sk_buff *next; | 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 | goto drop; | 349 | goto drop; |
| | 350 | } |
| 348 | | 351 | |
| 349 | if (!segs) { | 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 | goto drop; | 355 | goto drop; |
| | 356 | } |
| 352 | goto wake_up; | 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 | skb_list_walk_safe(segs, skb, next) { | 361 | skb_list_walk_safe(segs, skb, next) { |
| 357 | skb_mark_not_on_list(skb); | 362 | skb_mark_not_on_list(skb); |
| 358 | if (ptr_ring_produce(&q->ring, skb)) { | 363 | if (ptr_ring_produce(&q->ring, skb)) { |
| 359 | kfree_skb(skb); | 364 | drop_reason = SKB_DROP_REASON_FULL_RING; |
| 360 | kfree_skb_list(next); | 365 | kfree_skb_reason(skb, drop_reason); |
| | 366 | kfree_skb_list_reason(next, drop_reason); |
| 361 | break; | 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 | if (skb->ip_summed == CHECKSUM_PARTIAL && | 376 | if (skb->ip_summed == CHECKSUM_PARTIAL && |
| 371 | !(features & NETIF_F_CSUM_MASK) && | 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 | goto drop; | 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 | goto drop; | 384 | goto drop; |
| | 385 | } |
| 376 | } | 386 | } |
| 377 | | 387 | |
| 378 | wake_up: | 388 | wake_up: |
| @@ -383,7 +393,7 @@ drop: · 4 unmodified lines |
| 383 | /* Count errors/drops only here, thus don't care about args. */ | 393 | /* Count errors/drops only here, thus don't care about args. */ |
| 384 | if (tap->count_rx_dropped) | 394 | if (tap->count_rx_dropped) |
| 385 | tap->count_rx_dropped(tap); | 395 | tap->count_rx_dropped(tap); |
| 386 | kfree_skb(skb); | 396 | kfree_skb_reason(skb, drop_reason); |
| 387 | return RX_HANDLER_CONSUMED; | 397 | return RX_HANDLER_CONSUMED; |
| 388 | } | 398 | } |
| 389 | EXPORT_SYMBOL_GPL(tap_handle_frame); | 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 | int depth; | 642 | int depth; |
| 633 | bool zerocopy = false; | 643 | bool zerocopy = false; |
| 634 | size_t linear; | 644 | size_t linear; |
| | 645 | enum skb_drop_reason drop_reason; |
| 635 | | 646 | |
| 636 | if (q->flags & IFF_VNET_HDR) { | 647 | if (q->flags & IFF_VNET_HDR) { |
| 637 | vnet_hdr_len = READ_ONCE(q->vnet_hdr_sz); | 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 | else | 707 | else |
| 697 | err = skb_copy_datagram_from_iter(skb, 0, from, len); | 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 | goto err_kfree; | 712 | goto err_kfree; |
| | 713 | } |
| 701 | | 714 | |
| 702 | skb_set_network_header(skb, ETH_HLEN); | 715 | skb_set_network_header(skb, ETH_HLEN); |
| 703 | skb_reset_mac_header(skb); | 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 | if (vnet_hdr_len) { | 719 | if (vnet_hdr_len) { |
| 707 | err = virtio_net_hdr_to_skb(skb, &vnet_hdr, | 720 | err = virtio_net_hdr_to_skb(skb, &vnet_hdr, |
| 708 | tap_is_little_endian(q)); | 721 | tap_is_little_endian(q)); |
| 709 | if (err) | 722 | if (err) { |
| | 723 | drop_reason = SKB_DROP_REASON_DEV_HDR; |
| 710 | goto err_kfree; | 724 | goto err_kfree; |
| | 725 | } |
| 711 | } | 726 | } |
| 712 | | 727 | |
| 713 | skb_probe_transport_header(skb); | 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 | return total_len; | 753 | return total_len; |
| 739 | | 754 | |
| 740 | err_kfree: | 755 | err_kfree: |
| 741 | kfree_skb(skb); | 756 | kfree_skb_reason(skb, drop_reason); |
| 742 | | 757 | |
| 743 | err: | 758 | err: |
| 744 | rcu_read_lock(); | 759 | rcu_read_lock(); |