CVS commit: src/usr.sbin/tprof

2022-12-08 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Dec  9 02:19:07 UTC 2022

Modified Files:
src/usr.sbin/tprof: tprof_top.c

Log Message:
if column width changes, the screen must be updated.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/tprof/tprof_top.c

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

Modified files:

Index: src/usr.sbin/tprof/tprof_top.c
diff -u src/usr.sbin/tprof/tprof_top.c:1.4 src/usr.sbin/tprof/tprof_top.c:1.5
--- src/usr.sbin/tprof/tprof_top.c:1.4	Fri Dec  9 01:56:40 2022
+++ src/usr.sbin/tprof/tprof_top.c	Fri Dec  9 02:19:07 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: tprof_top.c,v 1.4 2022/12/09 01:56:40 ryo Exp $	*/
+/*	$NetBSD: tprof_top.c,v 1.5 2022/12/09 02:19:07 ryo Exp $	*/
 
 /*-
  * Copyright (c) 2022 Ryo Shimizu 
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: tprof_top.c,v 1.4 2022/12/09 01:56:40 ryo Exp $");
+__RCSID("$NetBSD: tprof_top.c,v 1.5 2022/12/09 02:19:07 ryo Exp $");
 #endif /* not lint */
 
 #include 
@@ -671,15 +671,19 @@ show_count_per_event(int *lim)
 	for (i = 0; i < nevent; i++) {
 		l = snprintf(buf, sizeof(buf), "%"PRIu64,
 		sample_n_per_event[opt_mode][i]);
-		if (sample_event_width < (u_int)l)
+		if (sample_event_width < (u_int)l) {
 			sample_event_width = l;
+			do_redraw = true;
+		}
 	}
 	for (i = 0; i < nevent; i++) {
 		for (n = 0; n < ncpu; n++) {
 			l = snprintf(buf, sizeof(buf), "%"PRIu64,
 			sample_n_per_event_cpu[opt_mode][nevent * n + i]);
-			if (sample_cpu_width[n] < (u_int)l)
+			if (sample_cpu_width[n] < (u_int)l) {
 sample_cpu_width[n] = l;
+do_redraw = true;
+			}
 		}
 	}
 



CVS commit: src/usr.sbin/tprof

2022-12-08 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Dec  9 02:19:07 UTC 2022

Modified Files:
src/usr.sbin/tprof: tprof_top.c

Log Message:
if column width changes, the screen must be updated.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/tprof/tprof_top.c

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



CVS commit: src/doc

2022-12-08 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Dec  9 02:01:09 UTC 2022

Modified Files:
src/doc: CHANGES

Log Message:
fix typo


To generate a diff of this commit:
cvs rdiff -u -r1.2935 -r1.2936 src/doc/CHANGES

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

Modified files:

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2935 src/doc/CHANGES:1.2936
--- src/doc/CHANGES:1.2935	Thu Dec  8 06:30:15 2022
+++ src/doc/CHANGES	Fri Dec  9 02:01:09 2022
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2935 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2936 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -750,7 +750,7 @@ Changes from NetBSD 9.0 to NetBSD 10.0:
 	ifconfig(8): Allow configuration of interfaces as
 		explicitly unnumbered. [knakahara 20221125]
 	tprof: Revamped tprof(4), and multiple event counters can be
-		referenced with tprof(8). Add some improvements to prof(8).
+		referenced with tprof(8). Add some improvements to tprof(8).
 		[ryo 20221201]
 	tprof: Add AMD family 19h (zen3 and zen4) support to tprof(4) and
 		tprof(8). [msaitoh 20221208]



CVS commit: src/doc

2022-12-08 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Dec  9 02:01:09 UTC 2022

Modified Files:
src/doc: CHANGES

Log Message:
fix typo


To generate a diff of this commit:
cvs rdiff -u -r1.2935 -r1.2936 src/doc/CHANGES

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



CVS commit: src/usr.sbin/tprof

2022-12-08 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Dec  9 01:59:51 UTC 2022

Modified Files:
src/usr.sbin/tprof: tprof.8

Log Message:
supported AMD family added


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/tprof/tprof.8

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

Modified files:

Index: src/usr.sbin/tprof/tprof.8
diff -u src/usr.sbin/tprof/tprof.8:1.21 src/usr.sbin/tprof/tprof.8:1.22
--- src/usr.sbin/tprof/tprof.8:1.21	Fri Dec  9 01:56:40 2022
+++ src/usr.sbin/tprof/tprof.8	Fri Dec  9 01:59:51 2022
@@ -1,4 +1,4 @@
-.\"	$NetBSD: tprof.8,v 1.21 2022/12/09 01:56:40 ryo Exp $
+.\"	$NetBSD: tprof.8,v 1.22 2022/12/09 01:59:51 ryo Exp $
 .\"
 .\" Copyright (c)2011 YAMAMOTO Takashi,
 .\" All rights reserved.
@@ -202,6 +202,8 @@ x86 AMD Family 15h
 .It
 x86 AMD Family 17h
 .It
+x86 AMD Family 19h
+.It
 x86 Intel Generic (all Intel CPUs)
 .It
 x86 Intel Skylake/Kabylake



CVS commit: src/usr.sbin/tprof

2022-12-08 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Dec  9 01:59:51 UTC 2022

Modified Files:
src/usr.sbin/tprof: tprof.8

Log Message:
supported AMD family added


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/tprof/tprof.8

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



CVS commit: src/usr.sbin/tprof

