This is an automated email from the ASF dual-hosted git repository.

GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit f772ef1b7f733ab5d42d8ec7de05315ccb5822d7
Author: zhanghongyu <[email protected]>
AuthorDate: Mon Nov 23 21:44:13 2026 +0800

    net/udp: Count datagrams dropped when the read-ahead buffer is full.
    
    udp_callback() drops an incoming datagram when the read-ahead buffer
    already holds more than SO_RCVBUF bytes, but returned without touching
    the statistics.  The drop was therefore invisible in both
    /proc/net/stat and the netdev statistics, while the neighbouring
    "no free read-ahead buffers" path does count it.
    
    Count the datagram and log it, as that path already does.
    
    Assisted-by: Kiro:claude-opus-4
    
    Signed-off-by: zhanghongyu <[email protected]>
---
 net/udp/udp_callback.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/net/udp/udp_callback.c b/net/udp/udp_callback.c
index a5c9eaee218..0ef8923a337 100644
--- a/net/udp/udp_callback.c
+++ b/net/udp/udp_callback.c
@@ -84,6 +84,14 @@ static uint16_t udp_datahandler(FAR struct net_driver_s *dev,
 #if CONFIG_NET_RECV_BUFSIZE > 0
   if (conn->readahead && conn->readahead->io_pktlen > conn->rcvbufs)
     {
+      /* The read-ahead buffer is full, drop the datagram. */
+
+      ninfo("Dropped %d bytes\n", dev->d_len);
+
+#ifdef CONFIG_NET_STATISTICS
+      g_netstats.udp.drop++;
+#endif
+
       conn_unlock(&conn->sconn);
       netdev_iob_release(dev);
       return 0;

Reply via email to