icmp: Add counters for rate limits
authorJamie Bainbridge <jamie.bainbridge@gmail.com>
Wed, 25 Jan 2023 00:16:52 +0000 (11:16 +1100)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 26 Jan 2023 09:52:18 +0000 (10:52 +0100)
commitd0941130c93515411c8d66fc22bdae407b509a6d
treee957d0231552d670cb9d36ef072c2d5b301a6e1e
parent9f92752788d719a4978d31082c98300274dd6ffc
icmp: Add counters for rate limits

There are multiple ICMP rate limiting mechanisms:

* Global limits: net.ipv4.icmp_msgs_burst/icmp_msgs_per_sec
* v4 per-host limits: net.ipv4.icmp_ratelimit/ratemask
* v6 per-host limits: net.ipv6.icmp_ratelimit/ratemask

However, when ICMP output is limited, there is no way to tell
which limit has been hit or even if the limits are responsible
for the lack of ICMP output.

Add counters for each of the cases above. As we are within
local_bh_disable(), use the __INC stats variant.

Example output:

 # nstat -sz "*RateLimit*"
 IcmpOutRateLimitGlobal          134                0.0
 IcmpOutRateLimitHost            770                0.0
 Icmp6OutRateLimitHost           84                 0.0

Signed-off-by: Jamie Bainbridge <jamie.bainbridge@gmail.com>
Suggested-by: Abhishek Rawal <rawal.abhishek92@gmail.com>
Link: https://lore.kernel.org/r/273b32241e6b7fdc5c609e6f5ebc68caf3994342.1674605770.git.jamie.bainbridge@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
include/uapi/linux/snmp.h
net/ipv4/icmp.c
net/ipv4/proc.c
net/ipv6/icmp.c
net/ipv6/proc.c