2022-12-08 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Dec  9 01:56:40 UTC 2022

Modified Files:
src/usr.sbin/tprof: Makefile tprof.8 tprof_top.c

Log Message:
mainly fixes around display.

- use terminfo
- dynamically adjust column widths
- mode can be changed while running


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/tprof/Makefile
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/tprof/tprof.8
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/tprof/tprof_top.c

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



CVS commit: src/usr.sbin/tprof

2022-12-08 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Dec  9 01:56:40 UTC 2022

Modified Files:
src/usr.sbin/tprof: Makefile tprof.8 tprof_top.c

Log Message:
mainly fixes around display.

- use terminfo
- dynamically adjust column widths
- mode can be changed while running


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/tprof/Makefile
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/tprof/tprof.8
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/tprof/tprof_top.c

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

Modified files:

Index: src/usr.sbin/tprof/Makefile
diff -u src/usr.sbin/tprof/Makefile:1.12 src/usr.sbin/tprof/Makefile:1.13
--- src/usr.sbin/tprof/Makefile:1.12	Thu Dec  1 00:43:27 2022
+++ src/usr.sbin/tprof/Makefile	Fri Dec  9 01:56:40 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.12 2022/12/01 00:43:27 ryo Exp $
+#	$NetBSD: Makefile,v 1.13 2022/12/09 01:56:40 ryo Exp $
 
 .PATH:	${.CURDIR}/arch
 
@@ -21,11 +21,15 @@ CPPFLAGS+= -I${NETBSDSRCDIR}/sys/
 LDADD+= -lpthread
 LDADD+= -lm
 LDADD+= -lelf
+LDADD+= -lterminfo
 LDADD+= -lutil
 DPADD+= ${LIBPTHREAD}
 DPADD+= ${LIBM}
 DPADD+= ${LIBELF}
+DPADD+= ${LIBTERMINFO}
 DPADD+= ${LIBUTIL}
 
+COPTS.tprof_top.c = -Wno-format-nonliteral
+
 .include 
 .include 

Index: src/usr.sbin/tprof/tprof.8
diff -u src/usr.sbin/tprof/tprof.8:1.20 src/usr.sbin/tprof/tprof.8:1.21
--- src/usr.sbin/tprof/tprof.8:1.20	Fri Dec  9 01:55:46 2022
+++ src/usr.sbin/tprof/tprof.8	Fri Dec  9 01:56:40 2022
@@ -1,4 +1,4 @@
-.\"	$NetBSD: tprof.8,v 1.20 2022/12/09 01:55:46 ryo Exp $
+.\"	$NetBSD: tprof.8,v 1.21 2022/12/09 01:56:40 ryo Exp $
 .\"
 .\" Copyright (c)2011 YAMAMOTO Takashi,
 .\" All rights reserved.
@@ -166,6 +166,21 @@ show the delta of the event counters.
 .It Fl u
 Userland processes are also included in the profiling.
 .El
+.Pp
+While
+.Nm
+.Ar top
+is running, it accepts commands from the terminal.
+These commands are currently recognized:
+.Bl -tag -width XXcommandsX -offset indent
+.It Ic a
+toggle accumurative mode.
+.It Ic q
+quit
+.Nm .
+.It Ic z
+clear accumulated data.
+.El
 .El
 .Sh EXAMPLES
 The following command profiles the system during 20 seconds and writes the

Index: src/usr.sbin/tprof/tprof_top.c
diff -u src/usr.sbin/tprof/tprof_top.c:1.3 src/usr.sbin/tprof/tprof_top.c:1.4
--- src/usr.sbin/tprof/tprof_top.c:1.3	Fri Dec  9 01:55:46 2022
+++ src/usr.sbin/tprof/tprof_top.c	Fri Dec  9 01:56:40 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: tprof_top.c,v 1.3 2022/12/09 01:55:46 ryo Exp $	*/
+/*	$NetBSD: tprof_top.c,v 1.4 2022/12/09 01:56:40 ryo Exp $	*/
 
 /*-
  * Copyright (c) 2022 Ryo Shimizu 
@@ -28,15 +28,17 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: tprof_top.c,v 1.3 2022/12/09 01:55:46 ryo Exp $");
+__RCSID("$NetBSD: tprof_top.c,v 1.4 2022/12/09 01:56:40 ryo Exp $");
 #endif /* not lint */
 
 #include 
 #include 
-#include 
 #include 
