git: 9d5481242127 - main - snmp_mibII: use net.inet.ip.fragttl sysctl for ipReasmTimeout

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Sun, 21 Aug 2022 14:45:39 UTC
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=9d54812421274e490dc5f0fe4722ab8d35d9b258

commit 9d54812421274e490dc5f0fe4722ab8d35d9b258
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2022-08-21 14:44:58 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2022-08-21 14:44:58 +0000

    snmp_mibII: use net.inet.ip.fragttl sysctl for ipReasmTimeout
    
    Using IPFRAGTTL define was never correct, as it was measured in
    PR_SLOWTIMO intervals.  The sysctl returns seconds, just what
    ipReasmTimeout is.
---
 contrib/bsnmp/snmp_mibII/mibII_ip.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/contrib/bsnmp/snmp_mibII/mibII_ip.c b/contrib/bsnmp/snmp_mibII/mibII_ip.c
index 8290eebbc6f0..6a59a5b8e388 100644
--- a/contrib/bsnmp/snmp_mibII/mibII_ip.c
+++ b/contrib/bsnmp/snmp_mibII/mibII_ip.c
@@ -44,6 +44,7 @@ static struct icmpstat icmpstat;
 
 static int	ip_forwarding;
 static int	ip_defttl;
+static u_int	ip_fragttl;
 static uint64_t ip_tick;
 
 static uint64_t ipstat_tick;
@@ -79,6 +80,17 @@ fetch_ipstat(void)
 		return (-1);
 	}
 
+	len = sizeof(ip_fragttl);
+	if (sysctlbyname("net.inet.ip.fragttl", &ip_fragttl, &len,
+	    NULL, 0) == -1) {
+		syslog(LOG_ERR, "net.inet.ip.fragttl: %m");
+		return (-1);
+	}
+	if (len != sizeof(ip_fragttl)) {
+		syslog(LOG_ERR, "net.inet.ip.fragttl: wrong size");
+		return (-1);
+	}
+
 	ipstat_tick = get_ticks();
 	return (0);
 }
@@ -309,7 +321,7 @@ op_ipstat(struct snmp_context *ctx __unused, struct snmp_value *value,
 		break;
 
 	  case LEAF_ipReasmTimeout:
-		value->v.integer = IPFRAGTTL;
+		value->v.integer = ip_fragttl;
 		break;
 
 	  case LEAF_ipReasmReqds: