Module Name:    src
Committed By:   riastradh
Date:           Sat Jun 29 13:01:14 UTC 2024

Modified Files:
        src/sys/netipsec: key.c keysock.c

Log Message:
netipsec: Use _NET_STAT* API instead of direct array access.

PR kern/58380


To generate a diff of this commit:
cvs rdiff -u -r1.282 -r1.283 src/sys/netipsec/key.c
cvs rdiff -u -r1.70 -r1.71 src/sys/netipsec/keysock.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netipsec/key.c
diff -u src/sys/netipsec/key.c:1.282 src/sys/netipsec/key.c:1.283
--- src/sys/netipsec/key.c:1.282	Thu Aug 10 06:44:12 2023
+++ src/sys/netipsec/key.c	Sat Jun 29 13:01:14 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: key.c,v 1.282 2023/08/10 06:44:12 andvar Exp $	*/
+/*	$NetBSD: key.c,v 1.283 2024/06/29 13:01:14 riastradh Exp $	*/
 /*	$FreeBSD: key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $	*/
 /*	$KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $	*/
 
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.282 2023/08/10 06:44:12 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.283 2024/06/29 13:01:14 riastradh Exp $");
 
 /*
  * This code is referred to RFC 2367
@@ -2958,9 +2958,9 @@ key_api_spddump(struct socket *so, struc
 		return key_senderror(so, m0, ENOENT);
 	}
 	{
-		uint64_t *ps = PFKEY_STAT_GETREF();
-		ps[PFKEY_STAT_IN_TOTAL]++;
-		ps[PFKEY_STAT_IN_BYTES] += len;
+		net_stat_ref_t ps = PFKEY_STAT_GETREF();
+		_NET_STATINC_REF(ps, PFKEY_STAT_IN_TOTAL);
+		_NET_STATADD_REF(ps, PFKEY_STAT_IN_BYTES, len);
 		PFKEY_STAT_PUTREF();
 	}
 
@@ -7744,9 +7744,9 @@ key_api_dump(struct socket *so, struct m
 		return key_senderror(so, m0, ENOENT);
 	}
 	{
-		uint64_t *ps = PFKEY_STAT_GETREF();
-		ps[PFKEY_STAT_IN_TOTAL]++;
-		ps[PFKEY_STAT_IN_BYTES] += len;
+		net_stat_ref_t ps = PFKEY_STAT_GETREF();
+		_NET_STATINC_REF(ps, PFKEY_STAT_IN_TOTAL);
+		_NET_STATADD_REF(ps, PFKEY_STAT_IN_BYTES, len);
 		PFKEY_STAT_PUTREF();
 	}
 

Index: src/sys/netipsec/keysock.c
diff -u src/sys/netipsec/keysock.c:1.70 src/sys/netipsec/keysock.c:1.71
--- src/sys/netipsec/keysock.c:1.70	Wed Jun 12 22:23:50 2019
+++ src/sys/netipsec/keysock.c	Sat Jun 29 13:01:14 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: keysock.c,v 1.70 2019/06/12 22:23:50 christos Exp $	*/
+/*	$NetBSD: keysock.c,v 1.71 2024/06/29 13:01:14 riastradh Exp $	*/
 /*	$FreeBSD: keysock.c,v 1.3.2.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$KAME: keysock.c,v 1.25 2001/08/13 20:07:41 itojun Exp $	*/
 
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: keysock.c,v 1.70 2019/06/12 22:23:50 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: keysock.c,v 1.71 2024/06/29 13:01:14 riastradh Exp $");
 
 /* This code has derived from sys/net/rtsock.c on FreeBSD2.2.5 */
 
@@ -113,9 +113,9 @@ key_output(struct mbuf *m, struct socket
 	KASSERT(m != NULL);
 
 	{
-		uint64_t *ps = PFKEY_STAT_GETREF();
-		ps[PFKEY_STAT_OUT_TOTAL]++;
-		ps[PFKEY_STAT_OUT_BYTES] += m->m_pkthdr.len;
+		net_stat_ref_t ps = PFKEY_STAT_GETREF();
+		_NET_STATINC_REF(ps, PFKEY_STAT_OUT_TOTAL);
+		_NET_STATADD_REF(ps, PFKEY_STAT_OUT_BYTES, m->m_pkthdr.len);
 		PFKEY_STAT_PUTREF();
 	}
 
@@ -249,9 +249,9 @@ _key_sendup_mbuf(struct socket *so, stru
 	}
 
 	{
-		uint64_t *ps = PFKEY_STAT_GETREF();
-		ps[PFKEY_STAT_IN_TOTAL]++;
-		ps[PFKEY_STAT_IN_BYTES] += m->m_pkthdr.len;
+		net_stat_ref_t ps = PFKEY_STAT_GETREF();
+		_NET_STATINC_REF(ps, PFKEY_STAT_IN_TOTAL);
+		_NET_STATADD_REF(ps, PFKEY_STAT_IN_BYTES, m->m_pkthdr.len);
 		PFKEY_STAT_PUTREF();
 	}
 	if (m->m_len < sizeof(struct sadb_msg)) {

Reply via email to