Skip to contentSkip to conversation

udp: add drop count for packets in udp_prod_queue

PATCH Applied Mahdi Faramarzpour 4 participants 4 messages Jan 29 – Jan 31

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 udp: add drop count for packets in udp_prod_queue

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.

---
v7:
- revert the last change and fix style
v6: https://lore.kernel.org/netdev/[email protected]/
- increasing a single counter based on socket family
v5: https://lore.kernel.org/netdev/[email protected]/
- check if drop counts are non-zero before increasing countrers
v4: https://lore.kernel.org/netdev/[email protected]/
- move all changes to unlikely(to_drop) branch
v3: https://lore.kernel.org/netdev/[email protected]/
- remove the unreachable UDP_MIB_RCVBUFERRORS code
v2: https://lore.kernel.org/netdev/[email protected]/
- change ENOMEM to ENOBUFS
v1: https://lore.kernel.org/netdev/[email protected]/

---
 net/ipv4/udp.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
net/ipv4/udp.c +19 -1
index ffe074cb5..6ad7296db 100644
@@ -1793,14 +1793,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);
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Mahdi Faramarzpour

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.

Reviewed-by
#2 lore raw
Quoted 9 lines · Willem de Bruijn
Quoted 7 lines · Mahdi Faramarzpour

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.

Quoted 3 lines
Quoted 1 line

Thanks

#3 lore raw
In reply to Mahdi Faramarzpour
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Thu, 29 Jan 2026 12:08:06 +0330 you wrote:

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.

[...]

Here is the summary with links:
- [net-next] udp: add drop count for packets in udp_prod_queue

    https://git.kernel.org/netdev/net-next/c/820990d66577

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html