CVS commit: src/sbin/ifconfig

2024-04-09 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Tue Apr  9 08:53:08 UTC 2024

Modified Files:
src/sbin/ifconfig: lagg.c

Log Message:
lagg(4): allocate memory for struct lagg_req by calloc(3)
to fix build error on clang


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sbin/ifconfig/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/sbin/ifconfig/lagg.c
diff -u src/sbin/ifconfig/lagg.c:1.7 src/sbin/ifconfig/lagg.c:1.8
--- src/sbin/ifconfig/lagg.c:1.7	Mon Apr  8 00:50:49 2024
+++ src/sbin/ifconfig/lagg.c	Tue Apr  9 08:53:08 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: lagg.c,v 1.7 2024/04/08 00:50:49 yamaguchi Exp $	*/
+/*	$NetBSD: lagg.c,v 1.8 2024/04/09 08:53:08 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2021 Internet Initiative Japan Inc.
@@ -28,7 +28,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: lagg.c,v 1.7 2024/04/08 00:50:49 yamaguchi Exp $");
+__RCSID("$NetBSD: lagg.c,v 1.8 2024/04/09 08:53:08 yamaguchi Exp $");
 #endif /* !defined(lint) */
 
 #include 
@@ -393,15 +393,13 @@ setlaggproto(prop_dictionary_t env, prop
 static int
 setlaggport(prop_dictionary_t env, prop_dictionary_t oenv __unused)
 {
-	struct {
-		struct lagg_req req;
-		struct laggreqport port[1];
-	} _req;
 	struct lagg_req *req;
 	struct laggreqport *rp;
 	const char *ifname;
 	enum lagg_ioctl ioc;
 	int64_t lpcmd, pri;
+	int rv;
+	size_t sz;
 
 	if (!prop_dictionary_get_string(env, "laggport", )) {
 		if (lagg_debug)
@@ -410,11 +408,15 @@ setlaggport(prop_dictionary_t env, prop_
 		return -1;
 	}
 
-	memset(&_req, 0, sizeof(_req));
-	req = (struct lagg_req *)&_req;
-	rp = >lrq_reqports[0];
-	req->lrq_nports = 1;
+	sz = sizeof(*req) + sizeof(req->lrq_reqports[0]) * 1;
+	req = calloc(1, sz);
+	if (req == NULL) {
+		errno = ENOBUFS;
+		return -1;
+	}
 
+	req->lrq_nports = 1;
+	rp = >lrq_reqports[0];
 	strlcpy(rp->rp_portname, ifname, sizeof(rp->rp_portname));
 	ioc = LAGGIOC_NOCMD;
 
@@ -433,15 +435,16 @@ setlaggport(prop_dictionary_t env, prop_
 
 	if (ioc != LAGGIOC_NOCMD) {
 		req->lrq_ioctl = ioc;
-		if (indirect_ioctl(env, SIOCSLAGG, req) == -1) {
-			if (lagg_debug) {
-warn("cmd=%d", ioc);
-			}
-			return -1;
-		}
+		rv = indirect_ioctl(env, SIOCSLAGG, req);
+		if (lagg_debug && rv == -1)
+			warn("cmd=%d", ioc);
+	} else {
+		rv = 0;
 	}
 
-	return 0;
+	free(req);
+
+	return rv;
 }
 
 static int



CVS commit: src/sbin/ifconfig

2024-04-09 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Tue Apr  9 08:53:08 UTC 2024

Modified Files:
src/sbin/ifconfig: lagg.c

Log Message:
lagg(4): allocate memory for struct lagg_req by calloc(3)
to fix build error on clang


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sbin/ifconfig/lagg.c

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



CVS commit: src/sbin/ifconfig

2024-04-08 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Mon Apr  8 20:28:34 UTC 2024

Modified Files:
src/sbin/ifconfig: ifconfig.8

Log Message:
Update the date of the documentation to reflect recent changes.


To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 src/sbin/ifconfig/ifconfig.8

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

Modified files:

Index: src/sbin/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.128 src/sbin/ifconfig/ifconfig.8:1.129
--- src/sbin/ifconfig/ifconfig.8:1.128	Mon Apr  8 12:32:57 2024
+++ src/sbin/ifconfig/ifconfig.8	Mon Apr  8 20:28:34 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ifconfig.8,v 1.128 2024/04/08 12:32:57 uwe Exp $
+.\"	$NetBSD: ifconfig.8,v 1.129 2024/04/08 20:28:34 andvar Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)ifconfig.8	8.4 (Berkeley) 6/1/94
 .\"
-.Dd November 25, 2022
+.Dd April 8, 2024
 .Dt IFCONFIG 8
 .Os
 .Sh NAME



CVS commit: src/sbin/ifconfig

2024-04-08 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Mon Apr  8 20:28:34 UTC 2024

Modified Files:
src/sbin/ifconfig: ifconfig.8

Log Message:
Update the date of the documentation to reflect recent changes.


To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 src/sbin/ifconfig/ifconfig.8

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



CVS commit: src/sbin/ifconfig

2024-04-08 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Mon Apr  8 12:32:57 UTC 2024

Modified Files:
src/sbin/ifconfig: ifconfig.8

Log Message:
ifconfig(8): move laggportpri next to laggport


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 src/sbin/ifconfig/ifconfig.8

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

Modified files:

Index: src/sbin/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.127 src/sbin/ifconfig/ifconfig.8:1.128
--- src/sbin/ifconfig/ifconfig.8:1.127	Mon Apr  8 09:25:25 2024
+++ src/sbin/ifconfig/ifconfig.8	Mon Apr  8 12:32:57 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ifconfig.8,v 1.127 2024/04/08 09:25:25 kre Exp $
+.\"	$NetBSD: ifconfig.8,v 1.128 2024/04/08 12:32:57 uwe Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -630,6 +630,13 @@ Remove the interface named by
 from the
 .Xr lagg 4
 interface.
+.It Cm laggportpri Ar interface Ar n
+If the interface is a
+.Xr lagg 4
+pseudo-interface, set the priority of
+.Ar interface
+to
+.Ar n
 .It Cm laggproto Ar proto
 Set the aggregation protocol of
 .Xr lagg 4 .
@@ -641,13 +648,6 @@ The available options are
 .Li loadbalance ,
 and
 .Li none .
-.It Cm laggportpri Ar interface Ar n
-If the interface is a
-.Xr lagg 4
-pseudo-interface, set the priority of
-.Ar interface
-to
-.Ar n
 .It Cm eee
 Enable IEEE 802.3az Energy Efficiency Ethernet function.
 .It Cm -eee



CVS commit: src/sbin/ifconfig

2024-04-08 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Mon Apr  8 12:32:57 UTC 2024

Modified Files:
src/sbin/ifconfig: ifconfig.8

Log Message:
ifconfig(8): move laggportpri next to laggport


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 src/sbin/ifconfig/ifconfig.8

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



CVS commit: src/sbin/ifconfig

2024-04-08 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Mon Apr  8 09:25:25 UTC 2024

Modified Files:
src/sbin/ifconfig: ifconfig.8

Log Message:
Correct a very minor typo (s/id/is/)


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 src/sbin/ifconfig/ifconfig.8

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

Modified files:

Index: src/sbin/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.126 src/sbin/ifconfig/ifconfig.8:1.127
--- src/sbin/ifconfig/ifconfig.8:1.126	Mon Apr  8 04:29:52 2024
+++ src/sbin/ifconfig/ifconfig.8	Mon Apr  8 09:25:25 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ifconfig.8,v 1.126 2024/04/08 04:29:52 yamaguchi Exp $
+.\"	$NetBSD: ifconfig.8,v 1.127 2024/04/08 09:25:25 kre Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -642,7 +642,7 @@ The available options are
 and
 .Li none .
 .It Cm laggportpri Ar interface Ar n
-If the interface id a
+If the interface is a
 .Xr lagg 4
 pseudo-interface, set the priority of
 .Ar interface



CVS commit: src/sbin/ifconfig

2024-04-08 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Mon Apr  8 09:25:25 UTC 2024

Modified Files:
src/sbin/ifconfig: ifconfig.8

Log Message:
Correct a very minor typo (s/id/is/)


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 src/sbin/ifconfig/ifconfig.8

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



Re: CVS commit: src/sbin/ifconfig

2024-04-08 Thread Andrius V
Hi,

It's likely minor, but I believe these changes are enough to also
update the documentation date:
Index: ./src/sbin/ifconfig/ifconfig.8

-.Dd November 25, 2022
+.Dd April 8, 2024

Also "If the interface id a lagg(4) pseudo-interface" probably was
meant to be "If the interface is a lagg(4)..."  (id->is).

Thank you for the changes!

Regards,
Andrius V

On Mon, Apr 8, 2024 at 7:29 AM Shoichi YAMAGUCHI  wrote:
>
> Module Name:src
> Committed By:   yamaguchi
> Date:   Mon Apr  8 04:29:52 UTC 2024
>
> Modified Files:
> src/sbin/ifconfig: ifconfig.8
>
> Log Message:
> Added documents about parameters related to lagg(4)
>
> PR misc/58125
>
>
> To generate a diff of this commit:
> cvs rdiff -u -r1.125 -r1.126 src/sbin/ifconfig/ifconfig.8
>
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.
>


CVS commit: src/sbin/ifconfig

2024-04-07 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Mon Apr  8 04:29:52 UTC 2024

Modified Files:
src/sbin/ifconfig: ifconfig.8

Log Message:
Added documents about parameters related to lagg(4)

PR misc/58125


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/sbin/ifconfig/ifconfig.8

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

Modified files:

Index: src/sbin/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.125 src/sbin/ifconfig/ifconfig.8:1.126
--- src/sbin/ifconfig/ifconfig.8:1.125	Sun Mar 26 01:04:16 2023
+++ src/sbin/ifconfig/ifconfig.8	Mon Apr  8 04:29:52 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ifconfig.8,v 1.125 2023/03/26 01:04:16 mlelstv Exp $
+.\"	$NetBSD: ifconfig.8,v 1.126 2024/04/08 04:29:52 yamaguchi Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -614,6 +614,40 @@ Remove
 from the
 .Xr agr 4
 interface.
+.It Cm laggport Ar interface Oo Cm pri Ar n Oc
+Add the interface named by
+.Ar interface
+as a port of the
+.Xr lagg 4
+interface,
+and set the priority of
+.Ar interface
+to
+.Ar n .
+.It Cm -laggport Ar interface
+Remove the interface named by
+.Ar interface
+from the
+.Xr lagg 4
+interface.
+.It Cm laggproto Ar proto
+Set the aggregation protocol of
+.Xr lagg 4 .
+The default is
+.Li none .
+The available options are
+.Li failover ,
+.Li lacp ,
+.Li loadbalance ,
+and
+.Li none .
+.It Cm laggportpri Ar interface Ar n
+If the interface id a
+.Xr lagg 4
+pseudo-interface, set the priority of
+.Ar interface
+to
+.Ar n
 .It Cm eee
 Enable IEEE 802.3az Energy Efficiency Ethernet function.
 .It Cm -eee
@@ -899,6 +933,7 @@ tried to alter an interface's configurat
 .Sh SEE ALSO
 .Xr netstat 1 ,
 .Xr agr 4 ,
+.Xr lagg 4 ,
 .Xr carp 4 ,
 .Xr ifmedia 4 ,
 .Xr netintro 4 ,



CVS commit: src/sbin/ifconfig

2024-04-07 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Mon Apr  8 04:29:52 UTC 2024

Modified Files:
src/sbin/ifconfig: ifconfig.8

Log Message:
Added documents about parameters related to lagg(4)

PR misc/58125


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/sbin/ifconfig/ifconfig.8

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



CVS commit: src/sbin/ifconfig

2024-04-07 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Mon Apr  8 00:50:49 UTC 2024

Modified Files:
src/sbin/ifconfig: lagg.c

Log Message:
lagg(4): fix missing initialization of the number of array

pointed out by martin@, thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sbin/ifconfig/lagg.c

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



CVS commit: src/sbin/ifconfig

2024-04-07 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Mon Apr  8 00:50:49 UTC 2024

Modified Files:
src/sbin/ifconfig: lagg.c

Log Message:
lagg(4): fix missing initialization of the number of array

pointed out by martin@, thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sbin/ifconfig/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/sbin/ifconfig/lagg.c
diff -u src/sbin/ifconfig/lagg.c:1.6 src/sbin/ifconfig/lagg.c:1.7
--- src/sbin/ifconfig/lagg.c:1.6	Thu Apr  4 08:01:55 2024
+++ src/sbin/ifconfig/lagg.c	Mon Apr  8 00:50:49 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: lagg.c,v 1.6 2024/04/04 08:01:55 yamaguchi Exp $	*/
+/*	$NetBSD: lagg.c,v 1.7 2024/04/08 00:50:49 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2021 Internet Initiative Japan Inc.
@@ -28,7 +28,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: lagg.c,v 1.6 2024/04/04 08:01:55 yamaguchi Exp $");
+__RCSID("$NetBSD: lagg.c,v 1.7 2024/04/08 00:50:49 yamaguchi Exp $");
 #endif /* !defined(lint) */
 
 #include 
@@ -413,6 +413,7 @@ setlaggport(prop_dictionary_t env, prop_
 	memset(&_req, 0, sizeof(_req));
 	req = (struct lagg_req *)&_req;
 	rp = >lrq_reqports[0];
+	req->lrq_nports = 1;
 
 	strlcpy(rp->rp_portname, ifname, sizeof(rp->rp_portname));
 	ioc = LAGGIOC_NOCMD;



CVS commit: src/sbin/ifconfig

2024-04-04 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Apr  4 08:01:55 UTC 2024

Modified Files:
src/sbin/ifconfig: lagg.c

Log Message:
ifconfig: remove optional space


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sbin/ifconfig/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/sbin/ifconfig/lagg.c
diff -u src/sbin/ifconfig/lagg.c:1.5 src/sbin/ifconfig/lagg.c:1.6
--- src/sbin/ifconfig/lagg.c:1.5	Thu Apr  4 07:55:32 2024
+++ src/sbin/ifconfig/lagg.c	Thu Apr  4 08:01:55 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: lagg.c,v 1.5 2024/04/04 07:55:32 yamaguchi Exp $	*/
+/*	$NetBSD: lagg.c,v 1.6 2024/04/04 08:01:55 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2021 Internet Initiative Japan Inc.
@@ -28,7 +28,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: lagg.c,v 1.5 2024/04/04 07:55:32 yamaguchi Exp $");
+__RCSID("$NetBSD: lagg.c,v 1.6 2024/04/04 08:01:55 yamaguchi Exp $");
 #endif /* !defined(lint) */
 
 #include 
@@ -279,7 +279,7 @@ getlagg(prop_dictionary_t env)
 
 		if (errno != ENOBUFS)
 			break;
-		nports = req->lrq_nports + 3; /* 3: additional space */
+		nports = req->lrq_nports;
 	}
 
 	if (req != NULL) {



CVS commit: src/sbin/ifconfig

2024-04-04 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Apr  4 08:01:55 UTC 2024

Modified Files:
src/sbin/ifconfig: lagg.c

Log Message:
ifconfig: remove optional space


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sbin/ifconfig/lagg.c

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



CVS commit: src/sbin/ifconfig

2023-12-05 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Wed Dec  6 05:57:39 UTC 2023

Modified Files:
src/sbin/ifconfig: lagg.c

Log Message:
Fix "ifconfig lagg* lagglacp -maxports" command

This command clears the setting of the maximum number of
lacp active ports. The command was accepted but it did not
work until this change.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sbin/ifconfig/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/sbin/ifconfig/lagg.c
diff -u src/sbin/ifconfig/lagg.c:1.3 src/sbin/ifconfig/lagg.c:1.4
--- src/sbin/ifconfig/lagg.c:1.3	Thu Mar 31 01:53:22 2022
+++ src/sbin/ifconfig/lagg.c	Wed Dec  6 05:57:39 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: lagg.c,v 1.3 2022/03/31 01:53:22 yamaguchi Exp $	*/
+/*	$NetBSD: lagg.c,v 1.4 2023/12/06 05:57:39 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2021 Internet Initiative Japan Inc.
@@ -28,7 +28,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: lagg.c,v 1.3 2022/03/31 01:53:22 yamaguchi Exp $");
+__RCSID("$NetBSD: lagg.c,v 1.4 2023/12/06 05:57:39 yamaguchi Exp $");
 #endif /* !defined(lint) */
 
 #include 
@@ -132,27 +132,35 @@ struct piface	 laggportpri_if = PIFACE_I
 
 static const struct kwinst	 lagglacpkw[] = {
 	  {.k_word = "dumpdu", .k_key = "lacpdumpdu",
-	   .k_type = KW_T_INT, .k_int = LAGGLACPOPT_DUMPDU}
+	   .k_type = KW_T_INT, .k_int = LAGGLACPOPT_DUMPDU,
+	   .k_exec = setlagglacp}
 	, {.k_word = "-dumpdu", .k_key = "lacpdumpdu",
-	   .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_DUMPDU}
+	   .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_DUMPDU,
+	   .k_exec = setlagglacp}
 	, {.k_word = "stopdu", .k_key = "lacpstopdu",
-	   .k_type = KW_T_INT, .k_int = LAGGLACPOPT_STOPDU}
+	   .k_type = KW_T_INT, .k_int = LAGGLACPOPT_STOPDU,
+	   .k_exec = setlagglacp}
 	, {.k_word = "-stopdu", .k_key = "lacpstopdu",
-	   .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_STOPDU}
+	   .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_STOPDU,
+	   .k_exec = setlagglacp}
 	, {.k_word = "optimistic", .k_key = "lacpoptimistic",
-	   .k_type = KW_T_INT, .k_int = LAGGLACPOPT_OPTIMISTIC}
+	   .k_type = KW_T_INT, .k_int = LAGGLACPOPT_OPTIMISTIC,
+	   .k_exec = setlagglacp}
 	, {.k_word = "-optimistic", .k_key = "lacpoptimistic",
-	   .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_OPTIMISTIC}
+	   .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_OPTIMISTIC,
+	   .k_exec = setlagglacp}
 	, {.k_word = "maxports", .k_nextparser = _parser}
 	, {.k_word = "-maxports", .k_key = "lacpmaxports",
-	   .k_type = KW_T_INT, .k_int = 0}
+	   .k_type = KW_T_INT, .k_int = 0, .k_exec = setlagglacpmaxports}
 	, {.k_word = "multi-linkspeed", .k_key = "lacpmultils",
-	   .k_type = KW_T_INT, .k_int = LAGGLACPOPT_MULTILS}
+	   .k_type = KW_T_INT, .k_int = LAGGLACPOPT_MULTILS,
+	   .k_exec = setlagglacp}
 	, {.k_word = "-multi-linkspeed", .k_key = "lacpmultils",
-	   .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_MULTILS}
+	   .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_MULTILS,
+	   .k_exec = setlagglacp}
 };
 struct pkw	 lagglacp = PKW_INITIALIZER(, "lagg-lacp-option",
-		setlagglacp, NULL, lagglacpkw, __arraycount(lagglacpkw),
+		NULL, NULL, lagglacpkw, __arraycount(lagglacpkw),
 		_root.pb_parser);
 
 static const struct kwinst	 laggfailkw[] = {



CVS commit: src/sbin/ifconfig

2023-12-05 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Wed Dec  6 05:57:39 UTC 2023

Modified Files:
src/sbin/ifconfig: lagg.c

Log Message:
Fix "ifconfig lagg* lagglacp -maxports" command

This command clears the setting of the maximum number of
lacp active ports. The command was accepted but it did not
work until this change.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sbin/ifconfig/lagg.c

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



CVS commit: src/sbin/ifconfig

2023-03-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Mar 26 01:04:16 UTC 2023

Modified Files:
src/sbin/ifconfig: carp.c ifconfig.8

Log Message:
Fix parser for carp state.
The state values are uppercase words INIT, BACKUP and MASTER.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sbin/ifconfig/carp.c
cvs rdiff -u -r1.124 -r1.125 src/sbin/ifconfig/ifconfig.8

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

Modified files:

Index: src/sbin/ifconfig/carp.c
diff -u src/sbin/ifconfig/carp.c:1.14 src/sbin/ifconfig/carp.c:1.15
--- src/sbin/ifconfig/carp.c:1.14	Sun Jun  7 06:02:58 2020
+++ src/sbin/ifconfig/carp.c	Sun Mar 26 01:04:16 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: carp.c,v 1.14 2020/06/07 06:02:58 thorpej Exp $ */
+/* $NetBSD: carp.c,v 1.15 2023/03/26 01:04:16 mlelstv Exp $ */
 
 /*
  * Copyright (c) 2002 Michael Shalayeff. All rights reserved.
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: carp.c,v 1.14 2020/06/07 06:02:58 thorpej Exp $");
+__RCSID("$NetBSD: carp.c,v 1.15 2023/03/26 01:04:16 mlelstv Exp $");
 #endif /* not lint */
 
 #include 
@@ -67,10 +67,16 @@ static int setcarpdev(prop_dictionary_t,
 
 static const char *carp_states[] = { CARP_STATES };
 
+/* from if_carp.c */
+enum carpstateval { INIT = 0, BACKUP, MASTER };
+
 struct kwinst carpstatekw[] = {
-	  {.k_word = "INIT", .k_nextparser = _root.pb_parser}
-	, {.k_word = "BACKUP", .k_nextparser = _root.pb_parser}
-	, {.k_word = "MASTER", .k_nextparser = _root.pb_parser}
+	  {.k_word = "INIT", .k_type = KW_T_INT, .k_int = INIT,
+	   .k_nextparser = _root.pb_parser}
+	, {.k_word = "BACKUP", .k_type = KW_T_INT, .k_int = BACKUP,
+	   .k_nextparser = _root.pb_parser}
+	, {.k_word = "MASTER", .k_type = KW_T_INT, .k_int = MASTER,
+	   .k_nextparser = _root.pb_parser}
 };
 
 struct pinteger parse_advbase = PINTEGER_INITIALIZER1(_advbase, "advbase",

Index: src/sbin/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.124 src/sbin/ifconfig/ifconfig.8:1.125
--- src/sbin/ifconfig/ifconfig.8:1.124	Fri Nov 25 08:41:05 2022
+++ src/sbin/ifconfig/ifconfig.8	Sun Mar 26 01:04:16 2023
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ifconfig.8,v 1.124 2022/11/25 08:41:05 knakahara Exp $
+.\"	$NetBSD: ifconfig.8,v 1.125 2023/03/26 01:04:16 mlelstv Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -315,10 +315,10 @@ Explicitly force the
 .Xr carp 4
 pseudo-device to enter this state.
 Valid states are
-.Ar init ,
-.Ar backup ,
+.Ar INIT ,
+.Ar BACKUP ,
 and
-.Ar master .
+.Ar MASTER .
 .It Cm frag Ar threshold
 .Pq IEEE 802.11 devices only
 Configure the fragmentation threshold for IEEE 802.11-based wireless



CVS commit: src/sbin/ifconfig

2023-03-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Mar 26 01:04:16 UTC 2023

Modified Files:
src/sbin/ifconfig: carp.c ifconfig.8

Log Message:
Fix parser for carp state.
The state values are uppercase words INIT, BACKUP and MASTER.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sbin/ifconfig/carp.c
cvs rdiff -u -r1.124 -r1.125 src/sbin/ifconfig/ifconfig.8

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



CVS commit: src/sbin/ifconfig

2022-11-25 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Fri Nov 25 08:41:05 UTC 2022

Modified Files:
src/sbin/ifconfig: ifconfig.8 ifconfig.c

Log Message:
ifconfig(8) support unnumbered flag.


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 src/sbin/ifconfig/ifconfig.8
cvs rdiff -u -r1.248 -r1.249 src/sbin/ifconfig/ifconfig.c

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

Modified files:

Index: src/sbin/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.123 src/sbin/ifconfig/ifconfig.8:1.124
--- src/sbin/ifconfig/ifconfig.8:1.123	Fri Jan  7 10:17:39 2022
+++ src/sbin/ifconfig/ifconfig.8	Fri Nov 25 08:41:05 2022
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ifconfig.8,v 1.123 2022/01/07 10:17:39 bad Exp $
+.\"	$NetBSD: ifconfig.8,v 1.124 2022/11/25 08:41:05 knakahara Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)ifconfig.8	8.4 (Berkeley) 6/1/94
 .\"
-.Dd March 9, 2021
+.Dd November 25, 2022
 .Dt IFCONFIG 8
 .Os
 .Sh NAME
@@ -744,6 +744,10 @@ traffic can be protected using
 If the driver is a
 .Xr pfsync 4
 pseudo-device, broadcast the packets using multicast.
+.It Cm unnumbered
+Treat the interface as unnumbered.
+.It Cm -unnumbered
+Don't treat the interface as unnumbered.
 .El
 .Pp
 .Nm

Index: src/sbin/ifconfig/ifconfig.c
diff -u src/sbin/ifconfig/ifconfig.c:1.248 src/sbin/ifconfig/ifconfig.c:1.249
--- src/sbin/ifconfig/ifconfig.c:1.248	Wed Oct 14 13:37:14 2020
+++ src/sbin/ifconfig/ifconfig.c	Fri Nov 25 08:41:05 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ifconfig.c,v 1.248 2020/10/14 13:37:14 roy Exp $	*/
+/*	$NetBSD: ifconfig.c,v 1.249 2022/11/25 08:41:05 knakahara Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 1983, 1993\
  The Regents of the University of California.  All rights reserved.");
-__RCSID("$NetBSD: ifconfig.c,v 1.248 2020/10/14 13:37:14 roy Exp $");
+__RCSID("$NetBSD: ifconfig.c,v 1.249 2022/11/25 08:41:05 knakahara Exp $");
 #endif /* not lint */
 
 #include 
@@ -141,6 +141,7 @@ __dead static void usage(void);
 static const struct kwinst ifflagskw[] = {
 	  IFKW("arp", -IFF_NOARP)
 	, IFKW("debug", IFF_DEBUG)
+	, IFKW("unnumbered", IFF_UNNUMBERED)
 	, IFKW("link0", IFF_LINK0)
 	, IFKW("link1", IFF_LINK1)
 	, IFKW("link2", IFF_LINK2)
@@ -1524,6 +1525,7 @@ usage(void)
 		"\t[ preference n ]\n"
 		"\t[ link0 | -link0 ] [ link1 | -link1 ] [ link2 | -link2 ]\n"
 		"\t[ linkstr str | -linkstr ]\n"
+		"\t[ unnumbered | -unnumbered ]\n"
 		"\t[ description str | descr str | -description | -descr ]\n"
 		"   %s -a [-b] [-d] [-h] %s[-u] [-v] [-z] [ af ]\n"
 		"   %s -l [-b] [-d] [-s] [-u]\n"



CVS commit: src/sbin/ifconfig

2022-11-25 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Fri Nov 25 08:41:05 UTC 2022

Modified Files:
src/sbin/ifconfig: ifconfig.8 ifconfig.c

Log Message:
ifconfig(8) support unnumbered flag.


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 src/sbin/ifconfig/ifconfig.8
cvs rdiff -u -r1.248 -r1.249 src/sbin/ifconfig/ifconfig.c

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



CVS commit: src/sbin/ifconfig

2022-08-17 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Wed Aug 17 23:36:48 UTC 2022

Modified Files:
src/sbin/ifconfig: af_inetany.c

Log Message:
Revert to previous as the atf tests are still failing.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sbin/ifconfig/af_inetany.c

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

Modified files:

Index: src/sbin/ifconfig/af_inetany.c
diff -u src/sbin/ifconfig/af_inetany.c:1.22 src/sbin/ifconfig/af_inetany.c:1.23
--- src/sbin/ifconfig/af_inetany.c:1.22	Wed Aug 17 12:35:10 2022
+++ src/sbin/ifconfig/af_inetany.c	Wed Aug 17 23:36:48 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inetany.c,v 1.22 2022/08/17 12:35:10 nat Exp $	*/
+/*	$NetBSD: af_inetany.c,v 1.23 2022/08/17 23:36:48 nat Exp $	*/
 
 /*-
  * Copyright (c) 2008 David Young.  All rights reserved.
@@ -27,7 +27,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: af_inetany.c,v 1.22 2022/08/17 12:35:10 nat Exp $");
+__RCSID("$NetBSD: af_inetany.c,v 1.23 2022/08/17 23:36:48 nat Exp $");
 #endif /* not lint */
 
 #include 
@@ -68,7 +68,6 @@ commit_address(prop_dictionary_t env, pr
 const struct afparam *param)
 {
 	const char *ifname;
-	struct ifreq ifr;
 	int af, rc, s;
 	bool alias, delete, replace;
 	prop_data_t d;
@@ -89,19 +88,8 @@ commit_address(prop_dictionary_t env, pr
 
 	if ((d = (prop_data_t)prop_dictionary_get(env, "address")) != NULL)
 		addr = prop_data_value(d);
-	else if (param->gifaddr.cmd == 0)
-		return;
-	else if (!prop_dictionary_get_bool(env, "alias", )) { 
-		static struct paddr_prefix existingaddr;
-
-		memset(, 0, sizeof(ifr));
-		estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
-		if (prog_ioctl(s, SIOCGIFADDR, ) == -1)
-			return;
-
-		existingaddr.pfx_addr = ifr.ifr_addr;
-		addr = 
-	} else if (alias)
+	else if (!prop_dictionary_get_bool(env, "alias", ) || alias ||
+	param->gifaddr.cmd == 0)
 		return;
 	else if (prog_ioctl(s, param->gifaddr.cmd, param->dgreq.buf) == -1)
 		err(EXIT_FAILURE, "%s", param->gifaddr.desc);



CVS commit: src/sbin/ifconfig

2022-08-17 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Wed Aug 17 23:36:48 UTC 2022

Modified Files:
src/sbin/ifconfig: af_inetany.c

Log Message:
Revert to previous as the atf tests are still failing.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sbin/ifconfig/af_inetany.c

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



CVS commit: src/sbin/ifconfig

2022-08-17 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Wed Aug 17 12:35:11 UTC 2022

Modified Files:
src/sbin/ifconfig: af_inetany.c

Log Message:
Use existing address when setting parameters.

No need to specify address every time when setting broadcast address or
netmask.

Hopefully successfully re addresses PR bin/10911.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sbin/ifconfig/af_inetany.c

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

Modified files:

Index: src/sbin/ifconfig/af_inetany.c
diff -u src/sbin/ifconfig/af_inetany.c:1.21 src/sbin/ifconfig/af_inetany.c:1.22
--- src/sbin/ifconfig/af_inetany.c:1.21	Tue Aug 16 22:31:24 2022
+++ src/sbin/ifconfig/af_inetany.c	Wed Aug 17 12:35:10 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inetany.c,v 1.21 2022/08/16 22:31:24 nat Exp $	*/
+/*	$NetBSD: af_inetany.c,v 1.22 2022/08/17 12:35:10 nat Exp $	*/
 
 /*-
  * Copyright (c) 2008 David Young.  All rights reserved.
@@ -27,7 +27,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: af_inetany.c,v 1.21 2022/08/16 22:31:24 nat Exp $");
+__RCSID("$NetBSD: af_inetany.c,v 1.22 2022/08/17 12:35:10 nat Exp $");
 #endif /* not lint */
 
 #include 
@@ -68,6 +68,7 @@ commit_address(prop_dictionary_t env, pr
 const struct afparam *param)
 {
 	const char *ifname;
+	struct ifreq ifr;
 	int af, rc, s;
 	bool alias, delete, replace;
 	prop_data_t d;
@@ -88,8 +89,19 @@ commit_address(prop_dictionary_t env, pr
 
 	if ((d = (prop_data_t)prop_dictionary_get(env, "address")) != NULL)
 		addr = prop_data_value(d);
-	else if (!prop_dictionary_get_bool(env, "alias", ) || alias ||
-	param->gifaddr.cmd == 0)
+	else if (param->gifaddr.cmd == 0)
+		return;
+	else if (!prop_dictionary_get_bool(env, "alias", )) { 
+		static struct paddr_prefix existingaddr;
+
+		memset(, 0, sizeof(ifr));
+		estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+		if (prog_ioctl(s, SIOCGIFADDR, ) == -1)
+			return;
+
+		existingaddr.pfx_addr = ifr.ifr_addr;
+		addr = 
+	} else if (alias)
 		return;
 	else if (prog_ioctl(s, param->gifaddr.cmd, param->dgreq.buf) == -1)
 		err(EXIT_FAILURE, "%s", param->gifaddr.desc);



CVS commit: src/sbin/ifconfig

2022-08-17 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Wed Aug 17 12:35:11 UTC 2022

Modified Files:
src/sbin/ifconfig: af_inetany.c

Log Message:
Use existing address when setting parameters.

No need to specify address every time when setting broadcast address or
netmask.

Hopefully successfully re addresses PR bin/10911.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sbin/ifconfig/af_inetany.c

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



CVS commit: src/sbin/ifconfig

2022-08-16 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Tue Aug 16 22:31:24 UTC 2022

Modified Files:
src/sbin/ifconfig: af_inetany.c

Log Message:
Revert to previous as atf tests were failing.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sbin/ifconfig/af_inetany.c

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

Modified files:

Index: src/sbin/ifconfig/af_inetany.c
diff -u src/sbin/ifconfig/af_inetany.c:1.20 src/sbin/ifconfig/af_inetany.c:1.21
--- src/sbin/ifconfig/af_inetany.c:1.20	Tue Aug 16 10:47:10 2022
+++ src/sbin/ifconfig/af_inetany.c	Tue Aug 16 22:31:24 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inetany.c,v 1.20 2022/08/16 10:47:10 nat Exp $	*/
+/*	$NetBSD: af_inetany.c,v 1.21 2022/08/16 22:31:24 nat Exp $	*/
 
 /*-
  * Copyright (c) 2008 David Young.  All rights reserved.
@@ -27,7 +27,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: af_inetany.c,v 1.20 2022/08/16 10:47:10 nat Exp $");
+__RCSID("$NetBSD: af_inetany.c,v 1.21 2022/08/16 22:31:24 nat Exp $");
 #endif /* not lint */
 
 #include 
@@ -68,15 +68,12 @@ commit_address(prop_dictionary_t env, pr
 const struct afparam *param)
 {
 	const char *ifname;
-	struct ifreq ifr;
 	int af, rc, s;
 	bool alias, delete, replace;
 	prop_data_t d;
 	const struct paddr_prefix *addr, *brd, *dst, *mask;
 	unsigned short flags;
 
-	addr = NULL;
-
 	if ((af = getaf(env)) == -1)
 		af = AF_INET;
 
@@ -92,23 +89,8 @@ commit_address(prop_dictionary_t env, pr
 	if ((d = (prop_data_t)prop_dictionary_get(env, "address")) != NULL)
 		addr = prop_data_value(d);
 	else if (!prop_dictionary_get_bool(env, "alias", ) || alias ||
-	param->gifaddr.cmd == 0) {
-		if (addr == NULL) {
-			static struct paddr_prefix existingaddr;
-
-			memset(, 0, sizeof(ifr));
-			estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
-			if (prog_ioctl(s, SIOCGIFADDR, ) == -1) {
-if (errno == EADDRNOTAVAIL ||
-errno == EAFNOSUPPORT)
-	return;
-err(EXIT_FAILURE,"SIOCGIFADDR");
-			}
-
-			existingaddr.pfx_addr = ifr.ifr_addr;
-			addr = 
-		}
-	}
+	param->gifaddr.cmd == 0)
+		return;
 	else if (prog_ioctl(s, param->gifaddr.cmd, param->dgreq.buf) == -1)
 		err(EXIT_FAILURE, "%s", param->gifaddr.desc);
 	else if (prog_ioctl(s, param->difaddr.cmd, param->dgreq.buf) == -1)



CVS commit: src/sbin/ifconfig

2022-08-16 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Tue Aug 16 22:31:24 UTC 2022

Modified Files:
src/sbin/ifconfig: af_inetany.c

Log Message:
Revert to previous as atf tests were failing.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sbin/ifconfig/af_inetany.c

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



CVS commit: src/sbin/ifconfig

2022-08-16 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Tue Aug 16 10:47:11 UTC 2022

Modified Files:
src/sbin/ifconfig: af_inetany.c

Log Message:
No need address every time to specify broadcast and netmask.

Previously ifconfig would fail silently.

Addresses PR bin/10911.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sbin/ifconfig/af_inetany.c

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

Modified files:

Index: src/sbin/ifconfig/af_inetany.c
diff -u src/sbin/ifconfig/af_inetany.c:1.19 src/sbin/ifconfig/af_inetany.c:1.20
--- src/sbin/ifconfig/af_inetany.c:1.19	Sun Jun  7 06:02:58 2020
+++ src/sbin/ifconfig/af_inetany.c	Tue Aug 16 10:47:10 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inetany.c,v 1.19 2020/06/07 06:02:58 thorpej Exp $	*/
+/*	$NetBSD: af_inetany.c,v 1.20 2022/08/16 10:47:10 nat Exp $	*/
 
 /*-
  * Copyright (c) 2008 David Young.  All rights reserved.
@@ -27,7 +27,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: af_inetany.c,v 1.19 2020/06/07 06:02:58 thorpej Exp $");
+__RCSID("$NetBSD: af_inetany.c,v 1.20 2022/08/16 10:47:10 nat Exp $");
 #endif /* not lint */
 
 #include 
@@ -68,12 +68,15 @@ commit_address(prop_dictionary_t env, pr
 const struct afparam *param)
 {
 	const char *ifname;
+	struct ifreq ifr;
 	int af, rc, s;
 	bool alias, delete, replace;
 	prop_data_t d;
 	const struct paddr_prefix *addr, *brd, *dst, *mask;
 	unsigned short flags;
 
+	addr = NULL;
+
 	if ((af = getaf(env)) == -1)
 		af = AF_INET;
 
@@ -89,8 +92,23 @@ commit_address(prop_dictionary_t env, pr
 	if ((d = (prop_data_t)prop_dictionary_get(env, "address")) != NULL)
 		addr = prop_data_value(d);
 	else if (!prop_dictionary_get_bool(env, "alias", ) || alias ||
-	param->gifaddr.cmd == 0)
-		return;
+	param->gifaddr.cmd == 0) {
+		if (addr == NULL) {
+			static struct paddr_prefix existingaddr;
+
+			memset(, 0, sizeof(ifr));
+			estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+			if (prog_ioctl(s, SIOCGIFADDR, ) == -1) {
+if (errno == EADDRNOTAVAIL ||
+errno == EAFNOSUPPORT)
+	return;
+err(EXIT_FAILURE,"SIOCGIFADDR");
+			}
+
+			existingaddr.pfx_addr = ifr.ifr_addr;
+			addr = 
+		}
+	}
 	else if (prog_ioctl(s, param->gifaddr.cmd, param->dgreq.buf) == -1)
 		err(EXIT_FAILURE, "%s", param->gifaddr.desc);
 	else if (prog_ioctl(s, param->difaddr.cmd, param->dgreq.buf) == -1)



CVS commit: src/sbin/ifconfig

2022-08-16 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Tue Aug 16 10:47:11 UTC 2022

Modified Files:
src/sbin/ifconfig: af_inetany.c

Log Message:
No need address every time to specify broadcast and netmask.

Previously ifconfig would fail silently.

Addresses PR bin/10911.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sbin/ifconfig/af_inetany.c

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



CVS commit: src/sbin/ifconfig

2019-10-01 Thread Frank Kardel
Module Name:src
Committed By:   kardel
Date:   Tue Oct  1 10:52:53 UTC 2019

Modified Files:
src/sbin/ifconfig: util.c

Log Message:
PR/54513 ifconfig exits on newly created carp interfaces
downgrade from err(EXIT_FAILURE, ... ) to warn() if ioctl(SIOCGLIFADDR) fails.
ifconfig now survives freshly created carp interfaces.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sbin/ifconfig/util.c

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

Modified files:

Index: src/sbin/ifconfig/util.c
diff -u src/sbin/ifconfig/util.c:1.18 src/sbin/ifconfig/util.c:1.19
--- src/sbin/ifconfig/util.c:1.18	Fri Aug 16 10:33:17 2019
+++ src/sbin/ifconfig/util.c	Tue Oct  1 10:52:53 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: util.c,v 1.18 2019/08/16 10:33:17 msaitoh Exp $	*/
+/*	$NetBSD: util.c,v 1.19 2019/10/01 10:52:53 kardel Exp $	*/
 
 /*-
  * Copyright (c) 2008 David Young.  All rights reserved.
@@ -27,7 +27,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: util.c,v 1.18 2019/08/16 10:33:17 msaitoh Exp $");
+__RCSID("$NetBSD: util.c,v 1.19 2019/10/01 10:52:53 kardel Exp $");
 #endif /* not lint */
 
 #include 
@@ -276,7 +276,7 @@ print_link_addresses(prop_dictionary_t e
 		iflr.prefixlen = sdl->sdl_alen * NBBY;
 
 		if (prog_ioctl(s, SIOCGLIFADDR, ) == -1)
-			err(EXIT_FAILURE, "%s: ioctl", __func__);
+			warn("%s: ioctl SIOCGLIFADDR", __func__);
 
 		if (((iflr.flags & IFLR_ACTIVE) != 0) != print_active_only)
 			continue;



CVS commit: src/sbin/ifconfig

2019-10-01 Thread Frank Kardel
Module Name:src
Committed By:   kardel
Date:   Tue Oct  1 10:52:53 UTC 2019

Modified Files:
src/sbin/ifconfig: util.c

Log Message:
PR/54513 ifconfig exits on newly created carp interfaces
downgrade from err(EXIT_FAILURE, ... ) to warn() if ioctl(SIOCGLIFADDR) fails.
ifconfig now survives freshly created carp interfaces.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sbin/ifconfig/util.c

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



CVS commit: src/sbin/ifconfig

2019-08-16 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Aug 16 10:33:17 UTC 2019

Modified Files:
src/sbin/ifconfig: af_atalk.c af_inet.c af_inet6.c af_inetany.c
af_link.c env.c ether.c extern.h ieee80211.c ifconfig.c parse.c
parse.h pfsync.c tunnel.c util.c vlan.c

Log Message:
 Whitespace fix.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sbin/ifconfig/af_atalk.c
cvs rdiff -u -r1.25 -r1.26 src/sbin/ifconfig/af_inet.c
cvs rdiff -u -r1.38 -r1.39 src/sbin/ifconfig/af_inet6.c
cvs rdiff -u -r1.17 -r1.18 src/sbin/ifconfig/af_inetany.c \
src/sbin/ifconfig/util.c
cvs rdiff -u -r1.7 -r1.8 src/sbin/ifconfig/af_link.c
cvs rdiff -u -r1.11 -r1.12 src/sbin/ifconfig/env.c
cvs rdiff -u -r1.6 -r1.7 src/sbin/ifconfig/ether.c
cvs rdiff -u -r1.15 -r1.16 src/sbin/ifconfig/extern.h
cvs rdiff -u -r1.29 -r1.30 src/sbin/ifconfig/ieee80211.c
cvs rdiff -u -r1.239 -r1.240 src/sbin/ifconfig/ifconfig.c
cvs rdiff -u -r1.18 -r1.19 src/sbin/ifconfig/parse.c
cvs rdiff -u -r1.8 -r1.9 src/sbin/ifconfig/parse.h
cvs rdiff -u -r1.1 -r1.2 src/sbin/ifconfig/pfsync.c
cvs rdiff -u -r1.20 -r1.21 src/sbin/ifconfig/tunnel.c
cvs rdiff -u -r1.14 -r1.15 src/sbin/ifconfig/vlan.c

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

Modified files:

Index: src/sbin/ifconfig/af_atalk.c
diff -u src/sbin/ifconfig/af_atalk.c:1.19 src/sbin/ifconfig/af_atalk.c:1.20
--- src/sbin/ifconfig/af_atalk.c:1.19	Sat Oct 19 00:35:30 2013
+++ src/sbin/ifconfig/af_atalk.c	Fri Aug 16 10:33:17 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_atalk.c,v 1.19 2013/10/19 00:35:30 christos Exp $	*/
+/*	$NetBSD: af_atalk.c,v 1.20 2019/08/16 10:33:17 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,14 +31,14 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: af_atalk.c,v 1.19 2013/10/19 00:35:30 christos Exp $");
+__RCSID("$NetBSD: af_atalk.c,v 1.20 2019/08/16 10:33:17 msaitoh Exp $");
 #endif /* not lint */
 
-#include  
-#include  
+#include 
+#include 
 #include 
 
-#include  
+#include 
 
 #include 
 
@@ -185,7 +185,7 @@ sat_print1(const char *prefix, const str
 	char buf[40];
 
 	(void)getnameinfo(sa, sa->sa_len, buf, sizeof(buf), NULL, 0, 0);
-	
+
 	printf("%s%s", prefix, buf);
 }
 

Index: src/sbin/ifconfig/af_inet.c
diff -u src/sbin/ifconfig/af_inet.c:1.25 src/sbin/ifconfig/af_inet.c:1.26
--- src/sbin/ifconfig/af_inet.c:1.25	Mon Jun 11 17:45:50 2018
+++ src/sbin/ifconfig/af_inet.c	Fri Aug 16 10:33:17 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inet.c,v 1.25 2018/06/11 17:45:50 kamil Exp $	*/
+/*	$NetBSD: af_inet.c,v 1.26 2019/08/16 10:33:17 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,14 +31,14 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: af_inet.c,v 1.25 2018/06/11 17:45:50 kamil Exp $");
+__RCSID("$NetBSD: af_inet.c,v 1.26 2019/08/16 10:33:17 msaitoh Exp $");
 #endif /* not lint */
 
-#include  
-#include  
+#include 
+#include 
 #include 
 
-#include  
+#include 
 #include 
 #include 
 

Index: src/sbin/ifconfig/af_inet6.c
diff -u src/sbin/ifconfig/af_inet6.c:1.38 src/sbin/ifconfig/af_inet6.c:1.39
--- src/sbin/ifconfig/af_inet6.c:1.38	Sat Oct  1 15:10:58 2016
+++ src/sbin/ifconfig/af_inet6.c	Fri Aug 16 10:33:17 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inet6.c,v 1.38 2016/10/01 15:10:58 roy Exp $	*/
+/*	$NetBSD: af_inet6.c,v 1.39 2019/08/16 10:33:17 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,14 +31,14 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: af_inet6.c,v 1.38 2016/10/01 15:10:58 roy Exp $");
+__RCSID("$NetBSD: af_inet6.c,v 1.39 2019/08/16 10:33:17 msaitoh Exp $");
 #endif /* not lint */
 
-#include  
-#include  
+#include 
+#include 
 #include 
 
-#include  
+#include 
 #include 
 #include 
 #include 
@@ -222,7 +222,7 @@ setia6eui64_impl(prop_dictionary_t env, 
 		errx(EXIT_FAILURE,
 		"eui64 address modifier not allowed for the AF");
 	}
- 	in6 = >ifra_addr.sin6_addr;
+	in6 = >ifra_addr.sin6_addr;
 	if (memcmp(_any.s6_addr[8], >s6_addr[8], 8) != 0) {
 		union {
 			struct sockaddr_in6 sin6;
@@ -250,9 +250,9 @@ setia6eui64_impl(prop_dictionary_t env, 
 		}
 	}
 	if (lladdr == NULL)
-		errx(EXIT_FAILURE, "could not determine link local address"); 
+		errx(EXIT_FAILURE, "could not determine link local address");
 
- 	memcpy(>s6_addr[8], >s6_addr[8], 8);
+	memcpy(>s6_addr[8], >s6_addr[8], 8);
 
 	freeifaddrs(ifap);
 	return 0;

Index: src/sbin/ifconfig/af_inetany.c
diff -u src/sbin/ifconfig/af_inetany.c:1.17 src/sbin/ifconfig/af_inetany.c:1.18
--- src/sbin/ifconfig/af_inetany.c:1.17	Sun Dec 30 22:52:35 2012
+++ src/sbin/ifconfig/af_inetany.c	Fri Aug 16 10:33:17 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inetany.c,v 1.17 2012/12/30 22:52:35 christos Exp $	*/
+/*	$NetBSD: af_inetany.c,v 1.18 2019/08/16 10:33:17 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 2008 David Young.  All rights reserved.
@@ -27,14 +27,14 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: af_inetany.c,v 1.17 2012/12/30 22:52:35 christos Exp $");

CVS commit: src/sbin/ifconfig

2019-08-16 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Aug 16 10:33:17 UTC 2019

Modified Files:
src/sbin/ifconfig: af_atalk.c af_inet.c af_inet6.c af_inetany.c
af_link.c env.c ether.c extern.h ieee80211.c ifconfig.c parse.c
parse.h pfsync.c tunnel.c util.c vlan.c

Log Message:
 Whitespace fix.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sbin/ifconfig/af_atalk.c
cvs rdiff -u -r1.25 -r1.26 src/sbin/ifconfig/af_inet.c
cvs rdiff -u -r1.38 -r1.39 src/sbin/ifconfig/af_inet6.c
cvs rdiff -u -r1.17 -r1.18 src/sbin/ifconfig/af_inetany.c \
src/sbin/ifconfig/util.c
cvs rdiff -u -r1.7 -r1.8 src/sbin/ifconfig/af_link.c
cvs rdiff -u -r1.11 -r1.12 src/sbin/ifconfig/env.c
cvs rdiff -u -r1.6 -r1.7 src/sbin/ifconfig/ether.c
cvs rdiff -u -r1.15 -r1.16 src/sbin/ifconfig/extern.h
cvs rdiff -u -r1.29 -r1.30 src/sbin/ifconfig/ieee80211.c
cvs rdiff -u -r1.239 -r1.240 src/sbin/ifconfig/ifconfig.c
cvs rdiff -u -r1.18 -r1.19 src/sbin/ifconfig/parse.c
cvs rdiff -u -r1.8 -r1.9 src/sbin/ifconfig/parse.h
cvs rdiff -u -r1.1 -r1.2 src/sbin/ifconfig/pfsync.c
cvs rdiff -u -r1.20 -r1.21 src/sbin/ifconfig/tunnel.c
cvs rdiff -u -r1.14 -r1.15 src/sbin/ifconfig/vlan.c

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



CVS commit: src/sbin/ifconfig

2019-07-07 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Jul  8 03:04:15 UTC 2019

Modified Files:
src/sbin/ifconfig: ether.c ifconfig.8

Log Message:
 Add "ifconfig [-]vlan-hwtagging" to enable/disable VLAN hardware tagging
offload function. It's useful to see Ethernet frame's VLAN tag by
disabling with "ifconfig fooX -vlan-hwtagging" and "tcpdump -e -i fooX".


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sbin/ifconfig/ether.c
cvs rdiff -u -r1.118 -r1.119 src/sbin/ifconfig/ifconfig.8

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

Modified files:

Index: src/sbin/ifconfig/ether.c
diff -u src/sbin/ifconfig/ether.c:1.3 src/sbin/ifconfig/ether.c:1.4
--- src/sbin/ifconfig/ether.c:1.3	Fri Dec 21 08:58:08 2018
+++ src/sbin/ifconfig/ether.c	Mon Jul  8 03:04:15 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ether.c,v 1.3 2018/12/21 08:58:08 msaitoh Exp $	*/
+/*	$NetBSD: ether.c,v 1.4 2019/07/08 03:04:15 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: ether.c,v 1.3 2018/12/21 08:58:08 msaitoh Exp $");
+__RCSID("$NetBSD: ether.c,v 1.4 2019/07/08 03:04:15 msaitoh Exp $");
 #endif /* not lint */
 
 #include  
@@ -67,6 +67,7 @@ static const struct kwinst ethercapskw[]
 #if 0 /* notyet */
 	  IFKW("vlan-hwfilter",	ETHERCAP_VLAN_HWFILTER)
 #endif
+	  IFKW("vlan-hwtagging", ETHERCAP_VLAN_HWTAGGING),
 	  IFKW("eee",		ETHERCAP_EEE)
 };
 

Index: src/sbin/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.118 src/sbin/ifconfig/ifconfig.8:1.119
--- src/sbin/ifconfig/ifconfig.8:1.118	Thu Jul  4 13:55:31 2019
+++ src/sbin/ifconfig/ifconfig.8	Mon Jul  8 03:04:15 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ifconfig.8,v 1.118 2019/07/04 13:55:31 wiz Exp $
+.\"	$NetBSD: ifconfig.8,v 1.119 2019/07/08 03:04:15 msaitoh Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)ifconfig.8	8.4 (Berkeley) 6/1/94
 .\"
-.Dd June 18, 2019
+.Dd July 8, 2019
 .Dt IFCONFIG 8
 .Os
 .Sh NAME
@@ -699,6 +699,12 @@ support it.
 .It Cm -tso6
 Disable hardware-assisted TCP/IPv6 segmentation on interfaces that
 support it.
+.It Cm vlan-hwtagging
+Enable hardware-assisted VLAN tag insertion/removal on interfaces that
+support it.
+.It Cm -vlan-hwtagging
+Disable hardware-assisted VLAN tag insertion/removal on interfaces that
+support it.
 .It Cm maxupd Ar n
 If the driver is a
 .Xr pfsync 4



CVS commit: src/sbin/ifconfig

2019-07-07 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Jul  8 03:04:15 UTC 2019

Modified Files:
src/sbin/ifconfig: ether.c ifconfig.8

Log Message:
 Add "ifconfig [-]vlan-hwtagging" to enable/disable VLAN hardware tagging
offload function. It's useful to see Ethernet frame's VLAN tag by
disabling with "ifconfig fooX -vlan-hwtagging" and "tcpdump -e -i fooX".


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sbin/ifconfig/ether.c
cvs rdiff -u -r1.118 -r1.119 src/sbin/ifconfig/ifconfig.8

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



CVS commit: src/sbin/ifconfig

2019-07-04 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Jul  4 13:55:31 UTC 2019

Modified Files:
src/sbin/ifconfig: ifconfig.8

Log Message:
Formatting nit.


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sbin/ifconfig/ifconfig.8

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



CVS commit: src/sbin/ifconfig

2019-07-04 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Jul  4 13:55:31 UTC 2019

Modified Files:
src/sbin/ifconfig: ifconfig.8

Log Message:
Formatting nit.


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sbin/ifconfig/ifconfig.8

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

Modified files:

Index: src/sbin/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.117 src/sbin/ifconfig/ifconfig.8:1.118
--- src/sbin/ifconfig/ifconfig.8:1.117	Thu Jul  4 02:45:45 2019
+++ src/sbin/ifconfig/ifconfig.8	Thu Jul  4 13:55:31 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ifconfig.8,v 1.117 2019/07/04 02:45:45 ozaki-r Exp $
+.\"	$NetBSD: ifconfig.8,v 1.118 2019/07/04 13:55:31 wiz Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -390,7 +390,7 @@ key.
 .Pq IEEE 802.11 devices only
 Enable WEP encryption for IEEE 802.11-based wireless network interfaces
 with the persistent key written in the network card.
-.It Cm nwkey Cm persist: Ns Ar key
+.It Cm nwkey Cm persist : Ns Ar key
 .Pq IEEE 802.11 devices only
 Write the
 .Ar key



CVS commit: src/sbin/ifconfig

2019-07-03 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Jul  4 02:45:46 UTC 2019

Modified Files:
src/sbin/ifconfig: ifconfig.8 ifconfig.c

Log Message:
Add descr,description/-descr,-description commands to ifconfig(8) to handle a 
description.

>From t-kusaba@IIJ


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/sbin/ifconfig/ifconfig.8
cvs rdiff -u -r1.238 -r1.239 src/sbin/ifconfig/ifconfig.c

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

Modified files:

Index: src/sbin/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.116 src/sbin/ifconfig/ifconfig.8:1.117
--- src/sbin/ifconfig/ifconfig.8:1.116	Thu Nov 15 04:37:20 2018
+++ src/sbin/ifconfig/ifconfig.8	Thu Jul  4 02:45:45 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ifconfig.8,v 1.116 2018/11/15 04:37:20 ozaki-r Exp $
+.\"	$NetBSD: ifconfig.8,v 1.117 2019/07/04 02:45:45 ozaki-r Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)ifconfig.8	8.4 (Berkeley) 6/1/94
 .\"
-.Dd November 15, 2018
+.Dd June 18, 2019
 .Dt IFCONFIG 8
 .Os
 .Sh NAME
@@ -186,6 +186,10 @@ pseudo-device, attach it to
 .Ar iface .
 If not specified, the kernel will attempt to select an interface with
 a subnet matching that of the carp interface.
+.It Cm description Ar description , Cm descr Ar description
+Set a description of the interface. (0-63 characters)
+.It Cm -description , Cm -descr
+Clear the description of the interface.
 .It Cm debug
 Enable driver dependent debugging code; usually, this turns on
 extra console error logging.

Index: src/sbin/ifconfig/ifconfig.c
diff -u src/sbin/ifconfig/ifconfig.c:1.238 src/sbin/ifconfig/ifconfig.c:1.239
--- src/sbin/ifconfig/ifconfig.c:1.238	Fri Dec 21 08:58:08 2018
+++ src/sbin/ifconfig/ifconfig.c	Thu Jul  4 02:45:45 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ifconfig.c,v 1.238 2018/12/21 08:58:08 msaitoh Exp $	*/
+/*	$NetBSD: ifconfig.c,v 1.239 2019/07/04 02:45:45 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 1983, 1993\
  The Regents of the University of California.  All rights reserved.");
-__RCSID("$NetBSD: ifconfig.c,v 1.238 2018/12/21 08:58:08 msaitoh Exp $");
+__RCSID("$NetBSD: ifconfig.c,v 1.239 2019/07/04 02:45:45 ozaki-r Exp $");
 #endif /* not lint */
 
 #include 
@@ -133,6 +133,8 @@ static int setifnetmask(prop_dictionary_
 static int setifprefixlen(prop_dictionary_t, prop_dictionary_t);
 static int setlinkstr(prop_dictionary_t, prop_dictionary_t);
 static int unsetlinkstr(prop_dictionary_t, prop_dictionary_t);
+static int setifdescr(prop_dictionary_t, prop_dictionary_t);
+static int unsetifdescr(prop_dictionary_t, prop_dictionary_t);
 static void status(const struct sockaddr *, prop_dictionary_t,
 prop_dictionary_t);
 __dead static void usage(void);
@@ -193,6 +195,9 @@ struct paddr parse_broadcast = PADDR_INI
 "broadcast address",
 setifbroadaddr, "broadcast", NULL, NULL, NULL, _root.pb_parser);
 
+struct pstr parse_descr = PSTR_INITIALIZER1(_descr, "descr",
+setifdescr, "descr", false, _root.pb_parser);
+
 static const struct kwinst misckw[] = {
 	  {.k_word = "alias", .k_key = "alias", .k_deact = "alias",
 	   .k_type = KW_T_BOOL, .k_neg = true,
@@ -213,6 +218,12 @@ static const struct kwinst misckw[] = {
 	, {.k_word = "linkstr", .k_nextparser = _linkstr.ps_parser }
 	, {.k_word = "-linkstr", .k_exec = unsetlinkstr,
 	   .k_nextparser = _root.pb_parser }
+	, {.k_word = "descr", .k_nextparser = _descr.ps_parser}
+	, {.k_word = "description", .k_nextparser = _descr.ps_parser}
+	, {.k_word = "-descr", .k_exec = unsetifdescr,
+	   .k_nextparser = _root.pb_parser}
+	, {.k_word = "-description", .k_exec = unsetifdescr,
+	   .k_nextparser = _root.pb_parser}
 };
 
 /* key: clonecmd */
@@ -1270,6 +1281,7 @@ status(const struct sockaddr *sdl, prop_
 	struct ifcapreq ifcr;
 	unsigned short flags;
 	const struct afswtch *afp;
+	char ifdescr[IFDESCRSIZE];
 
 	if ((af = getaf(env)) == -1) {
 		afp = NULL;
@@ -1321,6 +1333,12 @@ status(const struct sockaddr *sdl, prop_
 	SIMPLEQ_FOREACH(status_f, _funcs, f_next)
 		(*status_f->f_func)(env, oenv);
 
+	estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+	ifr.ifr_buf = 
+	ifr.ifr_buflen = sizeof(ifdescr);
+	if (prog_ioctl(s, SIOCGIFDESCR, ) == 0)
+		printf("\tdescription: \"%s\"\n", (char *)ifr.ifr_buf);
+
 	print_link_addresses(env, true);
 
 	estrlcpy(ifdrv.ifd_name, ifname, sizeof(ifdrv.ifd_name));
@@ -1461,6 +1479,55 @@ unsetlinkstr(prop_dictionary_t env, prop
 	return 0;
 }
 
+static int
+setifdescr(prop_dictionary_t env, prop_dictionary_t oenv)
+{
+	struct ifreq ifr;
+	size_t len;
+	prop_data_t data;
+	char *descr;
+
+ 	data = (prop_data_t)prop_dictionary_get(env, "descr");
+	if (data == NULL) {
+		errno = ENOENT;
+		return -1;
+	}
+	len = prop_data_size(data) + 1;
+

Re: CVS commit: src/sbin/ifconfig

2016-09-14 Thread Joerg Sonnenberger
On Wed, Sep 14, 2016 at 02:17:26PM +0100, Roy Marples wrote:
> On 14/09/2016 13:00, Joerg Sonnenberger wrote:
> > On Wed, Sep 14, 2016 at 11:46:43AM +, Roy Marples wrote:
> >> Module Name:   src
> >> Committed By:  roy
> >> Date:  Wed Sep 14 11:46:43 UTC 2016
> >>
> >> Modified Files:
> >>src/sbin/ifconfig: media.c
> >>
> >> Log Message:
> >> Don't bail if SIOGIFMEDIA doesn't return any media lists because we
> >> can still report link status.
> > 
> > As I mentioned in the review, I think this is the wrong approach. I find
> > the assumption that every interface supporting the IFMEDIA interface has
> > at least one medium to be perfectly reasonable. Setting up and
> > defaulting to one AUTO medium is two lines of code. Now we have to look
> > for bugs in every consumer of this interface...
> 
> There is no media to select because there is none. Providing a list of
> one just to satisfy strikes me as waste of bytes.

Of course there is a medium. You are transporting the byte stream via
something. Now technically, this can be Ethernet or a serial line or
whatever and that's not really relevant, so using something like
IFM_GENERIC would certainly be fine.

> Existing code that just cares about link status will function as before
> without any change.
> Ditto for any code which lists or sets the media in use because there
> has to be a list to start with.

You are only looking at code in the tree. Things like net-snmp and other
monitoring/reporting tools have a long list of strange assumptions. It
doesn't strike me as useful to make the job for them more difficult
without reason.

> It could also be argued that obtaining link status should be it's own
> ioctl and not bolted on-to media.

Separate issue, but it certainly sounds useful enough.

Joerg


Re: CVS commit: src/sbin/ifconfig

2016-09-14 Thread Roy Marples
On 14/09/2016 13:00, Joerg Sonnenberger wrote:
> On Wed, Sep 14, 2016 at 11:46:43AM +, Roy Marples wrote:
>> Module Name: src
>> Committed By:roy
>> Date:Wed Sep 14 11:46:43 UTC 2016
>>
>> Modified Files:
>>  src/sbin/ifconfig: media.c
>>
>> Log Message:
>> Don't bail if SIOGIFMEDIA doesn't return any media lists because we
>> can still report link status.
> 
> As I mentioned in the review, I think this is the wrong approach. I find
> the assumption that every interface supporting the IFMEDIA interface has
> at least one medium to be perfectly reasonable. Setting up and
> defaulting to one AUTO medium is two lines of code. Now we have to look
> for bugs in every consumer of this interface...

There is no media to select because there is none. Providing a list of
one just to satisfy strikes me as waste of bytes.

Existing code that just cares about link status will function as before
without any change.
Ditto for any code which lists or sets the media in use because there
has to be a list to start with.

The only case where this can possibly fail is where (like ifconfig) the
code assumes that if there is no list then there is no link status -
which is patently wrong itself because we have IFM_AVALID for that.
Old ifconfig still works with the new code, it will just warn that it
can't query a list of media and won't print any link status.

It could also be argued that obtaining link status should be it's own
ioctl and not bolted on-to media.

Roy


Re: CVS commit: src/sbin/ifconfig

2016-09-14 Thread Joerg Sonnenberger
On Wed, Sep 14, 2016 at 11:46:43AM +, Roy Marples wrote:
> Module Name:  src
> Committed By: roy
> Date: Wed Sep 14 11:46:43 UTC 2016
> 
> Modified Files:
>   src/sbin/ifconfig: media.c
> 
> Log Message:
> Don't bail if SIOGIFMEDIA doesn't return any media lists because we
> can still report link status.

As I mentioned in the review, I think this is the wrong approach. I find
the assumption that every interface supporting the IFMEDIA interface has
at least one medium to be perfectly reasonable. Setting up and
defaulting to one AUTO medium is two lines of code. Now we have to look
for bugs in every consumer of this interface...

Joerg


Re: CVS commit: src/sbin/ifconfig

2015-01-21 Thread Fredrik Pettai
Also RFC4941 related change (depends on ticket #441)

/P

On 20 Jan 2015, at 23:13 , Roy Marples r...@netbsd.org wrote:

 Module Name:  src
 Committed By: roy
 Date: Tue Jan 20 22:13:19 UTC 2015
 
 Modified Files:
   src/sbin/ifconfig: af_inet6.c
 
 Log Message:
 Display the IPv6 address flags autoconf and temporary
 
 
 To generate a diff of this commit:
 cvs rdiff -u -r1.30 -r1.31 src/sbin/ifconfig/af_inet6.c
 
 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.
 



Re: CVS commit: src/sbin/ifconfig

2012-03-18 Thread Julio Merino

On 3/18/12 1:53 AM, Jukka Ruohonen wrote:

On Fri, Mar 16, 2012 at 10:25:08PM -0400, Christos Zoulas wrote:

Module Name:src
Committed By:   christos
Date:   Sat Mar 17 02:25:08 UTC 2012

Modified Files:
src/sbin/ifconfig: af_inetany.c

Log Message:
PR/43141: Tobias Nygren: Print an error on unknown interfaces.


Now this is trival and it is fixed. But I guess there is a bug here in ATF.
The test only checks that the exit code is not zero:

 atf_check -s not-exit:0 ifconfig nonexistent0 1.2.3.4/24

But why is stderr being involved?


If you really want to ignore stderr in the test, pass -e ignore to 
atf_check.  The default is -o empty -e empty.


Now, the question is: do you really want to ignore the message, or do 
you want to validate that the appropriate error message is printed?  If 
the later (which should be the preferred way), -e inline:'foo bar\n' 
or -e match:'foo bar' or -e file:experr (with experr being 
pre-populated with the expected message) will do the job.


Re: CVS commit: src/sbin/ifconfig

2012-03-18 Thread Jukka Ruohonen
On Sun, Mar 18, 2012 at 11:57:08PM +0900, Julio Merino wrote:
 But why is stderr being involved?
 
 If you really want to ignore stderr in the test, pass -e ignore to 
 atf_check.  The default is -o empty -e empty.
 
 Now, the question is: do you really want to ignore the message, or do 
 you want to validate that the appropriate error message is printed?  If 
 the later (which should be the preferred way), -e inline:'foo bar\n' 
 or -e match:'foo bar' or -e file:experr (with experr being 
 pre-populated with the expected message) will do the job.

Thanks; this was pointed out already.

But I have a related question. Supposedly ATF uses something like freopen(3)
to capture the output in the standard streams. Now consider this from one
test I just added:

$ find /etc -type f -exit
$ echo $?
0

All good; exited without nothing printed to stderr and the status is zero.
But this:

atf_check -o ignore \
-s exit:0 -x find /etc -type f -exit

yields

tc-so:Executing command [ /bin/sh -c find /etc -type f -exit ]
tc-se:Fail: incorrect exit status: 1, expected: 0
tc-se:stdout:
tc-se:
tc-se:stderr:
tc-se:find: fts_read: Inappropriate ioctl for device
tc-se:
tc-end: 1332083101.965143, exit, failed, atf-check failed;
see the output of the test for details

So what is going on here? Likewise

$ find / -exit 99
$ echo $?
99

contra

atf_check -o ignore -e ignore -s exit:99 -x find / -exit 99

and

tc-so:Executing command [ /bin/sh -c find / -exit 99 ]
tc-se:Fail: incorrect exit status: 1, expected: 99
tc-se:stdout:
tc-se:
tc-se:stderr:
tc-se:find: fts_read: Inappropriate ioctl for device
tc-se:
tc-end: 1332083172.374247, exit_status, failed, atf-check failed;
see the output of the test for details

- Jukka.


Re: CVS commit: src/sbin/ifconfig

2012-03-17 Thread Nicolas Joly
On Sat, Mar 17, 2012 at 06:53:31PM +0200, Jukka Ruohonen wrote:
 On Fri, Mar 16, 2012 at 10:25:08PM -0400, Christos Zoulas wrote:
  Module Name:src
  Committed By:   christos
  Date:   Sat Mar 17 02:25:08 UTC 2012
  
  Modified Files:
  src/sbin/ifconfig: af_inetany.c
  
  Log Message:
  PR/43141: Tobias Nygren: Print an error on unknown interfaces.
 
 Now this is trival and it is fixed. But I guess there is a bug here in ATF.
 The test only checks that the exit code is not zero:
 
 atf_check -s not-exit:0 ifconfig nonexistent0 1.2.3.4/24
 
 But why is stderr being involved?

atf_check defaults to '-s exit:0 -o empty -e empty'.
Adding '-e ignore' should do the trick.

-- 
Nicolas Joly

Projects and Developments in Bioinformatics
Institut Pasteur, Paris.


CVS commit: src/sbin/ifconfig

2010-01-30 Thread Ignatios Souvatzis
Module Name:src
Committed By:   is
Date:   Sat Jan 30 18:30:33 UTC 2010

Modified Files:
src/sbin/ifconfig: af_atalk.c

Log Message:
Use getnameinfo() for printing AppleTalk addresses. While here, fix
printing of broadcast for this address family (AT broadcast is fixed
node 255 on the local net).


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sbin/ifconfig/af_atalk.c

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



CVS commit: src/sbin/ifconfig

2010-01-22 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Fri Jan 22 23:50:07 UTC 2010

Modified Files:
src/sbin/ifconfig: af_inet6.c

Log Message:
Compare a pointer with NULL instead of testing its truth.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sbin/ifconfig/af_inet6.c

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