+#include 
+#include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -46,6 +48,8 @@ __RCSID("$NetBSD: tprof_top.c,v 1.3 2022
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 
@@ -57,6 +61,9 @@ __RCSID("$NetBSD: tprof_top.c,v 1.3 2022
 #define SAMPLE_MODE_INSTANTANEOUS	1
 #define SAMPLE_MODE_NUM			2
 
+#define LINESTR	"-"
+#define SYMBOL_LEN			32	/* symbol and event name */
+
 struct sample_elm {
 	struct rb_node node;
 	uint64_t addr;
@@ -80,9 +87,14 @@ static int opt_userland = 0;
 static int opt_showcounter = 0;
 
 /* for display */
+static char *term;
 static struct winsize win;
 static int nontty;
+static struct termios termios_save;
+static bool termios_saved;
 static long top_interval = 1;
+static bool do_redraw;
+static u_int nshow;
 
 /* for profiling and counting samples */
 static sig_atomic_t sigalrm;
@@ -95,6 +107,8 @@ static rb_tree_t rb_tree_sample;
 struct ptrarray sample_list[SAMPLE_MODE_NUM];
 static u_int sample_n_kern[SAMPLE_MODE_NUM];
 static u_int sample_n_user[SAMPLE_MODE_NUM];
+static u_int sample_event_width = 7;
+static u_int *sample_cpu_width;	/* [ncpu] */
 static uint32_t *sample_n_kern_per_cpu[SAMPLE_MODE_NUM];	/* [ncpu] */
 static uint32_t *sample_n_user_per_cpu[SAMPLE_MODE_NUM];	/* [ncpu] */
 static uint64_t *sample_n_per_event[SAMPLE_MODE_NUM];		/* [nevent] */
@@ -127,43 +141,145 @@ cycle_event_name(void)
 	return cycleevent;
 }
 
-/* XXX: use terminfo or curses */
 static void
-cursor_address(u_int x, u_int y)
+reset_cursor_pos(void)
 {
-	if (nontty)
+	int i;
+	char *p;
+
+	if (nontty || term == NULL)
 		return;
-	printf("\e[%u;%uH", y - 1, x - 1);
+
+	printf("\r");
+
+	/* cursor_up * n */
+	if ((p = tigetstr("cuu")) != NULL) {
+		printf("%s", tparm(p, win.ws_row - 1, 0, 0, 0, 0, 0, 0, 0, 0));
+	} else if ((p = tigetstr("cuu1")) != NULL) {
+		for (i = win.ws_row - 1; i > 0; i--)
+			printf("%s", p);
+	}
 }
 
 static void
-cursor_home(void)
+clr_to_eol(void)
 {
-	if (nontty)
+	char *p;
+
+	if (nontty || 

CVS commit: src/usr.sbin/tprof

2022-12-08 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Dec  9 01:55:46 UTC 2022

Modified Files:
src/usr.sbin/tprof: tprof.8 tprof_top.c

Log Message:
add accumulative mode. "tprof top -a"


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/tprof/tprof.8
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/tprof/tprof_top.c

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



CVS commit: src/usr.sbin/tprof

2022-12-08 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Dec  9 01:55:46 UTC 2022

Modified Files:
src/usr.sbin/tprof: tprof.8 tprof_top.c

Log Message:
add accumulative mode. "tprof top -a"


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/tprof/tprof.8
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/tprof/tprof_top.c

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

Modified files:

Index: src/usr.sbin/tprof/tprof.8
diff -u src/usr.sbin/tprof/tprof.8:1.19 src/usr.sbin/tprof/tprof.8:1.20
--- src/usr.sbin/tprof/tprof.8:1.19	Thu Dec  1 00:43:27 2022
+++ src/usr.sbin/tprof/tprof.8	Fri Dec  9 01:55:46 2022
@@ -1,4 +1,4 @@
-.\"	$NetBSD: tprof.8,v 1.19 2022/12/01 00:43:27 ryo Exp $
+.\"	$NetBSD: tprof.8,v 1.20 2022/12/09 01:55:46 ryo Exp $
 .\"
 .\" Copyright (c)2011 YAMAMOTO Takashi,
 .\" All rights reserved.
@@ -24,7 +24,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd December 1, 2022
+.Dd December 9, 2022
 .Dt TPROF 8
 .Os
 .Sh NAME
@@ -137,8 +137,7 @@ Per symbol.
 .Op Fl e Ar ...
 .Oc
 .Op Fl i Ar interval
-.Op Fl c
-.Op Fl u
+.Op Fl acu
 .Xc
 Displays profiling results in real-time.
 .Ar name
@@ -158,6 +157,10 @@ is specified, profiling is performed eve
 .Bl -tag -width XXintervalX -offset indent
 .It Fl i Ar interval
 set the update interval in seconds. The default value is 1.
+.It Fl a
+Starts in accumulation mode. The display is updated every
+.Ar interval
+second, but the values are accumulative.
 .It Fl c
 show the delta of the event counters.
 .It Fl u
@@ -226,7 +229,9 @@ utility was written by
 .An YAMAMOTO Takashi .
 It was revamped by
 .An Maxime Villard
-in 2018.
+in 2018, and by
+.An Ryo Shimizu
+in 2022.
 .Sh CAVEATS
 The contents and representation of recorded samples are undocumented and
 will likely be changed for future releases of

Index: src/usr.sbin/tprof/tprof_top.c
diff -u src/usr.sbin/tprof/tprof_top.c:1.2 src/usr.sbin/tprof/tprof_top.c:1.3
--- src/usr.sbin/tprof/tprof_top.c:1.2	Thu Dec  1 03:32:24 2022
+++ src/usr.sbin/tprof/tprof_top.c	Fri Dec  9 01:55:46 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: tprof_top.c,v 1.2 2022/12/01 03:32:24 ryo Exp $	*/
+/*	$NetBSD: tprof_top.c,v 1.3 2022/12/09 01:55:46 ryo Exp $	*/
 
 /*-
  * Copyright (c) 2022 Ryo Shimizu 
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: tprof_top.c,v 1.2 2022/12/01 03:32:24 ryo Exp $");
+__RCSID("$NetBSD: tprof_top.c,v 1.3 2022/12/09 01:55:46 ryo Exp $");
 #endif /* not lint */
 
 #include 
@@ -37,7 +37,6 @@ __RCSID("$NetBSD: tprof_top.c,v 1.2 2022
 #include 
 #include 
 
-#include 
 #include 
 #include 
 #include 
@@ -54,14 +53,79 @@ __RCSID("$NetBSD: tprof_top.c,v 1.2 2022
 #include "tprof.h"
 #include "ksyms.h"
 
-static struct sym **ksyms;
-static size_t nksyms;
-static sig_atomic_t sigalrm;
+#define SAMPLE_MODE_ACCUMULATIVE	0
+#define SAMPLE_MODE_INSTANTANEOUS	1
+#define SAMPLE_MODE_NUM			2
+
+struct sample_elm {
+	struct rb_node node;
+	uint64_t addr;
+	const char *name;
+	uint32_t flags;
+#define SAMPLE_ELM_FLAGS_USER	0x0001
+	uint32_t num[SAMPLE_MODE_NUM];
+	uint32_t num_cpu[];	/* [SAMPLE_MODE_NUM][ncpu] */
+#define SAMPLE_ELM_NUM_CPU(e, k)		\
+	((e)->num_cpu + (k) *  ncpu)
+};
+
+struct ptrarray {
+	void **pa_ptrs;
+	size_t pa_allocnum;
+	size_t pa_inuse;
+};
+
+static int opt_mode = SAMPLE_MODE_INSTANTANEOUS;
+static int opt_userland = 0;
+static int opt_showcounter = 0;
+
+/* for display */
 static struct winsize win;
+static int nontty;
 static long top_interval = 1;
+
+/* for profiling and counting samples */
+static sig_atomic_t sigalrm;
+static struct sym **ksyms;
+static size_t nksyms;
 static u_int nevent;
 static const char *eventname[TPROF_MAXCOUNTERS];
-static int nontty;
+static size_t sizeof_sample_elm;
+static rb_tree_t rb_tree_sample;
+struct ptrarray sample_list[SAMPLE_MODE_NUM];
+static u_int sample_n_kern[SAMPLE_MODE_NUM];
+static u_int sample_n_user[SAMPLE_MODE_NUM];
+static uint32_t *sample_n_kern_per_cpu[SAMPLE_MODE_NUM];	/* [ncpu] */
+static uint32_t *sample_n_user_per_cpu[SAMPLE_MODE_NUM];	/* [ncpu] */
+static uint64_t *sample_n_per_event[SAMPLE_MODE_NUM];		/* [nevent] */
+static uint64_t *sample_n_per_event_cpu[SAMPLE_MODE_NUM];	/* [ncpu] */
+
+/* raw event counter */
+static uint64_t *counters;	/* counters[2][ncpu][nevent] */
+static u_int counters_i;
+
+static const char *
+cycle_event_name(void)
+{
+	const char *cycleevent;
+
+	switch (tprof_info.ti_ident) {
+	case TPROF_IDENT_INTEL_GENERIC:
+		cycleevent = "unhalted-core-cycles";
+		break;
+	case TPROF_IDENT_AMD_GENERIC:
+		cycleevent = "LsNotHaltedCyc";
+		break;
+	case TPROF_IDENT_ARMV8_GENERIC:
+	case TPROF_IDENT_ARMV7_GENERIC:
+		cycleevent = "CPU_CYCLES";
+		break;
+	default:
+		cycleevent = NULL;
+		break;
+	}
+	return cycleevent;
+}
 
 /* XXX: use terminfo or curses */
 static void
@@ -108,31 +172,37 @@ sigalrm_handler(int signo)
 	sigalrm = 1;
 }
 
-struct 

CVS commit: src/sys/dev/ic

2022-12-08 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Fri Dec  9 00:35:58 UTC 2022

Modified Files:
src/sys/dev/ic: com.c

Log Message:
Revert com.c:r1.381 because i386/qemu cannot boot.  Pointed out by gson@n.o and 
martin@n.o.


To generate a diff of this commit:
cvs rdiff -u -r1.381 -r1.382 src/sys/dev/ic/com.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/dev/ic/com.c
diff -u src/sys/dev/ic/com.c:1.381 src/sys/dev/ic/com.c:1.382
--- src/sys/dev/ic/com.c:1.381	Thu Dec  8 09:08:49 2022
+++ src/sys/dev/ic/com.c	Fri Dec  9 00:35:58 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: com.c,v 1.381 2022/12/08 09:08:49 knakahara Exp $ */
+/* $NetBSD: com.c,v 1.382 2022/12/09 00:35:58 knakahara Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2004, 2008 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.381 2022/12/08 09:08:49 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.382 2022/12/09 00:35:58 knakahara Exp $");
 
 #include "opt_com.h"
 #include "opt_ddb.h"
@@ -206,28 +206,6 @@ static struct consdev comcons = {
 	.cn_pri = CN_NORMAL
 };
 
-#define	CSR_WRITE_1_SYNC(r, o, v)	do {			\
-		CSR_WRITE_1(r, o, v);\
-		switch(o) {	\
-		case COM_REG_IER:\
-			(void)CSR_READ_1(r, COM_REG_IIR);	\
-			break;	\
-		case COM_REG_TXDATA:\
-			(void)CSR_READ_1(r, COM_REG_TLR);	\
-			break;	\
-		}		\
-	} while(0)
-#define	CSR_WRITE_MULTI_SYNC(r, o, p, n)	do {		\
-		CSR_WRITE_MULTI(r, o, p, n);			\
-		switch(o) {	\
-		case COM_REG_IER:\
-			(void)CSR_READ_1(r, COM_REG_IIR);	\
-			break;	\
-		case COM_REG_TXDATA:\
-			(void)CSR_READ_1(r, COM_REG_TLR);	\
-			break;	\
-		}		\
-	} while(0)
 
 const struct cdevsw com_cdevsw = {
 	.d_open = comopen,
@@ -1983,7 +1961,7 @@ comstart(struct tty *tp)
 	/* Enable transmit completion interrupts if necessary. */
 	if (!ISSET(sc->sc_ier, IER_ETXRDY)) {
 		SET(sc->sc_ier, IER_ETXRDY);
-		CSR_WRITE_1_SYNC(regsp, COM_REG_IER, sc->sc_ier);
+		CSR_WRITE_1(regsp, COM_REG_IER, sc->sc_ier);
 	}
 
 	/* Output the first chunk of the contiguous buffer. */
@@ -1993,7 +1971,7 @@ comstart(struct tty *tp)
 		n = sc->sc_tbc;
 		if (n > sc->sc_fifolen)
 			n = sc->sc_fifolen;
-		CSR_WRITE_MULTI_SYNC(regsp, COM_REG_TXDATA, sc->sc_tba, n);
+		CSR_WRITE_MULTI(regsp, COM_REG_TXDATA, sc->sc_tba, n);
 		sc->sc_tbc -= n;
 		sc->sc_tba += n;
 	}
@@ -2381,7 +2359,7 @@ again:	do {
 	CLR(sc->sc_ier, IER_ERXRDY);
 	break;
 }
-CSR_WRITE_1_SYNC(regsp, COM_REG_IER, sc->sc_ier);
+CSR_WRITE_1(regsp, COM_REG_IER, sc->sc_ier);
 			}
 		} else {
 			if ((iir & (IIR_RXRDY|IIR_TXRDY)) == IIR_RXRDY) {
@@ -2465,14 +2443,14 @@ do_tx:
 			n = sc->sc_tbc;
 			if (n > sc->sc_fifolen)
 n = sc->sc_fifolen;
-			CSR_WRITE_MULTI_SYNC(regsp, COM_REG_TXDATA, sc->sc_tba, n);
+			CSR_WRITE_MULTI(regsp, COM_REG_TXDATA, sc->sc_tba, n);
 			sc->sc_tbc -= n;
 			sc->sc_tba += n;
 		} else {
 			/* Disable transmit completion interrupts if necessary. */
 			if (ISSET(sc->sc_ier, IER_ETXRDY)) {
 CLR(sc->sc_ier, IER_ETXRDY);
-CSR_WRITE_1_SYNC(regsp, COM_REG_IER, sc->sc_ier);
+CSR_WRITE_1(regsp, COM_REG_IER, sc->sc_ier);
 			}
 			if (sc->sc_tx_busy) {
 sc->sc_tx_busy = 0;



CVS commit: src/sys/dev/ic

2022-12-08 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Fri Dec  9 00:35:58 UTC 2022

Modified Files:
src/sys/dev/ic: com.c

Log Message:
Revert com.c:r1.381 because i386/qemu cannot boot.  Pointed out by gson@n.o and 
martin@n.o.


To generate a diff of this commit:
cvs rdiff -u -r1.381 -r1.382 src/sys/dev/ic/com.c

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



CVS commit: src/share/misc

2022-12-08 Thread Jan Schaumann
Module Name:src
Committed By:   jschauma
Date:   Thu Dec  8 23:41:22 UTC 2022

Modified Files:
src/share/misc: acronyms.comp

Log Message:
+AEAD, HKDF, NMR, SIV


To generate a diff of this commit:
cvs rdiff -u -r1.329 -r1.330 src/share/misc/acronyms.comp

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

Modified files:

Index: src/share/misc/acronyms.comp
diff -u src/share/misc/acronyms.comp:1.329 src/share/misc/acronyms.comp:1.330
--- src/share/misc/acronyms.comp:1.329	Tue Dec  6 15:51:16 2022
+++ src/share/misc/acronyms.comp	Thu Dec  8 23:41:22 2022
@@ -1,4 +1,4 @@
-$NetBSD: acronyms.comp,v 1.329 2022/12/06 15:51:16 jschauma Exp $
+$NetBSD: acronyms.comp,v 1.330 2022/12/08 23:41:22 jschauma Exp $
 3WHS	three-way handshake
 8VSB	8-state vestigial side band modulation
 AA	anti-aliasing
@@ -30,6 +30,7 @@ ADPCM	adaptive differential pulse code m
 ADS	alternate data stream
 ADSL	asymmetric digital subscriber line
 ADT	abstract data type
+AEAD	authenticated encryption with associated data
 AEDC	advanced error detection and correction
 AER	advanced error reporting
 AES	Advanced Encryption Standard
@@ -681,6 +682,7 @@ HF	high frequency
 HFM	highest frequency mode
 HFS	hierarchical file system
 HID	human interface device
+HKDF	HMAC-based key derivation function
 HKP	HTTP Keyserver Protocol
 HLL	high-level language
 HMA	high memory area
@@ -1074,6 +1076,7 @@ NIST	National Institute of Standards and
 NLS	native language support
 NMI	non-maskable interrupt
 NNTP	Network News Transfer Protocol
+NMR	nonce-misuse resistance
 NOC	network operations center
 NOP	no operation
 NOS	network operating system
@@ -1492,6 +1495,7 @@ SIP	Session Initiation Protocol
 SIR	signal-to-interference ratio
 SIR	slow infrared
 SISD	single instruction, single data
+SIV	synthetic intialization vector
 SLAAC	stateless address auto-configuration
 SLC	single-level cell
 SLDRAM	synchronous-link dynamic random access memory



CVS commit: src/share/misc

2022-12-08 Thread Jan Schaumann
Module Name:src
Committed By:   jschauma
Date:   Thu Dec  8 23:41:22 UTC 2022

Modified Files:
src/share/misc: acronyms.comp

Log Message:
+AEAD, HKDF, NMR, SIV


To generate a diff of this commit:
cvs rdiff -u -r1.329 -r1.330 src/share/misc/acronyms.comp

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



CVS commit: src/sys/dev/ic

2022-12-08 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Thu Dec  8 09:08:49 UTC 2022

Modified Files:
src/sys/dev/ic: com.c

Log Message:
Fix hang up writing /dev/console rarely in specific environments.

Some BMC seems to require these syncronous operations.  If not,
it does not send transmit completion interrupts for some reason.


To generate a diff of this commit:
cvs rdiff -u -r1.380 -r1.381 src/sys/dev/ic/com.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/dev/ic/com.c
diff -u src/sys/dev/ic/com.c:1.380 src/sys/dev/ic/com.c:1.381
--- src/sys/dev/ic/com.c:1.380	Sat Dec  3 11:28:38 2022
+++ src/sys/dev/ic/com.c	Thu Dec  8 09:08:49 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: com.c,v 1.380 2022/12/03 11:28:38 skrll Exp $ */
+/* $NetBSD: com.c,v 1.381 2022/12/08 09:08:49 knakahara Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2004, 2008 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.380 2022/12/03 11:28:38 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.381 2022/12/08 09:08:49 knakahara Exp $");
 
 #include "opt_com.h"
 #include "opt_ddb.h"
@@ -206,6 +206,28 @@ static struct consdev comcons = {
 	.cn_pri = CN_NORMAL
 };
 
+#define	CSR_WRITE_1_SYNC(r, o, v)	do {			\
+		CSR_WRITE_1(r, o, v);\
+		switch(o) {	\
+		case COM_REG_IER:\
+			(void)CSR_READ_1(r, COM_REG_IIR);	\
+			break;	\
+		case COM_REG_TXDATA:\
+			(void)CSR_READ_1(r, COM_REG_TLR);	\
+			break;	\
+		}		\
+	} while(0)
+#define	CSR_WRITE_MULTI_SYNC(r, o, p, n)	do {		\
+		CSR_WRITE_MULTI(r, o, p, n);			\
+		switch(o) {	\
+		case COM_REG_IER:\
+			(void)CSR_READ_1(r, COM_REG_IIR);	\
+			break;	\
+		case COM_REG_TXDATA:\
+			(void)CSR_READ_1(r, COM_REG_TLR);	\
+			break;	\
+		}		\
+	} while(0)
 
 const struct cdevsw com_cdevsw = {
 	.d_open = comopen,
@@ -1961,7 +1983,7 @@ comstart(struct tty *tp)
 	/* Enable transmit completion interrupts if necessary. */
 	if (!ISSET(sc->sc_ier, IER_ETXRDY)) {
 		SET(sc->sc_ier, IER_ETXRDY);
-		CSR_WRITE_1(regsp, COM_REG_IER, sc->sc_ier);
+		CSR_WRITE_1_SYNC(regsp, COM_REG_IER, sc->sc_ier);
 	}
 
 	/* Output the first chunk of the contiguous buffer. */
@@ -1971,7 +1993,7 @@ comstart(struct tty *tp)
 		n = sc->sc_tbc;
 		if (n > sc->sc_fifolen)
 			n = sc->sc_fifolen;
-		CSR_WRITE_MULTI(regsp, COM_REG_TXDATA, sc->sc_tba, n);
+		CSR_WRITE_MULTI_SYNC(regsp, COM_REG_TXDATA, sc->sc_tba, n);
 		sc->sc_tbc -= n;
 		sc->sc_tba += n;
 	}
@@ -2359,7 +2381,7 @@ again:	do {
 	CLR(sc->sc_ier, IER_ERXRDY);
 	break;
 }
-CSR_WRITE_1(regsp, COM_REG_IER, sc->sc_ier);
+CSR_WRITE_1_SYNC(regsp, COM_REG_IER, sc->sc_ier);
 			}
 		} else {
 			if ((iir & (IIR_RXRDY|IIR_TXRDY)) == IIR_RXRDY) {
@@ -2443,14 +2465,14 @@ do_tx:
 			n = sc->sc_tbc;
 			if (n > sc->sc_fifolen)
 n = sc->sc_fifolen;
-			CSR_WRITE_MULTI(regsp, COM_REG_TXDATA, sc->sc_tba, n);
+			CSR_WRITE_MULTI_SYNC(regsp, COM_REG_TXDATA, sc->sc_tba, n);
 			sc->sc_tbc -= n;
 			sc->sc_tba += n;
 		} else {
 			/* Disable transmit completion interrupts if necessary. */
 			if (ISSET(sc->sc_ier, IER_ETXRDY)) {
 CLR(sc->sc_ier, IER_ETXRDY);
-CSR_WRITE_1(regsp, COM_REG_IER, sc->sc_ier);
+CSR_WRITE_1_SYNC(regsp, COM_REG_IER, sc->sc_ier);
 			}
 			if (sc->sc_tx_busy) {
 sc->sc_tx_busy = 0;



CVS commit: src/sys/dev/ic

2022-12-08 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Thu Dec  8 09:08:49 UTC 2022

Modified Files:
src/sys/dev/ic: com.c

Log Message:
Fix hang up writing /dev/console rarely in specific environments.

Some BMC seems to require these syncronous operations.  If not,
it does not send transmit completion interrupts for some reason.


To generate a diff of this commit:
cvs rdiff -u -r1.380 -r1.381 src/sys/dev/ic/com.c

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



CVS commit: src/sys/dev/pci

2022-12-08 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Thu Dec  8 08:14:28 UTC 2022

Modified Files:
src/sys/dev/pci: if_wm.c

Log Message:
Workaround for some hypervisor environments.

The environments cannot stop e1000 interrupt immediately.


To generate a diff of this commit:
cvs rdiff -u -r1.766 -r1.767 src/sys/dev/pci/if_wm.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/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.766 src/sys/dev/pci/if_wm.c:1.767
--- src/sys/dev/pci/if_wm.c:1.766	Wed Oct 26 06:36:39 2022
+++ src/sys/dev/pci/if_wm.c	Thu Dec  8 08:14:28 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.766 2022/10/26 06:36:39 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.767 2022/12/08 08:14:28 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.766 2022/10/26 06:36:39 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.767 2022/12/08 08:14:28 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_if_wm.h"
@@ -478,6 +478,7 @@ struct wm_queue {
 	char sysctlname[32];		/* Name for sysctl */
 
 	bool wmq_txrx_use_workqueue;
+	bool wmq_wq_enqueued;
 	struct work wmq_cookie;
 	void *wmq_si;
 };
@@ -10308,9 +10309,13 @@ static inline void
 wm_sched_handle_queue(struct wm_softc *sc, struct wm_queue *wmq)
 {
 
-	if (wmq->wmq_txrx_use_workqueue)
-		workqueue_enqueue(sc->sc_queue_wq, >wmq_cookie, curcpu());
-	else
+	if (wmq->wmq_txrx_use_workqueue) {
+		if (!wmq->wmq_wq_enqueued) {
+			wmq->wmq_wq_enqueued = true;
+			workqueue_enqueue(sc->sc_queue_wq, >wmq_cookie,
+			curcpu());
+		}
+	} else
 		softint_schedule(wmq->wmq_si);
 }
 
@@ -10593,8 +10598,10 @@ wm_handle_queue_work(struct work *wk, vo
 	struct wm_queue *wmq = container_of(wk, struct wm_queue, wmq_cookie);
 
 	/*
-	 * "enqueued flag" is not required here.
+	 * Some qemu environment workaround.  They don't stop interrupt
+	 * immediately.
 	 */
+	wmq->wmq_wq_enqueued = false;
 	wm_handle_queue(wmq);
 }
 



CVS commit: src/sys/dev/pci

2022-12-08 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Thu Dec  8 08:14:28 UTC 2022

Modified Files:
src/sys/dev/pci: if_wm.c

Log Message:
Workaround for some hypervisor environments.

The environments cannot stop e1000 interrupt immediately.


To generate a diff of this commit:
cvs rdiff -u -r1.766 -r1.767 src/sys/dev/pci/if_wm.c

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



CVS commit: src/sys/netipsec

2022-12-08 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Thu Dec  8 08:07:07 UTC 2022

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

Log Message:
Fix: sp->lastused should be updated by time_uptime, and refactor a little.


To generate a diff of this commit:
cvs rdiff -u -r1.176 -r1.177 src/sys/netipsec/ipsec.c
cvs rdiff -u -r1.279 -r1.280 src/sys/netipsec/key.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/ipsec.c
diff -u src/sys/netipsec/ipsec.c:1.176 src/sys/netipsec/ipsec.c:1.177
--- src/sys/netipsec/ipsec.c:1.176	Wed Nov  9 08:18:52 2022
+++ src/sys/netipsec/ipsec.c	Thu Dec  8 08:07:07 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: ipsec.c,v 1.176 2022/11/09 08:18:52 knakahara Exp $ */
+/* $NetBSD: ipsec.c,v 1.177 2022/12/08 08:07:07 knakahara Exp $ */
 /* $FreeBSD: ipsec.c,v 1.2.2.2 2003/07/01 01:38:13 sam Exp $ */
 /* $KAME: ipsec.c,v 1.103 2001/05/24 07:14:18 sakane Exp $ */
 
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.176 2022/11/09 08:18:52 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.177 2022/12/08 08:07:07 knakahara Exp $");
 
 /*
  * IPsec controller part.
@@ -248,7 +248,7 @@ ipsec_checkpcbcache(struct mbuf *m, stru
 		 */
 	}
 
-	sp->lastused = time_second;
+	key_sp_touch(sp);
 	KEY_SP_REF(sp);
 	KEYDEBUG_PRINTF(KEYDEBUG_IPSEC_STAMP,
 	"DP cause refcnt++:%d SP:%p\n",

Index: src/sys/netipsec/key.c
diff -u src/sys/netipsec/key.c:1.279 src/sys/netipsec/key.c:1.280
--- src/sys/netipsec/key.c:1.279	Thu Dec  8 08:05:03 2022
+++ src/sys/netipsec/key.c	Thu Dec  8 08:07:07 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: key.c,v 1.279 2022/12/08 08:05:03 knakahara Exp $	*/
+/*	$NetBSD: key.c,v 1.280 2022/12/08 08:07:07 knakahara 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 
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.279 2022/12/08 08:05:03 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.280 2022/12/08 08:07:07 knakahara Exp $");
 
 /*
  * This code is referred to RFC 2367
@@ -972,7 +972,7 @@ found:
 		KEY_CHKSPDIR(sp->spidx.dir, dir);
 
 		/* found a SPD entry */
-		sp->lastused = time_uptime;
+		key_sp_touch(sp);
 		key_sp_ref(sp, where, tag);
 	}
 	pserialize_read_exit(s);
@@ -1049,7 +1049,7 @@ key_gettunnel(const struct sockaddr *osr
 	sp = NULL;
 found:
 	if (sp) {
-		sp->lastused = time_uptime;
+		key_sp_touch(sp);
 		key_sp_ref(sp, where, tag);
 	}
 	pserialize_read_exit(s);



CVS commit: src/sys/netipsec

2022-12-08 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Thu Dec  8 08:07:07 UTC 2022

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

Log Message:
Fix: sp->lastused should be updated by time_uptime, and refactor a little.


To generate a diff of this commit:
cvs rdiff -u -r1.176 -r1.177 src/sys/netipsec/ipsec.c
cvs rdiff -u -r1.279 -r1.280 src/sys/netipsec/key.c

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



CVS commit: src/sys/netipsec

2022-12-08 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Thu Dec  8 08:05:03 UTC 2022

Modified Files:
src/sys/netipsec: ipsecif.c key.c key.h

Log Message:
Fix: update lastused of ipsecif(4) IPv6 out SP.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/netipsec/ipsecif.c
cvs rdiff -u -r1.278 -r1.279 src/sys/netipsec/key.c
cvs rdiff -u -r1.37 -r1.38 src/sys/netipsec/key.h

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/ipsecif.c
diff -u src/sys/netipsec/ipsecif.c:1.20 src/sys/netipsec/ipsecif.c:1.21
--- src/sys/netipsec/ipsecif.c:1.20	Wed Dec  7 08:30:15 2022
+++ src/sys/netipsec/ipsecif.c	Thu Dec  8 08:05:03 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipsecif.c,v 1.20 2022/12/07 08:30:15 knakahara Exp $  */
+/*	$NetBSD: ipsecif.c,v 1.21 2022/12/08 08:05:03 knakahara Exp $  */
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ipsecif.c,v 1.20 2022/12/07 08:30:15 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsecif.c,v 1.21 2022/12/08 08:05:03 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -395,7 +395,10 @@ ipsecif4_output(struct ipsec_variant *va
 	/*
 	 * The SPs in ipsec_variant are prevented from freed by
 	 * ipsec_variant->iv_psref. So, KEY_SP_REF() is unnecessary here.
+	 *
+	 * However, lastused should be updated.
 	 */
+	key_sp_touch(sp);
 
 	KASSERT(sp->policy != IPSEC_POLICY_NONE);
 	KASSERT(sp->policy != IPSEC_POLICY_ENTRUST);

Index: src/sys/netipsec/key.c
diff -u src/sys/netipsec/key.c:1.278 src/sys/netipsec/key.c:1.279
--- src/sys/netipsec/key.c:1.278	Wed Oct 19 21:28:02 2022
+++ src/sys/netipsec/key.c	Thu Dec  8 08:05:03 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: key.c,v 1.278 2022/10/19 21:28:02 christos Exp $	*/
+/*	$NetBSD: key.c,v 1.279 2022/12/08 08:05:03 knakahara 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 
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.278 2022/10/19 21:28:02 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.279 2022/12/08 08:05:03 knakahara Exp $");
 
 /*
  * This code is referred to RFC 2367
@@ -871,6 +871,13 @@ key_sp_refcnt(const struct secpolicy *sp
 	return 0;
 }
 
+void
+key_sp_touch(struct secpolicy *sp)
+{
+
+	sp->lastused = time_uptime;
+}
+
 static void
 key_spd_pserialize_perform(void)
 {

Index: src/sys/netipsec/key.h
diff -u src/sys/netipsec/key.h:1.37 src/sys/netipsec/key.h:1.38
--- src/sys/netipsec/key.h:1.37	Mon Aug  9 20:49:10 2021
+++ src/sys/netipsec/key.h	Thu Dec  8 08:05:03 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: key.h,v 1.37 2021/08/09 20:49:10 andvar Exp $	*/
+/*	$NetBSD: key.h,v 1.38 2022/12/08 08:05:03 knakahara Exp $	*/
 /*	$FreeBSD: key.h,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$KAME: key.h,v 1.21 2001/07/27 03:51:30 itojun Exp $	*/
 
@@ -67,6 +67,7 @@ void key_free_sp(struct secpolicy *);
 u_int key_sp_refcnt(const struct secpolicy *);
 void key_sp_ref(struct secpolicy *, const char *, int);
 void key_sp_unref(struct secpolicy *, const char *, int);
+void key_sp_touch(struct secpolicy *);
 void key_sa_ref(struct secasvar *, const char *, int);
 void key_sa_unref(struct secasvar *, const char *, int);
 u_int key_sa_refcnt(const struct secasvar *);



CVS commit: src/sys/netipsec

2022-12-08 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Thu Dec  8 08:05:03 UTC 2022

Modified Files:
src/sys/netipsec: ipsecif.c key.c key.h

Log Message:
Fix: update lastused of ipsecif(4) IPv6 out SP.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/netipsec/ipsecif.c
cvs rdiff -u -r1.278 -r1.279 src/sys/netipsec/key.c
cvs rdiff -u -r1.37 -r1.38 src/sys/netipsec/key.h

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