From: Mahdi Faramarzpour <mahdifrmx@gmail.com>
To: netdev@vger.kernel.org, kuba@kernel.org, edumazet@google.com
Cc: Mahdi Faramarzpour <mahdifrmx@gmail.com>
Subject: [PATCH net] udp: add drop count for packets in udp_prod_queue
Date: Sat, 3 Jan 2026 11:04:57 +0330 [thread overview]
Message-ID: <20260103073457.189244-1-mahdifrmx@gmail.com> (raw)
in commit b650bf0977d3 the busylock was removed and
per NUMA queues were added for a performance boost.
This commit implements SNMP drop count increment for
the queues.
Signed-off-by: Mahdi Faramarzpour <mahdifrmx@gmail.com>
---
net/ipv4/udp.c | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index ffe074cb5..00a8aeda1 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1709,6 +1709,13 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)
int dropcount;
int nb = 0;
+ struct {
+ int rcvbuf4;
+ int rcvbuf6;
+ int mem4;
+ int mem6;
+ } err_count = {0, 0, 0, 0};
+
rmem = atomic_read(&sk->sk_rmem_alloc);
rcvbuf = READ_ONCE(sk->sk_rcvbuf);
size = skb->truesize;
@@ -1760,6 +1767,17 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)
total_size += size;
err = udp_rmem_schedule(sk, size);
if (unlikely(err)) {
+ if (err == -ENOMEM) {
+ if (skb->protocol == htons(ETH_P_IP))
+ err_count.rcvbuf4++;
+ else
+ err_count.rcvbuf6++;
+ } else {
+ if (skb->protocol == htons(ETH_P_IP))
+ err_count.mem4++;
+ else
+ err_count.mem6++;
+ }
/* Free the skbs outside of locked section. */
skb->next = to_drop;
to_drop = skb;
@@ -1797,10 +1815,22 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)
skb = to_drop;
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);
+
+ SNMP_ADD_STATS(__UDPX_MIB(sk, true), UDP_MIB_RCVBUFERRORS,
+ err_count.rcvbuf4);
+ SNMP_ADD_STATS(__UDPX_MIB(sk, true), UDP_MIB_MEMERRORS,
+ err_count.mem4);
+ SNMP_ADD_STATS(__UDPX_MIB(sk, true), UDP_MIB_INERRORS,
+ err_count.mem4 + err_count.rcvbuf4);
+ SNMP_ADD_STATS(__UDPX_MIB(sk, false), UDP_MIB_RCVBUFERRORS,
+ err_count.rcvbuf6);
+ SNMP_ADD_STATS(__UDPX_MIB(sk, false), UDP_MIB_MEMERRORS,
+ err_count.mem6);
+ SNMP_ADD_STATS(__UDPX_MIB(sk, false), UDP_MIB_INERRORS,
+ err_count.mem6 + err_count.rcvbuf6);
}
atomic_sub(total_size, &udp_prod_queue->rmem_alloc);
--
2.34.1
reply other threads:[~2026-01-03 7:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260103073457.189244-1-mahdifrmx@gmail.com \
--to=mahdifrmx@gmail.com \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).