CVS commit: src/usr.bin/indent

2021-10-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Oct 20 05:41:57 UTC 2021

Modified Files:
src/usr.bin/indent: indent.h

Log Message:
indent: add reminder to make the code understandable for humans


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/usr.bin/indent/indent.h

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

Modified files:

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.42 src/usr.bin/indent/indent.h:1.43
--- src/usr.bin/indent/indent.h:1.42	Wed Oct 20 05:37:21 2021
+++ src/usr.bin/indent/indent.h	Wed Oct 20 05:41:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.42 2021/10/20 05:37:21 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.43 2021/10/20 05:41:57 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -249,6 +249,7 @@ extern bool inhibit_formatting;	/* true 
 
 #define	STACKSIZE 256
 
+/* TODO: group the members by purpose, don't sort them alphabetically */
 extern struct parser_state {
 token_type last_token;
 



CVS commit: src/usr.bin/indent

2021-10-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Oct 20 05:41:57 UTC 2021

Modified Files:
src/usr.bin/indent: indent.h

Log Message:
indent: add reminder to make the code understandable for humans


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/usr.bin/indent/indent.h

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



CVS commit: src/usr.bin/indent

2021-10-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Oct 20 05:37:21 UTC 2021

Modified Files:
src/usr.bin/indent: indent.c indent.h lexi.c

Log Message:
indent: rename ps.last_u_d to match its comment

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.143 -r1.144 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.41 -r1.42 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.91 -r1.92 src/usr.bin/indent/lexi.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.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.143 src/usr.bin/indent/indent.c:1.144
--- src/usr.bin/indent/indent.c:1.143	Wed Oct 20 05:26:46 2021
+++ src/usr.bin/indent/indent.c	Wed Oct 20 05:37:21 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.143 2021/10/20 05:26:46 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.144 2021/10/20 05:37:21 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.143 2021/10/20 05:26:46 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.144 2021/10/20 05:37:21 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -748,7 +748,7 @@ process_rparen_or_rbracket(bool *sp_sw, 
 token_type hd_type)
 {
 if ((ps.cast_mask & (1 << ps.p_l_follow) & ~ps.not_cast_mask) != 0) {
-	ps.last_u_d = true;
+	ps.next_unary = true;
 	ps.cast_mask &= (1 << ps.p_l_follow) - 1;
 	ps.want_blank = opt.space_after_cast;
 } else
@@ -769,8 +769,7 @@ process_rparen_or_rbracket(bool *sp_sw, 
 	 * such */
 	*sp_sw = false;
 	*force_nl = true;	/* must force newline after if */
-	ps.last_u_d = true;	/* inform lexi that a following operator is
- * unary */
+	ps.next_unary = true;
 	ps.in_stmt = false;	/* don't use stmt continuation indentation */
 
 	parse(hd_type);		/* let parser worry about if, or whatever */
@@ -1116,7 +1115,7 @@ process_ident(token_type ttype, int decl
 } else if (*sp_sw && ps.p_l_follow == 0) {
 	*sp_sw = false;
 	*force_nl = true;
-	ps.last_u_d = true;
+	ps.next_unary = true;
 	ps.in_stmt = false;
 	parse(hd_type);
 }

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.41 src/usr.bin/indent/indent.h:1.42
--- src/usr.bin/indent/indent.h:1.41	Wed Oct 20 05:26:46 2021
+++ src/usr.bin/indent/indent.h	Wed Oct 20 05:37:21 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.41 2021/10/20 05:26:46 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.42 2021/10/20 05:37:21 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -292,7 +292,7 @@ extern struct parser_state {
 bool ind_stmt;		/* whether the next line should have an extra
  * indentation level because we are in the
  * middle of a stmt */
-bool last_u_d;		/* whether the following operator should be
+bool next_unary;		/* whether the following operator should be
  * unary */
 int p_l_follow;		/* used to remember how to indent the
  * following statement */

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.91 src/usr.bin/indent/lexi.c:1.92
--- src/usr.bin/indent/lexi.c:1.91	Mon Oct 11 20:31:06 2021
+++ src/usr.bin/indent/lexi.c	Wed Oct 20 05:37:21 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.91 2021/10/11 20:31:06 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.92 2021/10/20 05:37:21 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)lexi.c	8.1 (
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.91 2021/10/11 20:31:06 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.92 2021/10/20 05:37:21 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -404,25 +404,25 @@ lexi_alnum(struct parser_state *state)
 
 if (state->last_token == keyword_struct_union_enum &&
 	state->p_l_follow == 0) {
-	state->last_u_d = true;
+	state->next_unary = true;
 	return decl;
 }
 
 /* Operator after identifier is binary unless last token was 'struct'. */
-state->last_u_d = (state->last_token == keyword_struct_union_enum);
+state->next_unary = state->last_token == keyword_struct_union_enum;
 
 const struct keyword *kw = bsearch(token.s, keywords,
 	nitems(keywords), sizeof(keywords[0]), cmp_keyword_by_name);
 if (kw == NULL) {
 	if (is_typename()) {
 	state->keyword = kw_type;
-	state->last_u_d = true;
+	state->next_unary = true;
 	goto found_typename;
 	}
 
 } else {			/* we have a keyword */
 	state->keyword = kw->kind;
-	state->last_u_d = true;
+	state->next_unary = true;
 
 	switch (kw->kind) {
 	case kw_switch:
@@ -481,13 +481,13 @@ not_proc:;
 
 } else if (probably_typename(state)) {
 	state->keyword = kw_type;
-	state->last_u_d = true;
+	sta

CVS commit: src/usr.bin/indent

2021-10-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Oct 20 05:37:21 UTC 2021

Modified Files:
src/usr.bin/indent: indent.c indent.h lexi.c

Log Message:
indent: rename ps.last_u_d to match its comment

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.143 -r1.144 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.41 -r1.42 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.91 -r1.92 src/usr.bin/indent/lexi.c

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



CVS commit: src/usr.bin/indent

2021-10-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Oct 20 05:26:46 UTC 2021

Modified Files:
src/usr.bin/indent: indent.c indent.h parse.c

Log Message:
indent: rename parser stack variables

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.142 -r1.143 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.40 -r1.41 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/indent/parse.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.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.142 src/usr.bin/indent/indent.c:1.143
--- src/usr.bin/indent/indent.c:1.142	Wed Oct 20 05:14:21 2021
+++ src/usr.bin/indent/indent.c	Wed Oct 20 05:26:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.142 2021/10/20 05:14:21 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.143 2021/10/20 05:26:46 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.142 2021/10/20 05:14:21 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.143 2021/10/20 05:26:46 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -428,7 +428,7 @@ main_init_globals(void)
 {
 found_err = false;
 
-ps.p_stack[0] = stmt;
+ps.s_ttype[0] = stmt;
 ps.last_nl = true;
 ps.last_token = semicolon;
 buf_init(&com);
@@ -982,7 +982,7 @@ process_lbrace(bool *force_nl, bool *sp_
 static void
 process_rbrace(bool *sp_sw, int *decl_ind, const int *di_stack)
 {
-if (ps.p_stack[ps.tos] == decl && !ps.block_init)	/* semicolons can be
+if (ps.s_ttype[ps.tos] == decl && !ps.block_init)	/* semicolons can be
 			 * omitted in
 			 * declarations */
 	parse(semicolon);
@@ -1016,8 +1016,8 @@ process_rbrace(bool *sp_sw, int *decl_in
 blank_line_before = false;
 parse(rbrace);		/* let parser know about this */
 ps.search_brace = opt.cuddle_else
-	&& ps.p_stack[ps.tos] == if_expr_stmt
-	&& ps.il[ps.tos] >= ps.ind_level;
+	&& ps.s_ttype[ps.tos] == if_expr_stmt
+	&& ps.s_ind_level[ps.tos] >= ps.ind_level;
 
 if (ps.tos <= 1 && opt.blanklines_after_procs && ps.decl_nest <= 0)
 	blank_line_after = true;

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.40 src/usr.bin/indent/indent.h:1.41
--- src/usr.bin/indent/indent.h:1.40	Wed Oct 20 05:14:21 2021
+++ src/usr.bin/indent/indent.h	Wed Oct 20 05:26:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.40 2021/10/20 05:14:21 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.41 2021/10/20 05:26:46 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -251,9 +251,12 @@ extern bool inhibit_formatting;	/* true 
 
 extern struct parser_state {
 token_type last_token;
-token_type p_stack[STACKSIZE];
-int il[STACKSIZE];		/* this stack stores indentation levels */
-float cstk[STACKSIZE];	/* used to store case stmt indentation levels */
+
+int tos;			/* pointer to top of stack */
+token_type s_ttype[STACKSIZE];
+int s_ind_level[STACKSIZE];
+float s_case_ind_level[STACKSIZE];
+
 int comment_delta;		/* used to set up indentation for all lines of
  * a boxed comment after the first one */
 int n_comment_delta;	/* remembers how many columns there were
@@ -311,7 +314,6 @@ extern struct parser_state {
 enum keyword_kind keyword;
 bool dumped_decl_indent;
 bool in_parameter_declaration;
-int tos;			/* pointer to top of stack */
 char procname[100];		/* The name of the current procedure */
 int just_saw_decl;
 

Index: src/usr.bin/indent/parse.c
diff -u src/usr.bin/indent/parse.c:1.35 src/usr.bin/indent/parse.c:1.36
--- src/usr.bin/indent/parse.c:1.35	Fri Oct  8 23:47:41 2021
+++ src/usr.bin/indent/parse.c	Wed Oct 20 05:26:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.35 2021/10/08 23:47:41 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.36 2021/10/20 05:26:46 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -66,8 +66,8 @@ parse(token_type ttype)
 	token_type_name(ttype), token.s);
 
 if (ttype != keyword_else) {
-	while (ps.p_stack[ps.tos] == if_expr_stmt) {
-	ps.p_stack[ps.tos] = stmt;
+	while (ps.s_ttype[ps.tos] == if_expr_stmt) {
+	ps.s_ttype[ps.tos] = stmt;
 	reduce();
 	}
 }
@@ -78,17 +78,17 @@ parse(token_type ttype)
 	ps.search_brace = opt.brace_same_line;
 	/* indicate that following brace should be on same line */
 
-	if (ps.p_stack[ps.tos] != decl) {	/* only put one declaration
+	if (ps.s_ttype[ps.tos] != decl) {	/* only put one declaration
 		 * onto stack */
 	break_comma = true;	/* while in declaration, newline should be
  * forced after comma */
-	ps.p_stack[++ps.tos] = decl;
-	ps.il[ps.tos] = ps.ind_level_follow;
+	ps.s_ttype[++ps.tos] = decl;
+	ps.s_ind_level[ps

CVS commit: src/usr.bin/indent

2021-10-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Oct 20 05:26:46 UTC 2021

Modified Files:
src/usr.bin/indent: indent.c indent.h parse.c

Log Message:
indent: rename parser stack variables

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.142 -r1.143 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.40 -r1.41 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/indent/parse.c

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



CVS commit: src

2021-10-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Oct 20 05:14:21 UTC 2021

Modified Files:
src/tests/usr.bin/indent: opt_bacc.c
src/usr.bin/indent: indent.c indent.h io.c pr_comment.c

Log Message:
indent: rename blankline_requested variables

The words 'prefix' and 'postfix' sounded too much like horizontal
concepts, like in operators. The actual purpose of these variables is to
add blank lines before and after the current line, so use the same
wording as in the command line options.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/opt_bacc.c
cvs rdiff -u -r1.141 -r1.142 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.39 -r1.40 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.98 -r1.99 src/usr.bin/indent/io.c
cvs rdiff -u -r1.79 -r1.80 src/usr.bin/indent/pr_comment.c

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

Modified files:

Index: src/tests/usr.bin/indent/opt_bacc.c
diff -u src/tests/usr.bin/indent/opt_bacc.c:1.3 src/tests/usr.bin/indent/opt_bacc.c:1.4
--- src/tests/usr.bin/indent/opt_bacc.c:1.3	Mon Oct 18 07:11:31 2021
+++ src/tests/usr.bin/indent/opt_bacc.c	Wed Oct 20 05:14:21 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_bacc.c,v 1.3 2021/10/18 07:11:31 rillig Exp $ */
+/* $NetBSD: opt_bacc.c,v 1.4 2021/10/20 05:14:21 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -23,7 +23,7 @@ int		c;
 
 /*
  * XXX: As of 2021-10-05, the option -bacc has no effect on declarations since
- * process_decl resets prefix_blankline_requested unconditionally.
+ * process_decl resets blank_line_before unconditionally.
  */
 #indent run -bacc
 int		a;

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.141 src/usr.bin/indent/indent.c:1.142
--- src/usr.bin/indent/indent.c:1.141	Wed Oct 20 05:07:08 2021
+++ src/usr.bin/indent/indent.c	Wed Oct 20 05:14:21 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.141 2021/10/20 05:07:08 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.142 2021/10/20 05:14:21 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.141 2021/10/20 05:07:08 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.142 2021/10/20 05:14:21 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -103,8 +103,8 @@ char *saved_inp_e;
 
 bool found_err;
 int blank_lines_to_output;
-bool prefix_blankline_requested;
-bool postfix_blankline_requested;
+bool blank_line_before;
+bool blank_line_after;
 bool break_comma;
 float case_ind;
 bool had_eof;
@@ -939,7 +939,7 @@ process_lbrace(bool *force_nl, bool *sp_
 }
 
 if (ps.in_parameter_declaration)
-	prefix_blankline_requested = false;
+	blank_line_before = false;
 
 if (ps.p_l_follow > 0) {	/* check for preceding unbalanced parens */
 	diag(1, "Unbalanced parens");
@@ -965,7 +965,7 @@ process_lbrace(bool *force_nl, bool *sp_
 	 * declaration, so don't do special
 	 * indentation of comments */
 	if (opt.blanklines_after_decl_at_top && ps.in_parameter_declaration)
-	postfix_blankline_requested = true;
+	blank_line_after = true;
 	ps.in_parameter_declaration = false;
 	ps.in_decl = false;
 }
@@ -1013,14 +1013,14 @@ process_rbrace(bool *sp_sw, int *decl_in
 	ps.in_decl = true;
 }
 
-prefix_blankline_requested = false;
+blank_line_before = false;
 parse(rbrace);		/* let parser know about this */
 ps.search_brace = opt.cuddle_else
 	&& ps.p_stack[ps.tos] == if_expr_stmt
 	&& ps.il[ps.tos] >= ps.ind_level;
 
 if (ps.tos <= 1 && opt.blanklines_after_procs && ps.decl_nest <= 0)
-	postfix_blankline_requested = true;
+	blank_line_after = true;
 }
 
 static void
@@ -1080,7 +1080,7 @@ process_decl(int *decl_ind, bool *tabs_t
 if (ps.decl_nest <= 0)
 	ps.just_saw_decl = 2;
 
-prefix_blankline_requested = false;
+blank_line_before = false;
 
 int len = (int)buf_len(&token) + 1;
 int ind = ps.ind_level == 0 || ps.decl_nest > 0
@@ -1298,11 +1298,11 @@ process_preprocessing(void)
 }
 
 if (opt.blanklines_around_conditional_compilation) {
-	postfix_blankline_requested = true;
+	blank_line_after = true;
 	blank_lines_to_output = 0;
 } else {
-	postfix_blankline_requested = false;
-	prefix_blankline_requested = false;
+	blank_line_after = false;
+	blank_line_before = false;
 }
 
 /*
@@ -1444,7 +1444,7 @@ main_loop(void)
 
 	case type_def:
 	case storage_class:
-	prefix_blankline_requested = false;
+	blank_line_before = false;
 	goto copy_token;
 
 	case keyword_struct_union_enum:

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.39 src/usr.bin/indent/indent.h:1.40
--- src/usr.bin/indent/indent.h:1.39	Wed Oct 20 05:00:37 2021
+++ src/usr.bin/indent/indent.h	Wed Oct 20 05:14:21 2021
@@ -1,4 +1,

CVS commit: src

2021-10-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Oct 20 05:14:21 UTC 2021

Modified Files:
src/tests/usr.bin/indent: opt_bacc.c
src/usr.bin/indent: indent.c indent.h io.c pr_comment.c

Log Message:
indent: rename blankline_requested variables

The words 'prefix' and 'postfix' sounded too much like horizontal
concepts, like in operators. The actual purpose of these variables is to
add blank lines before and after the current line, so use the same
wording as in the command line options.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/opt_bacc.c
cvs rdiff -u -r1.141 -r1.142 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.39 -r1.40 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.98 -r1.99 src/usr.bin/indent/io.c
cvs rdiff -u -r1.79 -r1.80 src/usr.bin/indent/pr_comment.c

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



CVS commit: src/usr.bin/indent

2021-10-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Oct 20 05:07:08 UTC 2021

Modified Files:
src/usr.bin/indent: indent.c

Log Message:
indent: invert condition in process_newline

It's hard to follow a condition that combines many negated terms with
'||'. Group the conditions by their origin.

The condition '!opt.break_after_comma && break_comma' still sounds like
a contradition, more investigations to follow.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.140 -r1.141 src/usr.bin/indent/indent.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.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.140 src/usr.bin/indent/indent.c:1.141
--- src/usr.bin/indent/indent.c:1.140	Wed Oct 20 05:00:37 2021
+++ src/usr.bin/indent/indent.c	Wed Oct 20 05:07:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.140 2021/10/20 05:00:37 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.141 2021/10/20 05:07:08 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.140 2021/10/20 05:00:37 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.141 2021/10/20 05:07:08 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -670,11 +670,15 @@ process_form_feed(void)
 static void
 process_newline(void)
 {
-if (ps.last_token != comma || ps.p_l_follow > 0 || opt.break_after_comma
-	|| ps.block_init || !break_comma || com.s != com.e) {
-	dump_line();
-	ps.want_blank = false;
-}
+if (ps.last_token == comma && ps.p_l_follow == 0 && !ps.block_init &&
+	!opt.break_after_comma && break_comma &&
+	com.s == com.e)
+	goto stay_in_line;
+
+dump_line();
+ps.want_blank = false;
+
+stay_in_line:
 ++line_no;
 }
 



CVS commit: src/usr.bin/indent

2021-10-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Oct 20 05:07:08 UTC 2021

Modified Files:
src/usr.bin/indent: indent.c

Log Message:
indent: invert condition in process_newline

It's hard to follow a condition that combines many negated terms with
'||'. Group the conditions by their origin.

The condition '!opt.break_after_comma && break_comma' still sounds like
a contradition, more investigations to follow.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.140 -r1.141 src/usr.bin/indent/indent.c

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



CVS commit: src/usr.bin/indent

2021-10-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Oct 20 05:00:37 UTC 2021

Modified Files:
src/usr.bin/indent: indent.c indent.h io.c

Log Message:
indent: rename next_blank_lines to blank_lines_to_output

The previous name was already an improvement over the name before that
(n_real_blanklines), but didn't express the intended purpose clearly
enough, so try another name.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.139 -r1.140 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.38 -r1.39 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.97 -r1.98 src/usr.bin/indent/io.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.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.139 src/usr.bin/indent/indent.c:1.140
--- src/usr.bin/indent/indent.c:1.139	Tue Oct 19 18:29:59 2021
+++ src/usr.bin/indent/indent.c	Wed Oct 20 05:00:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.139 2021/10/19 18:29:59 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.140 2021/10/20 05:00:37 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.139 2021/10/19 18:29:59 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.140 2021/10/20 05:00:37 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -102,7 +102,7 @@ char *saved_inp_s;
 char *saved_inp_e;
 
 bool found_err;
-int next_blank_lines;
+int blank_lines_to_output;
 bool prefix_blankline_requested;
 bool postfix_blankline_requested;
 bool break_comma;
@@ -1295,7 +1295,7 @@ process_preprocessing(void)
 
 if (opt.blanklines_around_conditional_compilation) {
 	postfix_blankline_requested = true;
-	next_blank_lines = 0;
+	blank_lines_to_output = 0;
 } else {
 	postfix_blankline_requested = false;
 	prefix_blankline_requested = false;

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.38 src/usr.bin/indent/indent.h:1.39
--- src/usr.bin/indent/indent.h:1.38	Sat Oct  9 11:00:27 2021
+++ src/usr.bin/indent/indent.h	Wed Oct 20 05:00:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.38 2021/10/09 11:00:27 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.39 2021/10/20 05:00:37 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -236,7 +236,7 @@ enum keyword_kind {
 
 
 extern bool found_err;
-extern int next_blank_lines;
+extern int blank_lines_to_output;
 extern bool prefix_blankline_requested;
 extern bool postfix_blankline_requested;
 extern bool break_comma;	/* when true and not in parens, break after a

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.97 src/usr.bin/indent/io.c:1.98
--- src/usr.bin/indent/io.c:1.97	Tue Oct 19 21:39:19 2021
+++ src/usr.bin/indent/io.c	Wed Oct 20 05:00:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.97 2021/10/19 21:39:19 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.98 2021/10/20 05:00:37 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.97 2021/10/19 21:39:19 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.98 2021/10/20 05:00:37 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -221,21 +221,21 @@ dump_line(void)
 	if (suppress_blanklines)
 	suppress_blanklines = false;
 	else
-	next_blank_lines++;
+	blank_lines_to_output++;
 
 } else if (!inhibit_formatting) {
 	suppress_blanklines = false;
 	if (prefix_blankline_requested && !first_line) {
 	if (opt.swallow_optional_blanklines) {
-		if (next_blank_lines == 1)
-		next_blank_lines = 0;
+		if (blank_lines_to_output == 1)
+		blank_lines_to_output = 0;
 	} else {
-		if (next_blank_lines == 0)
-		next_blank_lines = 1;
+		if (blank_lines_to_output == 0)
+		blank_lines_to_output = 1;
 	}
 	}
 
-	for (; next_blank_lines > 0; next_blank_lines--)
+	for (; blank_lines_to_output > 0; blank_lines_to_output--)
 	output_char('\n');
 
 	if (ps.ind_level == 0)
@@ -387,7 +387,7 @@ parse_indent_comment(void)
 
 inhibit_formatting = !on;
 if (on) {
-	next_blank_lines = 0;
+	blank_lines_to_output = 0;
 	postfix_blankline_requested = false;
 	prefix_blankline_requested = false;
 	suppress_blanklines = true;



CVS commit: src/usr.bin/indent

2021-10-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Oct 20 05:00:37 UTC 2021

Modified Files:
src/usr.bin/indent: indent.c indent.h io.c

Log Message:
indent: rename next_blank_lines to blank_lines_to_output

The previous name was already an improvement over the name before that
(n_real_blanklines), but didn't express the intended purpose clearly
enough, so try another name.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.139 -r1.140 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.38 -r1.39 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.97 -r1.98 src/usr.bin/indent/io.c

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



CVS commit: src/lib/libc/sys

2021-10-19 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Oct 20 03:26:20 UTC 2021

Modified Files:
src/lib/libc/sys: kqueue.2

Log Message:
Oops, forgot to note the history of NOTE_OPEN, NOTE_CLOSE, NOTE_CLOSE_WRITE,
and NOTE_READ.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/lib/libc/sys/kqueue.2

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

Modified files:

Index: src/lib/libc/sys/kqueue.2
diff -u src/lib/libc/sys/kqueue.2:1.55 src/lib/libc/sys/kqueue.2:1.56
--- src/lib/libc/sys/kqueue.2:1.55	Wed Oct 20 03:08:19 2021
+++ src/lib/libc/sys/kqueue.2	Wed Oct 20 03:26:20 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: kqueue.2,v 1.55 2021/10/20 03:08:19 thorpej Exp $
+.\"	$NetBSD: kqueue.2,v 1.56 2021/10/20 03:26:20 thorpej Exp $
 .\"
 .\" Copyright (c) 2000 Jonathan Lemon
 .\" All rights reserved.
@@ -860,3 +860,14 @@ filter flags for
 .Dv EVFILT_TIMER
 was added in
 .Nx 10.0 .
+.Pp
+Support for
+.Dv NOTE_OPEN ,
+.Dv NOTE_CLOSE ,
+.Dv NOTE_CLOSE_WRITE ,
+and
+NOTE_READ
+filter flags for
+.Dv EVFILT_VNODE
+was added in
+.Nx 10.0 .



CVS commit: src/lib/libc/sys

2021-10-19 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Oct 20 03:26:20 UTC 2021

Modified Files:
src/lib/libc/sys: kqueue.2

Log Message:
Oops, forgot to note the history of NOTE_OPEN, NOTE_CLOSE, NOTE_CLOSE_WRITE,
and NOTE_READ.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/lib/libc/sys/kqueue.2

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



CVS commit: src/sys

2021-10-19 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Oct 20 03:13:14 UTC 2021

Modified Files:
src/sys/kern: vnode_if.c
src/sys/rump/include/rump: rumpvnode_if.h
src/sys/rump/librump/rumpvfs: rumpvnode_if.c
src/sys/sys: vnode_if.h

Log Message:
Regen for:

Overhaul of the EVFILT_VNODE kevent(2) filter:

- Centralize vnode kevent handling in the VOP_*() wrappers, rather than
  forcing each individual file system to deal with it (except VOP_RENAME(),
  because VOP_RENAME() is a mess and we currently have 2 different ways
  of handling it; at least it's reasonably well-centralized in the "new"
  way).
- Add support for NOTE_OPEN, NOTE_CLOSE, NOTE_CLOSE_WRITE, and NOTE_READ,
  compatible with the same events in FreeBSD.
- Track which kevent notifications clients are interested in receiving
  to avoid doing work for events no one cares about (avoiding, e.g.
  taking locks and traversing the klist to send a NOTE_WRITE when
  someone is merely watching for a file to be deleted, for example).

In support of the above:

- Add support in vnode_if.sh for specifying PRE- and POST-op handlers,
  to be invoked before and after vop_pre() and vop_post(), respectively.
  Basic idea from FreeBSD, but implemented differently.
- Add support in vnode_if.sh for specifying CONTEXT fields in the
  vop_*_args structures.  These context fields are used to convey information
  between the file system VOP function and the VOP wrapper, but do not
  occupy an argument slot in the VOP_*() call itself.  These context fields
  are initialized and subsequently interpreted by PRE- and POST-op handlers.
- Version VOP_REMOVE(), uses the a context field for the file system to report
  back the resulting link count of the target vnode.  Return this in tmpfs,
  udf, nfs, chfs, ext2fs, lfs, and ufs.

NetBSD 9.99.92.


To generate a diff of this commit:
cvs rdiff -u -r1.114 -r1.115 src/sys/kern/vnode_if.c
cvs rdiff -u -r1.36 -r1.37 src/sys/rump/include/rump/rumpvnode_if.h
cvs rdiff -u -r1.36 -r1.37 src/sys/rump/librump/rumpvfs/rumpvnode_if.c
cvs rdiff -u -r1.107 -r1.108 src/sys/sys/vnode_if.h

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



CVS commit: src/sys

2021-10-19 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Oct 20 03:13:14 UTC 2021

Modified Files:
src/sys/kern: vnode_if.c
src/sys/rump/include/rump: rumpvnode_if.h
src/sys/rump/librump/rumpvfs: rumpvnode_if.c
src/sys/sys: vnode_if.h

Log Message:
Regen for:

Overhaul of the EVFILT_VNODE kevent(2) filter:

- Centralize vnode kevent handling in the VOP_*() wrappers, rather than
  forcing each individual file system to deal with it (except VOP_RENAME(),
  because VOP_RENAME() is a mess and we currently have 2 different ways
  of handling it; at least it's reasonably well-centralized in the "new"
  way).
- Add support for NOTE_OPEN, NOTE_CLOSE, NOTE_CLOSE_WRITE, and NOTE_READ,
  compatible with the same events in FreeBSD.
- Track which kevent notifications clients are interested in receiving
  to avoid doing work for events no one cares about (avoiding, e.g.
  taking locks and traversing the klist to send a NOTE_WRITE when
  someone is merely watching for a file to be deleted, for example).

In support of the above:

- Add support in vnode_if.sh for specifying PRE- and POST-op handlers,
  to be invoked before and after vop_pre() and vop_post(), respectively.
  Basic idea from FreeBSD, but implemented differently.
- Add support in vnode_if.sh for specifying CONTEXT fields in the
  vop_*_args structures.  These context fields are used to convey information
  between the file system VOP function and the VOP wrapper, but do not
  occupy an argument slot in the VOP_*() call itself.  These context fields
  are initialized and subsequently interpreted by PRE- and POST-op handlers.
- Version VOP_REMOVE(), uses the a context field for the file system to report
  back the resulting link count of the target vnode.  Return this in tmpfs,
  udf, nfs, chfs, ext2fs, lfs, and ufs.

NetBSD 9.99.92.


To generate a diff of this commit:
cvs rdiff -u -r1.114 -r1.115 src/sys/kern/vnode_if.c
cvs rdiff -u -r1.36 -r1.37 src/sys/rump/include/rump/rumpvnode_if.h
cvs rdiff -u -r1.36 -r1.37 src/sys/rump/librump/rumpvfs/rumpvnode_if.c
cvs rdiff -u -r1.107 -r1.108 src/sys/sys/vnode_if.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/kern/vnode_if.c
diff -u src/sys/kern/vnode_if.c:1.114 src/sys/kern/vnode_if.c:1.115
--- src/sys/kern/vnode_if.c:1.114	Fri Jul  2 16:57:15 2021
+++ src/sys/kern/vnode_if.c	Wed Oct 20 03:13:14 2021
@@ -1,13 +1,13 @@
-/*	$NetBSD: vnode_if.c,v 1.114 2021/07/02 16:57:15 dholland Exp $	*/
+/*	$NetBSD: vnode_if.c,v 1.115 2021/10/20 03:13:14 thorpej Exp $	*/
 
 /*
  * Warning: DO NOT EDIT! This file is automatically generated!
  * (Modifications made here may easily be lost!)
  *
  * Created from the file:
- *	NetBSD: vnode_if.src,v 1.82 2021/07/02 16:56:22 dholland Exp
+ *	NetBSD: vnode_if.src,v 1.83 2021/10/20 03:08:18 thorpej Exp
  * by the script:
- *	NetBSD: vnode_if.sh,v 1.70 2020/05/16 18:31:50 christos Exp
+ *	NetBSD: vnode_if.sh,v 1.72 2021/10/20 03:08:18 thorpej Exp
  */
 
 /*
@@ -40,11 +40,12 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vnode_if.c,v 1.114 2021/07/02 16:57:15 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnode_if.c,v 1.115 2021/10/20 03:13:14 thorpej Exp $");
 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -89,6 +90,199 @@ vop_pre(vnode_t *vp, struct mount **mp, 
 	return 0;
 }
 
+static inline u_quad_t
+vop_pre_get_size(struct vnode *vp)
+{
+	mutex_enter(vp->v_interlock);
+	KASSERT(vp->v_size != VSIZENOTSET);
+	u_quad_t rv = (u_quad_t)vp->v_size;
+	mutex_exit(vp->v_interlock);
+
+	return rv;
+}
+
+/*
+ * VOP_RMDIR(), VOP_REMOVE(), and VOP_RENAME() need special handling
+ * because they each drop the caller's references on one or more of
+ * their arguments.  While there must be an open file descriptor in
+ * associated with a vnode in order for knotes to be attached to it,
+ * that status could change during the course of the operation.  So,
+ * for the vnode arguments that are WILLRELE or WILLPUT, we check
+ * pre-op if there are registered knotes, take a hold count if so,
+ * and post-op release the hold after activating any knotes still
+ * associated with the vnode.
+ */
+
+#define	VOP_POST_KNOTE(thisvp, e, n)	\
+do {	\
+	if (__predict_true((e) == 0)) {	\
+		/*			\
+		 * VN_KNOTE() does the VN_KEVENT_INTEREST()		\
+		 * check for us.	\
+		 */			\
+		VN_KNOTE((thisvp), (n));\
+	}\
+} while (/*CONSTCOND*/0)
+
+#define	VOP_POST_KNOTE_HELD(thisvp, e, n)\
+do {	\
+	/*\
+	 * We don't perform a VN_KEVENT_INTEREST() check here; it	\
+	 * was already performed when we did the pre-op work that	\
+	 * caused the vnode to be held in the first place.		\
+	 */\
+	mutex_enter((thisvp)->v_interlock);\
+	if (__predict_true((e) == 0)) {	\
+		knote(&(thisvp)->v_klist, (n));\
+	}\
+	holdrelel((thisvp));		\
+	mutex_exit((thisvp)->v_interlock)

CVS commit: src/sys/sys

2021-10-19 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Oct 20 03:09:45 UTC 2021

Modified Files:
src/sys/sys: param.h

Log Message:
Overhaul of the EVFILT_VNODE kevent(2) filter:

- Centralize vnode kevent handling in the VOP_*() wrappers, rather than
  forcing each individual file system to deal with it (except VOP_RENAME(),
  because VOP_RENAME() is a mess and we currently have 2 different ways
  of handling it; at least it's reasonably well-centralized in the "new"
  way).
- Add support for NOTE_OPEN, NOTE_CLOSE, NOTE_CLOSE_WRITE, and NOTE_READ,
  compatible with the same events in FreeBSD.
- Track which kevent notifications clients are interested in receiving
  to avoid doing work for events no one cares about (avoiding, e.g.
  taking locks and traversing the klist to send a NOTE_WRITE when
  someone is merely watching for a file to be deleted, for example).

In support of the above:

- Add support in vnode_if.sh for specifying PRE- and POST-op handlers,
  to be invoked before and after vop_pre() and vop_post(), respectively.
  Basic idea from FreeBSD, but implemented differently.
- Add support in vnode_if.sh for specifying CONTEXT fields in the
  vop_*_args structures.  These context fields are used to convey information
  between the file system VOP function and the VOP wrapper, but do not
  occupy an argument slot in the VOP_*() call itself.  These context fields
  are initialized and subsequently interpreted by PRE- and POST-op handlers.
- Version VOP_REMOVE(), uses the a context field for the file system to report
  back the resulting link count of the target vnode.  Return this in tmpfs,
  udf, nfs, chfs, ext2fs, lfs, and ufs.

NetBSD 9.99.92.


To generate a diff of this commit:
cvs rdiff -u -r1.704 -r1.705 src/sys/sys/param.h

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



CVS commit: src/sys/sys

2021-10-19 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Oct 20 03:09:45 UTC 2021

Modified Files:
src/sys/sys: param.h

Log Message:
Overhaul of the EVFILT_VNODE kevent(2) filter:

- Centralize vnode kevent handling in the VOP_*() wrappers, rather than
  forcing each individual file system to deal with it (except VOP_RENAME(),
  because VOP_RENAME() is a mess and we currently have 2 different ways
  of handling it; at least it's reasonably well-centralized in the "new"
  way).
- Add support for NOTE_OPEN, NOTE_CLOSE, NOTE_CLOSE_WRITE, and NOTE_READ,
  compatible with the same events in FreeBSD.
- Track which kevent notifications clients are interested in receiving
  to avoid doing work for events no one cares about (avoiding, e.g.
  taking locks and traversing the klist to send a NOTE_WRITE when
  someone is merely watching for a file to be deleted, for example).

In support of the above:

- Add support in vnode_if.sh for specifying PRE- and POST-op handlers,
  to be invoked before and after vop_pre() and vop_post(), respectively.
  Basic idea from FreeBSD, but implemented differently.
- Add support in vnode_if.sh for specifying CONTEXT fields in the
  vop_*_args structures.  These context fields are used to convey information
  between the file system VOP function and the VOP wrapper, but do not
  occupy an argument slot in the VOP_*() call itself.  These context fields
  are initialized and subsequently interpreted by PRE- and POST-op handlers.
- Version VOP_REMOVE(), uses the a context field for the file system to report
  back the resulting link count of the target vnode.  Return this in tmpfs,
  udf, nfs, chfs, ext2fs, lfs, and ufs.

NetBSD 9.99.92.


To generate a diff of this commit:
cvs rdiff -u -r1.704 -r1.705 src/sys/sys/param.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/sys/param.h
diff -u src/sys/sys/param.h:1.704 src/sys/sys/param.h:1.705
--- src/sys/sys/param.h:1.704	Mon Oct 11 01:07:36 2021
+++ src/sys/sys/param.h	Wed Oct 20 03:09:45 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.704 2021/10/11 01:07:36 thorpej Exp $	*/
+/*	$NetBSD: param.h,v 1.705 2021/10/20 03:09:45 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -67,7 +67,7 @@
  *	2.99.9		(299000900)
  */
 
-#define	__NetBSD_Version__	999009100	/* NetBSD 9.99.91 */
+#define	__NetBSD_Version__	999009200	/* NetBSD 9.99.92 */
 
 #define __NetBSD_Prereq__(M,m,p) (M) * 1) + \
 (m) * 100) + (p) * 100) <= __NetBSD_Version__)



CVS commit: src

2021-10-19 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Oct 20 03:08:19 UTC 2021

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vnops.c
src/lib/libc/sys: kqueue.2
src/sys/coda: coda_vnops.c
src/sys/fs/msdosfs: msdosfs_vnops.c
src/sys/fs/nilfs: nilfs_vnops.c
src/sys/fs/ptyfs: ptyfs_vnops.c
src/sys/fs/puffs: puffs_vnops.c
src/sys/fs/sysvbfs: sysvbfs_vnops.c
src/sys/fs/tmpfs: tmpfs_rename.c tmpfs_subr.c tmpfs_vnops.c
src/sys/fs/udf: udf_rename.c udf_vnops.c
src/sys/fs/union: union_vnops.c
src/sys/fs/unionfs: unionfs_vnops.c
src/sys/fs/v7fs: v7fs_vnops.c
src/sys/kern: vfs_vnode.c vfs_vnops.c vnode_if.sh vnode_if.src
src/sys/miscfs/deadfs: dead_vnops.c
src/sys/miscfs/genfs: genfs.h genfs_rename.c genfs_vnops.c
layer_vnops.c
src/sys/miscfs/umapfs: umap_vnops.c
src/sys/nfs: nfs_bio.c nfs_kq.c nfs_vnops.c
src/sys/rump/librump/rumpvfs: rumpfs.c
src/sys/sys: event.h vnode.h
src/sys/ufs/chfs: chfs_vnops.c
src/sys/ufs/ext2fs: ext2fs_readwrite.c ext2fs_rename.c ext2fs_vnops.c
src/sys/ufs/lfs: lfs_rename.c lfs_vnops.c ulfs_readwrite.c ulfs_vnops.c
src/sys/ufs/ufs: ufs_acl.c ufs_extern.h ufs_readwrite.c ufs_rename.c
ufs_vnops.c
src/tests/kernel/kqueue: t_vnode.c

Log Message:
Overhaul of the EVFILT_VNODE kevent(2) filter:

- Centralize vnode kevent handling in the VOP_*() wrappers, rather than
  forcing each individual file system to deal with it (except VOP_RENAME(),
  because VOP_RENAME() is a mess and we currently have 2 different ways
  of handling it; at least it's reasonably well-centralized in the "new"
  way).
- Add support for NOTE_OPEN, NOTE_CLOSE, NOTE_CLOSE_WRITE, and NOTE_READ,
  compatible with the same events in FreeBSD.
- Track which kevent notifications clients are interested in receiving
  to avoid doing work for events no one cares about (avoiding, e.g.
  taking locks and traversing the klist to send a NOTE_WRITE when
  someone is merely watching for a file to be deleted, for example).

In support of the above:

- Add support in vnode_if.sh for specifying PRE- and POST-op handlers,
  to be invoked before and after vop_pre() and vop_post(), respectively.
  Basic idea from FreeBSD, but implemented differently.
- Add support in vnode_if.sh for specifying CONTEXT fields in the
  vop_*_args structures.  These context fields are used to convey information
  between the file system VOP function and the VOP wrapper, but do not
  occupy an argument slot in the VOP_*() call itself.  These context fields
  are initialized and subsequently interpreted by PRE- and POST-op handlers.
- Version VOP_REMOVE(), uses the a context field for the file system to report
  back the resulting link count of the target vnode.  Return this in tmpfs,
  udf, nfs, chfs, ext2fs, lfs, and ufs.

NetBSD 9.99.92.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c
cvs rdiff -u -r1.54 -r1.55 src/lib/libc/sys/kqueue.2
cvs rdiff -u -r1.115 -r1.116 src/sys/coda/coda_vnops.c
cvs rdiff -u -r1.106 -r1.107 src/sys/fs/msdosfs/msdosfs_vnops.c
cvs rdiff -u -r1.44 -r1.45 src/sys/fs/nilfs/nilfs_vnops.c
cvs rdiff -u -r1.66 -r1.67 src/sys/fs/ptyfs/ptyfs_vnops.c
cvs rdiff -u -r1.222 -r1.223 src/sys/fs/puffs/puffs_vnops.c
cvs rdiff -u -r1.67 -r1.68 src/sys/fs/sysvbfs/sysvbfs_vnops.c
cvs rdiff -u -r1.10 -r1.11 src/sys/fs/tmpfs/tmpfs_rename.c
cvs rdiff -u -r1.113 -r1.114 src/sys/fs/tmpfs/tmpfs_subr.c
cvs rdiff -u -r1.147 -r1.148 src/sys/fs/tmpfs/tmpfs_vnops.c
cvs rdiff -u -r1.13 -r1.14 src/sys/fs/udf/udf_rename.c
cvs rdiff -u -r1.116 -r1.117 src/sys/fs/udf/udf_vnops.c
cvs rdiff -u -r1.78 -r1.79 src/sys/fs/union/union_vnops.c
cvs rdiff -u -r1.16 -r1.17 src/sys/fs/unionfs/unionfs_vnops.c
cvs rdiff -u -r1.31 -r1.32 src/sys/fs/v7fs/v7fs_vnops.c
cvs rdiff -u -r1.127 -r1.128 src/sys/kern/vfs_vnode.c
cvs rdiff -u -r1.223 -r1.224 src/sys/kern/vfs_vnops.c
cvs rdiff -u -r1.71 -r1.72 src/sys/kern/vnode_if.sh
cvs rdiff -u -r1.82 -r1.83 src/sys/kern/vnode_if.src
cvs rdiff -u -r1.65 -r1.66 src/sys/miscfs/deadfs/dead_vnops.c
cvs rdiff -u -r1.37 -r1.38 src/sys/miscfs/genfs/genfs.h
cvs rdiff -u -r1.5 -r1.6 src/sys/miscfs/genfs/genfs_rename.c
cvs rdiff -u -r1.215 -r1.216 src/sys/miscfs/genfs/genfs_vnops.c
cvs rdiff -u -r1.71 -r1.72 src/sys/miscfs/genfs/layer_vnops.c
cvs rdiff -u -r1.61 -r1.62 src/sys/miscfs/umapfs/umap_vnops.c
cvs rdiff -u -r1.199 -r1.200 src/sys/nfs/nfs_bio.c
cvs rdiff -u -r1.31 -r1.32 src/sys/nfs/nfs_kq.c
cvs rdiff -u -r1.320 -r1.321 src/sys/nfs/nfs_vnops.c
cvs rdiff -u -r1.165 -r1.166 src/sys/rump/librump/rumpvfs/rumpfs.c
cvs rdiff -u -r1.48 -r1.49 src/sys/sys/event.h
cvs rdiff -u -r1.297 -r1.298 src/sys/sys/vnode.h
cvs rdiff -u -r1.45 -r1.46 src/sys/ufs/chfs/chfs_vnops.c
cvs rdiff -u -r1.77 -r1.78 src/sys/ufs/ext2fs/ext2fs_readwr

CVS commit: src

2021-10-19 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Oct 20 03:08:19 UTC 2021

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vnops.c
src/lib/libc/sys: kqueue.2
src/sys/coda: coda_vnops.c
src/sys/fs/msdosfs: msdosfs_vnops.c
src/sys/fs/nilfs: nilfs_vnops.c
src/sys/fs/ptyfs: ptyfs_vnops.c
src/sys/fs/puffs: puffs_vnops.c
src/sys/fs/sysvbfs: sysvbfs_vnops.c
src/sys/fs/tmpfs: tmpfs_rename.c tmpfs_subr.c tmpfs_vnops.c
src/sys/fs/udf: udf_rename.c udf_vnops.c
src/sys/fs/union: union_vnops.c
src/sys/fs/unionfs: unionfs_vnops.c
src/sys/fs/v7fs: v7fs_vnops.c
src/sys/kern: vfs_vnode.c vfs_vnops.c vnode_if.sh vnode_if.src
src/sys/miscfs/deadfs: dead_vnops.c
src/sys/miscfs/genfs: genfs.h genfs_rename.c genfs_vnops.c
layer_vnops.c
src/sys/miscfs/umapfs: umap_vnops.c
src/sys/nfs: nfs_bio.c nfs_kq.c nfs_vnops.c
src/sys/rump/librump/rumpvfs: rumpfs.c
src/sys/sys: event.h vnode.h
src/sys/ufs/chfs: chfs_vnops.c
src/sys/ufs/ext2fs: ext2fs_readwrite.c ext2fs_rename.c ext2fs_vnops.c
src/sys/ufs/lfs: lfs_rename.c lfs_vnops.c ulfs_readwrite.c ulfs_vnops.c
src/sys/ufs/ufs: ufs_acl.c ufs_extern.h ufs_readwrite.c ufs_rename.c
ufs_vnops.c
src/tests/kernel/kqueue: t_vnode.c

Log Message:
Overhaul of the EVFILT_VNODE kevent(2) filter:

- Centralize vnode kevent handling in the VOP_*() wrappers, rather than
  forcing each individual file system to deal with it (except VOP_RENAME(),
  because VOP_RENAME() is a mess and we currently have 2 different ways
  of handling it; at least it's reasonably well-centralized in the "new"
  way).
- Add support for NOTE_OPEN, NOTE_CLOSE, NOTE_CLOSE_WRITE, and NOTE_READ,
  compatible with the same events in FreeBSD.
- Track which kevent notifications clients are interested in receiving
  to avoid doing work for events no one cares about (avoiding, e.g.
  taking locks and traversing the klist to send a NOTE_WRITE when
  someone is merely watching for a file to be deleted, for example).

In support of the above:

- Add support in vnode_if.sh for specifying PRE- and POST-op handlers,
  to be invoked before and after vop_pre() and vop_post(), respectively.
  Basic idea from FreeBSD, but implemented differently.
- Add support in vnode_if.sh for specifying CONTEXT fields in the
  vop_*_args structures.  These context fields are used to convey information
  between the file system VOP function and the VOP wrapper, but do not
  occupy an argument slot in the VOP_*() call itself.  These context fields
  are initialized and subsequently interpreted by PRE- and POST-op handlers.
- Version VOP_REMOVE(), uses the a context field for the file system to report
  back the resulting link count of the target vnode.  Return this in tmpfs,
  udf, nfs, chfs, ext2fs, lfs, and ufs.

NetBSD 9.99.92.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c
cvs rdiff -u -r1.54 -r1.55 src/lib/libc/sys/kqueue.2
cvs rdiff -u -r1.115 -r1.116 src/sys/coda/coda_vnops.c
cvs rdiff -u -r1.106 -r1.107 src/sys/fs/msdosfs/msdosfs_vnops.c
cvs rdiff -u -r1.44 -r1.45 src/sys/fs/nilfs/nilfs_vnops.c
cvs rdiff -u -r1.66 -r1.67 src/sys/fs/ptyfs/ptyfs_vnops.c
cvs rdiff -u -r1.222 -r1.223 src/sys/fs/puffs/puffs_vnops.c
cvs rdiff -u -r1.67 -r1.68 src/sys/fs/sysvbfs/sysvbfs_vnops.c
cvs rdiff -u -r1.10 -r1.11 src/sys/fs/tmpfs/tmpfs_rename.c
cvs rdiff -u -r1.113 -r1.114 src/sys/fs/tmpfs/tmpfs_subr.c
cvs rdiff -u -r1.147 -r1.148 src/sys/fs/tmpfs/tmpfs_vnops.c
cvs rdiff -u -r1.13 -r1.14 src/sys/fs/udf/udf_rename.c
cvs rdiff -u -r1.116 -r1.117 src/sys/fs/udf/udf_vnops.c
cvs rdiff -u -r1.78 -r1.79 src/sys/fs/union/union_vnops.c
cvs rdiff -u -r1.16 -r1.17 src/sys/fs/unionfs/unionfs_vnops.c
cvs rdiff -u -r1.31 -r1.32 src/sys/fs/v7fs/v7fs_vnops.c
cvs rdiff -u -r1.127 -r1.128 src/sys/kern/vfs_vnode.c
cvs rdiff -u -r1.223 -r1.224 src/sys/kern/vfs_vnops.c
cvs rdiff -u -r1.71 -r1.72 src/sys/kern/vnode_if.sh
cvs rdiff -u -r1.82 -r1.83 src/sys/kern/vnode_if.src
cvs rdiff -u -r1.65 -r1.66 src/sys/miscfs/deadfs/dead_vnops.c
cvs rdiff -u -r1.37 -r1.38 src/sys/miscfs/genfs/genfs.h
cvs rdiff -u -r1.5 -r1.6 src/sys/miscfs/genfs/genfs_rename.c
cvs rdiff -u -r1.215 -r1.216 src/sys/miscfs/genfs/genfs_vnops.c
cvs rdiff -u -r1.71 -r1.72 src/sys/miscfs/genfs/layer_vnops.c
cvs rdiff -u -r1.61 -r1.62 src/sys/miscfs/umapfs/umap_vnops.c
cvs rdiff -u -r1.199 -r1.200 src/sys/nfs/nfs_bio.c
cvs rdiff -u -r1.31 -r1.32 src/sys/nfs/nfs_kq.c
cvs rdiff -u -r1.320 -r1.321 src/sys/nfs/nfs_vnops.c
cvs rdiff -u -r1.165 -r1.166 src/sys/rump/librump/rumpvfs/rumpfs.c
cvs rdiff -u -r1.48 -r1.49 src/sys/sys/event.h
cvs rdiff -u -r1.297 -r1.298 src/sys/sys/vnode.h
cvs rdiff -u -r1.45 -r1.46 src/sys/ufs/chfs/chfs_vnops.c
cvs rdiff -u -r1.77 -r1.78 src/sys/ufs/ext2fs/ext2fs_readwr

CVS commit: src/sys/dev/pci

2021-10-19 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Wed Oct 20 02:12:37 UTC 2021

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

Log Message:
Uniform INTx/MSI handler's Tx/Rx behavior to MSI-X's one.

Because the difference has caused INTx/MSI own bugs.


To generate a diff of this commit:
cvs rdiff -u -r1.710 -r1.711 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.710 src/sys/dev/pci/if_wm.c:1.711
--- src/sys/dev/pci/if_wm.c:1.710	Wed Oct 20 02:05:15 2021
+++ src/sys/dev/pci/if_wm.c	Wed Oct 20 02:12:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.710 2021/10/20 02:05:15 knakahara Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.711 2021/10/20 02:12:36 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.710 2021/10/20 02:05:15 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.711 2021/10/20 02:12:36 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -9835,88 +9835,85 @@ wm_intr_legacy(void *arg)
 	struct wm_queue *wmq = &sc->sc_queue[0];
 	struct wm_txqueue *txq = &wmq->wmq_txq;
 	struct wm_rxqueue *rxq = &wmq->wmq_rxq;
+	u_int txlimit = sc->sc_tx_intr_process_limit;
+	u_int rxlimit = sc->sc_rx_intr_process_limit;
 	uint32_t icr, rndval = 0;
-	int handled = 0;
 	bool more = false;
 
-	while (1 /* CONSTCOND */) {
-		icr = CSR_READ(sc, WMREG_ICR);
-		if ((icr & sc->sc_icr) == 0)
-			break;
-		if (handled == 0)
-			DPRINTF(sc, WM_DEBUG_TX,
-			("%s: INTx: got intr\n",device_xname(sc->sc_dev)));
-		if (rndval == 0)
-			rndval = icr;
+	icr = CSR_READ(sc, WMREG_ICR);
+	if ((icr & sc->sc_icr) == 0)
+		return 0;
 
-		mutex_enter(rxq->rxq_lock);
+	DPRINTF(sc, WM_DEBUG_TX,
+	("%s: INTx: got intr\n",device_xname(sc->sc_dev)));
+	if (rndval == 0)
+		rndval = icr;
 
-		if (rxq->rxq_stopping) {
-			mutex_exit(rxq->rxq_lock);
-			break;
-		}
+	mutex_enter(rxq->rxq_lock);
 
-		handled = 1;
+	if (rxq->rxq_stopping) {
+		mutex_exit(rxq->rxq_lock);
+		return 0;
+	}
 
 #if defined(WM_DEBUG) || defined(WM_EVENT_COUNTERS)
-		if (icr & (ICR_RXDMT0 | ICR_RXT0)) {
-			DPRINTF(sc, WM_DEBUG_RX,
-			("%s: RX: got Rx intr 0x%08x\n",
-device_xname(sc->sc_dev),
-icr & (ICR_RXDMT0 | ICR_RXT0)));
-			WM_Q_EVCNT_INCR(rxq, intr);
-		}
+	if (icr & (ICR_RXDMT0 | ICR_RXT0)) {
+		DPRINTF(sc, WM_DEBUG_RX,
+		("%s: RX: got Rx intr 0x%08x\n",
+			device_xname(sc->sc_dev),
+			icr & (ICR_RXDMT0 | ICR_RXT0)));
+		WM_Q_EVCNT_INCR(rxq, intr);
+	}
 #endif
-		/*
-		 * wm_rxeof() does *not* call upper layer functions directly,
-		 * as if_percpuq_enqueue() just call softint_schedule().
-		 * So, we can call wm_rxeof() in interrupt context.
-		 */
-		more = wm_rxeof(rxq, UINT_MAX);
+	/*
+	 * wm_rxeof() does *not* call upper layer functions directly,
+	 * as if_percpuq_enqueue() just call softint_schedule().
+	 * So, we can call wm_rxeof() in interrupt context.
+	 */
+	more = wm_rxeof(rxq, rxlimit);
 
-		mutex_exit(rxq->rxq_lock);
-		mutex_enter(txq->txq_lock);
+	mutex_exit(rxq->rxq_lock);
+	mutex_enter(txq->txq_lock);
 
-		if (txq->txq_stopping) {
-			mutex_exit(txq->txq_lock);
-			break;
-		}
+	if (txq->txq_stopping) {
+		mutex_exit(txq->txq_lock);
+		return 0;
+	}
 
 #if defined(WM_DEBUG) || defined(WM_EVENT_COUNTERS)
-		if (icr & ICR_TXDW) {
-			DPRINTF(sc, WM_DEBUG_TX,
-			("%s: TX: got TXDW interrupt\n",
-device_xname(sc->sc_dev)));
-			WM_Q_EVCNT_INCR(txq, txdw);
-		}
+	if (icr & ICR_TXDW) {
+		DPRINTF(sc, WM_DEBUG_TX,
+		("%s: TX: got TXDW interrupt\n",
+			device_xname(sc->sc_dev)));
+		WM_Q_EVCNT_INCR(txq, txdw);
+	}
 #endif
-		more |= wm_txeof(txq, UINT_MAX);
-		if (!IF_IS_EMPTY(&ifp->if_snd))
-			more = true;
+	more |= wm_txeof(txq, txlimit);
+	if (!IF_IS_EMPTY(&ifp->if_snd))
+		more = true;
 
-		mutex_exit(txq->txq_lock);
-		WM_CORE_LOCK(sc);
+	mutex_exit(txq->txq_lock);
+	WM_CORE_LOCK(sc);
 
-		if (sc->sc_core_stopping) {
-			WM_CORE_UNLOCK(sc);
-			break;
-		}
+	if (sc->sc_core_stopping) {
+		WM_CORE_UNLOCK(sc);
+		return 0;
+	}
 
-		if (icr & (ICR_LSC | ICR_RXSEQ)) {
-			WM_EVCNT_INCR(&sc->sc_ev_linkintr);
-			wm_linkintr(sc, icr);
-		}
-		if ((icr & ICR_GPI(0)) != 0)
-			device_printf(sc->sc_dev, "got module interrupt\n");
+	if (icr & (ICR_LSC | ICR_RXSEQ)) {
+		WM_EVCNT_INCR(&sc->sc_ev_linkintr);
+		wm_linkintr(sc, icr);
+	}
+	if ((icr & ICR_GPI(0)) != 0)
+		device_printf(sc->sc_dev, "got module interrupt\n");
 
-		WM_CORE_UNLOCK(sc);
+	WM_CORE_UNLOCK(sc);
 
-		if (icr & ICR_RXO) {
+	if (icr & ICR_RXO) {
 #if defined(WM_DEBUG)
-			log(LOG_WARNING, "%s: Receive overrun\n",
-			device_xname(sc->sc_dev));
+		log(LOG_WARNING, "%s: Receive overrun\n",
+		device_xname(sc->sc_dev));
 #endif /* defined(WM_DEBUG) */
-		}
 	}
 
 	rnd_add_uint32(&sc->rnd_source, rndval);
@@ -9928,7 +9925,7 @@ wm_in

CVS commit: src/sys/dev/pci

2021-10-19 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Wed Oct 20 02:12:37 UTC 2021

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

Log Message:
Uniform INTx/MSI handler's Tx/Rx behavior to MSI-X's one.

Because the difference has caused INTx/MSI own bugs.


To generate a diff of this commit:
cvs rdiff -u -r1.710 -r1.711 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/dev/pci

2021-10-19 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Wed Oct 20 02:05:15 UTC 2021

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

Log Message:
Fix Tx stall, reported and implemented original patch by chs@n.o, thanks.

Check if_snd queue because if.c::if_transmit() doesn't call ifp->if_start()
when IFQ_ENQUEUE failed.

Reviewed and tested by chs@n.o and msaitoh@n.o.


To generate a diff of this commit:
cvs rdiff -u -r1.709 -r1.710 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.709 src/sys/dev/pci/if_wm.c:1.710
--- src/sys/dev/pci/if_wm.c:1.709	Mon Oct 18 11:36:11 2021
+++ src/sys/dev/pci/if_wm.c	Wed Oct 20 02:05:15 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.709 2021/10/18 11:36:11 jmcneill Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.710 2021/10/20 02:05:15 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.709 2021/10/18 11:36:11 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.710 2021/10/20 02:05:15 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -9831,6 +9831,7 @@ static int
 wm_intr_legacy(void *arg)
 {
 	struct wm_softc *sc = arg;
+	struct ifnet *ifp = &sc->sc_ethercom.ec_if;
 	struct wm_queue *wmq = &sc->sc_queue[0];
 	struct wm_txqueue *txq = &wmq->wmq_txq;
 	struct wm_rxqueue *rxq = &wmq->wmq_rxq;
@@ -9890,6 +9891,8 @@ wm_intr_legacy(void *arg)
 		}
 #endif
 		more |= wm_txeof(txq, UINT_MAX);
+		if (!IF_IS_EMPTY(&ifp->if_snd))
+			more = true;
 
 		mutex_exit(txq->txq_lock);
 		WM_CORE_LOCK(sc);



CVS commit: src/sys/dev/pci

2021-10-19 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Wed Oct 20 02:05:15 UTC 2021

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

Log Message:
Fix Tx stall, reported and implemented original patch by chs@n.o, thanks.

Check if_snd queue because if.c::if_transmit() doesn't call ifp->if_start()
when IFQ_ENQUEUE failed.

Reviewed and tested by chs@n.o and msaitoh@n.o.


To generate a diff of this commit:
cvs rdiff -u -r1.709 -r1.710 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

2021-10-19 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Oct 20 01:09:49 UTC 2021

Modified Files:
src/sys/arch/evbarm/dev: plcom.c
src/sys/dev/ic: com.c

Log Message:
- microtime -> microuptime
- avoid kpause with timeo=0


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/arch/evbarm/dev/plcom.c
cvs rdiff -u -r1.369 -r1.370 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/arch/evbarm/dev/plcom.c
diff -u src/sys/arch/evbarm/dev/plcom.c:1.63 src/sys/arch/evbarm/dev/plcom.c:1.64
--- src/sys/arch/evbarm/dev/plcom.c:1.63	Sun Oct 17 22:34:17 2021
+++ src/sys/arch/evbarm/dev/plcom.c	Wed Oct 20 01:09:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: plcom.c,v 1.63 2021/10/17 22:34:17 jmcneill Exp $	*/
+/*	$NetBSD: plcom.c,v 1.64 2021/10/20 01:09:49 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2001 ARM Ltd
@@ -94,7 +94,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.63 2021/10/17 22:34:17 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.64 2021/10/20 01:09:49 jmcneill Exp $");
 
 #include "opt_plcom.h"
 #include "opt_ddb.h"
@@ -686,7 +686,7 @@ plcom_shutdown(struct plcom_softc *sc)
 	 */
 	if (ISSET(tp->t_cflag, HUPCL)) {
 		plcom_modem(sc, 0);
-		microtime(&sc->sc_hup_pending);
+		microuptime(&sc->sc_hup_pending);
 		sc->sc_hup_pending.tv_sec++;
 	}
 
@@ -790,13 +790,14 @@ plcomopen(dev_t dev, int flag, int mode,
 		}
 
 		if (timerisset(&sc->sc_hup_pending)) {
-			microtime(&now);
+			microuptime(&now);
 			while (timercmp(&now, &sc->sc_hup_pending, <)) {
 timersub(&sc->sc_hup_pending, &now, &diff);
 const int ms = diff.tv_sec * 100 +
-uimax(diff.tv_usec / 1000, 1);
-kpause(ttclos, false, mstohz(ms), &sc->sc_lock);
-microtime(&now);
+diff.tv_usec / 1000;
+kpause(ttclos, false, uimax(mstohz(ms), 1),
+&sc->sc_lock);
+microuptime(&now);
 			}
 			timerclear(&sc->sc_hup_pending);
 		}

Index: src/sys/dev/ic/com.c
diff -u src/sys/dev/ic/com.c:1.369 src/sys/dev/ic/com.c:1.370
--- src/sys/dev/ic/com.c:1.369	Thu Oct 14 09:56:12 2021
+++ src/sys/dev/ic/com.c	Wed Oct 20 01:09:49 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: com.c,v 1.369 2021/10/14 09:56:12 jmcneill Exp $ */
+/* $NetBSD: com.c,v 1.370 2021/10/20 01:09:49 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2004, 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.369 2021/10/14 09:56:12 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.370 2021/10/20 01:09:49 jmcneill Exp $");
 
 #include "opt_com.h"
 #include "opt_ddb.h"
@@ -891,7 +891,7 @@ com_shutdown(struct com_softc *sc)
 	 */
 	if (ISSET(tp->t_cflag, HUPCL)) {
 		com_modem(sc, 0);
-		microtime(&sc->sc_hup_pending);
+		microuptime(&sc->sc_hup_pending);
 		sc->sc_hup_pending.tv_sec++;
 	}
 
@@ -984,14 +984,14 @@ comopen(dev_t dev, int flag, int mode, s
 		}
 
 		if (timerisset(&sc->sc_hup_pending)) {
-			microtime(&now);
+			microuptime(&now);
 			while (timercmp(&now, &sc->sc_hup_pending, <)) {
 timersub(&sc->sc_hup_pending, &now, &diff);
 const int ms = diff.tv_sec * 1000 +
-uimax(diff.tv_usec / 1000, 1);
-kpause(ttclos, false, mstohz(ms),
+diff.tv_usec / 1000;
+kpause(ttclos, false, uimax(mstohz(ms), 1),
 &sc->sc_lock);
-microtime(&now);
+microuptime(&now);
 			}
 			timerclear(&sc->sc_hup_pending);
 		}



CVS commit: src/sys

2021-10-19 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Oct 20 01:09:49 UTC 2021

Modified Files:
src/sys/arch/evbarm/dev: plcom.c
src/sys/dev/ic: com.c

Log Message:
- microtime -> microuptime
- avoid kpause with timeo=0


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/arch/evbarm/dev/plcom.c
cvs rdiff -u -r1.369 -r1.370 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/usr.bin/indent

2021-10-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Oct 19 21:39:19 UTC 2021

Modified Files:
src/usr.bin/indent: io.c

Log Message:
indent: always keep next_blank_lines >= 0

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 src/usr.bin/indent/io.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.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.96 src/usr.bin/indent/io.c:1.97
--- src/usr.bin/indent/io.c:1.96	Tue Oct 19 21:21:07 2021
+++ src/usr.bin/indent/io.c	Tue Oct 19 21:39:19 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.96 2021/10/19 21:21:07 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.97 2021/10/19 21:39:19 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.96 2021/10/19 21:21:07 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.97 2021/10/19 21:39:19 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -235,9 +235,8 @@ dump_line(void)
 	}
 	}
 
-	while (--next_blank_lines >= 0)
+	for (; next_blank_lines > 0; next_blank_lines--)
 	output_char('\n');
-	next_blank_lines = 0;
 
 	if (ps.ind_level == 0)
 	ps.ind_stmt = false;	/* this is a class A kludge. don't do



CVS commit: src/usr.bin/indent

2021-10-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Oct 19 21:39:19 UTC 2021

Modified Files:
src/usr.bin/indent: io.c

Log Message:
indent: always keep next_blank_lines >= 0

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 src/usr.bin/indent/io.c

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



CVS commit: src/lib/libform

2021-10-19 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue Oct 19 21:22:20 UTC 2021

Modified Files:
src/lib/libform: internals.c

Log Message:
Fix for PR lib/47397

Fix a misinterpretation of the role of field fore and back.  Now field
pad is rendered in the back attribute always instead of only being used
for the non-current field.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/lib/libform/internals.c

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

Modified files:

Index: src/lib/libform/internals.c
diff -u src/lib/libform/internals.c:1.40 src/lib/libform/internals.c:1.41
--- src/lib/libform/internals.c:1.40	Tue Apr 13 13:13:04 2021
+++ src/lib/libform/internals.c	Tue Oct 19 21:22:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: internals.c,v 1.40 2021/04/13 13:13:04 christos Exp $	*/
+/*	$NetBSD: internals.c,v 1.41 2021/10/19 21:22:20 blymn Exp $	*/
 
 /*-
  * Copyright (c) 1998-1999 Brett Lymn
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: internals.c,v 1.40 2021/04/13 13:13:04 christos Exp $");
+__RCSID("$NetBSD: internals.c,v 1.41 2021/10/19 21:22:20 blymn Exp $");
 
 #include 
 #include 
@@ -1606,11 +1606,6 @@ _formi_redraw_field(FORM *form, int fiel
 			}
 		}
 
-		if (form->cur_field == field)
-			wattrset(form->scrwin, cur->fore);
-		else
-			wattrset(form->scrwin, cur->back);
-
 		str = &row->string[cur->start_char];
 
 #ifdef DEBUG
@@ -1631,11 +1626,14 @@ _formi_redraw_field(FORM *form, int fiel
 		_formi_dbg_printf("%s: %s\n", __func__,  buffer);
 #endif
 
+		wattrset(form->scrwin, cur->back);
+
 		for (i = start + cur->start_char; i < pre; i++)
 			waddch(form->scrwin, cur->pad);
 
 		_formi_dbg_printf("%s: will add %d chars\n", __func__,
 			min(slen, flen));
+		wattrset(form->scrwin, cur->fore);
 		for (i = 0, cpos = cur->start_char; i < min(slen, flen);
 		 i++, str++, cpos++) 
 		{
@@ -1647,8 +1645,11 @@ _formi_redraw_field(FORM *form, int fiel
 if (c == '\t')
 	tab = add_tab(form, row, cpos,
 		  cur->pad);
-else
+else {
+	wattrset(form->scrwin, cur->back);
 	waddch(form->scrwin, cur->pad);
+	wattrset(form->scrwin, cur->fore);
+}
 			} else if ((cur->opts & O_VISIBLE) == O_VISIBLE) {
 if (c == '\t')
 	tab = add_tab(form, row, cpos, ' ');
@@ -1670,6 +1671,7 @@ _formi_redraw_field(FORM *form, int fiel
 i += tab - 1;
 		}
 
+		wattrset(form->scrwin, cur->back);
 		for (i = 0; i < post; i++)
 			waddch(form->scrwin, cur->pad);
 	}
@@ -1678,10 +1680,7 @@ _formi_redraw_field(FORM *form, int fiel
 		wmove(form->scrwin, (int) (cur->form_row + i),
 		  (int) cur->form_col);
 
-		if (form->cur_field == field)
-			wattrset(form->scrwin, cur->fore);
-		else
-			wattrset(form->scrwin, cur->back);
+		wattrset(form->scrwin, cur->back);
 
 		for (j = 0; j < cur->cols; j++) {
 			waddch(form->scrwin, cur->pad);



CVS commit: src/lib/libform

2021-10-19 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue Oct 19 21:22:20 UTC 2021

Modified Files:
src/lib/libform: internals.c

Log Message:
Fix for PR lib/47397

Fix a misinterpretation of the role of field fore and back.  Now field
pad is rendered in the back attribute always instead of only being used
for the non-current field.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/lib/libform/internals.c

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



CVS commit: src

2021-10-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Oct 19 21:21:07 UTC 2021

Modified Files:
src/tests/usr.bin/indent: indent_off_on.c
src/usr.bin/indent: io.c

Log Message:
indent: use simpler code for copying the input buffer

In debug mode, this reduces the amount of debug output lines.

No functional change in default mode.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/indent_off_on.c
cvs rdiff -u -r1.95 -r1.96 src/usr.bin/indent/io.c

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

Modified files:

Index: src/tests/usr.bin/indent/indent_off_on.c
diff -u src/tests/usr.bin/indent/indent_off_on.c:1.2 src/tests/usr.bin/indent/indent_off_on.c:1.3
--- src/tests/usr.bin/indent/indent_off_on.c:1.2	Tue Oct 19 20:41:42 2021
+++ src/tests/usr.bin/indent/indent_off_on.c	Tue Oct 19 21:21:07 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: indent_off_on.c,v 1.2 2021/10/19 20:41:42 rillig Exp $ */
+/* $NetBSD: indent_off_on.c,v 1.3 2021/10/19 21:21:07 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -33,6 +33,24 @@
 
 #indent input
 {}
+
+
+/*INDENT OFF*/
+/*INDENT ON*/
+#indent end
+
+#indent run
+{
+}
+/* $ FIXME: This empty line must stay. */
+/* $ FIXME: This empty line must stay. */
+/*INDENT OFF*/
+/* INDENT ON */
+#indent end
+
+
+#indent input
+{}
  /* INDENT OFF */
  /* INDENT ON */
 {}

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.95 src/usr.bin/indent/io.c:1.96
--- src/usr.bin/indent/io.c:1.95	Tue Oct 19 18:29:59 2021
+++ src/usr.bin/indent/io.c	Tue Oct 19 21:21:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.95 2021/10/19 18:29:59 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.96 2021/10/19 21:21:07 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.95 2021/10/19 18:29:59 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.96 2021/10/19 21:21:07 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -451,10 +451,8 @@ inbuf_read_line(void)
 	parse_indent_comment();
 }
 
-if (inhibit_formatting) {
-	for (p = inp.s; p < inp.e; p++)
-	output_char(*p);
-}
+if (inhibit_formatting)
+	output_range(inp.s, inp.e);
 }
 
 int



CVS commit: src

2021-10-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Oct 19 21:21:07 UTC 2021

Modified Files:
src/tests/usr.bin/indent: indent_off_on.c
src/usr.bin/indent: io.c

Log Message:
indent: use simpler code for copying the input buffer

In debug mode, this reduces the amount of debug output lines.

No functional change in default mode.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/indent_off_on.c
cvs rdiff -u -r1.95 -r1.96 src/usr.bin/indent/io.c

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



CVS commit: src/tests/usr.bin/indent

2021-10-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Oct 19 20:41:42 UTC 2021

Modified Files:
src/tests/usr.bin/indent: indent_off_on.c token_comment.c

Log Message:
tests/indent: move tests for indent comments

The special INDENT ON and INDENT OFF comments look like ordinary
comments but are handled in inbuf_read_line. Implementing this feature
in the input function has several unintended side effects regarding
indentation of these comments, as demonstrated by the tests.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/indent_off_on.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/token_comment.c

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

Modified files:

Index: src/tests/usr.bin/indent/indent_off_on.c
diff -u src/tests/usr.bin/indent/indent_off_on.c:1.1 src/tests/usr.bin/indent/indent_off_on.c:1.2
--- src/tests/usr.bin/indent/indent_off_on.c:1.1	Tue Oct 19 20:20:25 2021
+++ src/tests/usr.bin/indent/indent_off_on.c	Tue Oct 19 20:41:42 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: indent_off_on.c,v 1.1 2021/10/19 20:20:25 rillig Exp $ */
+/* $NetBSD: indent_off_on.c,v 1.2 2021/10/19 20:41:42 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -116,3 +116,82 @@ int   decl   ;
 /* INDENT		ON		*/
 int decl;
 #indent end
+
+
+#indent input
+/*INDENT OFF*/
+/* No formatting takes place here. */
+int format( void ) {{{
+/*INDENT ON*/
+}}}
+#indent end
+
+#indent run
+/*INDENT OFF*/
+/* No formatting takes place here. */
+int format( void ) {{{
+/* $ XXX: Why is the INDENT ON comment indented? */
+/* $ XXX: Why does the INDENT ON comment get spaces, but not the OFF comment? */
+			/* INDENT ON */
+}
+}
+}
+#indent end
+
+
+#indent input
+/* INDENT OFF */
+void indent_off ( void ) ;
+/*  INDENT */
+void indent_on ( void ) ;
+/* INDENT OFF */
+void indent_off ( void ) ;
+	/* INDENT ON */
+void indent_on ( void ) ;	/* the comment may be indented */
+/* INDENT		OFF	*/
+void indent_off ( void ) ;
+/* INDENTATION ON */
+void indent_still_off ( void ) ;	/* due to the word 'INDENTATION' */
+/* INDENT ON * */
+void indent_still_off ( void ) ;	/* due to the extra '*' at the end */
+/* INDENT ON */
+void indent_on ( void ) ;
+/* INDENT: OFF */
+void indent_still_on ( void ) ;	/* due to the colon in the middle */
+/* INDENT OFF */		/* extra comment */
+void indent_still_on ( void ) ;	/* due to the extra comment to the right */
+#indent end
+
+#indent run
+/* INDENT OFF */
+void indent_off ( void ) ;
+/* $ XXX: The double space from the below comment got merged to a single */
+/* $ XXX: space even though the comment might be regarded to be still in */
+/* $ XXX: the OFF section. */
+/* INDENT */
+void
+indent_on(void);
+/* INDENT OFF */
+void indent_off ( void ) ;
+/* $ XXX: The below comment got moved from column 9 to column 1. */
+/* INDENT ON */
+void
+indent_on(void);		/* the comment may be indented */
+/* INDENT		OFF	*/
+void indent_off ( void ) ;
+/* INDENTATION ON */
+void indent_still_off ( void ) ;	/* due to the word 'INDENTATION' */
+/* INDENT ON * */
+void indent_still_off ( void ) ;	/* due to the extra '*' at the end */
+/* INDENT ON */
+void
+indent_on(void);
+/* INDENT: OFF */
+void
+indent_still_on(void);		/* due to the colon in the middle */
+/* $ The extra comment got moved to the left since there is no code in */
+/* $ that line. */
+/* INDENT OFF *//* extra comment */
+void
+indent_still_on(void);		/* due to the extra comment to the right */
+#indent end

Index: src/tests/usr.bin/indent/token_comment.c
diff -u src/tests/usr.bin/indent/token_comment.c:1.4 src/tests/usr.bin/indent/token_comment.c:1.5
--- src/tests/usr.bin/indent/token_comment.c:1.4	Tue Oct 19 18:29:59 2021
+++ src/tests/usr.bin/indent/token_comment.c	Tue Oct 19 20:41:42 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token_comment.c,v 1.4 2021/10/19 18:29:59 rillig Exp $ */
+/* $NetBSD: token_comment.c,v 1.5 2021/10/19 20:41:42 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -508,102 +508,6 @@ function(void)
 }
 #indent end
 
-#indent input
-void
-function(void)
-{
-	code();
-}
-
-/*INDENT OFF*/
-#indent end
-
-#indent run
-void
-function(void)
-{
-	code();
-}
-/* $ FIXME: Missing empty line. */
-/*INDENT OFF*/
-#indent end
-
-/*
- * The special comments 'INDENT OFF' and 'INDENT ON' toggle whether the code
- * is formatted or kept as is.
- */
-#indent input
-/*INDENT OFF*/
-/* No formatting takes place here. */
-int format( void ) {{{
-/*INDENT ON*/
-}}}
-
-/* INDENT OFF */
-void indent_off ( void ) ;
-/*  INDENT */
-void indent_on ( void ) ;
-/* INDENT OFF */
-void indent_off ( void ) ;
-	/* INDENT ON */
-void indent_on ( void ) ;	/* the comment may be indented */
-/* INDENT		OFF	*/
-void indent_off ( void ) ;
-/* INDENTATION ON */
-void indent_still_off ( void ) ;	/* due to the word 'INDENTATION' */
-/* INDENT ON * */
-void indent_still_off ( void ) ;	/* due to the extra '*' at the end */
-/* INDENT ON */
-void indent_on ( void ) ;
-/* INDENT

CVS commit: src/tests/usr.bin/indent

2021-10-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Oct 19 20:41:42 UTC 2021

Modified Files:
src/tests/usr.bin/indent: indent_off_on.c token_comment.c

Log Message:
tests/indent: move tests for indent comments

The special INDENT ON and INDENT OFF comments look like ordinary
comments but are handled in inbuf_read_line. Implementing this feature
in the input function has several unintended side effects regarding
indentation of these comments, as demonstrated by the tests.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/indent_off_on.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/token_comment.c

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



CVS commit: src

2021-10-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Oct 19 20:20:25 UTC 2021

Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/usr.bin/indent: Makefile
Added Files:
src/tests/usr.bin/indent: indent_off_on.c

Log Message:
tests/indent: add test for INDENT OFF/ON comments

Just to prevent unintended side effects when fixing bugs in this area.


To generate a diff of this commit:
cvs rdiff -u -r1.1147 -r1.1148 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.23 -r1.24 src/tests/usr.bin/indent/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/indent/indent_off_on.c

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



CVS commit: src

2021-10-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Oct 19 20:20:25 UTC 2021

Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/usr.bin/indent: Makefile
Added Files:
src/tests/usr.bin/indent: indent_off_on.c

Log Message:
tests/indent: add test for INDENT OFF/ON comments

Just to prevent unintended side effects when fixing bugs in this area.


To generate a diff of this commit:
cvs rdiff -u -r1.1147 -r1.1148 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.23 -r1.24 src/tests/usr.bin/indent/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/indent/indent_off_on.c

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1147 src/distrib/sets/lists/tests/mi:1.1148
--- src/distrib/sets/lists/tests/mi:1.1147	Mon Oct 18 23:01:10 2021
+++ src/distrib/sets/lists/tests/mi	Tue Oct 19 20:20:24 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1147 2021/10/18 23:01:10 rillig Exp $
+# $NetBSD: mi,v 1.1148 2021/10/19 20:20:24 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4752,6 +4752,7 @@
 ./usr/tests/usr.bin/indent/f_decls.0.stdouttests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/float.0	tests-obsolete		obsolete,atf
 ./usr/tests/usr.bin/indent/float.0.stdouttests-obsolete		obsolete,atf
+./usr/tests/usr.bin/indent/indent_off_on.ctests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/indent_variables.0tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/indent_variables.0.pro			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/indent_variables.0.stdout			tests-usr.bin-tests	compattestfile,atf

Index: src/tests/usr.bin/indent/Makefile
diff -u src/tests/usr.bin/indent/Makefile:1.23 src/tests/usr.bin/indent/Makefile:1.24
--- src/tests/usr.bin/indent/Makefile:1.23	Tue Oct 19 19:59:05 2021
+++ src/tests/usr.bin/indent/Makefile	Tue Oct 19 20:20:24 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.23 2021/10/19 19:59:05 rillig Exp $
+#	$NetBSD: Makefile,v 1.24 2021/10/19 20:20:24 rillig Exp $
 
 .include 
 
@@ -19,6 +19,7 @@ FILES+=		elsecomment.0.stdout
 FILES+=		elsecomment.0.pro
 FILES+=		f_decls.0
 FILES+=		f_decls.0.stdout
+FILES+=		indent_off_on.c
 FILES+=		indent_variables.0
 FILES+=		indent_variables.0.pro
 FILES+=		indent_variables.0.stdout

Added files:

Index: src/tests/usr.bin/indent/indent_off_on.c
diff -u /dev/null src/tests/usr.bin/indent/indent_off_on.c:1.1
--- /dev/null	Tue Oct 19 20:20:25 2021
+++ src/tests/usr.bin/indent/indent_off_on.c	Tue Oct 19 20:20:25 2021
@@ -0,0 +1,118 @@
+/* $NetBSD: indent_off_on.c,v 1.1 2021/10/19 20:20:25 rillig Exp $ */
+/* $FreeBSD$ */
+
+/*
+ * Tests for the comments 'INDENT OFF' and 'INDENT ON', which temporarily
+ * disable formatting.
+ */
+
+#indent input
+{}
+
+/*INDENT OFF*/
+/*INDENT ON*/
+
+{}
+#indent end
+
+/*
+ * XXX: It is asymmetric that 'INDENT OFF' is kept as is, while 'INDENT ON'
+ * gets enclosed with spaces.
+ */
+#indent run
+{
+}
+/* $ FIXME: This empty line must stay. */
+/*INDENT OFF*/
+/* INDENT ON */
+
+{
+}
+#indent end
+
+
+#indent input
+{}
+ /* INDENT OFF */
+ /* INDENT ON */
+{}
+#indent end
+
+/*
+ * XXX: It is asymmetric that 'INDENT OFF' is indented, while 'INDENT ON'
+ * is aligned.
+ */
+#indent run
+{
+}
+ /* INDENT OFF */
+/* INDENT ON */
+{
+}
+#indent end
+
+
+#indent input
+{}
+	/* INDENT OFF */
+	/* INDENT ON */
+{}
+#indent end
+
+/*
+ * XXX: It is asymmetric that 'INDENT OFF' is indented, while 'INDENT ON'
+ * is aligned.
+ */
+#indent run
+{
+}
+	/* INDENT OFF */
+/* INDENT ON */
+{
+}
+#indent end
+
+/*
+ * The INDENT comments can be written without space between the words, but
+ * nobody does this.
+ */
+#indent input
+int   decl   ;
+/*INDENTOFF*/
+int   decl   ;
+/*INDENTON*/
+int   decl   ;
+#indent end
+
+#indent run -di0
+int decl;
+/*INDENTOFF*/
+int   decl   ;
+/* INDENTON */
+int decl;
+#indent end
+
+
+/*
+ * Any whitespace around the 'INDENT ON/OFF' is ignored, as is any whitespace
+ * between the two words.
+ */
+#indent input
+int decl;
+/*		INDENT		OFF		*/
+int   decl   ;
+/*		INDENT		ON		*/
+int decl;
+#indent end
+
+/*
+ * XXX: It is asymmetric that 'INDENT OFF' is indented, while 'INDENT ON'
+ * is aligned.
+ */
+#indent run -di0
+int decl;
+/*		INDENT		OFF		*/
+int   decl   ;
+/* INDENT		ON		*/
+int decl;
+#indent end



CVS commit: src/sys/netinet

2021-10-19 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Oct 19 20:01:09 UTC 2021

Modified Files:
src/sys/netinet: in_pcb.c

Log Message:
netinet: Allow binding the unspecified address when no addresses exist

You should always be able to bind to the unspecified address even if
no addresses have been configured on any interface.

For example, a DHCP client could be started before the loopback interface
has been fully configured.


To generate a diff of this commit:
cvs rdiff -u -r1.185 -r1.186 src/sys/netinet/in_pcb.c

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



CVS commit: src/sys/netinet

2021-10-19 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Oct 19 20:01:09 UTC 2021

Modified Files:
src/sys/netinet: in_pcb.c

Log Message:
netinet: Allow binding the unspecified address when no addresses exist

You should always be able to bind to the unspecified address even if
no addresses have been configured on any interface.

For example, a DHCP client could be started before the loopback interface
has been fully configured.


To generate a diff of this commit:
cvs rdiff -u -r1.185 -r1.186 src/sys/netinet/in_pcb.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/netinet/in_pcb.c
diff -u src/sys/netinet/in_pcb.c:1.185 src/sys/netinet/in_pcb.c:1.186
--- src/sys/netinet/in_pcb.c:1.185	Tue Sep  8 14:12:57 2020
+++ src/sys/netinet/in_pcb.c	Tue Oct 19 20:01:09 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: in_pcb.c,v 1.185 2020/09/08 14:12:57 christos Exp $	*/
+/*	$NetBSD: in_pcb.c,v 1.186 2021/10/19 20:01:09 roy Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -93,7 +93,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.185 2020/09/08 14:12:57 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.186 2021/10/19 20:01:09 roy Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -436,8 +436,6 @@ in_pcbbind(void *v, struct sockaddr_in *
 	if (inp->inp_af != AF_INET)
 		return (EINVAL);
 
-	if (IN_ADDRLIST_READER_EMPTY())
-		return (EADDRNOTAVAIL);
 	if (inp->inp_lport || !in_nullhost(inp->inp_laddr))
 		return (EINVAL);
 



CVS commit: src/tests/usr.bin/indent

2021-10-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Oct 19 19:59:05 UTC 2021

Modified Files:
src/tests/usr.bin/indent: Makefile

Log Message:
tests/indent: make add-test generate flexible tests

They need fewer source files and are more versatile.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/tests/usr.bin/indent/Makefile

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

Modified files:

Index: src/tests/usr.bin/indent/Makefile
diff -u src/tests/usr.bin/indent/Makefile:1.22 src/tests/usr.bin/indent/Makefile:1.23
--- src/tests/usr.bin/indent/Makefile:1.22	Mon Oct 18 23:01:10 2021
+++ src/tests/usr.bin/indent/Makefile	Tue Oct 19 19:59:05 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.22 2021/10/18 23:01:10 rillig Exp $
+#	$NetBSD: Makefile,v 1.23 2021/10/19 19:59:05 rillig Exp $
 
 .include 
 
@@ -185,11 +185,11 @@ FILES+=		wchar.0.stdout
 
 add-test: .PHONY
 	@set -eu; \
-	test=${NAME:Q}; \
-	[ "$$test" ] || { \
+	test=${NAME:Q}.c; \
+	if [ "$$test" = ".c" ]; then \
 		echo "usage: ${MAKE} add-test NAME="; \
 		exit; \
-	}; \
+	fi; \
 	\
 	if [ -f "$$test" ]; then \
 		echo "error: test $$test already exists." 1>&2; \
@@ -205,25 +205,18 @@ add-test: .PHONY
 		' * TODO: Explain the purpose of the test.' \
 		' */' \
 		'' \
-		'// TODO: Add some code that passes.' \
-	> "$$test"; \
-	printf '%s\n' \
-		'/* $$''NetBSD$$ */' \
-		'/* $$''FreeBSD$$ */' \
+		'#indent input' \
+		'// TODO: add input' \
+		'#indent end' \
 		'' \
-		'/*' \
-		' * TODO: Explain the command line options of the test.' \
-		' */' \
-		'' \
-		'/* TODO: Add some command line options */' \
-	> "$$test.pro"; \
-	cat < "$$test" > "$$test.stdout"; \
-	cvs add "$$test" "$$test.pro" "$$test.stdout"; \
+		'#indent run [-options]' \
+		'// TODO: add expected output' \
+		'#indent end' \
+	> "$$test"; \
+	cvs add "$$test"; \
 	printf '%s\n' \
 		'/^FILES+=/i' \
 		"FILES+=		$$test" \
-		"FILES+=		$$test.pro" \
-		"FILES+=		$$test.stdout" \
 		'.' 'w' 'q' \
 	| ed Makefile; \
 	${MAKE} sync-mi



CVS commit: src/tests/usr.bin/indent

2021-10-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Oct 19 19:59:05 UTC 2021

Modified Files:
src/tests/usr.bin/indent: Makefile

Log Message:
tests/indent: make add-test generate flexible tests

They need fewer source files and are more versatile.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/tests/usr.bin/indent/Makefile

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



CVS commit: src

2021-10-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Oct 19 18:29:59 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_comment.c
src/usr.bin/indent: indent.c io.c

Log Message:
indent: if a file ends with indent off, don't add space-newline


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/token_comment.c
cvs rdiff -u -r1.138 -r1.139 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.94 -r1.95 src/usr.bin/indent/io.c

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

Modified files:

Index: src/tests/usr.bin/indent/token_comment.c
diff -u src/tests/usr.bin/indent/token_comment.c:1.3 src/tests/usr.bin/indent/token_comment.c:1.4
--- src/tests/usr.bin/indent/token_comment.c:1.3	Tue Oct 19 18:18:23 2021
+++ src/tests/usr.bin/indent/token_comment.c	Tue Oct 19 18:29:59 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token_comment.c,v 1.3 2021/10/19 18:18:23 rillig Exp $ */
+/* $NetBSD: token_comment.c,v 1.4 2021/10/19 18:29:59 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -526,8 +526,6 @@ function(void)
 }
 /* $ FIXME: Missing empty line. */
 /*INDENT OFF*/
- 
-/* $ FIXME: The line above has a trailing space. */
 #indent end
 
 /*

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.138 src/usr.bin/indent/indent.c:1.139
--- src/usr.bin/indent/indent.c:1.138	Sun Oct 17 18:13:00 2021
+++ src/usr.bin/indent/indent.c	Tue Oct 19 18:29:59 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.138 2021/10/17 18:13:00 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.139 2021/10/19 18:29:59 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.138 2021/10/17 18:13:00 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.139 2021/10/19 18:29:59 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -274,7 +274,7 @@ static void
 switch_buffer(void)
 {
 ps.search_brace = false;	/* stop looking for start of stmt */
-saved_inp_s = inp.s;		/* save current input buffer */
+saved_inp_s = inp.s;	/* save current input buffer */
 saved_inp_e = inp.e;
 inp.s = save_com;		/* fix so that subsequent calls to lexi will
  * take tokens out of save_com */

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.94 src/usr.bin/indent/io.c:1.95
--- src/usr.bin/indent/io.c:1.94	Mon Oct 11 19:04:47 2021
+++ src/usr.bin/indent/io.c	Tue Oct 19 18:29:59 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.94 2021/10/11 19:04:47 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.95 2021/10/19 18:29:59 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.94 2021/10/11 19:04:47 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.95 2021/10/19 18:29:59 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -427,8 +427,10 @@ inbuf_read_line(void)
 	}
 
 	if ((ch = getc(f)) == EOF) {
-	*p++ = ' ';
-	*p++ = '\n';
+	if (!inhibit_formatting) {
+		*p++ = ' ';
+		*p++ = '\n';
+	}
 	had_eof = true;
 	break;
 	}
@@ -450,10 +452,8 @@ inbuf_read_line(void)
 }
 
 if (inhibit_formatting) {
-	p = inp.buf;
-	do {
+	for (p = inp.s; p < inp.e; p++)
 	output_char(*p);
-	} while (*p++ != '\n');
 }
 }
 



CVS commit: src

2021-10-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Oct 19 18:29:59 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_comment.c
src/usr.bin/indent: indent.c io.c

Log Message:
indent: if a file ends with indent off, don't add space-newline


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/token_comment.c
cvs rdiff -u -r1.138 -r1.139 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.94 -r1.95 src/usr.bin/indent/io.c

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



CVS commit: src/tests/usr.bin/indent

2021-10-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Oct 19 18:18:23 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_comment.c

Log Message:
tests/indent: remove main code from test for token_comment

I had indented to use that code for completing the list of missing tests
but somehow forgot to remove it.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/token_comment.c

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



CVS commit: src/tests/usr.bin/indent

2021-10-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Oct 19 18:18:23 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_comment.c

Log Message:
tests/indent: remove main code from test for token_comment

I had indented to use that code for completing the list of missing tests
but somehow forgot to remove it.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/token_comment.c

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

Modified files:

Index: src/tests/usr.bin/indent/token_comment.c
diff -u src/tests/usr.bin/indent/token_comment.c:1.2 src/tests/usr.bin/indent/token_comment.c:1.3
--- src/tests/usr.bin/indent/token_comment.c:1.2	Mon Oct 18 22:30:34 2021
+++ src/tests/usr.bin/indent/token_comment.c	Tue Oct 19 18:18:23 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token_comment.c,v 1.2 2021/10/18 22:30:34 rillig Exp $ */
+/* $NetBSD: token_comment.c,v 1.3 2021/10/19 18:18:23 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -12,9 +12,9 @@
 /*-
  * TODO: systematically test comments
  *
- * - starting in column 1, with opt.format_col1_comments
- * - starting in column 1, without opt.format_col1_comments
- * - starting in column 9, independent of opt.format_col1_comments
+ * - starting in column 1, with opt.format_col1_comments (-fc1)
+ * - starting in column 1, without opt.format_col1_comments (-fc1)
+ * - starting in column 9, independent of opt.format_col1_comments (-fc1)
  * - starting in column 33, the default
  * - starting in column 65, which is already close to the default right margin
  * - starting in column 81, spilling into the right margin
@@ -30,352 +30,27 @@
  * - block/end-of-line comment to the right of code
  * - block/end-of-line comment to the right of label with code
  *
- * - with/without opt.comment_delimiter_on_blankline
- * - with/without opt.star_comment_cont
- * - with/without opt.format_block_comments
+ * - with/without opt.comment_delimiter_on_blankline (-cdb)
+ * - with/without opt.star_comment_cont (-sc)
+ * - with/without opt.format_block_comments (-fbc)
  * - with varying opt.max_line_length (32, 64, 80, 140)
- * - with varying opt.unindent_displace (0, 2, -5)
+ * - with varying opt.unindent_displace (-d0, -d2, -d-5)
  * - with varying opt.indent_size (3, 4, 8)
  * - with varying opt.tabsize (3, 4, 8, 16)
- * - with varying opt.block_comment_max_line_length (60, 78, 90)
- * - with varying opt.decl_comment_column (0, 1, 33, 80)
+ * - with varying opt.block_comment_max_line_length (-lc60, -lc78, -lc90)
+ * - with varying opt.comment_column (-c0, -c1, -c33, -c80)
+ * - with varying opt.decl_comment_column (-cd0, -cd1, -cd20, -cd33, -cd80)
  * - with/without ps.decl_on_line
  * - with/without ps.last_nl
- */
-
-#include 
-#include 
-#include 
-
-#include "indent.h"
-
-static void
-com_add_char(char ch)
-{
-if (com.e + 1 >= com.l)
-	buf_expand(&com, 1);
-*com.e++ = ch;
-}
-
-static void
-com_add_delim(void)
-{
-if (!opt.star_comment_cont)
-	return;
-size_t len = 3;
-if (com.e + len >= com.l)
-	buf_expand(&com, len);
-memcpy(com.e, " * ", len);
-com.e += len;
-}
-
-static void
-com_terminate(void)
-{
-if (com.e + 1 >= com.l)
-	buf_expand(&com, 1);
-*com.e = '\0';
-}
-
-static bool
-fits_in_one_line(int max_line_length)
-{
-for (const char *p = inp.s; *p != '\n'; p++) {
-	assert(*p != '\0');
-	assert(inp.e - p >= 2);
-	if (!(p[0] == '*' && p[1] == '/'))
-	continue;
-
-	int len = indentation_after_range(ps.com_ind + 3, inp.s, p);
-	len += is_hspace(p[-1]) ? 2 : 3;
-	if (len <= max_line_length)
-	return true;
-}
-return false;
-}
-
-/*
- * Scan, reformat and output a single comment, which is either a block comment
- * starting with '/' '*' or an end-of-line comment starting with '//'.
  *
- * Try to keep comments from going over the maximum line length.  If a line is
- * too long, move everything starting from the last blank to the next comment
- * line.  Blanks and tabs from the beginning of the input line are removed.
- *
- * ALGORITHM:
- *	1) Decide where the comment should be aligned, and if lines should
- *	   be broken.
- *	2) If lines should not be broken and filled, just copy up to end of
- *	   comment.
- *	3) If lines should be filled, then scan through the input buffer,
- *	   copying characters to com_buf.  Remember where the last blank,
- *	   tab, or newline was.  When line is filled, print up to last blank
- *	   and continue copying.
+ * - very long comments that overflow the buffer 'com'
+ * - comments that come from save_com
+ * - very long word that already spills over the right margin
+ * - wrap/nowrap comment containing '\n'
+ * - wrap/nowrap comment containing '\f'
+ * - wrap/nowrap comment containing '\t'
+ * - wrap/nowrap comment containing '\b'
  */
-void
-process_comment(void)
-{
-int adj_max_line_length;	/* Adjusted max_line_length for comments that
- * spill over the right margin */
-ssiz

CVS commit: src/usr.bin/make/unit-tests

2021-10-19 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Tue Oct 19 15:59:26 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: Makefile varname-empty.exp

Log Message:
Replace ${.OBJDIR} with  for consistent results.

If we replace ${.OBJDIR} with  some tests produce
different results depending on the value of .OBJDIR

For similar reasons eliminate .OBJDIR and .PATH from output of
varname-empty

Reviewed by: rillig


To generate a diff of this commit:
cvs rdiff -u -r1.283 -r1.284 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/varname-empty.exp

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

Modified files:

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.283 src/usr.bin/make/unit-tests/Makefile:1.284
--- src/usr.bin/make/unit-tests/Makefile:1.283	Mon Aug 30 17:08:13 2021
+++ src/usr.bin/make/unit-tests/Makefile	Tue Oct 19 15:59:26 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.283 2021/08/30 17:08:13 rillig Exp $
+# $NetBSD: Makefile,v 1.284 2021/10/19 15:59:26 sjg Exp $
 #
 # Unit tests for make(1)
 #
@@ -530,9 +530,7 @@ SED_CMDS.varname-dot-parsefile=	-e '/in 
 SED_CMDS.varname-dot-shell=	-e 's, = /[^ ]*, = (details omitted),g'
 SED_CMDS.varname-dot-shell+=	-e 's,"/[^" ]*","(details omitted)",g'
 SED_CMDS.varname-dot-shell+=	-e 's,\[/[^] ]*\],[(details omitted)],g'
-SED_CMDS.varname-empty=		-e 's,${.CURDIR},,g'
-SED_CMDS.varname-empty+=	-e '/\.PARSEDIR/d'
-SED_CMDS.varname-empty+=	-e '/\.SHELL/d'
+SED_CMDS.varname-empty=		${.OBJDIR .PARSEDIR .PATH .SHELL:L:@v@-e '/\\$v/d'@}
 
 # Some tests need an additional round of postprocessing.
 POSTPROC.deptgt-suffixes=	awk '/^\#\*\*\* Suffixes/,/^never-stop/'
@@ -689,8 +687,14 @@ _SED_CMDS+=	-e 's,^usage: ${TEST_MAKE:T:
 # replace anything after 'stopped in' with unit-tests
 _SED_CMDS+=	-e '/stopped/s, /.*, unit-tests,'
 _SED_CMDS+=	-e 's,${TMPDIR},TMPDIR,g'
-# strip ${.CURDIR}/ from the output
-_SED_CMDS+=	-e 's,${.CURDIR:S,.,\\.,g}/,,g'
+# canonicalize ${.OBJDIR} and ${.CURDIR}
+.if ${.OBJDIR} != ${.CURDIR}
+# yes this is inaccurate but none of the tests expect  anywhere
+# which we get depending on how MAKEOBJDIR is set.
+_SED_CMDS+=	-e 's,${.OBJDIR},,g'
+.endif
+_SED_CMDS+=	-e 's,${.CURDIR},,g'
+_SED_CMDS+=	-e 's,/,,g'
 _SED_CMDS+=	-e 's,${UNIT_TESTS:S,.,\\.,g}/,,g'
 
 .rawout.out:

Index: src/usr.bin/make/unit-tests/varname-empty.exp
diff -u src/usr.bin/make/unit-tests/varname-empty.exp:1.16 src/usr.bin/make/unit-tests/varname-empty.exp:1.17
--- src/usr.bin/make/unit-tests/varname-empty.exp:1.16	Wed Apr 14 17:20:48 2021
+++ src/usr.bin/make/unit-tests/varname-empty.exp	Tue Oct 19 15:59:26 2021
@@ -2,10 +2,6 @@ Var_SetExpand: variable name "${:U}" exp
 Var_SetExpand: variable name "" expands to empty string, with value "cmdline-plain" - ignored
 Global: .CURDIR = 
 Var_Parse: ${MAKE_OBJDIR_CHECK_WRITABLE} (eval)
-Global: .OBJDIR = 
-Global:delete .PATH (not found)
-Global: .PATH = .
-Global: .PATH = . 
 Global: .TARGETS = 
 Internal: MAKEFILE = varname-empty.mk
 Global: .MAKE.MAKEFILES = varname-empty.mk



CVS commit: src/usr.bin/make/unit-tests

2021-10-19 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Tue Oct 19 15:59:26 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: Makefile varname-empty.exp

Log Message:
Replace ${.OBJDIR} with  for consistent results.

If we replace ${.OBJDIR} with  some tests produce
different results depending on the value of .OBJDIR

For similar reasons eliminate .OBJDIR and .PATH from output of
varname-empty

Reviewed by: rillig


To generate a diff of this commit:
cvs rdiff -u -r1.283 -r1.284 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/varname-empty.exp

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



CVS commit: [netbsd-9] src/doc

2021-10-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct 19 10:56:08 UTC 2021

Modified Files:
src/doc [netbsd-9]: CHANGES-9.3

Log Message:
Ticket #1361


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.38 -r1.1.2.39 src/doc/CHANGES-9.3

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-9.3
diff -u src/doc/CHANGES-9.3:1.1.2.38 src/doc/CHANGES-9.3:1.1.2.39
--- src/doc/CHANGES-9.3:1.1.2.38	Fri Oct 15 15:15:52 2021
+++ src/doc/CHANGES-9.3	Tue Oct 19 10:56:08 2021
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.3,v 1.1.2.38 2021/10/15 15:15:52 martin Exp $
+# $NetBSD: CHANGES-9.3,v 1.1.2.39 2021/10/19 10:56:08 martin Exp $
 
 A complete list of changes from the NetBSD 9.2 release to the NetBSD 9.3
 release:
@@ -822,3 +822,9 @@ distrib/amd64/installimage-bios/spec.ins
 	Restore having a BIOS-only amd64 USB image.
 	[maya, ticket #1360]
 
+sys/dev/raidframe/rf_diskqueue.c		1.58-1.59
+sys/dev/raidframe/rf_netbsd.h			1.36 (patch)
+
+	RAIDframe could run out of IO buffers.
+	[oster, ticket #1361]
+



CVS commit: [netbsd-9] src/doc

2021-10-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct 19 10:56:08 UTC 2021

Modified Files:
src/doc [netbsd-9]: CHANGES-9.3

Log Message:
Ticket #1361


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.38 -r1.1.2.39 src/doc/CHANGES-9.3

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



CVS commit: [netbsd-9] src/sys/dev/raidframe

2021-10-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct 19 10:55:15 UTC 2021

Modified Files:
src/sys/dev/raidframe [netbsd-9]: rf_diskqueue.c rf_netbsd.h

Log Message:
Pull up following revision(s) (requested by oster in ticket #1361):

sys/dev/raidframe/rf_netbsd.h: revision 1.36 (via patch)
sys/dev/raidframe/rf_diskqueue.c: revision 1.58
sys/dev/raidframe/rf_diskqueue.c: revision 1.59

remove unnnecessary splbio() in rf_FreeDiskQueueData()

getiobuf() can return NULL if there are no IO buffers available.
RAIDframe can't deal with that, so create a dedicated pool of buffers
to use for IO.  PR_WAITOK is fine here, as we pre-allocate more than
we need to guarantee IO can make progress.  Tuning of pool still to
come.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.55.4.1 src/sys/dev/raidframe/rf_diskqueue.c
cvs rdiff -u -r1.33 -r1.33.4.1 src/sys/dev/raidframe/rf_netbsd.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/dev/raidframe/rf_diskqueue.c
diff -u src/sys/dev/raidframe/rf_diskqueue.c:1.55 src/sys/dev/raidframe/rf_diskqueue.c:1.55.4.1
--- src/sys/dev/raidframe/rf_diskqueue.c:1.55	Sun Feb 10 17:13:33 2019
+++ src/sys/dev/raidframe/rf_diskqueue.c	Tue Oct 19 10:55:15 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_diskqueue.c,v 1.55 2019/02/10 17:13:33 christos Exp $	*/
+/*	$NetBSD: rf_diskqueue.c,v 1.55.4.1 2021/10/19 10:55:15 martin Exp $	*/
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -66,7 +66,7 @@
  /
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rf_diskqueue.c,v 1.55 2019/02/10 17:13:33 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_diskqueue.c,v 1.55.4.1 2021/10/19 10:55:15 martin Exp $");
 
 #include 
 
@@ -84,6 +84,8 @@ __KERNEL_RCSID(0, "$NetBSD: rf_diskqueue
 #include "rf_fifo.h"
 #include "rf_kintf.h"
 
+#include 
+
 static void rf_ShutdownDiskQueueSystem(void *);
 
 #ifndef RF_DEBUG_DISKQUEUE
@@ -147,10 +149,15 @@ static const RF_DiskQueueSW_t diskqueues
 };
 #define NUM_DISK_QUEUE_TYPES (sizeof(diskqueuesw)/sizeof(RF_DiskQueueSW_t))
 
+
 #define RF_MAX_FREE_DQD 256
 #define RF_MIN_FREE_DQD  64
 
-#include 
+/* XXX: scale these... */
+#define RF_MAX_FREE_BUFIO 256
+#define RF_MIN_FREE_BUFIO  64
+
+
 
 /* configures a single disk queue */
 
@@ -189,6 +196,7 @@ static void
 rf_ShutdownDiskQueueSystem(void *ignored)
 {
 	pool_destroy(&rf_pools.dqd);
+	pool_destroy(&rf_pools.bufio);
 }
 
 int
@@ -197,6 +205,8 @@ rf_ConfigureDiskQueueSystem(RF_ShutdownL
 
 	rf_pool_init(&rf_pools.dqd, sizeof(RF_DiskQueueData_t),
 		 "rf_dqd_pl", RF_MIN_FREE_DQD, RF_MAX_FREE_DQD);
+	rf_pool_init(&rf_pools.bufio, sizeof(buf_t),
+		 "rf_bufio_pl", RF_MIN_FREE_BUFIO, RF_MAX_FREE_BUFIO);
 	rf_ShutdownCreate(listp, rf_ShutdownDiskQueueSystem, NULL);
 
 	return (0);
@@ -367,19 +377,20 @@ rf_CreateDiskQueueData(RF_IoType_t typ, 
 {
 	RF_DiskQueueData_t *p;
 
-	p = pool_get(&rf_pools.dqd, waitflag | PR_ZERO);
-	if (p == NULL)
-		return (NULL);
+	p = pool_get(&rf_pools.dqd, PR_WAITOK | PR_ZERO);
+	KASSERT(p != NULL);
 
-	if (waitflag == PR_WAITOK) {
-		p->bp = getiobuf(NULL, true);
-	} else {
-		p->bp = getiobuf(NULL, false);
-	}
-	if (p->bp == NULL) {
-		pool_put(&rf_pools.dqd, p);
-		return (NULL);
-	}
+	/* Obtain a buffer from our own pool.  It is possible for the
+	   regular getiobuf() to run out of memory and return NULL.
+	   We need to guarantee that never happens, as RAIDframe
+	   doesn't have a good way to recover if memory allocation
+	   fails here.
+	*/
+	p->bp = pool_get(&rf_pools.bufio, PR_WAITOK | PR_ZERO);
+	KASSERT(p->bp != NULL);
+	
+	buf_init(p->bp);
+		
 	SET(p->bp->b_cflags, BC_BUSY);	/* mark buffer busy */
 
 	p->sectorOffset = ssect + rf_protectedSectors;
@@ -402,9 +413,6 @@ rf_CreateDiskQueueData(RF_IoType_t typ, 
 void
 rf_FreeDiskQueueData(RF_DiskQueueData_t *p)
 {
-	int s;
-	s = splbio();		/* XXX protect only pool_put, or neither? */
-	putiobuf(p->bp);
+	pool_put(&rf_pools.bufio, p->bp);
 	pool_put(&rf_pools.dqd, p);
-	splx(s);
 }

Index: src/sys/dev/raidframe/rf_netbsd.h
diff -u src/sys/dev/raidframe/rf_netbsd.h:1.33 src/sys/dev/raidframe/rf_netbsd.h:1.33.4.1
--- src/sys/dev/raidframe/rf_netbsd.h:1.33	Wed Feb  6 02:49:09 2019
+++ src/sys/dev/raidframe/rf_netbsd.h	Tue Oct 19 10:55:15 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_netbsd.h,v 1.33 2019/02/06 02:49:09 oster Exp $	*/
+/*	$NetBSD: rf_netbsd.h,v 1.33.4.1 2021/10/19 10:55:15 martin Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -61,6 +61,7 @@ struct RF_Pools_s {
 	struct pool asm_hdr; /* Access Stripe Map Header */
 	struct pool asmap;   /* Access Stripe Map */
 	struct pool asmhle;  /* Access Stripe Map Header List Elements */
+	struct pool bufio;   /* Buffer IO Pool */
 	struct pool callback;/* Callback descriptors */
 	struct poo

CVS commit: [netbsd-9] src/sys/dev/raidframe

2021-10-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct 19 10:55:15 UTC 2021

Modified Files:
src/sys/dev/raidframe [netbsd-9]: rf_diskqueue.c rf_netbsd.h

Log Message:
Pull up following revision(s) (requested by oster in ticket #1361):

sys/dev/raidframe/rf_netbsd.h: revision 1.36 (via patch)
sys/dev/raidframe/rf_diskqueue.c: revision 1.58
sys/dev/raidframe/rf_diskqueue.c: revision 1.59

remove unnnecessary splbio() in rf_FreeDiskQueueData()

getiobuf() can return NULL if there are no IO buffers available.
RAIDframe can't deal with that, so create a dedicated pool of buffers
to use for IO.  PR_WAITOK is fine here, as we pre-allocate more than
we need to guarantee IO can make progress.  Tuning of pool still to
come.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.55.4.1 src/sys/dev/raidframe/rf_diskqueue.c
cvs rdiff -u -r1.33 -r1.33.4.1 src/sys/dev/raidframe/rf_netbsd.h

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



CVS commit: src/sys/net/lagg

2021-10-19 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Tue Oct 19 08:02:42 UTC 2021

Modified Files:
src/sys/net/lagg: if_lagg.c

Log Message:
lagg: reject a vlan interface that is not configured

The vlan I/F has no MAC address used in LACP.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/net/lagg/if_lagg.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/net/lagg/if_lagg.c
diff -u src/sys/net/lagg/if_lagg.c:1.15 src/sys/net/lagg/if_lagg.c:1.16
--- src/sys/net/lagg/if_lagg.c:1.15	Tue Oct 19 07:52:33 2021
+++ src/sys/net/lagg/if_lagg.c	Tue Oct 19 08:02:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.15 2021/10/19 07:52:33 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.16 2021/10/19 08:02:42 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.15 2021/10/19 07:52:33 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.16 2021/10/19 08:02:42 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2271,7 +2271,6 @@ lagg_port_setup(struct lagg_softc *sc,
 
 	switch (ifp_port->if_type) {
 	case IFT_ETHER:
-	case IFT_L2VLAN:
 	case IFT_L2TP:
 		if_type = IFT_IEEE8023ADLAG;
 		break;



CVS commit: src/sys/net/lagg

2021-10-19 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Tue Oct 19 08:02:42 UTC 2021

Modified Files:
src/sys/net/lagg: if_lagg.c

Log Message:
lagg: reject a vlan interface that is not configured

The vlan I/F has no MAC address used in LACP.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/net/lagg/if_lagg.c

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



CVS commit: src/tests/net/if_lagg

2021-10-19 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Tue Oct 19 07:57:15 UTC 2021

Modified Files:
src/tests/net/if_lagg: t_lagg.sh

Log Message:
added test cases for lagg(4) on l2tp(4)


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/net/if_lagg/t_lagg.sh

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



CVS commit: src/tests/net/if_lagg

2021-10-19 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Tue Oct 19 07:57:15 UTC 2021

Modified Files:
src/tests/net/if_lagg: t_lagg.sh

Log Message:
added test cases for lagg(4) on l2tp(4)


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/net/if_lagg/t_lagg.sh

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

Modified files:

Index: src/tests/net/if_lagg/t_lagg.sh
diff -u src/tests/net/if_lagg/t_lagg.sh:1.2 src/tests/net/if_lagg/t_lagg.sh:1.3
--- src/tests/net/if_lagg/t_lagg.sh:1.2	Tue May 25 00:38:30 2021
+++ src/tests/net/if_lagg/t_lagg.sh	Tue Oct 19 07:57:15 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: t_lagg.sh,v 1.2 2021/05/25 00:38:30 yamaguchi Exp $
+#	$NetBSD: t_lagg.sh,v 1.3 2021/10/19 07:57:15 yamaguchi Exp $
 #
 # Copyright (c) 2021 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -85,6 +85,59 @@ expected_inactive()
 	rump.ifconfig ${if_lagg}
 }
 
+setup_l2tp_ipv4tunnel()
+{
+	local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
+
+	local a_addr0=10.0.0.1
+	local a_addr1=10.0.0.2
+	local b_addr0=10.0.1.1
+	local b_addr1=10.0.1.2
+	local c_addr0=10.0.2.1
+	local c_addr1=10.0.2.2
+
+	local a_session0=1001
+	local a_session1=1002
+	local b_session0=1011
+	local b_session1=1012
+	local c_session0=1021
+	local c_session1=1022
+
+	rump_server_add_iface $SOCK_HOST0 l2tp0
+	rump_server_add_iface $SOCK_HOST0 l2tp1
+	rump_server_add_iface $SOCK_HOST0 l2tp2
+	rump_server_add_iface $SOCK_HOST1 l2tp0
+	rump_server_add_iface $SOCK_HOST1 l2tp1
+	rump_server_add_iface $SOCK_HOST1 l2tp2
+
+
+	export RUMP_SERVER=$SOCK_HOST0
+	$atf_ifconfig shmif0 $a_addr0/24
+	$atf_ifconfig l2tp0  tunnel  $a_addr0$a_addr1
+	$atf_ifconfig l2tp0  session $a_session0 $a_session1
+
+	$atf_ifconfig shmif1 $b_addr0/24
+	$atf_ifconfig l2tp1  tunnel  $b_addr0$b_addr1
+	$atf_ifconfig l2tp1  session $b_session0 $b_session1
+
+	$atf_ifconfig shmif2 $c_addr0/24
+	$atf_ifconfig l2tp2  tunnel  $c_addr0$c_addr1
+	$atf_ifconfig l2tp2  session $c_session0 $c_session1
+
+	export RUMP_SERVER=$SOCK_HOST1
+	$atf_ifconfig shmif0 $a_addr1/24
+	$atf_ifconfig l2tp0  tunnel  $a_addr1$a_addr0
+	$atf_ifconfig l2tp0  session $a_session1 $a_session0
+
+	$atf_ifconfig shmif1 $b_addr1/24
+	$atf_ifconfig l2tp1  tunnel  $b_addr1$b_addr0
+	$atf_ifconfig l2tp1  session $b_session1 $b_session0
+
+	$atf_ifconfig shmif2 $c_addr1/24
+	$atf_ifconfig l2tp2  tunnel  $c_addr1$c_addr0
+	$atf_ifconfig l2tp2  session $c_session1 $c_session0
+}
+
 atf_test_case lagg_ifconfig cleanup
 lagg_ifconfig_head()
 {
@@ -403,6 +456,7 @@ lagg_lacp_ping()
 	local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
 
 	local af=$1
+	local l2proto=$2
 	local atf_ping="atf_check -s exit:0 -o ignore rump.ping -c 1"
 	local ping=rump.ping
 	local rumplib=""
@@ -423,6 +477,20 @@ lagg_lacp_ping()
 		;;
 	esac
 
+	case $l2proto in
+	"ether")
+		iface0=shmif0
+		iface1=shmif1
+		iface2=shmif2
+		;;
+	"l2tp")
+		rumplib="$rumplib l2tp"
+		iface0=l2tp0
+		iface1=l2tp1
+		iface2=l2tp2
+		;;
+	esac
+
 	rump_server_start $SOCK_HOST0 lagg $rumplib
 	rump_server_start $SOCK_HOST1 lagg $rumplib
 
@@ -434,18 +502,22 @@ lagg_lacp_ping()
 	rump_server_add_iface $SOCK_HOST1 shmif1 $BUS1
 	rump_server_add_iface $SOCK_HOST1 shmif2 $BUS2
 
+	if [ x"$l2proto" = x"l2tp" ];then
+		setup_l2tp_ipv4tunnel
+	fi
+
 	export RUMP_SERVER=$SOCK_HOST0
 	$atf_ifconfig lagg0 create
-	$atf_ifconfig lagg0 laggproto lacp laggport shmif0
+	$atf_ifconfig lagg0 laggproto lacp laggport $iface0
 	$atf_ifconfig lagg0 $af $addr_host0/$pfx
-	$atf_ifconfig shmif0 up
+	$atf_ifconfig $iface0 up
 	$atf_ifconfig lagg0 up
 
 	export RUMP_SERVER=$SOCK_HOST1
 	$atf_ifconfig lagg0 create
-	$atf_ifconfig lagg0 laggproto lacp laggport shmif0
+	$atf_ifconfig lagg0 laggproto lacp laggport $iface0
 	$atf_ifconfig lagg0 $af $addr_host1/$pfx
-	$atf_ifconfig shmif0 up
+	$atf_ifconfig $iface0 up
 	$atf_ifconfig lagg0 up
 
 	export RUMP_SERVER=$SOCK_HOST0
@@ -459,22 +531,22 @@ lagg_lacp_ping()
 	$atf_ping $addr_host0
 
 	export RUMP_SERVER=$SOCK_HOST0
-	$atf_ifconfig shmif1 up
-	$atf_ifconfig lagg0 laggport shmif1 laggport shmif2
-	$atf_ifconfig shmif2 up
+	$atf_ifconfig $iface1 up
+	$atf_ifconfig lagg0 laggport $iface1 laggport $iface2
+	$atf_ifconfig $iface2 up
 
 	export RUMP_SERVER=$SOCK_HOST1
-	$atf_ifconfig shmif1 up
-	$atf_ifconfig lagg0 laggport shmif1 laggport shmif2
-	$atf_ifconfig shmif2 up
+	$atf_ifconfig $iface1 up
+	$atf_ifconfig lagg0 laggport $iface1 laggport $iface2
+	$atf_ifconfig $iface2 up
 
 	export RUMP_SERVER=$SOCK_HOST0
-	wait_for_distributing lagg0 shmif1
-	wait_for_distributing lagg0 shmif2
+	wait_for_distributing lagg0 $iface1
+	wait_for_distributing lagg0 $iface2
 
 	export RUMP_SERVER=$SOCK_HOST1
-	wait_for_distributing lagg0 shmif1
-	wait_for_distributing lagg0 shmif2
+	wait_for_distributing lagg0 $iface1
+	wait_for_distributing lagg0 $iface2
 
 	$atf_ping $addr_host0
 }
@@ -490,7 +562,7 @@ lagg_lacp_ipv4_

CVS commit: src/sys/net/lagg

2021-10-19 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Tue Oct 19 07:52:33 UTC 2021

Modified Files:
src/sys/net/lagg: if_lagg.c if_lagg_lacp.c if_laggproto.h

Log Message:
lagg: support l2tp(4) aggregation

- Accept "ifconfig lagg* laggport l2tp*"
- Set promiscuous mode when the added interface is l2tp*
- check IFF_UP in addition to IFF_RUNNING on
  SIOCSIFFLAGS to a child interface.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/net/lagg/if_lagg.c
cvs rdiff -u -r1.5 -r1.6 src/sys/net/lagg/if_lagg_lacp.c
cvs rdiff -u -r1.8 -r1.9 src/sys/net/lagg/if_laggproto.h

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



CVS commit: src/sys/net/lagg

2021-10-19 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Tue Oct 19 07:52:33 UTC 2021

Modified Files:
src/sys/net/lagg: if_lagg.c if_lagg_lacp.c if_laggproto.h

Log Message:
lagg: support l2tp(4) aggregation

- Accept "ifconfig lagg* laggport l2tp*"
- Set promiscuous mode when the added interface is l2tp*
- check IFF_UP in addition to IFF_RUNNING on
  SIOCSIFFLAGS to a child interface.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/net/lagg/if_lagg.c
cvs rdiff -u -r1.5 -r1.6 src/sys/net/lagg/if_lagg_lacp.c
cvs rdiff -u -r1.8 -r1.9 src/sys/net/lagg/if_laggproto.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/net/lagg/if_lagg.c
diff -u src/sys/net/lagg/if_lagg.c:1.14 src/sys/net/lagg/if_lagg.c:1.15
--- src/sys/net/lagg/if_lagg.c:1.14	Tue Oct 19 07:40:52 2021
+++ src/sys/net/lagg/if_lagg.c	Tue Oct 19 07:52:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.14 2021/10/19 07:40:52 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.15 2021/10/19 07:52:33 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.14 2021/10/19 07:40:52 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.15 2021/10/19 07:52:33 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1141,6 +1141,7 @@ lagg_input_ethernet(struct ifnet *ifp_po
 	m = lagg_proto_input(lp->lp_softc, lp, m);
 	if (m != NULL) {
 		m_set_rcvif(m, ifp);
+		m->m_flags &= ~M_PROMISC;
 		if_input(ifp, m);
 		m = NULL;
 	}
@@ -2073,25 +2074,81 @@ lagg_port_setsadl(struct lagg_port *lp, 
 	KASSERT(LAGG_LOCKED(lp->lp_softc));
 	KASSERT(IFNET_LOCKED(ifp_port));
 
-	lladdr_changed = false;
-	if (iftype_changed) {
-		lladdr_changed = true;
-	} else if (lagg_lladdr_equal(lladdr,
-	CLLADDR(ifp_port->if_sadl)) == false) {
-		lladdr_changed = true;
-	}
+	switch (lp->lp_iftype) {
+	case IFT_ETHER:
+		lladdr_changed = lagg_lladdr_equal(lladdr,
+		CLLADDR(ifp_port->if_sadl)) ? false : true;
+
+		if (lladdr_changed == false &&
+		iftype_changed == false) {
+			break;
+		}
 
-	if (lladdr_changed) {
 		if_set_sadl(ifp_port, lladdr,
 		ETHER_ADDR_LEN, false);
-		if (ISSET(ifp_port->if_flags, IFF_RUNNING)) {
-			error = ifp_port->if_init(ifp_port);
-			if (error != 0) {
-lagg_log(lp->lp_softc, LOG_WARNING,
-"%s failed to if_init() on %d\n",
-ifp_port->if_xname, error);
-			}
+
+		if (!ISSET(ifp_port->if_flags, IFF_RUNNING)) {
+			break;
+		}
+
+		error = ifp_port->if_init(ifp_port);
+		if (error != 0) {
+			lagg_log(lp->lp_softc, LOG_WARNING,
+			"%s failed to if_init() on %d\n",
+			ifp_port->if_xname, error);
+		}
+		break;
+	default:
+		if_alloc_sadl(ifp_port);
+		if (lp->lp_promisc == false) {
+			ifpromisc_locked(ifp_port, 1);
+			lp->lp_promisc = true;
+		}
+		break;
+	}
+}
+
+static void
+lagg_port_unsetsadl(struct lagg_port *lp)
+{
+	struct ifnet *ifp_port;
+	int error;
+
+	ifp_port = lp->lp_ifp;
+
+	KASSERT(LAGG_LOCKED(lp->lp_softc));
+	KASSERT(IFNET_LOCKED(ifp_port));
+
+	switch (lp->lp_iftype) {
+	case IFT_ETHER:
+		/* reset if_type before if_set_sadl */
+		ifp_port->if_type = lp->lp_iftype;
+
+		if_set_sadl(ifp_port, lp->lp_lladdr,
+		ETHER_ADDR_LEN, false);
+
+		if (!ISSET(ifp_port->if_flags, IFF_RUNNING)) {
+			break;
+		}
+
+		error = ifp_port->if_init(ifp_port);
+		if (error != 0) {
+			lagg_log(lp->lp_softc, LOG_WARNING,
+			"%s failed to if_init() on %d\n",
+			ifp_port->if_xname, error);
 		}
+		break;
+
+	default:
+		/* reset if_type before if_alloc_sadl */
+		ifp_port->if_type = lp->lp_iftype;
+		if_alloc_sadl(ifp_port);
+
+		if (lp->lp_promisc == true) {
+			ifpromisc_locked(ifp_port, 0);
+			lp->lp_promisc = false;
+		}
+		break;
 	}
 }
 
@@ -2152,11 +2209,9 @@ lagg_lladdr_update(struct lagg_softc *sc
 	lagg_lladdr_cpy(sc->sc_lladdr, lladdr);
 
 	LAGG_PORTS_FOREACH(sc, lp) {
-		if (lp->lp_iftype == IFT_ETHER) {
-			IFNET_LOCK(lp->lp_ifp);
-			lagg_port_setsadl(lp, sc->sc_lladdr, false);
-			IFNET_UNLOCK(lp->lp_ifp);
-		}
+		IFNET_LOCK(lp->lp_ifp);
+		lagg_port_setsadl(lp, sc->sc_lladdr, false);
+		IFNET_UNLOCK(lp->lp_ifp);
 	}
 }
 
@@ -2217,6 +2272,7 @@ lagg_port_setup(struct lagg_softc *sc,
 	switch (ifp_port->if_type) {
 	case IFT_ETHER:
 	case IFT_L2VLAN:
+	case IFT_L2TP:
 		if_type = IFT_IEEE8023ADLAG;
 		break;
 	default:
@@ -2253,7 +2309,8 @@ lagg_port_setup(struct lagg_softc *sc,
 
 	iftype_changed = (lp->lp_iftype != ifp_port->if_type);
 
-	if (ISSET(ifp_port->if_flags, IFF_RUNNING)) {
+	if (ISSET(ifp_port->if_flags, IFF_RUNNING) &&
+	ifp_port->if_init != NULL) {
 		ifp_port->if_stop(ifp_port, 0);
 		stopped = true;
 	}
@@ -2268,8 +2325,8 @@ lagg_port_setup(struct lagg_softc *sc,
 
 	if (lp->lp_iftype == IFT_ETHER) {
 		lagg_setup_lladdr(sc, lp);
-		lagg_port_setsadl(lp, sc->sc_lladdr, iftype_changed);
 	}
+	lagg_port_setsadl(lp, sc->sc_lladdr, iftype

CVS commit: src/sys/net/lagg

2021-10-19 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Tue Oct 19 07:40:53 UTC 2021

Modified Files:
src/sys/net/lagg: if_lagg.c

Log Message:
lagg: clear I/G bitg and set G/L bit in a generated MAC address


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/net/lagg/if_lagg.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/net/lagg/if_lagg.c
diff -u src/sys/net/lagg/if_lagg.c:1.13 src/sys/net/lagg/if_lagg.c:1.14
--- src/sys/net/lagg/if_lagg.c:1.13	Tue Oct 12 08:30:58 2021
+++ src/sys/net/lagg/if_lagg.c	Tue Oct 19 07:40:52 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.13 2021/10/12 08:30:58 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.14 2021/10/19 07:40:52 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.13 2021/10/12 08:30:58 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.14 2021/10/19 07:40:52 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -416,6 +416,8 @@ lagg_clone_create(struct if_clone *ifc, 
 	switch (lagg_iftype) {
 	case LAGG_IF_TYPE_ETHERNET:
 		cprng_fast(sc->sc_lladdr_rand, sizeof(sc->sc_lladdr_rand));
+		sc->sc_lladdr_rand[0] &= 0xFE; /* clear I/G bit */
+		sc->sc_lladdr_rand[0] |= 0x02; /* set G/L bit */
 		lagg_lladdr_cpy(sc->sc_lladdr, sc->sc_lladdr_rand);
 		ether_set_vlan_cb((struct ethercom *)ifp, lagg_vlan_cb);
 		ether_ifattach(ifp, sc->sc_lladdr);



CVS commit: src/sys/net/lagg

2021-10-19 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Tue Oct 19 07:40:53 UTC 2021

Modified Files:
src/sys/net/lagg: if_lagg.c

Log Message:
lagg: clear I/G bitg and set G/L bit in a generated MAC address


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/net/lagg/if_lagg.c

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