Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: udp: introduce UDP_MIB_MEMERRORS for udp_mem

When udp_memory_allocated is at the limit, __udp_enqueue_schedule_skb
will return a -ENOBUFS, and skb will be dropped in __udp_queue_rcv_skb
without any counters being done. It's hard to find out what happened
once this happen.

So we introduce a UDP_MIB_MEMERRORS to do this job. Well, this change
looks friendly to the existing users, such as netstat:

$ netstat -u -s
Udp:
0 packets received
639 packets to unknown port received.
158689 packet receive errors
180022 packets sent
RcvbufErrors: 20930
MemErrors: 137759
UdpLite:
IpExt:
InOctets: 257426235
OutOctets: 257460598
InNoECTPkts: 181177

v2:
- Fix some alignment problems

Signed-off-by: Menglong Dong <dong.menglong@zte.com.cn>
Link: https://lore.kernel.org/r/1604627354-43207-1-git-send-email-dong.menglong@zte.com.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Menglong Dong and committed by
Jakub Kicinski
a3ce2b10 bff6f1db

+10
+1
include/uapi/linux/snmp.h
··· 159 159 UDP_MIB_SNDBUFERRORS, /* SndbufErrors */ 160 160 UDP_MIB_CSUMERRORS, /* InCsumErrors */ 161 161 UDP_MIB_IGNOREDMULTI, /* IgnoredMulti */ 162 + UDP_MIB_MEMERRORS, /* MemErrors */ 162 163 __UDP_MIB_MAX 163 164 }; 164 165
+1
net/ipv4/proc.c
··· 167 167 SNMP_MIB_ITEM("SndbufErrors", UDP_MIB_SNDBUFERRORS), 168 168 SNMP_MIB_ITEM("InCsumErrors", UDP_MIB_CSUMERRORS), 169 169 SNMP_MIB_ITEM("IgnoredMulti", UDP_MIB_IGNOREDMULTI), 170 + SNMP_MIB_ITEM("MemErrors", UDP_MIB_MEMERRORS), 170 171 SNMP_MIB_SENTINEL 171 172 }; 172 173
+3
net/ipv4/udp.c
··· 2038 2038 if (rc == -ENOMEM) 2039 2039 UDP_INC_STATS(sock_net(sk), UDP_MIB_RCVBUFERRORS, 2040 2040 is_udplite); 2041 + else 2042 + UDP_INC_STATS(sock_net(sk), UDP_MIB_MEMERRORS, 2043 + is_udplite); 2041 2044 UDP_INC_STATS(sock_net(sk), UDP_MIB_INERRORS, is_udplite); 2042 2045 kfree_skb(skb); 2043 2046 trace_udp_fail_queue_rcv_skb(rc, sk);
+2
net/ipv6/proc.c
··· 126 126 SNMP_MIB_ITEM("Udp6SndbufErrors", UDP_MIB_SNDBUFERRORS), 127 127 SNMP_MIB_ITEM("Udp6InCsumErrors", UDP_MIB_CSUMERRORS), 128 128 SNMP_MIB_ITEM("Udp6IgnoredMulti", UDP_MIB_IGNOREDMULTI), 129 + SNMP_MIB_ITEM("Udp6MemErrors", UDP_MIB_MEMERRORS), 129 130 SNMP_MIB_SENTINEL 130 131 }; 131 132 ··· 138 137 SNMP_MIB_ITEM("UdpLite6RcvbufErrors", UDP_MIB_RCVBUFERRORS), 139 138 SNMP_MIB_ITEM("UdpLite6SndbufErrors", UDP_MIB_SNDBUFERRORS), 140 139 SNMP_MIB_ITEM("UdpLite6InCsumErrors", UDP_MIB_CSUMERRORS), 140 + SNMP_MIB_ITEM("UdpLite6MemErrors", UDP_MIB_MEMERRORS), 141 141 SNMP_MIB_SENTINEL 142 142 }; 143 143
+3
net/ipv6/udp.c
··· 637 637 if (rc == -ENOMEM) 638 638 UDP6_INC_STATS(sock_net(sk), 639 639 UDP_MIB_RCVBUFERRORS, is_udplite); 640 + else 641 + UDP6_INC_STATS(sock_net(sk), 642 + UDP_MIB_MEMERRORS, is_udplite); 640 643 UDP6_INC_STATS(sock_net(sk), UDP_MIB_INERRORS, is_udplite); 641 644 kfree_skb(skb); 642 645 return -1;