git: 4399e055ea61 - main - icmp: allow zero value for ICMP limits

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Mon, 25 Mar 2024 02:56:03 UTC
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=4399e055ea610cdefa1470ad1ee614dd81ba5e56

commit 4399e055ea610cdefa1470ad1ee614dd81ba5e56
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2024-03-25 02:52:03 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2024-03-25 02:52:03 +0000

    icmp: allow zero value for ICMP limits
    
    Zero means limit is disabled, so the value doesn't need to be checked
    against jitter value.
    
    Fixes:  ac44739fd834f51cacb26485a4140fd482e20150
    Fixes:  a03aff88a14448c3084a0384082ec996d7213897
---
 sys/netinet/ip_icmp.c | 2 +-
 sys/netinet6/icmp6.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c
index acb707b1d192..4dfbd0c525ff 100644
--- a/sys/netinet/ip_icmp.c
+++ b/sys/netinet/ip_icmp.c
@@ -1135,7 +1135,7 @@ sysctl_icmplim_and_jitter(SYSCTL_HANDLER_ARGS)
 	error = sysctl_handle_int(oidp, &new, 0, req);
 	if (error == 0 && req->newptr) {
 		if (lim) {
-			if (new <= V_icmplim_jitter)
+			if (new != 0 && new <= V_icmplim_jitter)
 				error = EINVAL;
 			else
 				V_icmplim = new;
diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c
index ef4216b844b5..e56ec3bc7afd 100644
--- a/sys/netinet6/icmp6.c
+++ b/sys/netinet6/icmp6.c
@@ -2804,7 +2804,7 @@ sysctl_icmp6lim_and_jitter(SYSCTL_HANDLER_ARGS)
 	error = sysctl_handle_int(oidp, &new, 0, req);
 	if (error == 0 && req->newptr) {
 		if (lim) {
-			if (new <= V_icmp6lim_jitter)
+			if (new != 0 && new <= V_icmp6lim_jitter)
 				error = EINVAL;
 			else
 				V_icmp6errppslim = new;