]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
udp: add drop count for packets in udp_prod_queue
authorMahdi Faramarzpour <mahdifrmx@gmail.com>
Thu, 29 Jan 2026 08:38:06 +0000 (12:08 +0330)
committerJakub Kicinski <kuba@kernel.org>
Sat, 31 Jan 2026 01:18:53 +0000 (17:18 -0800)
This commit adds SNMP drop count increment for the packets in
per NUMA queues which were introduced in commit b650bf0977d3
("udp: remove busylock and add per NUMA queues"). note that SNMP
counters are incremented currently by the caller for skb. And
that these skbs on the intermediate queue cannot be counted
there so need similar logic in their error path.

Signed-off-by: Mahdi Faramarzpour <mahdifrmx@gmail.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260129083806.204752-1-mahdifrmx@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ipv4/udp.c

index 1db63db7e5d4ec912ff19f6b12f542c2c303d679..b96e47f1c8a2a92296acc0a9c724019c44c097ea 100644 (file)
@@ -1794,14 +1794,32 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)
        }
 
        if (unlikely(to_drop)) {
+               int err_ipv4 = 0;
+               int err_ipv6 = 0;
+
                for (nb = 0; to_drop != NULL; nb++) {
                        skb = to_drop;
+                       if (skb->protocol == htons(ETH_P_IP))
+                               err_ipv4++;
+                       else
+                               err_ipv6++;
                        to_drop = skb->next;
                        skb_mark_not_on_list(skb);
-                       /* TODO: update SNMP values. */
                        sk_skb_reason_drop(sk, skb, SKB_DROP_REASON_PROTO_MEM);
                }
                numa_drop_add(&udp_sk(sk)->drop_counters, nb);
+               if (err_ipv4 > 0) {
+                       SNMP_ADD_STATS(__UDPX_MIB(sk, true), UDP_MIB_MEMERRORS,
+                                      err_ipv4);
+                       SNMP_ADD_STATS(__UDPX_MIB(sk, true), UDP_MIB_INERRORS,
+                                      err_ipv4);
+               }
+               if (err_ipv6 > 0) {
+                       SNMP_ADD_STATS(__UDPX_MIB(sk, false), UDP_MIB_MEMERRORS,
+                                      err_ipv6);
+                       SNMP_ADD_STATS(__UDPX_MIB(sk, false), UDP_MIB_INERRORS,
+                                      err_ipv6);
+               }
        }
 
        atomic_sub(total_size, &udp_prod_queue->rmem_alloc);