Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add skb drop reasons to IPv6 UDP receive path

Enumerate the skb drop reasons in the receive path for IPv6 UDP packets.

Signed-off-by: Donald Hunter <donald.hunter@redhat.com>
Link: https://lore.kernel.org/r/20220926120350.14928-1-donald.hunter@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Donald Hunter and committed by
Jakub Kicinski
0d92efde ab7ea1e7

+16 -6
+16 -6
net/ipv6/udp.c
··· 650 650 rc = __udp_enqueue_schedule_skb(sk, skb); 651 651 if (rc < 0) { 652 652 int is_udplite = IS_UDPLITE(sk); 653 + enum skb_drop_reason drop_reason; 653 654 654 655 /* Note that an ENOMEM error is charged twice */ 655 - if (rc == -ENOMEM) 656 + if (rc == -ENOMEM) { 656 657 UDP6_INC_STATS(sock_net(sk), 657 658 UDP_MIB_RCVBUFERRORS, is_udplite); 658 - else 659 + drop_reason = SKB_DROP_REASON_SOCKET_RCVBUFF; 660 + } else { 659 661 UDP6_INC_STATS(sock_net(sk), 660 662 UDP_MIB_MEMERRORS, is_udplite); 663 + drop_reason = SKB_DROP_REASON_PROTO_MEM; 664 + } 661 665 UDP6_INC_STATS(sock_net(sk), UDP_MIB_INERRORS, is_udplite); 662 - kfree_skb(skb); 666 + kfree_skb_reason(skb, drop_reason); 663 667 return -1; 664 668 } 665 669 ··· 679 675 680 676 static int udpv6_queue_rcv_one_skb(struct sock *sk, struct sk_buff *skb) 681 677 { 678 + enum skb_drop_reason drop_reason = SKB_DROP_REASON_NOT_SPECIFIED; 682 679 struct udp_sock *up = udp_sk(sk); 683 680 int is_udplite = IS_UDPLITE(sk); 684 681 685 - if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) 682 + if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) { 683 + drop_reason = SKB_DROP_REASON_XFRM_POLICY; 686 684 goto drop; 685 + } 687 686 688 687 if (static_branch_unlikely(&udpv6_encap_needed_key) && up->encap_type) { 689 688 int (*encap_rcv)(struct sock *sk, struct sk_buff *skb); ··· 745 738 udp_lib_checksum_complete(skb)) 746 739 goto csum_error; 747 740 748 - if (sk_filter_trim_cap(sk, skb, sizeof(struct udphdr))) 741 + if (sk_filter_trim_cap(sk, skb, sizeof(struct udphdr))) { 742 + drop_reason = SKB_DROP_REASON_SOCKET_FILTER; 749 743 goto drop; 744 + } 750 745 751 746 udp_csum_pull_header(skb); 752 747 ··· 757 748 return __udpv6_queue_rcv_skb(sk, skb); 758 749 759 750 csum_error: 751 + drop_reason = SKB_DROP_REASON_UDP_CSUM; 760 752 __UDP6_INC_STATS(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite); 761 753 drop: 762 754 __UDP6_INC_STATS(sock_net(sk), UDP_MIB_INERRORS, is_udplite); 763 755 atomic_inc(&sk->sk_drops); 764 - kfree_skb(skb); 756 + kfree_skb_reason(skb, drop_reason); 765 757 return -1; 766 758 } 767 759