net: dlink: count dropped packets on skb allocation failure
Subsystems (2)
PATCH 1/1 net: dlink: count dropped packets on skb allocation failure
Track dropped packet statistics when skb allocation fails in the receive path.
Tested-on: D-Link DGE-550T Rev-A3
--- drivers/net/ethernet/dlink/dl2k.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/dlink/dl2k.c +1 -0
@@ -1009,6 +1009,7 @@ receive_packet (struct net_device *dev) skb =netdev_alloc_skb_ip_align (dev, np->rx_buf_sz);if (skb ==NULL ) { np->rx_ring[entry].fraginfo =0 ; + dev->stats.rx_dropped++; printk (KERN_INFO "%s: receive_packet: " "Unable to re-allocate Rx skbuff.#%d\n",
Signature · 1 line
2.51.0
Quoted 14 lines · Yeounsu Moon
Track dropped packet statistics when skb allocation fails in the receive path.
Tested-on: D-Link DGE-550T Rev-A3
Signed-off-by Yeounsu Moon <[email protected]>--- drivers/net/ethernet/dlink/dl2k.c | 1 + 1 file changed, 1 insertion(+)drivers/net/ethernet/dlink/dl2k.c +0
-0
drivers/net/ethernet/dlink/dl2k.c receive_packet (struct net_device *dev) · line 1012
Quoted 4 lines
drivers/net/ethernet/dlink/dl2k.c +1
-0@@ -1009,6 +1009,7 @@ receive_packet (struct net_device *dev) skb =netdev_alloc_skb_ip_align (dev, np->rx_buf_sz);if (skb ==NULL ) { np->rx_ring[entry].fraginfo =0 ; + dev->stats.rx_dropped++;
Although new users of dev->stats are discoraged (see ndetdevice.h). That is not the case here, as the driver already uses dev-stats. So I believe this is change is good.
drivers/net/ethernet/dlink/dl2k.c receive_packet (struct net_device *dev) · line 1015
Quoted 3 lines
drivers/net/ethernet/dlink/dl2k.c +0
-0printk (KERN_INFO "%s: receive_packet: " "Unable to re-allocate Rx skbuff.#%d\n",
Jakub Kicinski
maintainerQuoted 2 lines · On Wed, 10 Sep 2025 14:48:37 +0900 Yeounsu Moon wrote:
Track dropped packet statistics when skb allocation fails in the receive path.
I'm not sure that failing to allocate a buffer results in dropping one packet in this driver. The statistics have specific meaning, if you're just trying to use dropped to mean "buffer allocation failures" that's not allowed. If I'm misreading the code please explain in more detail in the commit message and repost.
Quoted 12 lines
drivers/net/ethernet/dlink/dl2k.c +1
-0@@ -1009,6 +1009,7 @@ receive_packet (struct net_device *dev) skb =netdev_alloc_skb_ip_align (dev, np->rx_buf_sz);if (skb ==NULL ) { np->rx_ring[entry].fraginfo =0 ; + dev->stats.rx_dropped++; printk (KERN_INFO "%s: receive_packet: " "Unable to re-allocate Rx skbuff.#%d\n",
Quoted 3 lines · Simon Horman
Although new users of
dev->statsare discoraged (seendetdevice.h). That is not the case here, as the driver already uses dev-stats. So I believe this is change is good.
Thank you for pointing that out! I also plan to rework statistics code to rtnl-based statistics. However, that change affects a large amount of code, so I'd like to introduce it gradually and gracefully.
Quoted 6 lines
drivers/net/ethernet/dlink/dl2k.c receive_packet (struct net_device *dev) · line 1015
Quoted 4 lines
drivers/net/ethernet/dlink/dl2k.c +0
-0printk (KERN_INFO "%s: receive_packet: " "Unable to re-allocate Rx skbuff.#%d\n",Reviewed-by Simon Horman <[email protected]>
Thank you again for reviewing my patch, Simon :)
Yeounsu Moon
Quoted 10 lines · Jakub Kicinski
Quoted 2 lines · On Wed, 10 Sep 2025 14:48:37 +0900 Yeounsu Moon wrote:
Track dropped packet statistics when skb allocation fails in the receive path.
I'm not sure that failing to allocate a buffer results in dropping one packet in this driver. The statistics have specific meaning, if you're just trying to use dropped to mean "buffer allocation failures" that's not allowed. If I'm misreading the code please explain in more detail in the commit message and repost.
I think you understand the code better than I do.
Your insights are always surprising to me.
I believed that when netdev_alloc_skb() fails, it leads to dropping packets. I also found many cases where rx_dropped was incremented when netdev_alloc_skb() failed.
However, I'm not entirely sure whether such a failure actually results in a misisng packet. I'll resend the patch after verifying whether the packet is really dropped.
Thank you for reviewing!
Yeounsu Moon
Jakub Kicinski
maintainerQuoted 9 lines · On Fri, 12 Sep 2025 19:03:46 +0900 Yeounsu Moon wrote:
Quoted 5 lines
I'm not sure that failing to allocate a buffer results in dropping one packet in this driver. The statistics have specific meaning, if you're just trying to use dropped to mean "buffer allocation failures" that's not allowed. If I'm misreading the code please explain in more detail in the commit message and repost.
I think you understand the code better than I do.
Your insights are always surprising to me.
Quoted 7 lines
I believed that when
netdev_alloc_skb()fails, it leads to dropping packets. I also found many cases whererx_droppedwas incremented whennetdev_alloc_skb()failed.However, I'm not entirely sure whether such a failure actually results in a misisng packet. I'll resend the patch after verifying whether the packet is really dropped.
There's a ring of outstanding Rx buffers. If the ring becomes completely empty we'll start dropping. But that's not the same as one allocation failure == one packet drop.