CVS commit: src/sys/net/lagg

2022-01-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Jan  6 12:09:42 UTC 2022

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

Log Message:
lagg(4): Take lock as required around if ioctl.

Note: There are some calls to SIOCADDMULTI/SIOCDELMULTI that take the
lock when they don't need it, but it's not clear it's harmful either
unless they come via a caller that holds softnet_lock.

candidate fix for
https://mail-index.netbsd.org/current-users/2021/12/31/msg041876.html

ok yamaguchi


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/net/lagg/if_lagg_lacp.c

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

2022-01-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Jan  6 12:09:42 UTC 2022

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

Log Message:
lagg(4): Take lock as required around if ioctl.

Note: There are some calls to SIOCADDMULTI/SIOCDELMULTI that take the
lock when they don't need it, but it's not clear it's harmful either
unless they come via a caller that holds softnet_lock.

candidate fix for
https://mail-index.netbsd.org/current-users/2021/12/31/msg041876.html

ok yamaguchi


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/net/lagg/if_lagg_lacp.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_lacp.c
diff -u src/sys/net/lagg/if_lagg_lacp.c:1.10 src/sys/net/lagg/if_lagg_lacp.c:1.11
--- src/sys/net/lagg/if_lagg_lacp.c:1.10	Fri Dec 31 14:24:51 2021
+++ src/sys/net/lagg/if_lagg_lacp.c	Thu Jan  6 12:09:42 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg_lacp.c,v 1.10 2021/12/31 14:24:51 riastradh Exp $	*/
+/*	$NetBSD: if_lagg_lacp.c,v 1.11 2022/01/06 12:09:42 riastradh Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.10 2021/12/31 14:24:51 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.11 2022/01/06 12:09:42 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_lagg.h"
@@ -839,7 +839,9 @@ lacp_linkstate(struct lagg_proto_softc *
 
 	memset(&ifmr, 0, sizeof(ifmr));
 	ifmr.ifm_count = 0;
+	IFNET_LOCK(ifp_port);
 	error = if_ioctl(ifp_port, SIOCGIFMEDIA, (void *)&ifmr);
+	IFNET_UNLOCK(ifp_port);
 	if (error == 0) {
 		media = lacp_ifmedia2lacpmedia(ifmr.ifm_active);
 	} else if (error != ENOTTY){



CVS commit: src/sys/net/lagg

2022-01-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jan 12 01:21:36 UTC 2022

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

Log Message:
lagg(4): Need to take IFNET_LOCK around if_init.

This should really just avoid dropping IFNET_LOCK before it's done
changing the port interface's configuration, but this stop-gap change
will serve provisionally to reduce crashes until we can confirm that
there's no deadlock lurking in the time this logic drops IFNET_LOCK.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 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.28 src/sys/net/lagg/if_lagg.c:1.29
--- src/sys/net/lagg/if_lagg.c:1.28	Fri Dec 31 14:25:24 2021
+++ src/sys/net/lagg/if_lagg.c	Wed Jan 12 01:21:36 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.28 2021/12/31 14:25:24 riastradh Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.29 2022/01/12 01:21:36 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.28 2021/12/31 14:25:24 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.29 2022/01/12 01:21:36 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2385,9 +2385,13 @@ lagg_port_setup(struct lagg_softc *sc,
 	lagg_port_syncvlan(sc, lp);
 
 	if (stopped) {
-		error = if_init(ifp_port);
-		if (error != 0)
-			goto remove_port;
+		IFNET_LOCK(ifp_port);
+		if (!ISSET(ifp_port->if_flags, IFF_RUNNING)) {
+			error = if_init(ifp_port);
+			if (error != 0)
+goto remove_port;
+		}
+		IFNET_UNLOCK(ifp_port);
 	}
 
 	lagg_config_promisc(sc, lp);
@@ -2484,11 +2488,11 @@ lagg_port_teardown(struct lagg_softc *sc
 		ifp_port->if_ioctl = lp->lp_ioctl;
 	ifp_port->if_output = lp->lp_output;
 	lagg_teardown_mtu(sc, lp);
-	IFNET_UNLOCK(ifp_port);
 
 	if (stopped) {
 		if_init(ifp_port);
 	}
+	IFNET_UNLOCK(ifp_port);
 
 	if (is_ifdetach == false) {
 		lagg_unconfig_promisc(sc, lp);



CVS commit: src/sys/net/lagg

2022-01-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jan 12 01:21:36 UTC 2022

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

Log Message:
lagg(4): Need to take IFNET_LOCK around if_init.

This should really just avoid dropping IFNET_LOCK before it's done
changing the port interface's configuration, but this stop-gap change
will serve provisionally to reduce crashes until we can confirm that
there's no deadlock lurking in the time this logic drops IFNET_LOCK.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 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/sys/net/lagg

2022-01-12 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Wed Jan 12 08:23:53 UTC 2022

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

Log Message:
Fix to call lacp_linkstate with IFNET_LOCK held

Network stack calls lacp_linkstate through lagg_port_ioctl when
doing "ifconfig up" or "ifconfig down" to an interface that is
a member of lagg(4). And IFNET_LOCK in the member interface
is held while the ioctl.
Therefore, lacp_linkstate is renamed to
lacp_linkstate_ifnet_locked, and always called with IFNET_LOCK
held. It avoids locking agains myself.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/net/lagg/if_lagg.c
cvs rdiff -u -r1.11 -r1.12 src/sys/net/lagg/if_lagg_lacp.c
cvs rdiff -u -r1.9 -r1.10 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.29 src/sys/net/lagg/if_lagg.c:1.30
--- src/sys/net/lagg/if_lagg.c:1.29	Wed Jan 12 01:21:36 2022
+++ src/sys/net/lagg/if_lagg.c	Wed Jan 12 08:23:53 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.29 2022/01/12 01:21:36 riastradh Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.30 2022/01/12 08:23:53 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.29 2022/01/12 01:21:36 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.30 2022/01/12 08:23:53 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -102,7 +102,7 @@ static const struct lagg_proto lagg_prot
 		.pr_stopport = lacp_stopport,
 		.pr_protostat = lacp_protostat,
 		.pr_portstat = lacp_portstat,
-		.pr_linkstate = lacp_linkstate,
+		.pr_linkstate = lacp_linkstate_ifnet_locked,
 		.pr_ioctl = lacp_ioctl,
 	},
 	[LAGG_PROTO_FAILOVER] = {
@@ -1490,6 +1490,8 @@ lagg_proto_linkstate(struct lagg_softc *
 	lagg_proto pr;
 	int bound;
 
+	KASSERT(IFNET_LOCKED(lp->lp_ifp));
+
 	bound = curlwp_bind();
 	var = lagg_variant_getref(sc, &psref);
 
@@ -2692,6 +2694,8 @@ lagg_port_ioctl(struct ifnet *ifp, u_lon
 		goto fallback;
 	}
 
+	KASSERT(IFNET_LOCKED(lp->lp_ifp));
+
 	switch (cmd) {
 	case SIOCSIFCAP:
 	case SIOCSIFMTU:
@@ -2817,7 +2821,10 @@ lagg_linkstate_changed(void *xifp)
 	}
 	pserialize_read_exit(s);
 
+	IFNET_LOCK(lp->lp_ifp);
 	lagg_proto_linkstate(lp->lp_softc, lp);
+	IFNET_UNLOCK(lp->lp_ifp);
+
 	lagg_port_putref(lp, &psref);
 	curlwp_bindx(bound);
 }

Index: src/sys/net/lagg/if_lagg_lacp.c
diff -u src/sys/net/lagg/if_lagg_lacp.c:1.11 src/sys/net/lagg/if_lagg_lacp.c:1.12
--- src/sys/net/lagg/if_lagg_lacp.c:1.11	Thu Jan  6 12:09:42 2022
+++ src/sys/net/lagg/if_lagg_lacp.c	Wed Jan 12 08:23:53 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg_lacp.c,v 1.11 2022/01/06 12:09:42 riastradh Exp $	*/
+/*	$NetBSD: if_lagg_lacp.c,v 1.12 2022/01/12 08:23:53 yamaguchi Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.11 2022/01/06 12:09:42 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.12 2022/01/12 08:23:53 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_lagg.h"
@@ -212,8 +212,6 @@ static void	lacp_dprintf(const struct la
 #define LACP_LOCK(_sc)		mutex_enter(&(_sc)->lsc_lock)
 #define LACP_UNLOCK(_sc)	mutex_exit(&(_sc)->lsc_lock)
 #define LACP_LOCKED(_sc)	mutex_owned(&(_sc)->lsc_lock)
-#define LACP_LINKSTATE(_sc, _lp)			\
-	lacp_linkstate((struct lagg_proto_softc *)(_sc), (_lp))
 #define LACP_TIMER_ARM(_lacpp, _timer, _val)		\
 	(_lacpp)->lp_timer[(_timer)] = (_val)
 #define LACP_TIMER_DISARM(_lacpp, _timer)		\
@@ -242,6 +240,7 @@ static void	lacp_dprintf(const struct la
 
 static void	lacp_tick(void *);
 static void	lacp_tick_work(struct lagg_work *, void *);
+static void	lacp_linkstate(struct lagg_proto_softc *, struct lagg_port *);
 static uint32_t	lacp_ifmedia2lacpmedia(u_int);
 static void	lacp_port_disable(struct lacp_softc *, struct lacp_port *);
 static void	lacp_port_enable(struct lacp_softc *, struct lacp_port *);
@@ -673,7 +672,7 @@ lacp_allocport(struct lagg_proto_softc *
 
 	lp->lp_proto_ctx = (void *)lacpp;
 	lp->lp_prio = ntohs(lacpp->lp_actor.lpi_portprio);
-	LACP_LINKSTATE(lsc, lp);
+	lacp_linkstate(xlsc, lp);
 
 	return 0;
 }
@@ -689,7 +688,7 @@ lacp_startport(struct lagg_proto_softc *
 	prio = (uint16_t)MIN(lp->lp_prio, UINT16_MAX);
 	lacpp->lp_actor.lpi_portprio = htons(prio);
 
-	LACP_LINKSTATE((struct lacp_softc *)xlsc, lp);
+	lacp_linkstate(xlsc, lp);
 }
 
 void
@@ -821,7 +820,7 @@ lacp_portstat(struct lagg_proto_softc *x
 }
 
 void
-lacp_linkstate(struct lagg_proto_softc *xlsc, struct lagg_port *lp)
+lacp_linkstate_ifnet_locked(struct lagg_proto_softc *xlsc, struct lagg_port *lp)
 {
 	struct lacp_softc *lsc;
 	struct lacp_port *lacpp;
@@ -831,6 +830,8 @@ lacp_linkstate(struct lagg_proto_softc *
 	uint32_t media, old_media;
 	int erro

CVS commit: src/sys/net/lagg

2022-01-12 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Wed Jan 12 08:23:53 UTC 2022

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

Log Message:
Fix to call lacp_linkstate with IFNET_LOCK held

Network stack calls lacp_linkstate through lagg_port_ioctl when
doing "ifconfig up" or "ifconfig down" to an interface that is
a member of lagg(4). And IFNET_LOCK in the member interface
is held while the ioctl.
Therefore, lacp_linkstate is renamed to
lacp_linkstate_ifnet_locked, and always called with IFNET_LOCK
held. It avoids locking agains myself.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/net/lagg/if_lagg.c
cvs rdiff -u -r1.11 -r1.12 src/sys/net/lagg/if_lagg_lacp.c
cvs rdiff -u -r1.9 -r1.10 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

2022-01-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 16 10:45:17 UTC 2022

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

Log Message:
lagg: remove stray semicolon

No binary change.


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

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

2022-01-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 16 10:45:17 UTC 2022

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

Log Message:
lagg: remove stray semicolon

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/net/lagg/if_lagg_lacp.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_lacp.c
diff -u src/sys/net/lagg/if_lagg_lacp.c:1.12 src/sys/net/lagg/if_lagg_lacp.c:1.13
--- src/sys/net/lagg/if_lagg_lacp.c:1.12	Wed Jan 12 08:23:53 2022
+++ src/sys/net/lagg/if_lagg_lacp.c	Sun Jan 16 10:45:17 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg_lacp.c,v 1.12 2022/01/12 08:23:53 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg_lacp.c,v 1.13 2022/01/16 10:45:17 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.12 2022/01/12 08:23:53 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.13 2022/01/16 10:45:17 rillig Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_lagg.h"
@@ -2542,7 +2542,7 @@ lacp_dump_lacpdutlv(const struct lacpdu_
 		printf("actor.state=%s portno=%d portprio=0x%04x\n",
 		str,
 		ntohs(pi_actor->lpi_port_no),
-		ntohs(pi_actor->lpi_port_prio));;
+		ntohs(pi_actor->lpi_port_prio));
 	} else {
 		printf("no actor info\n");
 	}



CVS commit: src/sys/net/lagg

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 01:39:09 UTC 2022

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

Log Message:
lagg(4): fix typo

pointed out by k-goda@IIJ


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 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/sys/net/lagg

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 01:39:09 UTC 2022

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

Log Message:
lagg(4): fix typo

pointed out by k-goda@IIJ


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 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.30 src/sys/net/lagg/if_lagg.c:1.31
--- src/sys/net/lagg/if_lagg.c:1.30	Wed Jan 12 08:23:53 2022
+++ src/sys/net/lagg/if_lagg.c	Thu Mar 31 01:39:09 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.30 2022/01/12 08:23:53 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.31 2022/03/31 01:39:09 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.30 2022/01/12 08:23:53 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.31 2022/03/31 01:39:09 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -215,7 +215,7 @@ static enum lagg_iftypes
 #ifdef LAGG_DEBUG
 #define LAGG_DPRINTF(_sc, _fmt, _args...)	do {	\
 	printf("%s: " _fmt, (_sc) != NULL ?		\
-	sc->sc_if.if_xname : "lagg", ##_args);		\
+	(_sc)->sc_if.if_xname : "lagg", ##_args);		\
 } while (0)
 #else
 #define LAGG_DPRINTF(_sc, _fmt, _args...)	__nothing



CVS commit: src/sys/net/lagg

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 01:40:34 UTC 2022

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

Log Message:
Added missing kmem_free

pointed out by k-goda@IIJ


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

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

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 01:40:34 UTC 2022

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

Log Message:
Added missing kmem_free

pointed out by k-goda@IIJ


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/net/lagg/if_lagg_lacp.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_lacp.c
diff -u src/sys/net/lagg/if_lagg_lacp.c:1.14 src/sys/net/lagg/if_lagg_lacp.c:1.15
--- src/sys/net/lagg/if_lagg_lacp.c:1.14	Thu Mar 31 01:36:47 2022
+++ src/sys/net/lagg/if_lagg_lacp.c	Thu Mar 31 01:40:34 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg_lacp.c,v 1.14 2022/03/31 01:36:47 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg_lacp.c,v 1.15 2022/03/31 01:40:34 yamaguchi Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.14 2022/03/31 01:36:47 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.15 2022/03/31 01:40:34 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_lagg.h"
@@ -499,6 +499,7 @@ lacp_attach(struct lagg_softc *sc, struc
 
 destroy_lock:
 	mutex_destroy(&lsc->lsc_lock);
+	kmem_free(lsc, sizeof(*lsc));
 
 	return error;
 }



CVS commit: src/sys/net/lagg

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 01:42:40 UTC 2022

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

Log Message:
lagg(4): commonize the error handling


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 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/sys/net/lagg

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 01:42:40 UTC 2022

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

Log Message:
lagg(4): commonize the error handling


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 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.31 src/sys/net/lagg/if_lagg.c:1.32
--- src/sys/net/lagg/if_lagg.c:1.31	Thu Mar 31 01:39:09 2022
+++ src/sys/net/lagg/if_lagg.c	Thu Mar 31 01:42:40 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.31 2022/03/31 01:39:09 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.32 2022/03/31 01:42:40 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.31 2022/03/31 01:39:09 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.32 2022/03/31 01:42:40 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1371,16 +1371,10 @@ lagg_proto_updown(struct lagg_softc *sc,
 
 	pr = var->lv_proto;
 
-	if (is_up) {
-		if (lagg_protos[pr].pr_up != NULL)
-			error = lagg_protos[pr].pr_up(var->lv_psc);
-		else
-			error = 0;
-	} else {
-		if (lagg_protos[pr].pr_down != NULL)
-			lagg_protos[pr].pr_down(var->lv_psc);
-		else
-			error = 0;
+	if (is_up && lagg_protos[pr].pr_up != NULL) {
+		error = lagg_protos[pr].pr_up(var->lv_psc);
+	} else if (!is_up && lagg_protos[pr].pr_down != NULL) {
+		lagg_protos[pr].pr_down(var->lv_psc);
 	}
 
 	lagg_variant_putref(var, &psref);
@@ -1423,35 +1417,43 @@ lagg_proto_portctrl(struct lagg_softc *s
 
 	pr = var->lv_proto;
 
-	error = EPROTONOSUPPORT;
 	switch (ctrl) {
 	case LAGG_PORTCTRL_ALLOC:
-		if (lagg_protos[pr].pr_allocport != NULL)
-			error = lagg_protos[pr].pr_allocport(var->lv_psc, lp);
+		if (lagg_protos[pr].pr_allocport == NULL) {
+			goto nosupport;
+		}
+		error = lagg_protos[pr].pr_allocport(var->lv_psc, lp);
 		break;
 	case LAGG_PORTCTRL_FREE:
-		if (lagg_protos[pr].pr_freeport != NULL) {
-			lagg_protos[pr].pr_freeport(var->lv_psc, lp);
-			error = 0;
+		if (lagg_protos[pr].pr_freeport == NULL) {
+			goto nosupport;
 		}
+		lagg_protos[pr].pr_freeport(var->lv_psc, lp);
 		break;
 	case LAGG_PORTCTRL_START:
-		if (lagg_protos[pr].pr_startport != NULL) {
-			lagg_protos[pr].pr_startport(var->lv_psc, lp);
-			error = 0;
+		if (lagg_protos[pr].pr_startport == NULL) {
+			goto nosupport;
 		}
+		lagg_protos[pr].pr_startport(var->lv_psc, lp);
 		break;
 	case LAGG_PORTCTRL_STOP:
-		if (lagg_protos[pr].pr_stopport != NULL) {
-			lagg_protos[pr].pr_stopport(var->lv_psc, lp);
-			error = 0;
+		if (lagg_protos[pr].pr_stopport == NULL) {
+			goto nosupport;
 		}
+		lagg_protos[pr].pr_stopport(var->lv_psc, lp);
 		break;
+	default:
+		goto nosupport;
 	}
 
 	lagg_variant_putref(var, &psref);
 	curlwp_bindx(bound);
 	return error;
+
+nosupport:
+	lagg_variant_putref(var, &psref);
+	curlwp_bindx(bound);
+	return EPROTONOSUPPORT;
 }
 
 static int



CVS commit: src/sys/net/lagg

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 01:43:48 UTC 2022

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

Log Message:
Added missing NULL check

pointed out by k-goda@IIJ


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 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/sys/net/lagg

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 01:43:48 UTC 2022

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

Log Message:
Added missing NULL check

pointed out by k-goda@IIJ


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 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.32 src/sys/net/lagg/if_lagg.c:1.33
--- src/sys/net/lagg/if_lagg.c:1.32	Thu Mar 31 01:42:40 2022
+++ src/sys/net/lagg/if_lagg.c	Thu Mar 31 01:43:48 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.32 2022/03/31 01:42:40 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.33 2022/03/31 01:43:48 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.32 2022/03/31 01:42:40 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.33 2022/03/31 01:43:48 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2613,6 +2613,10 @@ lagg_get_stats(struct lagg_softc *sc, st
 
 	bound = curlwp_bind();
 	var = lagg_variant_getref(sc, &psref);
+	if (var == NULL) {
+		curlwp_bindx(bound);
+		return ENOENT;
+	}
 
 	resp->lrq_proto = var->lv_proto;
 



CVS commit: src/sys/net/lagg

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 01:46:25 UTC 2022

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

Log Message:
Switch ifp->if_output along with configuring ifp->if_lagg

lagg_port_output stored to ifp->if_output uses ifp->if_lagg.
Therefore, ifp->if_output switches to lagg_port_output after
ifp->if_lagg is configured, and restores in reverse order.

This missing order is pointed out by k-goda@IIJ


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 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.33 src/sys/net/lagg/if_lagg.c:1.34
--- src/sys/net/lagg/if_lagg.c:1.33	Thu Mar 31 01:43:48 2022
+++ src/sys/net/lagg/if_lagg.c	Thu Mar 31 01:46:25 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.33 2022/03/31 01:43:48 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.34 2022/03/31 01:46:25 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.33 2022/03/31 01:43:48 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.34 2022/03/31 01:46:25 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2352,7 +2352,6 @@ lagg_port_setup(struct lagg_softc *sc,
 
 	ifp_port->if_type = if_type;
 	ifp_port->if_ioctl = lagg_port_ioctl;
-	ifp_port->if_output = lagg_port_output;
 
 	iftype_changed = (lp->lp_iftype != ifp_port->if_type);
 
@@ -2388,15 +2387,16 @@ lagg_port_setup(struct lagg_softc *sc,
 	lagg_port_syncmulti(sc, lp);
 	lagg_port_syncvlan(sc, lp);
 
+	IFNET_LOCK(ifp_port);
+	ifp_port->if_output = lagg_port_output;
 	if (stopped) {
-		IFNET_LOCK(ifp_port);
 		if (!ISSET(ifp_port->if_flags, IFF_RUNNING)) {
 			error = if_init(ifp_port);
 			if (error != 0)
 goto remove_port;
 		}
-		IFNET_UNLOCK(ifp_port);
 	}
+	IFNET_UNLOCK(ifp_port);
 
 	lagg_config_promisc(sc, lp);
 	lagg_proto_startport(sc, lp);
@@ -2407,6 +2407,9 @@ lagg_port_setup(struct lagg_softc *sc,
 remove_port:
 	SIMPLEQ_REMOVE(&sc->sc_ports, lp, lagg_port, lp_entry);
 	sc->sc_nports--;
+	IFNET_LOCK(ifp_port);
+	ifp_port->if_output = lp->lp_output;
+	IFNET_UNLOCK(ifp_port);
 	atomic_store_release(&ifp_port->if_lagg, NULL);
 	pserialize_perform(sc->sc_psz);
 	lagg_port_purgemulti(sc, lp);
@@ -2432,7 +2435,6 @@ restore_ipv6lla:
 	ifp_port->if_type = lp->lp_iftype;
 	if (ifp_port->if_ioctl == lagg_port_ioctl)
 		ifp_port->if_ioctl = lp->lp_ioctl;
-	ifp_port->if_output = lp->lp_output;
 
 	IFNET_UNLOCK(ifp_port);
 
@@ -2465,6 +2467,17 @@ lagg_port_teardown(struct lagg_softc *sc
 		return;
 	}
 
+	lagg_proto_stopport(sc, lp);
+
+	IFNET_LOCK(ifp_port);
+	if (ISSET(ifp_port->if_flags, IFF_RUNNING) &&
+	ifp_port->if_init != NULL) {
+		if_stop(ifp_port, 0);
+		stopped = true;
+	}
+	ifp_port->if_output = lp->lp_output;
+	IFNET_UNLOCK(ifp_port);
+
 	SIMPLEQ_REMOVE(&sc->sc_ports, lp, lagg_port, lp_entry);
 	sc->sc_nports--;
 	atomic_store_release(&ifp_port->if_lagg, NULL);
@@ -2473,7 +2486,6 @@ lagg_port_teardown(struct lagg_softc *sc
 	if_linkstate_change_disestablish(ifp_port,
 	lp->lp_linkstate_hook, NULL);
 
-	lagg_proto_stopport(sc, lp);
 	psref_target_destroy(&lp->lp_psref, lagg_port_psref_class);
 
 	lagg_port_purgemulti(sc, lp);
@@ -2481,16 +2493,9 @@ lagg_port_teardown(struct lagg_softc *sc
 	lagg_teardown_lladdr(sc, lp);
 
 	IFNET_LOCK(ifp_port);
-	if (ISSET(ifp_port->if_flags, IFF_RUNNING) &&
-	ifp_port->if_init != NULL) {
-		if_stop(ifp_port, 0);
-		stopped = true;
-	}
-
 	ifp_port->if_type = lp->lp_iftype;
 	if (ifp_port->if_ioctl == lagg_port_ioctl)
 		ifp_port->if_ioctl = lp->lp_ioctl;
-	ifp_port->if_output = lp->lp_output;
 	lagg_teardown_mtu(sc, lp);
 
 	if (stopped) {



CVS commit: src/sys/net/lagg

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 01:46:25 UTC 2022

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

Log Message:
Switch ifp->if_output along with configuring ifp->if_lagg

lagg_port_output stored to ifp->if_output uses ifp->if_lagg.
Therefore, ifp->if_output switches to lagg_port_output after
ifp->if_lagg is configured, and restores in reverse order.

This missing order is pointed out by k-goda@IIJ


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 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/sys/net/lagg

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 01:49:02 UTC 2022

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

Log Message:
Fix missing freeing resource related to protocol

pointed out by k-goda@IIJ


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 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/sys/net/lagg

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 01:49:02 UTC 2022

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

Log Message:
Fix missing freeing resource related to protocol

pointed out by k-goda@IIJ


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 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.34 src/sys/net/lagg/if_lagg.c:1.35
--- src/sys/net/lagg/if_lagg.c:1.34	Thu Mar 31 01:46:25 2022
+++ src/sys/net/lagg/if_lagg.c	Thu Mar 31 01:49:02 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.34 2022/03/31 01:46:25 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.35 2022/03/31 01:49:02 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.34 2022/03/31 01:46:25 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.35 2022/03/31 01:49:02 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2414,6 +2414,7 @@ remove_port:
 	pserialize_perform(sc->sc_psz);
 	lagg_port_purgemulti(sc, lp);
 	lagg_port_purgevlan(sc, lp);
+	lagg_proto_freeport(sc, lp);
 
 teardown_lladdr:
 	IFNET_LOCK(ifp_port);



CVS commit: src/sys/net/lagg

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 01:57:13 UTC 2022

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

Log Message:
lagg(4): remove duplicated bpf_mtap


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 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/sys/net/lagg

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 01:57:13 UTC 2022

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

Log Message:
lagg(4): remove duplicated bpf_mtap


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 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.36 src/sys/net/lagg/if_lagg.c:1.37
--- src/sys/net/lagg/if_lagg.c:1.36	Thu Mar 31 01:53:22 2022
+++ src/sys/net/lagg/if_lagg.c	Thu Mar 31 01:57:13 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.36 2022/03/31 01:53:22 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.37 2022/03/31 01:57:13 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.36 2022/03/31 01:53:22 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.37 2022/03/31 01:57:13 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1094,7 +1094,6 @@ lagg_proto_input(struct lagg_softc *sc, 
 		return NULL;
 	}
 
-	bpf_mtap((struct ifnet *)&sc->sc_if, m, BPF_D_IN);
 	pr = var->lv_proto;
 
 	if (lagg_protos[pr].pr_input != NULL) {



CVS commit: src/sys/net/lagg

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 01:59:05 UTC 2022

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

Log Message:
Added length check for safety

pointed out by k-goda@IIJ


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

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

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 01:59:05 UTC 2022

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

Log Message:
Added length check for safety

pointed out by k-goda@IIJ


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/net/lagg/if_lagg_lacp.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_lacp.c
diff -u src/sys/net/lagg/if_lagg_lacp.c:1.15 src/sys/net/lagg/if_lagg_lacp.c:1.16
--- src/sys/net/lagg/if_lagg_lacp.c:1.15	Thu Mar 31 01:40:34 2022
+++ src/sys/net/lagg/if_lagg_lacp.c	Thu Mar 31 01:59:05 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg_lacp.c,v 1.15 2022/03/31 01:40:34 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg_lacp.c,v 1.16 2022/03/31 01:59:05 yamaguchi Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.15 2022/03/31 01:40:34 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.16 2022/03/31 01:59:05 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_lagg.h"
@@ -430,6 +430,9 @@ tlv_parse(void *vp, size_t len, struct t
 		if (th->tlv_type == TLV_TYPE_TERMINATE)
 			break;
 
+		if (th->tlv_length <= 0)
+			break;
+
 		for (i = 0; list[i].tlv_t != TLV_TYPE_TERMINATE; i++) {
 			if (th->tlv_type != list[i].tlv_t)
 continue;



CVS commit: src/sys/net/lagg

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 02:00:28 UTC 2022

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

Log Message:
fix coding style


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/net/lagg/if_lagg.c
cvs rdiff -u -r1.16 -r1.17 src/sys/net/lagg/if_lagg_lacp.c
cvs rdiff -u -r1.10 -r1.11 src/sys/net/lagg/if_laggproto.h
cvs rdiff -u -r1.4 -r1.5 src/sys/net/lagg/if_laggvar.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

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 02:00:28 UTC 2022

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

Log Message:
fix coding style


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/net/lagg/if_lagg.c
cvs rdiff -u -r1.16 -r1.17 src/sys/net/lagg/if_lagg_lacp.c
cvs rdiff -u -r1.10 -r1.11 src/sys/net/lagg/if_laggproto.h
cvs rdiff -u -r1.4 -r1.5 src/sys/net/lagg/if_laggvar.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.37 src/sys/net/lagg/if_lagg.c:1.38
--- src/sys/net/lagg/if_lagg.c:1.37	Thu Mar 31 01:57:13 2022
+++ src/sys/net/lagg/if_lagg.c	Thu Mar 31 02:00:27 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.37 2022/03/31 01:57:13 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.38 2022/03/31 02:00:27 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.37 2022/03/31 01:57:13 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.38 2022/03/31 02:00:27 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -283,9 +283,8 @@ lagg_in6_ifdetach(struct ifnet *ifp)
 
 #ifdef INET6
 	KERNEL_LOCK_UNLESS_NET_MPSAFE();
-	if (in6_present) {
+	if (in6_present)
 		in6_ifdetach(ifp);
-	}
 	KERNEL_UNLOCK_UNLESS_NET_MPSAFE();
 #endif
 }
@@ -761,9 +760,8 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd
 			/* set every port back to the original MTU */
 			ifr->ifr_mtu = ifp->if_mtu;
 			LAGG_PORTS_FOREACH(sc, lp) {
-if (lp->lp_ioctl != NULL) {
+if (lp->lp_ioctl != NULL)
 	lagg_lp_ioctl(lp, cmd, (void *)ifr);
-}
 			}
 		}
 		LAGG_UNLOCK(sc);
@@ -907,17 +905,16 @@ lagg_hashmbuf(struct lagg_softc *sc, str
 } while(0)
 
 	eh = lagg_m_extract(m, 0, sizeof(*eh), &buf);
-	if (eh == NULL) {
+	if (eh == NULL)
 		goto out;
-	}
+
 	off = ETHER_HDR_LEN;
 	etype = ntohs(eh->ether_type);
 
 	if (etype == ETHERTYPE_VLAN) {
 		evl = lagg_m_extract(m, 0, sizeof(*evl), &buf);
-		if (evl == NULL) {
+		if (evl == NULL)
 			goto out;
-		}
 
 		vlantag = ntohs(evl->evl_tag);
 		etype = ntohs(evl->evl_proto);
@@ -937,9 +934,8 @@ lagg_hashmbuf(struct lagg_softc *sc, str
 	switch (etype) {
 	case ETHERTYPE_IP:
 		ip = lagg_m_extract(m, off, sizeof(*ip), &buf);
-		if (ip == NULL) {
+		if (ip == NULL)
 			goto out;
-		}
 
 		if (sc->sc_hash_ipaddr) {
 			LAGG_HASH_ADD(&hash_src, ip->ip_src);
@@ -951,9 +947,8 @@ lagg_hashmbuf(struct lagg_softc *sc, str
 		break;
 	case ETHERTYPE_IPV6:
 		ip6 = lagg_m_extract(m, off, sizeof(*ip6), &buf);
-		if (ip6 == NULL) {
+		if (ip6 == NULL)
 			goto out;
-		}
 
 		if (sc->sc_hash_ip6addr) {
 			LAGG_HASH_ADD(&hash_src, ip6->ip6_src);
@@ -972,9 +967,8 @@ lagg_hashmbuf(struct lagg_softc *sc, str
 	switch (proto) {
 	case IPPROTO_TCP:
 		th = lagg_m_extract(m, off, sizeof(*th), &buf);
-		if (th == NULL) {
+		if (th == NULL)
 			goto out;
-		}
 
 		if (sc->sc_hash_tcp) {
 			LAGG_HASH_ADD(&hash_src, th->th_sport);
@@ -983,9 +977,8 @@ lagg_hashmbuf(struct lagg_softc *sc, str
 		break;
 	case IPPROTO_UDP:
 		uh = lagg_m_extract(m, off, sizeof(*uh), &buf);
-		if (uh == NULL) {
+		if (uh == NULL)
 			goto out;
-		}
 
 		if (sc->sc_hash_udp) {
 			LAGG_HASH_ADD(&hash_src, uh->uh_sport);
@@ -1149,9 +1142,8 @@ lagg_input_ethernet(struct ifnet *ifp_po
 	}
 
 	if (pfil_run_hooks(ifp_port->if_pfil, &m,
-	ifp_port, PFIL_IN) != 0) {
+	ifp_port, PFIL_IN) != 0)
 		goto out;
-	}
 
 	m = lagg_proto_input(lp->lp_softc, lp, m);
 	if (m != NULL) {
@@ -2036,9 +2028,8 @@ lagg_setup_mtu(struct lagg_softc *sc, st
 		ifr.ifr_mtu = sc->sc_if.if_mtu;
 	}
 
-	if (sc->sc_if.if_mtu != (uint64_t)ifr.ifr_mtu) {
+	if (sc->sc_if.if_mtu != (uint64_t)ifr.ifr_mtu)
 		sc->sc_if.if_mtu = ifr.ifr_mtu;
-	}
 
 	if (lp->lp_mtu != (uint64_t)ifr.ifr_mtu) {
 		if (lp->lp_ioctl == NULL) {
@@ -2072,9 +2063,8 @@ lagg_teardown_mtu(struct lagg_softc *sc,
 	ifp_port = lp->lp_ifp;
 	KASSERT(IFNET_LOCKED(ifp_port));
 
-	if (SIMPLEQ_EMPTY(&sc->sc_ports)) {
+	if (SIMPLEQ_EMPTY(&sc->sc_ports))
 		sc->sc_if.if_mtu = 0;
-	}
 
 	if (ifp_port->if_mtu != lp->lp_mtu) {
 		memset(&ifr, 0, sizeof(ifr));
@@ -2198,9 +2188,8 @@ lagg_setup_lladdr(struct lagg_softc *sc,
 
 	KASSERT(LAGG_LOCKED(sc));
 
-	if (lagg_lladdr_equal(sc->sc_lladdr, sc->sc_lladdr_rand)) {
+	if (lagg_lladdr_equal(sc->sc_lladdr, sc->sc_lladdr_rand))
 		lagg_lladdr_cpy(sc->sc_lladdr, lp->lp_lladdr);
-	}
 }
 
 static void
@@ -2305,9 +2294,8 @@ lagg_port_setup(struct lagg_softc *sc,
 		return EINVAL;
 	}
 
-	if (sc->sc_nports > LAGG_MAX_PORTS) {
+	if (sc->sc_nports > LAGG_MAX_PORTS)
 		return ENOSPC;
-	}
 
 	if (ifp_port->if_lagg != NULL) {
 		lp = (struct lagg_port *)ifp_port->if_lagg;
@@ -2364,13 +2352,12 @@ lagg_port_setup(struct lagg_softc *sc,
 	lagg_in6_ifdetach(ifp_port);
 
 	error = lagg_setup_mtu(sc, lp);
-	if (error != 0)

CVS commit: src/sys/net/lagg

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 02:04:50 UTC 2022

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

Log Message:
handle LACPDU and MarkerDU in thread context

Those handler move from softint to thread context to
improve throughput in high load, because they hold LACP_LOCK.

pointed out by k-goda@IIJ


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/net/lagg/if_lagg_lacp.c
cvs rdiff -u -r1.3 -r1.4 src/sys/net/lagg/if_lagg_lacp.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_lacp.c
diff -u src/sys/net/lagg/if_lagg_lacp.c:1.17 src/sys/net/lagg/if_lagg_lacp.c:1.18
--- src/sys/net/lagg/if_lagg_lacp.c:1.17	Thu Mar 31 02:00:27 2022
+++ src/sys/net/lagg/if_lagg_lacp.c	Thu Mar 31 02:04:50 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg_lacp.c,v 1.17 2022/03/31 02:00:27 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg_lacp.c,v 1.18 2022/03/31 02:04:50 yamaguchi Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.17 2022/03/31 02:00:27 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.18 2022/03/31 02:04:50 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_lagg.h"
@@ -42,6 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -163,13 +164,18 @@ struct lacp_softc {
  lsc_aggregators;
 	struct workqueue	*lsc_workq;
 	struct lagg_work	 lsc_work_tick;
+	struct lagg_work	 lsc_work_rcvdu;
 	callout_t		 lsc_tick;
+	pcq_t			*lsc_du_q;
 
 	char			 lsc_evgroup[32];
 	struct evcnt		 lsc_mgethdr_failed;
 	struct evcnt		 lsc_mpullup_failed;
 	struct evcnt		 lsc_badlacpdu;
 	struct evcnt		 lsc_badmarkerdu;
+	struct evcnt		 lsc_norcvif;
+	struct evcnt		 lsc_nolaggport;
+	struct evcnt		 lsc_duq_nospc;
 
 	bool			 lsc_optimistic;
 	bool			 lsc_stop_lacpdu;
@@ -277,6 +283,7 @@ static void	lacp_sm_ptx_timer(struct lac
 static void	lacp_sm_ptx_schedule(struct lacp_port *);
 static void	lacp_sm_ptx_update_timeout(struct lacp_port *, uint8_t);
 
+static void	lacp_rcvdu_work(struct lagg_work *, void *);
 static void	lacp_marker_work(struct lagg_work *, void *);
 static void	lacp_dump_lacpdutlv(const struct lacpdu_peerinfo *,
 		const struct lacpdu_peerinfo *,
@@ -463,6 +470,12 @@ lacp_attach(struct lagg_softc *sc, struc
 	if (lsc == NULL)
 		return ENOMEM;
 
+	lsc->lsc_du_q = pcq_create(LACP_RCVDU_LIMIT, KM_NOSLEEP);
+	if (lsc->lsc_du_q == NULL) {
+		error = ENOMEM;
+		goto free_lsc;
+	}
+
 	mutex_init(&lsc->lsc_lock, MUTEX_DEFAULT, IPL_SOFTNET);
 	lsc->lsc_softc = sc;
 	lsc->lsc_key = htons(if_get_index(&sc->sc_if));
@@ -473,6 +486,8 @@ lacp_attach(struct lagg_softc *sc, struc
 	TAILQ_INIT(&lsc->lsc_aggregators);
 
 	lagg_work_set(&lsc->lsc_work_tick, lacp_tick_work, lsc);
+	lagg_work_set(&lsc->lsc_work_rcvdu, lacp_rcvdu_work, lsc);
+
 	snprintf(xnamebuf, sizeof(xnamebuf), "%s.lacp",
 	sc->sc_if.if_xname);
 	lsc->lsc_workq = lagg_workq_create(xnamebuf,
@@ -494,14 +509,18 @@ lacp_attach(struct lagg_softc *sc, struc
 	lacp_evcnt_attach(lsc, &lsc->lsc_mpullup_failed, "m_pullup failed");
 	lacp_evcnt_attach(lsc, &lsc->lsc_badlacpdu, "Bad LACPDU recieved");
 	lacp_evcnt_attach(lsc, &lsc->lsc_badmarkerdu, "Bad MarkerDU recieved");
+	lacp_evcnt_attach(lsc, &lsc->lsc_norcvif, "No received interface");
+	lacp_evcnt_attach(lsc, &lsc->lsc_nolaggport, "No lagg context");
+	lacp_evcnt_attach(lsc, &lsc->lsc_duq_nospc, "No space left on queues");
 
 	if_link_state_change(&sc->sc_if, LINK_STATE_DOWN);
 
 	*lscp = (struct lagg_proto_softc *)lsc;
 	return 0;
-
 destroy_lock:
 	mutex_destroy(&lsc->lsc_lock);
+	pcq_destroy(lsc->lsc_du_q);
+free_lsc:
 	kmem_free(lsc, sizeof(*lsc));
 
 	return error;
@@ -519,13 +538,18 @@ lacp_detach(struct lagg_proto_softc *xls
 
 	lacp_down(xlsc);
 
+	lagg_workq_wait(lsc->lsc_workq, &lsc->lsc_work_rcvdu);
 	evcnt_detach(&lsc->lsc_mgethdr_failed);
 	evcnt_detach(&lsc->lsc_mpullup_failed);
 	evcnt_detach(&lsc->lsc_badlacpdu);
 	evcnt_detach(&lsc->lsc_badmarkerdu);
+	evcnt_detach(&lsc->lsc_norcvif);
+	evcnt_detach(&lsc->lsc_nolaggport);
+	evcnt_detach(&lsc->lsc_duq_nospc);
 	lagg_workq_destroy(lsc->lsc_workq);
 	pserialize_destroy(lsc->lsc_psz);
 	mutex_destroy(&lsc->lsc_lock);
+	pcq_destroy(lsc->lsc_du_q);
 	kmem_free(lsc, sizeof(*lsc));
 }
 
@@ -1223,12 +1247,17 @@ lacp_input(struct lagg_proto_softc *xlsc
 
 		m_copydata(m, sizeof(struct ether_header),
 		sizeof(subtype), &subtype);
+
 		switch (subtype) {
 		case SLOWPROTOCOLS_SUBTYPE_LACP:
-			(void)lacp_pdu_input(lsc, lacpp, m);
-			return NULL;
 		case SLOWPROTOCOLS_SUBTYPE_MARKER:
-			(void)lacp_marker_input(lsc, lacpp, m);
+			if (pcq_put(lsc->lsc_du_q, (void *)m)) {
+lagg_workq_add(lsc->lsc_workq,
+&lsc->lsc_work_rcvdu);
+			} else {
+m_freem(m);
+lsc->lsc_duq_nospc

CVS commit: src/sys/net/lagg

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 02:04:50 UTC 2022

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

Log Message:
handle LACPDU and MarkerDU in thread context

Those handler move from softint to thread context to
improve throughput in high load, because they hold LACP_LOCK.

pointed out by k-goda@IIJ


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/net/lagg/if_lagg_lacp.c
cvs rdiff -u -r1.3 -r1.4 src/sys/net/lagg/if_lagg_lacp.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

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 02:07:26 UTC 2022

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

Log Message:
lagg(4): use KASSERT


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/net/lagg/if_laggproto.c

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

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 02:07:26 UTC 2022

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

Log Message:
lagg(4): use KASSERT


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/net/lagg/if_laggproto.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_laggproto.c
diff -u src/sys/net/lagg/if_laggproto.c:1.2 src/sys/net/lagg/if_laggproto.c:1.3
--- src/sys/net/lagg/if_laggproto.c:1.2	Mon May 24 13:43:21 2021
+++ src/sys/net/lagg/if_laggproto.c	Thu Mar 31 02:07:26 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_laggproto.c,v 1.2 2021/05/24 13:43:21 thorpej Exp $	*/
+/*	$NetBSD: if_laggproto.c,v 1.3 2022/03/31 02:07:26 yamaguchi Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_laggproto.c,v 1.2 2021/05/24 13:43:21 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_laggproto.c,v 1.3 2022/03/31 02:07:26 yamaguchi Exp $");
 
 #include 
 #include 
@@ -324,8 +324,8 @@ lagg_common_stopport(struct lagg_proto_s
 	lagg_proto_remove_port(psc, pport);
 
 	if (pport->lpp_active) {
-		if (psc->psc_nactports > 0)
-			psc->psc_nactports--;
+		KASSERT(psc->psc_nactports > 0);
+		psc->psc_nactports--;
 
 		if (psc->psc_nactports == 0) {
 			ifp = &psc->psc_softc->sc_if;
@@ -355,8 +355,8 @@ lagg_common_linkstate(struct lagg_proto_
 		if (psc->psc_nactports == 1)
 			if_link_state_change(ifp, LINK_STATE_UP);
 	} else {
-		if (psc->psc_nactports > 0)
-			psc->psc_nactports--;
+		KASSERT(psc->psc_nactports > 0);
+		psc->psc_nactports--;
 
 		if (psc->psc_nactports == 0)
 			if_link_state_change(ifp, LINK_STATE_DOWN);



CVS commit: src/sys/net/lagg

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 03:04:04 UTC 2022

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

Log Message:
update state of aggregator on multi-speed changing


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/net/lagg/if_lagg_lacp.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_lacp.c
diff -u src/sys/net/lagg/if_lagg_lacp.c:1.18 src/sys/net/lagg/if_lagg_lacp.c:1.19
--- src/sys/net/lagg/if_lagg_lacp.c:1.18	Thu Mar 31 02:04:50 2022
+++ src/sys/net/lagg/if_lagg_lacp.c	Thu Mar 31 03:04:04 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg_lacp.c,v 1.18 2022/03/31 02:04:50 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg_lacp.c,v 1.19 2022/03/31 03:04:04 yamaguchi Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.18 2022/03/31 02:04:50 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.19 2022/03/31 03:04:04 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_lagg.h"
@@ -947,8 +947,14 @@ lacp_ioctl(struct lagg_proto_softc *xlsc
 			lsc->lsc_dump_du = set;
 		if (ISSET(rplacp->flags, LAGGREQLACP_STOPDU))
 			lsc->lsc_stop_lacpdu = set;
-		if (ISSET(rplacp->flags, LAGGREQLACP_MULTILS))
+
+		if (ISSET(rplacp->flags, LAGGREQLACP_MULTILS) &&
+		lsc->lsc_multi_linkspeed != set) {
 			lsc->lsc_multi_linkspeed = set;
+			TAILQ_FOREACH(la, &lsc->lsc_aggregators, la_q) {
+lacp_selected_update(lsc, la);
+			}
+		}
 
 		LACP_UNLOCK(lsc);
 		break;



CVS commit: src/sys/net/lagg

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 03:04:04 UTC 2022

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

Log Message:
update state of aggregator on multi-speed changing


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/net/lagg/if_lagg_lacp.c

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

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 03:05:41 UTC 2022

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

Log Message:
set active when the port is distributing


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

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

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 03:05:41 UTC 2022

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

Log Message:
set active when the port is distributing


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/net/lagg/if_laggproto.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_laggproto.c
diff -u src/sys/net/lagg/if_laggproto.c:1.3 src/sys/net/lagg/if_laggproto.c:1.4
--- src/sys/net/lagg/if_laggproto.c:1.3	Thu Mar 31 02:07:26 2022
+++ src/sys/net/lagg/if_laggproto.c	Thu Mar 31 03:05:41 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_laggproto.c,v 1.3 2022/03/31 02:07:26 yamaguchi Exp $	*/
+/*	$NetBSD: if_laggproto.c,v 1.4 2022/03/31 03:05:41 yamaguchi Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_laggproto.c,v 1.3 2022/03/31 02:07:26 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_laggproto.c,v 1.4 2022/03/31 03:05:41 yamaguchi Exp $");
 
 #include 
 #include 
@@ -470,16 +470,19 @@ lagg_fail_portstat(struct lagg_proto_sof
 	pport = lp->lp_proto_ctx;
 
 	if (pport->lpp_active) {
-		SET(resp->rp_flags, LAGG_PORT_ACTIVE);
-		if (fovr->fo_rx_all) {
-			SET(resp->rp_flags, LAGG_PORT_COLLECTING);
-		}
-
 		lp0 = lagg_link_active(psc, NULL, &psref);
 		if (lp0 == lp) {
 			SET(resp->rp_flags,
-			LAGG_PORT_COLLECTING | LAGG_PORT_DISTRIBUTING);
+			(LAGG_PORT_ACTIVE |
+			LAGG_PORT_COLLECTING |
+			LAGG_PORT_DISTRIBUTING));
+		} else {
+			if (fovr->fo_rx_all) {
+SET(resp->rp_flags,
+LAGG_PORT_COLLECTING);
+			}
 		}
+
 		if (lp0 != NULL)
 			lagg_port_putref(lp0, &psref);
 	}



CVS commit: src/sys/net/lagg

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 03:07:05 UTC 2022

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

Log Message:
Set flags related to MTU on adding l2tp(4) to lagg(4)


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 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/sys/net/lagg

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 03:07:05 UTC 2022

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

Log Message:
Set flags related to MTU on adding l2tp(4) to lagg(4)


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 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.38 src/sys/net/lagg/if_lagg.c:1.39
--- src/sys/net/lagg/if_lagg.c:1.38	Thu Mar 31 02:00:27 2022
+++ src/sys/net/lagg/if_lagg.c	Thu Mar 31 03:07:05 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.38 2022/03/31 02:00:27 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.39 2022/03/31 03:07:05 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.38 2022/03/31 02:00:27 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.39 2022/03/31 03:07:05 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1949,11 +1949,17 @@ lagg_ethercap_update(struct lagg_softc *
 	ena = ~0;
 	cap = ~0;
 	LAGG_PORTS_FOREACH(sc, lp) {
-		if (lp->lp_iftype == IFT_ETHER) {
+		switch (lp->lp_iftype) {
+		case IFT_ETHER:
 			ec = (struct ethercom *)lp->lp_ifp;
 			ena &= ec->ec_capenable;
 			cap &= ec->ec_capabilities;
-		} else {
+			break;
+		case IFT_L2TP:
+			ena &= (ETHERCAP_VLAN_MTU | ETHERCAP_JUMBO_MTU);
+			cap &= (ETHERCAP_VLAN_MTU | ETHERCAP_JUMBO_MTU);
+			break;
+		default:
 			ena = 0;
 			cap = 0;
 		}



CVS commit: src/sys/net/lagg

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 03:10:59 UTC 2022

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

Log Message:
added log when ifpromisc is failed


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/net/lagg/if_lagg.c
cvs rdiff -u -r1.11 -r1.12 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

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 03:10:59 UTC 2022

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

Log Message:
added log when ifpromisc is failed


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/net/lagg/if_lagg.c
cvs rdiff -u -r1.11 -r1.12 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.39 src/sys/net/lagg/if_lagg.c:1.40
--- src/sys/net/lagg/if_lagg.c:1.39	Thu Mar 31 03:07:05 2022
+++ src/sys/net/lagg/if_lagg.c	Thu Mar 31 03:10:59 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.39 2022/03/31 03:07:05 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.40 2022/03/31 03:10:59 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.39 2022/03/31 03:07:05 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.40 2022/03/31 03:10:59 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -181,7 +181,7 @@ static int	lagg_delport_all(struct lagg_
 static int	lagg_port_ioctl(struct ifnet *, u_long, void *);
 static int	lagg_port_output(struct ifnet *, struct mbuf *,
 		const struct sockaddr *, const struct rtentry *);
-static int	lagg_config_promisc(struct lagg_softc *, struct lagg_port *);
+static void	lagg_config_promisc(struct lagg_softc *, struct lagg_port *);
 static void	lagg_unconfig_promisc(struct lagg_softc *, struct lagg_port *);
 static struct lagg_variant *
 		lagg_variant_getref(struct lagg_softc *, struct psref *);
@@ -2130,10 +2130,6 @@ lagg_port_setsadl(struct lagg_port *lp, 
 		break;
 	default:
 		if_alloc_sadl(ifp_port);
-		if (lp->lp_promisc == false) {
-			ifpromisc_locked(ifp_port, 1);
-			lp->lp_promisc = true;
-		}
 		break;
 	}
 }
@@ -2179,11 +2175,6 @@ lagg_port_unsetsadl(struct lagg_port *lp
 		/* 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;
 	}
 }
@@ -2647,39 +2638,65 @@ lagg_get_stats(struct lagg_softc *sc, st
 	return 0;
 }
 
-static int
+static void
 lagg_config_promisc(struct lagg_softc *sc, struct lagg_port *lp)
 {
-	struct ifnet *ifp;
-	uint64_t chg_flags;
+	struct ifnet *ifp, *ifp_port;
 	int error;
+	bool promisc;
+
+	KASSERT(LAGG_LOCKED(sc));
 
-	error = 0;
 	ifp = &sc->sc_if;
-	chg_flags = ifp->if_flags ^ lp->lp_ifflags;
+	ifp_port = lp->lp_ifp;
 
-	if (ISSET(chg_flags, IFF_PROMISC)) {
-		error = ifpromisc(lp->lp_ifp,
-		ISSET(ifp->if_flags, IFF_PROMISC) ? 1 : 0);
-		if (error == 0) {
-			lp->lp_ifflags ^= IFF_PROMISC;
-		}
+	if (lp->lp_iftype == IFT_ETHER) {
+		promisc = ISSET(ifp->if_flags, IFF_PROMISC) ?
+		true : false;
+	} else {
+		promisc = true;
 	}
 
-	return error;
+	if (lp->lp_promisc == promisc)
+		return;
+
+	error = ifpromisc(ifp_port, promisc ? 1 : 0);
+	if (error == ENETRESET) {
+		error = ifp_port->if_init(ifp_port);
+	}
+
+	if (error == 0) {
+		lp->lp_promisc = promisc;
+	} else {
+		lagg_log(sc, LOG_WARNING,
+		"couldn't %s promisc on %s\n",
+		promisc ? "set" : "unset",
+		ifp_port->if_xname);
+	}
 }
 
 static void
 lagg_unconfig_promisc(struct lagg_softc *sc, struct lagg_port *lp)
 {
+	struct ifnet *ifp_port;
 	int error;
 
-	if (ISSET(lp->lp_ifflags, IFF_PROMISC)) {
-		error = ifpromisc(lp->lp_ifp, 0);
-		if (error != 0) {
-			lagg_log(sc, LOG_DEBUG,
-			"couldn't unset promiscuous mode");
-		}
+	KASSERT(LAGG_LOCKED(sc));
+
+	ifp_port = lp->lp_ifp;
+
+	if (lp->lp_promisc == false)
+		return;
+
+	error = ifpromisc(ifp_port, 0);
+	if (error == ENETRESET) {
+		error = ifp_port->if_init(ifp_port);
+	}
+
+	if (error != 0) {
+		lagg_log(sc, LOG_WARNING,
+		"couldn't unset promisc on %s\n",
+		ifp_port->if_xname);
 	}
 }
 

Index: src/sys/net/lagg/if_laggproto.h
diff -u src/sys/net/lagg/if_laggproto.h:1.11 src/sys/net/lagg/if_laggproto.h:1.12
--- src/sys/net/lagg/if_laggproto.h:1.11	Thu Mar 31 02:00:27 2022
+++ src/sys/net/lagg/if_laggproto.h	Thu Mar 31 03:10:59 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_laggproto.h,v 1.11 2022/03/31 02:00:27 yamaguchi Exp $	*/
+/*	$NetBSD: if_laggproto.h,v 1.12 2022/03/31 03:10:59 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2021 Internet Initiative Japan Inc.
@@ -77,7 +77,6 @@ struct lagg_port {
 
 	u_char			 lp_iftype;
 	uint8_t			 lp_lladdr[ETHER_ADDR_LEN];
-	unsigned short		 lp_ifflags;
 	int			 lp_eccapenable;
 	uint64_t		 lp_ifcapenable;
 	uint64_t		 lp_mtu;



CVS commit: src/sys/net/lagg

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 03:12:31 UTC 2022

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

Log Message:
Make lagg interface specified "laggproto none" able to up


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/net/lagg/if_lagg.c
cvs rdiff -u -r1.4 -r1.5 src/sys/net/lagg/if_laggproto.c
cvs rdiff -u -r1.12 -r1.13 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

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 03:12:31 UTC 2022

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

Log Message:
Make lagg interface specified "laggproto none" able to up


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/net/lagg/if_lagg.c
cvs rdiff -u -r1.4 -r1.5 src/sys/net/lagg/if_laggproto.c
cvs rdiff -u -r1.12 -r1.13 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.40 src/sys/net/lagg/if_lagg.c:1.41
--- src/sys/net/lagg/if_lagg.c:1.40	Thu Mar 31 03:10:59 2022
+++ src/sys/net/lagg/if_lagg.c	Thu Mar 31 03:12:31 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.40 2022/03/31 03:10:59 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.41 2022/03/31 03:12:31 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.40 2022/03/31 03:10:59 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.41 2022/03/31 03:12:31 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -86,7 +86,6 @@ static const struct lagg_proto lagg_prot
 	[LAGG_PROTO_NONE] = {
 		.pr_num = LAGG_PROTO_NONE,
 		.pr_attach = lagg_none_attach,
-		.pr_up = lagg_none_up,
 	},
 	[LAGG_PROTO_LACP] = {
 		.pr_num = LAGG_PROTO_LACP,

Index: src/sys/net/lagg/if_laggproto.c
diff -u src/sys/net/lagg/if_laggproto.c:1.4 src/sys/net/lagg/if_laggproto.c:1.5
--- src/sys/net/lagg/if_laggproto.c:1.4	Thu Mar 31 03:05:41 2022
+++ src/sys/net/lagg/if_laggproto.c	Thu Mar 31 03:12:31 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_laggproto.c,v 1.4 2022/03/31 03:05:41 yamaguchi Exp $	*/
+/*	$NetBSD: if_laggproto.c,v 1.5 2022/03/31 03:12:31 yamaguchi Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_laggproto.c,v 1.4 2022/03/31 03:05:41 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_laggproto.c,v 1.5 2022/03/31 03:12:31 yamaguchi Exp $");
 
 #include 
 #include 
@@ -381,13 +381,6 @@ lagg_none_attach(struct lagg_softc *sc, 
 }
 
 int
-lagg_none_up(struct lagg_proto_softc *psc __unused)
-{
-
-	return EBUSY;
-}
-
-int
 lagg_fail_attach(struct lagg_softc *sc, struct lagg_proto_softc **xpsc)
 {
 	struct lagg_proto_softc *psc;

Index: src/sys/net/lagg/if_laggproto.h
diff -u src/sys/net/lagg/if_laggproto.h:1.12 src/sys/net/lagg/if_laggproto.h:1.13
--- src/sys/net/lagg/if_laggproto.h:1.12	Thu Mar 31 03:10:59 2022
+++ src/sys/net/lagg/if_laggproto.h	Thu Mar 31 03:12:31 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_laggproto.h,v 1.12 2022/03/31 03:10:59 yamaguchi Exp $	*/
+/*	$NetBSD: if_laggproto.h,v 1.13 2022/03/31 03:12:31 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2021 Internet Initiative Japan Inc.
@@ -282,7 +282,6 @@ void		lagg_common_linkstate(struct lagg_
 
 int		lagg_none_attach(struct lagg_softc *,
 		struct lagg_proto_softc **);
-int		lagg_none_up(struct lagg_proto_softc *);
 
 int		lagg_fail_attach(struct lagg_softc *,
 		struct lagg_proto_softc **);



CVS commit: src/sys/net/lagg

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 03:15:15 UTC 2022

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

Log Message:
Use addlog(4) for putting 2 messages to one line


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/net/lagg/if_lagg.c
cvs rdiff -u -r1.19 -r1.20 src/sys/net/lagg/if_lagg_lacp.c
cvs rdiff -u -r1.13 -r1.14 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

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 03:15:15 UTC 2022

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

Log Message:
Use addlog(4) for putting 2 messages to one line


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/net/lagg/if_lagg.c
cvs rdiff -u -r1.19 -r1.20 src/sys/net/lagg/if_lagg_lacp.c
cvs rdiff -u -r1.13 -r1.14 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.41 src/sys/net/lagg/if_lagg.c:1.42
--- src/sys/net/lagg/if_lagg.c:1.41	Thu Mar 31 03:12:31 2022
+++ src/sys/net/lagg/if_lagg.c	Thu Mar 31 03:15:15 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.41 2022/03/31 03:12:31 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.42 2022/03/31 03:15:15 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.41 2022/03/31 03:12:31 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.42 2022/03/31 03:15:15 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -244,15 +244,6 @@ lagg_sizeof_softc(enum lagg_iftypes ift)
 	return s;
 }
 
-static bool
-lagg_debug_enable(struct lagg_softc *sc)
-{
-	if (__predict_false(ISSET(sc->sc_if.if_flags, IFF_DEBUG)))
-		return true;
-
-	return false;
-}
-
 static void
 lagg_evcnt_attach(struct lagg_softc *sc,
 struct evcnt *ev, const char *name)
@@ -743,7 +734,7 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd
 			error = lagg_lp_ioctl(lp, cmd, (void *)ifr);
 
 			if (error != 0) {
-lagg_log(sc, LOG_ERR,
+LAGG_LOG(sc, LOG_ERR,
 "failed to change MTU to %d on port %s, "
 "reverting all ports to original "
 "MTU(%" PRIu64 ")\n",
@@ -798,65 +789,65 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd
 static int
 lagg_setup_sysctls(struct lagg_softc *sc)
 {
-	struct sysctllog **log;
+	struct sysctllog **slog;
 	const struct sysctlnode **rnode, *hashnode;
 	const char *ifname;
 	int error;
 
-	log = &sc->sc_sysctllog;
+	slog = &sc->sc_sysctllog;
 	rnode = &sc->sc_sysctlnode;
 	ifname = sc->sc_if.if_xname;
 
-	error = sysctl_createv(log, 0, NULL, rnode,
+	error = sysctl_createv(slog, 0, NULL, rnode,
 	CTLFLAG_PERMANENT, CTLTYPE_NODE, ifname,
 	SYSCTL_DESCR("lagg information and settings"),
 	NULL, 0, NULL, 0, CTL_NET, CTL_CREATE, CTL_EOL);
 	if (error != 0)
 		goto done;
 
-	error = sysctl_createv(log, 0, rnode, &hashnode,
+	error = sysctl_createv(slog, 0, rnode, &hashnode,
 	CTLFLAG_PERMANENT, CTLTYPE_NODE, "hash",
 	SYSCTL_DESCR("hash calculation settings"),
 	NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL);
 	if (error != 0)
 		goto done;
 
-	error = sysctl_createv(log, 0, &hashnode, NULL,
+	error = sysctl_createv(slog, 0, &hashnode, NULL,
 	CTLFLAG_READWRITE, CTLTYPE_BOOL, "macaddr",
 	SYSCTL_DESCR("use src/dst mac addresses"),
 	NULL, 0, &sc->sc_hash_mac, 0, CTL_CREATE, CTL_EOL);
 	if (error != 0)
 		goto done;
 
-	error = sysctl_createv(log, 0, &hashnode, NULL,
+	error = sysctl_createv(slog, 0, &hashnode, NULL,
 	CTLFLAG_READWRITE, CTLTYPE_BOOL, "ipaddr",
 	SYSCTL_DESCR("use src/dst IPv4 addresses"),
 	NULL, 0, &sc->sc_hash_ipaddr, 0, CTL_CREATE, CTL_EOL);
 	if (error != 0)
 		goto done;
 
-	error = sysctl_createv(log, 0, &hashnode, NULL,
+	error = sysctl_createv(slog, 0, &hashnode, NULL,
 	CTLFLAG_READWRITE, CTLTYPE_BOOL, "ip6addr",
 	SYSCTL_DESCR("use src/dst IPv6 addresses"),
 	NULL, 0, &sc->sc_hash_ip6addr, 0, CTL_CREATE, CTL_EOL);
 	if (error != 0)
 		goto done;
 
-	error = sysctl_createv(log, 0, &hashnode, NULL,
+	error = sysctl_createv(slog, 0, &hashnode, NULL,
 	CTLFLAG_READWRITE, CTLTYPE_BOOL, "tcp",
 	SYSCTL_DESCR("use TCP src/dst port"),
 	NULL, 0, &sc->sc_hash_tcp, 0, CTL_CREATE, CTL_EOL);
 	if (error != 0)
 		goto done;
 
-	error = sysctl_createv(log, 0, &hashnode, NULL,
+	error = sysctl_createv(slog, 0, &hashnode, NULL,
 	   CTLFLAG_READWRITE, CTLTYPE_BOOL, "udp",
 	   SYSCTL_DESCR("use UDP src/dst port"),
 	   NULL, 0, &sc->sc_hash_udp, 0, CTL_CREATE, CTL_EOL);
 done:
 	if (error != 0) {
-		lagg_log(sc, LOG_ERR, "unable to create sysctl node\n");
-		sysctl_teardown(log);
+		LAGG_LOG(sc, LOG_ERR, "unable to create sysctl node\n");
+		sysctl_teardown(slog);
 	}
 
 	return error;
@@ -1243,7 +1234,7 @@ lagg_vlan_cb(struct ethercom *ec, uint16
 	LAGG_PORTS_FOREACH(sc, lp) {
 		error = lagg_port_vlan_cb(lp, lvt, set);
 		if (error != 0) {
-			lagg_log(sc, LOG_WARNING,
+			LAGG_LOG(sc, LOG_WARNING,
 			"%s failed to configure vlan on %d\n",
 			lp->lp_ifp->if_xname, error);
 		}
@@ -1763,7 +1754,7 @@ lagg_port_vlan(struct lagg_softc *sc, st
 	TAILQ_FOREACH(lvt, &sc->sc_vtags, lvt_entry) {
 		error = lagg_port_vlan_cb(lp, lvt, set);
 		if (error != 0) {
-			lagg_log(sc, LOG_WARNING,
+			LAGG_LOG(s

CVS commit: src/sys/net/lagg

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 03:21:33 UTC 2022

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

Log Message:
Use ether_ioctl to change mtu of lagg(4)


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 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/sys/net/lagg

2022-03-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 03:21:33 UTC 2022

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

Log Message:
Use ether_ioctl to change mtu of lagg(4)


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 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.42 src/sys/net/lagg/if_lagg.c:1.43
--- src/sys/net/lagg/if_lagg.c:1.42	Thu Mar 31 03:15:15 2022
+++ src/sys/net/lagg/if_lagg.c	Thu Mar 31 03:21:33 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.42 2022/03/31 03:15:15 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.43 2022/03/31 03:21:33 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.42 2022/03/31 03:15:15 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.43 2022/03/31 03:21:33 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -730,6 +730,7 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd
 		break;
 	case SIOCSIFMTU:
 		LAGG_LOCK(sc);
+		/* set the MTU to each port */
 		LAGG_PORTS_FOREACH(sc, lp) {
 			error = lagg_lp_ioctl(lp, cmd, (void *)ifr);
 
@@ -744,10 +745,12 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd
 			}
 		}
 
-		if (error == 0) {
-			ifp->if_mtu = ifr->ifr_mtu;
-		} else {
-			/* set every port back to the original MTU */
+		/* set the MTU to the lagg interface */
+		if (error == 0)
+			error = ether_ioctl(ifp, cmd, data);
+
+		if (error != 0) {
+			/* undo the changed MTU */
 			ifr->ifr_mtu = ifp->if_mtu;
 			LAGG_PORTS_FOREACH(sc, lp) {
 if (lp->lp_ioctl != NULL)
@@ -2008,11 +2011,13 @@ lagg_capabilities_update(struct lagg_sof
 static int
 lagg_setup_mtu(struct lagg_softc *sc, struct lagg_port *lp)
 {
-	struct ifnet *ifp_port;
+	struct ifnet *ifp, *ifp_port;
 	struct ifreq ifr;
 	int error;
 
+	ifp = &sc->sc_if;
 	ifp_port = lp->lp_ifp;
+
 	KASSERT(IFNET_LOCKED(ifp_port));
 
 	error = 0;
@@ -2020,30 +2025,35 @@ lagg_setup_mtu(struct lagg_softc *sc, st
 
 	if (SIMPLEQ_EMPTY(&sc->sc_ports)) {
 		ifr.ifr_mtu = lp->lp_mtu;
+
+		if (ifp->if_mtu != (uint64_t)ifr.ifr_mtu) {
+			KASSERT(IFNET_LOCKED(ifp));
+			error = ether_ioctl(ifp, SIOCSIFMTU, &ifr);
+		}
 	} else {
 		ifr.ifr_mtu = sc->sc_if.if_mtu;
-	}
 
-	if (sc->sc_if.if_mtu != (uint64_t)ifr.ifr_mtu)
-		sc->sc_if.if_mtu = ifr.ifr_mtu;
-
-	if (lp->lp_mtu != (uint64_t)ifr.ifr_mtu) {
-		if (lp->lp_ioctl == NULL) {
-			LAGG_DPRINTF(sc, "cannot change MTU for %s\n",
-			ifp_port->if_xname);
-			return EINVAL;
-		}
+		if (lp->lp_mtu != (uint64_t)ifr.ifr_mtu) {
+			if (lp->lp_ioctl == NULL) {
+LAGG_DPRINTF(sc,
+"cannot change MTU for %s\n",
+ifp_port->if_xname);
+return EINVAL;
+			}
 
-		strlcpy(ifr.ifr_name, ifp_port->if_xname, sizeof(ifr.ifr_name));
-		error = lp->lp_ioctl(ifp_port, SIOCSIFMTU, (void *)&ifr);
-		if (error != 0) {
-			LAGG_DPRINTF(sc, "invalid MTU %d for %s\n",
-			ifr.ifr_mtu, ifp_port->if_xname);
-			return error;
+			strlcpy(ifr.ifr_name, ifp_port->if_xname,
+			sizeof(ifr.ifr_name));
+			error = lp->lp_ioctl(ifp_port,
+			SIOCSIFMTU, (void *)&ifr);
+			if (error != 0) {
+LAGG_DPRINTF(sc,
+"invalid MTU %d for %s\n",
+ifr.ifr_mtu, ifp_port->if_xname);
+			}
 		}
 	}
 
-	return 0;
+	return error;
 }
 
 static void
@@ -2059,9 +2069,6 @@ lagg_teardown_mtu(struct lagg_softc *sc,
 	ifp_port = lp->lp_ifp;
 	KASSERT(IFNET_LOCKED(ifp_port));
 
-	if (SIMPLEQ_EMPTY(&sc->sc_ports))
-		sc->sc_if.if_mtu = 0;
-
 	if (ifp_port->if_mtu != lp->lp_mtu) {
 		memset(&ifr, 0, sizeof(ifr));
 		strlcpy(ifr.ifr_name, ifp_port->if_xname, sizeof(ifr.ifr_name));
@@ -2338,6 +2345,8 @@ lagg_port_setup(struct lagg_softc *sc,
 	/* to delete ipv6 link local address */
 	lagg_in6_ifdetach(ifp_port);
 
+	lagg_capabilities_update(sc);
+
 	error = lagg_setup_mtu(sc, lp);
 	if (error != 0)
 		goto restore_ipv6lla;
@@ -2373,7 +2382,6 @@ lagg_port_setup(struct lagg_softc *sc,
 
 	lagg_config_promisc(sc, lp);
 	lagg_proto_startport(sc, lp);
-	lagg_capabilities_update(sc);
 
 	return 0;
 



CVS commit: src/sys/net/lagg

2022-03-31 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 07:59:05 UTC 2022

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

Log Message:
rename lagg_enqueue to lagg_output

NFC


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/net/lagg/if_lagg.c
cvs rdiff -u -r1.20 -r1.21 src/sys/net/lagg/if_lagg_lacp.c
cvs rdiff -u -r1.5 -r1.6 src/sys/net/lagg/if_laggproto.c
cvs rdiff -u -r1.14 -r1.15 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

2022-03-31 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Mar 31 07:59:05 UTC 2022

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

Log Message:
rename lagg_enqueue to lagg_output

NFC


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/net/lagg/if_lagg.c
cvs rdiff -u -r1.20 -r1.21 src/sys/net/lagg/if_lagg_lacp.c
cvs rdiff -u -r1.5 -r1.6 src/sys/net/lagg/if_laggproto.c
cvs rdiff -u -r1.14 -r1.15 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.43 src/sys/net/lagg/if_lagg.c:1.44
--- src/sys/net/lagg/if_lagg.c:1.43	Thu Mar 31 03:21:33 2022
+++ src/sys/net/lagg/if_lagg.c	Thu Mar 31 07:59:05 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.43 2022/03/31 03:21:33 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.44 2022/03/31 07:59:05 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.43 2022/03/31 03:21:33 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.44 2022/03/31 07:59:05 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1041,7 +1041,7 @@ lagg_start(struct ifnet *ifp)
 }
 
 void
-lagg_enqueue(struct lagg_softc *sc, struct lagg_port *lp, struct mbuf *m)
+lagg_output(struct lagg_softc *sc, struct lagg_port *lp, struct mbuf *m)
 {
 	struct ifnet *ifp;
 	int len, error;

Index: src/sys/net/lagg/if_lagg_lacp.c
diff -u src/sys/net/lagg/if_lagg_lacp.c:1.20 src/sys/net/lagg/if_lagg_lacp.c:1.21
--- src/sys/net/lagg/if_lagg_lacp.c:1.20	Thu Mar 31 03:15:15 2022
+++ src/sys/net/lagg/if_lagg_lacp.c	Thu Mar 31 07:59:05 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg_lacp.c,v 1.20 2022/03/31 03:15:15 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg_lacp.c,v 1.21 2022/03/31 07:59:05 yamaguchi Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.20 2022/03/31 03:15:15 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.21 2022/03/31 07:59:05 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_lagg.h"
@@ -647,7 +647,7 @@ lacp_transmit(struct lagg_proto_softc *x
 		return ENOENT;
 	}
 
-	lagg_enqueue(lsc->lsc_softc, lp, m);
+	lagg_output(lsc->lsc_softc, lp, m);
 	lagg_port_putref(lp, &psref);
 
 	return 0;

Index: src/sys/net/lagg/if_laggproto.c
diff -u src/sys/net/lagg/if_laggproto.c:1.5 src/sys/net/lagg/if_laggproto.c:1.6
--- src/sys/net/lagg/if_laggproto.c:1.5	Thu Mar 31 03:12:31 2022
+++ src/sys/net/lagg/if_laggproto.c	Thu Mar 31 07:59:05 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_laggproto.c,v 1.5 2022/03/31 03:12:31 yamaguchi Exp $	*/
+/*	$NetBSD: if_laggproto.c,v 1.6 2022/03/31 07:59:05 yamaguchi Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_laggproto.c,v 1.5 2022/03/31 03:12:31 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_laggproto.c,v 1.6 2022/03/31 07:59:05 yamaguchi Exp $");
 
 #include 
 #include 
@@ -412,7 +412,7 @@ lagg_fail_transmit(struct lagg_proto_sof
 		return ENOENT;
 	}
 
-	lagg_enqueue(psc->psc_softc, lp, m);
+	lagg_output(psc->psc_softc, lp, m);
 	lagg_port_putref(lp, &psref);
 	return 0;
 }
@@ -613,7 +613,7 @@ lagg_lb_transmit(struct lagg_proto_softc
 		return ENOENT;
 	}
 
-	lagg_enqueue(psc->psc_softc, lp, m);
+	lagg_output(psc->psc_softc, lp, m);
 	lagg_port_putref(lp, &psref);
 
 	return 0;

Index: src/sys/net/lagg/if_laggproto.h
diff -u src/sys/net/lagg/if_laggproto.h:1.14 src/sys/net/lagg/if_laggproto.h:1.15
--- src/sys/net/lagg/if_laggproto.h:1.14	Thu Mar 31 03:15:15 2022
+++ src/sys/net/lagg/if_laggproto.h	Thu Mar 31 07:59:05 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_laggproto.h,v 1.14 2022/03/31 03:15:15 yamaguchi Exp $	*/
+/*	$NetBSD: if_laggproto.h,v 1.15 2022/03/31 07:59:05 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2021 Internet Initiative Japan Inc.
@@ -280,7 +280,7 @@ lagg_debug_enable(struct lagg_softc *sc)
 
 void		lagg_port_getref(struct lagg_port *, struct psref *);
 void		lagg_port_putref(struct lagg_port *, struct psref *);
-void		lagg_enqueue(struct lagg_softc *,
+void		lagg_output(struct lagg_softc *,
 		struct lagg_port *, struct mbuf *);
 uint32_t	lagg_hashmbuf(struct lagg_softc *, struct mbuf *);
 



CVS commit: src/sys/net/lagg

2022-04-01 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Fri Apr  1 07:26:51 UTC 2022

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

Log Message:
lagg(4): reimplement add and delete port

The IFNET_LOCK for the adding or deleting port became to
be held the whole time while the ifnet of the port is changed.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/net/lagg/if_lagg.c
cvs rdiff -u -r1.21 -r1.22 src/sys/net/lagg/if_lagg_lacp.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.44 src/sys/net/lagg/if_lagg.c:1.45
--- src/sys/net/lagg/if_lagg.c:1.44	Thu Mar 31 07:59:05 2022
+++ src/sys/net/lagg/if_lagg.c	Fri Apr  1 07:26:51 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.44 2022/03/31 07:59:05 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.45 2022/04/01 07:26:51 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.44 2022/03/31 07:59:05 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.45 2022/04/01 07:26:51 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -133,7 +133,7 @@ static const struct lagg_proto lagg_prot
 	},
 };
 
-static int	lagg_chg_sadl(struct ifnet *, uint8_t *, size_t);
+static int	lagg_chg_sadl(struct ifnet *, const uint8_t *, size_t);
 static struct mbuf *
 		lagg_input_ethernet(struct ifnet *, struct mbuf *);
 static int	lagg_clone_create(struct if_clone *, int);
@@ -195,10 +195,10 @@ static void	lagg_port_teardown(struct la
 		bool);
 static void	lagg_port_syncvlan(struct lagg_softc *, struct lagg_port *);
 static void	lagg_port_purgevlan(struct lagg_softc *, struct lagg_port *);
-static void	lagg_lladdr_update(struct lagg_softc *);
 static void	lagg_capabilities_update(struct lagg_softc *);
 static void	lagg_sync_ifcaps(struct lagg_softc *);
 static void	lagg_sync_ethcaps(struct lagg_softc *);
+static void	lagg_sync_sadl(struct lagg_softc *);
 
 static struct if_clone	 lagg_cloner =
 IF_CLONE_INITIALIZER("lagg", lagg_clone_create, lagg_clone_destroy);
@@ -212,11 +212,13 @@ static enum lagg_iftypes
 		 lagg_iftype = LAGG_IF_TYPE_ETHERNET;
 
 #ifdef LAGG_DEBUG
+#define __LAGGDEBUGUSED
 #define LAGG_DPRINTF(_sc, _fmt, _args...)	do {	\
 	printf("%s: " _fmt, (_sc) != NULL ?		\
 	(_sc)->sc_if.if_xname : "lagg", ##_args);		\
 } while (0)
 #else
+#define __LAGGDEBUGUSED__unused
 #define LAGG_DPRINTF(_sc, _fmt, _args...)	__nothing
 #endif
 
@@ -413,7 +415,7 @@ lagg_clone_create(struct if_clone *ifc, 
 		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);
+		ether_ifattach(ifp, sc->sc_lladdr_rand);
 		break;
 	default:
 		panic("unknown if type");
@@ -500,7 +502,7 @@ lagg_init_locked(struct lagg_softc *sc)
 	if (ISSET(ifp->if_flags, IFF_RUNNING))
 		lagg_stop_locked(sc);
 
-	lagg_lladdr_update(sc);
+	lagg_sync_sadl(sc);
 
 	SET(ifp->if_flags, IFF_RUNNING);
 
@@ -2009,85 +2011,42 @@ lagg_capabilities_update(struct lagg_sof
 }
 
 static int
-lagg_setup_mtu(struct lagg_softc *sc, struct lagg_port *lp)
+lagg_setmtu(struct ifnet *ifp, uint64_t mtu)
 {
-	struct ifnet *ifp, *ifp_port;
+	struct lagg_softc *sc __LAGGDEBUGUSED;
+	struct lagg_port *lp;
 	struct ifreq ifr;
 	int error;
 
-	ifp = &sc->sc_if;
-	ifp_port = lp->lp_ifp;
-
-	KASSERT(IFNET_LOCKED(ifp_port));
+	KASSERT(IFNET_LOCKED(ifp));
 
-	error = 0;
 	memset(&ifr, 0, sizeof(ifr));
+	ifr.ifr_mtu = mtu;
+	lp = ifp->if_lagg;
 
-	if (SIMPLEQ_EMPTY(&sc->sc_ports)) {
-		ifr.ifr_mtu = lp->lp_mtu;
-
-		if (ifp->if_mtu != (uint64_t)ifr.ifr_mtu) {
-			KASSERT(IFNET_LOCKED(ifp));
-			error = ether_ioctl(ifp, SIOCSIFMTU, &ifr);
-		}
+	if (lp != NULL) {
+		/* ioctl for port interface */
+		error = lp->lp_ioctl(ifp, SIOCSIFMTU, &ifr);
+		sc = lp->lp_softc;
 	} else {
-		ifr.ifr_mtu = sc->sc_if.if_mtu;
-
-		if (lp->lp_mtu != (uint64_t)ifr.ifr_mtu) {
-			if (lp->lp_ioctl == NULL) {
-LAGG_DPRINTF(sc,
-"cannot change MTU for %s\n",
-ifp_port->if_xname);
-return EINVAL;
-			}
+		/* ioctl for lagg interface */
+		error = ether_ioctl(ifp, SIOCSIFMTU, &ifr);
+		sc = ifp->if_softc;
+	}
 
-			strlcpy(ifr.ifr_name, ifp_port->if_xname,
-			sizeof(ifr.ifr_name));
-			error = lp->lp_ioctl(ifp_port,
-			SIOCSIFMTU, (void *)&ifr);
-			if (error != 0) {
-LAGG_DPRINTF(sc,
-"invalid MTU %d for %s\n",
-ifr.ifr_mtu, ifp_port->if_xname);
-			}
-		}
+	if (error != 0) {
+		LAGG_DPRINTF(sc,
+		"couldn't change MTU for %s\n",
+		ifp->if_xname);
 	}
 
 	return error;
 }
 
 static void
-lagg_teardown_mtu(struct lagg_softc *sc, struct lagg_port *lp)
-{
-	struct ifnet *ifp_port;
-	struct ifreq ifr;
-	int error;
-
-	if (lp->lp_ioctl == NULL)
-		return;

CVS commit: src/sys/net/lagg

2022-04-01 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Fri Apr  1 07:26:51 UTC 2022

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

Log Message:
lagg(4): reimplement add and delete port

The IFNET_LOCK for the adding or deleting port became to
be held the whole time while the ifnet of the port is changed.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/net/lagg/if_lagg.c
cvs rdiff -u -r1.21 -r1.22 src/sys/net/lagg/if_lagg_lacp.c

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

2022-04-03 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Mon Apr  4 06:12:27 UTC 2022

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

Log Message:
Fix missing m_reset_rcvif for allocated mbuf


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/net/lagg/if_lagg_lacp.c

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

2022-04-03 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Mon Apr  4 06:12:27 UTC 2022

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

Log Message:
Fix missing m_reset_rcvif for allocated mbuf


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/net/lagg/if_lagg_lacp.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_lacp.c
diff -u src/sys/net/lagg/if_lagg_lacp.c:1.23 src/sys/net/lagg/if_lagg_lacp.c:1.24
--- src/sys/net/lagg/if_lagg_lacp.c:1.23	Mon Apr  4 06:10:00 2022
+++ src/sys/net/lagg/if_lagg_lacp.c	Mon Apr  4 06:12:27 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg_lacp.c,v 1.23 2022/04/04 06:10:00 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg_lacp.c,v 1.24 2022/04/04 06:12:27 yamaguchi Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.23 2022/04/04 06:10:00 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.24 2022/04/04 06:12:27 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_lagg.h"
@@ -1383,6 +1383,7 @@ lacp_lacpdu_mbuf(struct lacp_softc *lsc,
 	}
 
 	m->m_pkthdr.len = m->m_len = sizeof(*du);
+	m_reset_rcvif(m);
 
 	du = mtod(m, struct lacpdu *);
 	memset(du, 0, sizeof(*du));
@@ -2542,6 +2543,7 @@ lacp_markerdu_mbuf(struct lacp_softc *ls
 	}
 
 	m->m_pkthdr.len = m->m_len = sizeof(*mdu);
+	m_reset_rcvif(m);
 
 	mdu = mtod(m, struct markerdu *);
 



CVS commit: src/sys/net/lagg

2022-04-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Apr  4 09:59:42 UTC 2022

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

Log Message:
Avoid signed/unsigned comparision by casting the sizeof expression.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 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/sys/net/lagg

2022-04-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Apr  4 09:59:42 UTC 2022

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

Log Message:
Avoid signed/unsigned comparision by casting the sizeof expression.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 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.46 src/sys/net/lagg/if_lagg.c:1.47
--- src/sys/net/lagg/if_lagg.c:1.46	Mon Apr  4 06:10:00 2022
+++ src/sys/net/lagg/if_lagg.c	Mon Apr  4 09:59:41 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.46 2022/04/04 06:10:00 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.47 2022/04/04 09:59:41 martin Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.46 2022/04/04 06:10:00 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.47 2022/04/04 09:59:41 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1121,7 +1121,7 @@ lagg_input_ethernet(struct ifnet *ifp_po
 	 * if we are not in promiscuous mode.
 	 */
 
-	if (__predict_false(m->m_len < sizeof(*eh))) {
+	if (__predict_false(m->m_len < (int)sizeof(*eh))) {
 		if ((m = m_pullup(m, sizeof(*eh))) == NULL) {
 			if_statinc(ifp, if_ierrors);
 			goto out;



CVS commit: src/sys/net/lagg

2023-10-16 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Mon Oct 16 07:49:01 UTC 2023

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

Log Message:
lagg(4): release LAGG_LOCK before mtu changing

PR kern/57650


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 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.48 src/sys/net/lagg/if_lagg.c:1.49
--- src/sys/net/lagg/if_lagg.c:1.48	Sun Jun 26 17:55:24 2022
+++ src/sys/net/lagg/if_lagg.c	Mon Oct 16 07:49:01 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.48 2022/06/26 17:55:24 riastradh Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.49 2023/10/16 07:49:01 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.48 2022/06/26 17:55:24 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.49 2023/10/16 07:49:01 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -727,8 +727,8 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd
 		LAGG_UNLOCK(sc);
 		break;
 	case SIOCSIFMTU:
-		LAGG_LOCK(sc);
 		/* set the MTU to each port */
+		LAGG_LOCK(sc);
 		LAGG_PORTS_FOREACH(sc, lp) {
 			error = lagg_lp_ioctl(lp, cmd, (void *)ifr);
 
@@ -742,6 +742,7 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd
 break;
 			}
 		}
+		LAGG_UNLOCK(sc);
 
 		/* set the MTU to the lagg interface */
 		if (error == 0)
@@ -750,12 +751,14 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd
 		if (error != 0) {
 			/* undo the changed MTU */
 			ifr->ifr_mtu = ifp->if_mtu;
+
+			LAGG_LOCK(sc);
 			LAGG_PORTS_FOREACH(sc, lp) {
 if (lp->lp_ioctl != NULL)
 	lagg_lp_ioctl(lp, cmd, (void *)ifr);
 			}
+			LAGG_UNLOCK(sc);
 		}
-		LAGG_UNLOCK(sc);
 		break;
 	case SIOCADDMULTI:
 		if (sc->sc_if.if_type == IFT_ETHER) {



CVS commit: src/sys/net/lagg

2023-10-16 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Mon Oct 16 07:49:01 UTC 2023

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

Log Message:
lagg(4): release LAGG_LOCK before mtu changing

PR kern/57650


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 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/sys/net/lagg

2023-10-16 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Mon Oct 16 08:25:57 UTC 2023

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

Log Message:
Fix missing IFNET_LOCK holding while destroy the lagg interface


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 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/sys/net/lagg

2023-10-16 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Mon Oct 16 08:25:57 UTC 2023

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

Log Message:
Fix missing IFNET_LOCK holding while destroy the lagg interface


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 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.49 src/sys/net/lagg/if_lagg.c:1.50
--- src/sys/net/lagg/if_lagg.c:1.49	Mon Oct 16 07:49:01 2023
+++ src/sys/net/lagg/if_lagg.c	Mon Oct 16 08:25:57 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.49 2023/10/16 07:49:01 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.50 2023/10/16 08:25:57 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.49 2023/10/16 07:49:01 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.50 2023/10/16 08:25:57 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -444,11 +444,13 @@ lagg_clone_destroy(struct ifnet *ifp)
 
 	lagg_stop(ifp, 1);
 
+	IFNET_LOCK(ifp);
 	LAGG_LOCK(sc);
 	while ((lp = LAGG_PORTS_FIRST(sc)) != NULL) {
 		lagg_port_teardown(sc, lp, false);
 	}
 	LAGG_UNLOCK(sc);
+	IFNET_UNLOCK(ifp);
 
 	switch (ifp->if_type) {
 	case IFT_ETHER:



CVS commit: src/sys/net/lagg

2023-10-17 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Wed Oct 18 06:37:08 UTC 2023

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

Log Message:
copy MTU of lagg to a interface added to lagg
even if the interface is the first member of the lagg

This change breaks ATF test case for lagg MTU


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 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/sys/net/lagg

2023-10-17 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Wed Oct 18 06:37:08 UTC 2023

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

Log Message:
copy MTU of lagg to a interface added to lagg
even if the interface is the first member of the lagg

This change breaks ATF test case for lagg MTU


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 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.50 src/sys/net/lagg/if_lagg.c:1.51
--- src/sys/net/lagg/if_lagg.c:1.50	Mon Oct 16 08:25:57 2023
+++ src/sys/net/lagg/if_lagg.c	Wed Oct 18 06:37:08 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.50 2023/10/16 08:25:57 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.51 2023/10/18 06:37:08 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.50 2023/10/16 08:25:57 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.51 2023/10/18 06:37:08 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2243,11 +2243,12 @@ lagg_port_setup(struct lagg_softc *sc,
 			lagg_port_setsadl(lp, NULL);
 	} else {
 		lagg_port_setsadl(lp, CLLADDR(ifp->if_sadl));
-		error = lagg_setmtu(ifp_port, ifp->if_mtu);
-		if (error != 0)
-			goto restore_sadl;
 	}
 
+	error = lagg_setmtu(ifp_port, ifp->if_mtu);
+	if (error != 0)
+		goto restore_sadl;
+
 	error = lagg_proto_allocport(sc, lp);
 	if (error != 0)
 		goto restore_mtu;
@@ -2263,9 +2264,6 @@ lagg_port_setup(struct lagg_softc *sc,
 	IFNET_UNLOCK(ifp_port);
 
 	if (is_1st_port) {
-		error = lagg_setmtu(ifp, lp->lp_mtu);
-		if (error != 0)
-			goto restore_ifp_port;
 		if (lp->lp_iftype == IFT_ETHER &&
 		lagg_lladdr_equal(sc->sc_lladdr_rand,
 		CLLADDR(ifp->if_sadl))) {
@@ -2285,11 +2283,6 @@ lagg_port_setup(struct lagg_softc *sc,
 
 	return 0;
 
-restore_ifp_port:
-	IFNET_LOCK(ifp_port);
-	if (stopped) {
-		if_stop(ifp_port, 0);
-	}
 free_port:
 	KASSERT(IFNET_LOCKED(ifp_port));
 	lagg_proto_freeport(sc, lp);



CVS commit: src/sys/net/lagg

2023-11-21 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Wed Nov 22 03:23:54 UTC 2023

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

Log Message:
Change LACPDU sending interval by TIMEOUT bit in partner's state


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/net/lagg/if_lagg_lacp.c

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

2023-11-21 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Wed Nov 22 03:23:54 UTC 2023

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

Log Message:
Change LACPDU sending interval by TIMEOUT bit in partner's state


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/net/lagg/if_lagg_lacp.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_lacp.c
diff -u src/sys/net/lagg/if_lagg_lacp.c:1.25 src/sys/net/lagg/if_lagg_lacp.c:1.26
--- src/sys/net/lagg/if_lagg_lacp.c:1.25	Sun Apr 10 09:50:46 2022
+++ src/sys/net/lagg/if_lagg_lacp.c	Wed Nov 22 03:23:54 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg_lacp.c,v 1.25 2022/04/10 09:50:46 andvar Exp $	*/
+/*	$NetBSD: if_lagg_lacp.c,v 1.26 2023/11/22 03:23:54 yamaguchi Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.25 2022/04/10 09:50:46 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.26 2023/11/22 03:23:54 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_lagg.h"
@@ -1855,7 +1855,7 @@ lacp_sm_ptx_schedule(struct lacp_port *l
 	if (LACP_TIMER_ISARMED(lacpp, LACP_TIMER_PERIODIC))
 		return;
 
-	timeout = ISSET(lacpp->lp_actor.lpi_state, LACP_STATE_TIMEOUT) ?
+	timeout = ISSET(lacpp->lp_partner.lpi_state, LACP_STATE_TIMEOUT) ?
 		LACP_FAST_PERIODIC_TIME : LACP_SLOW_PERIODIC_TIME;
 
 	LACP_TIMER_ARM(lacpp, LACP_TIMER_PERIODIC, timeout);



CVS commit: src/sys/net/lagg

2023-11-21 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Wed Nov 22 03:27:00 UTC 2023

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

Log Message:
Update sending interval when the partner's state is changed


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/net/lagg/if_lagg_lacp.c

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

2023-11-21 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Wed Nov 22 03:27:00 UTC 2023

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

Log Message:
Update sending interval when the partner's state is changed


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/net/lagg/if_lagg_lacp.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_lacp.c
diff -u src/sys/net/lagg/if_lagg_lacp.c:1.26 src/sys/net/lagg/if_lagg_lacp.c:1.27
--- src/sys/net/lagg/if_lagg_lacp.c:1.26	Wed Nov 22 03:23:54 2023
+++ src/sys/net/lagg/if_lagg_lacp.c	Wed Nov 22 03:27:00 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg_lacp.c,v 1.26 2023/11/22 03:23:54 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg_lacp.c,v 1.27 2023/11/22 03:27:00 yamaguchi Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.26 2023/11/22 03:23:54 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.27 2023/11/22 03:27:00 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_lagg.h"
@@ -1689,6 +1689,8 @@ lacp_sm_rx_record_default(struct lacp_so
 		LACP_STATE_STR(pi->lpi_state, buf, sizeof(buf));
 		LACP_DPRINTF((lsc, lacpp, "newpstate %s\n", buf));
 	}
+
+	lacp_sm_ptx_update_timeout(lacpp, oldpstate);
 }
 
 static inline bool
@@ -1764,12 +1766,17 @@ lacp_sm_rx_record_peerinfo(struct lacp_s
 static void
 lacp_sm_rx_set_expired(struct lacp_port *lacpp)
 {
+	uint8_t oldpstate;
+
+	oldpstate = lacpp->lp_partner.lpi_state;
 
 	CLR(lacpp->lp_partner.lpi_state, LACP_STATE_SYNC);
 	SET(lacpp->lp_partner.lpi_state, LACP_STATE_TIMEOUT);
 	LACP_TIMER_ARM(lacpp, LACP_TIMER_CURRENT_WHILE,
 	LACP_SHORT_TIMEOUT_TIME);
 	SET(lacpp->lp_actor.lpi_state, LACP_STATE_EXPIRED);
+
+	lacp_sm_ptx_update_timeout(lacpp, oldpstate);
 }
 
 static void



CVS commit: src/sys/net/lagg

2023-11-21 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Wed Nov 22 03:28:57 UTC 2023

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

Log Message:
lagg(4): Fix missing pfil_run_hooks() and bpf_mtap()


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 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/sys/net/lagg

2023-11-21 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Wed Nov 22 03:28:57 UTC 2023

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

Log Message:
lagg(4): Fix missing pfil_run_hooks() and bpf_mtap()


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 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.51 src/sys/net/lagg/if_lagg.c:1.52
--- src/sys/net/lagg/if_lagg.c:1.51	Wed Oct 18 06:37:08 2023
+++ src/sys/net/lagg/if_lagg.c	Wed Nov 22 03:28:57 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.51 2023/10/18 06:37:08 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.52 2023/11/22 03:28:57 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.51 2023/10/18 06:37:08 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.52 2023/11/22 03:28:57 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1056,6 +1056,11 @@ lagg_output(struct lagg_softc *sc, struc
 	len = m->m_pkthdr.len;
 	mflags = m->m_flags;
 
+	error = pfil_run_hooks(ifp->if_pfil, &m, ifp, PFIL_OUT);
+	if (error != 0)
+		return;
+	bpf_mtap(ifp, m, BPF_D_OUT);
+
 	error = lagg_port_xmit(lp, m);
 	if (error) {
 		/* mbuf is already freed */



CVS commit: src/sys/net/lagg

2023-11-21 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Wed Nov 22 03:30:57 UTC 2023

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

Log Message:
Set ETHERCAP_VLAN_HWTAGGING on lagg(4)
that doesn't has physical interfaces


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 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.52 src/sys/net/lagg/if_lagg.c:1.53
--- src/sys/net/lagg/if_lagg.c:1.52	Wed Nov 22 03:28:57 2023
+++ src/sys/net/lagg/if_lagg.c	Wed Nov 22 03:30:57 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.52 2023/11/22 03:28:57 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.53 2023/11/22 03:30:57 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.52 2023/11/22 03:28:57 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.53 2023/11/22 03:30:57 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -365,6 +365,7 @@ lagg_clone_create(struct if_clone *ifc, 
 {
 	struct lagg_softc *sc;
 	struct ifnet *ifp;
+	struct ethercom *ec;
 	int error;
 
 	sc = lagg_softc_alloc(lagg_iftype);
@@ -406,11 +407,19 @@ lagg_clone_create(struct if_clone *ifc, 
 
 	switch (lagg_iftype) {
 	case LAGG_IF_TYPE_ETHERNET:
+		ec = (struct ethercom *)ifp;
 		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_set_vlan_cb(ec, lagg_vlan_cb);
+
+		/*
+		 * notify ETHERCAP_VLAN_HWTAGGING to ether_ifattach
+		 * to handle VLAN tag, stripped by hardware, in bpf(4)
+		 */
+		ec->ec_capabilities = ETHERCAP_VLAN_HWTAGGING;
+
 		ether_ifattach(ifp, sc->sc_lladdr_rand);
 		break;
 	default:
@@ -1972,31 +1981,31 @@ lagg_ethercap_update(struct lagg_softc *
 	if (sc->sc_if.if_type != IFT_ETHER)
 		return;
 
-	/* Get common enabled capabilities for the lagg ports */
-	ena = ~0;
-	cap = ~0;
-	LAGG_PORTS_FOREACH(sc, lp) {
-		switch (lp->lp_iftype) {
-		case IFT_ETHER:
-			ec = (struct ethercom *)lp->lp_ifp;
-			ena &= ec->ec_capenable;
-			cap &= ec->ec_capabilities;
-			break;
-		case IFT_L2TP:
-			ena &= (ETHERCAP_VLAN_MTU | ETHERCAP_JUMBO_MTU);
-			cap &= (ETHERCAP_VLAN_MTU | ETHERCAP_JUMBO_MTU);
-			break;
-		default:
-			ena = 0;
-			cap = 0;
+	if (SIMPLEQ_EMPTY(&sc->sc_ports)) {
+		ena = 0;
+		cap = ETHERCAP_VLAN_HWTAGGING;
+	} else {
+		/* Get common enabled capabilities for the lagg ports */
+		ena = ~0;
+		cap = ~0;
+		LAGG_PORTS_FOREACH(sc, lp) {
+			switch (lp->lp_iftype) {
+			case IFT_ETHER:
+ec = (struct ethercom *)lp->lp_ifp;
+ena &= ec->ec_capenable;
+cap &= ec->ec_capabilities;
+break;
+			case IFT_L2TP:
+ena &= (ETHERCAP_VLAN_MTU | ETHERCAP_JUMBO_MTU);
+cap &= (ETHERCAP_VLAN_MTU | ETHERCAP_JUMBO_MTU);
+break;
+			default:
+ena = 0;
+cap = 0;
+			}
 		}
 	}
 
-	if (ena == ~0)
-		ena = 0;
-	if (cap == ~0)
-		cap = 0;
-
 	/*
 	 * Apply common enabled capabilities back to the lagg ports.
 	 * May require several iterations if they are dependent.



CVS commit: src/sys/net/lagg

2023-11-21 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Wed Nov 22 03:30:57 UTC 2023

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

Log Message:
Set ETHERCAP_VLAN_HWTAGGING on lagg(4)
that doesn't has physical interfaces


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 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/sys/net/lagg

2023-11-21 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Wed Nov 22 03:49:13 UTC 2023

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

Log Message:
Set the fastest linkspeed in each physical interface to lagg(4)


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/net/lagg/if_lagg.c
cvs rdiff -u -r1.27 -r1.28 src/sys/net/lagg/if_lagg_lacp.c
cvs rdiff -u -r1.4 -r1.5 src/sys/net/lagg/if_lagg_lacp.h
cvs rdiff -u -r1.6 -r1.7 src/sys/net/lagg/if_laggproto.c
cvs rdiff -u -r1.18 -r1.19 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

2023-11-21 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Wed Nov 22 03:49:13 UTC 2023

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

Log Message:
Set the fastest linkspeed in each physical interface to lagg(4)


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/net/lagg/if_lagg.c
cvs rdiff -u -r1.27 -r1.28 src/sys/net/lagg/if_lagg_lacp.c
cvs rdiff -u -r1.4 -r1.5 src/sys/net/lagg/if_lagg_lacp.h
cvs rdiff -u -r1.6 -r1.7 src/sys/net/lagg/if_laggproto.c
cvs rdiff -u -r1.18 -r1.19 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.53 src/sys/net/lagg/if_lagg.c:1.54
--- src/sys/net/lagg/if_lagg.c:1.53	Wed Nov 22 03:30:57 2023
+++ src/sys/net/lagg/if_lagg.c	Wed Nov 22 03:49:13 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.53 2023/11/22 03:30:57 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.54 2023/11/22 03:49:13 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.53 2023/11/22 03:30:57 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.54 2023/11/22 03:49:13 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1217,6 +1217,9 @@ lagg_media_status(struct ifnet *ifp, str
 	imr->ifm_active = IFM_ETHER | IFM_AUTO;
 
 	LAGG_LOCK(sc);
+
+	imr->ifm_active |= sc->sc_media_active;
+
 	LAGG_PORTS_FOREACH(sc, lp) {
 		if (lagg_portactive(lp))
 			imr->ifm_status |= IFM_ACTIVE;
@@ -1224,6 +1227,52 @@ lagg_media_status(struct ifnet *ifp, str
 	LAGG_UNLOCK(sc);
 }
 
+static uint64_t
+lagg_search_media_type(uint64_t linkspeed)
+{
+
+	if (linkspeed == IF_Gbps(40))
+		return IFM_40G_T | IFM_FDX;
+
+	if (linkspeed == IF_Gbps(25))
+		return IFM_25G_T | IFM_FDX;
+
+	if (linkspeed == IF_Gbps(10))
+		return IFM_10G_T | IFM_FDX;
+
+	if (linkspeed == IF_Gbps(5))
+		return IFM_5000_T | IFM_FDX;
+
+	if (linkspeed == IF_Mbps(2500))
+		return IFM_2500_T | IFM_FDX;
+
+	if (linkspeed == IF_Gbps(1))
+		return IFM_1000_T | IFM_FDX;
+
+	if (linkspeed == IF_Mbps(100))
+		return IFM_100_TX | IFM_FDX;
+
+	if (linkspeed == IF_Mbps(10))
+		return IFM_10_T | IFM_FDX;
+
+	return 0;
+}
+
+void
+lagg_set_linkspeed(struct lagg_softc *sc, uint64_t linkspeed)
+{
+	struct ifnet *ifp;
+
+	ifp = &sc->sc_if;
+
+	KASSERT(LAGG_LOCKED(sc));
+
+	ifp->if_baudrate = linkspeed;
+
+	sc->sc_media_active =
+	lagg_search_media_type(linkspeed);
+}
+
 static int
 lagg_port_vlan_cb(struct lagg_port *lp,
 struct lagg_vlantag *lvt, bool set)
@@ -1630,6 +1679,8 @@ lagg_pr_attach(struct lagg_softc *sc, la
 		lagg_proto_detach(oldvar);
 		cleanup_oldvar = true;
 	}
+
+	lagg_set_linkspeed(sc, 0);
 done:
 	LAGG_UNLOCK(sc);
 

Index: src/sys/net/lagg/if_lagg_lacp.c
diff -u src/sys/net/lagg/if_lagg_lacp.c:1.27 src/sys/net/lagg/if_lagg_lacp.c:1.28
--- src/sys/net/lagg/if_lagg_lacp.c:1.27	Wed Nov 22 03:27:00 2023
+++ src/sys/net/lagg/if_lagg_lacp.c	Wed Nov 22 03:49:13 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg_lacp.c,v 1.27 2023/11/22 03:27:00 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg_lacp.c,v 1.28 2023/11/22 03:49:13 yamaguchi Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.27 2023/11/22 03:27:00 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.28 2023/11/22 03:49:13 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_lagg.h"
@@ -126,7 +126,7 @@ struct lacp_port {
 	struct lacp_aggregator	*lp_aggregator;
 	struct lacp_aggregator_systemid
  lp_aggregator_sidbuf;
-	uint32_t		 lp_media;
+	uint64_t		 lp_linkspeed;
 	int			 lp_pending;
 	LIST_ENTRY(lacp_port)	 lp_entry_la;
 	struct timeval		 lp_last_lacpdu;
@@ -165,6 +165,7 @@ struct lacp_softc {
 	struct workqueue	*lsc_workq;
 	struct lagg_work	 lsc_work_tick;
 	struct lagg_work	 lsc_work_rcvdu;
+	struct lagg_work	 lsc_work_linkspeed;
 	callout_t		 lsc_tick;
 	pcq_t			*lsc_du_q;
 
@@ -247,7 +248,6 @@ static void	lacp_dprintf(const struct la
 static void	lacp_tick(void *);
 static void	lacp_tick_work(struct lagg_work *, void *);
 static void	lacp_linkstate(struct lagg_proto_softc *, struct lagg_port *);
-static uint32_t	lacp_ifmedia2lacpmedia(u_int);
 static void	lacp_port_disable(struct lacp_softc *, struct lacp_port *);
 static void	lacp_port_enable(struct lacp_softc *, struct lacp_port *);
 static void	lacp_peerinfo_actor(struct lacp_softc *, struct lacp_port *,
@@ -285,6 +285,7 @@ static void	lacp_sm_ptx_update_timeout(s
 
 static void	lacp_rcvdu_work(struct lagg_work *, void *);
 static void	lacp_marker_work(struct lagg_work *, void *);
+static void	lacp_linkspeed_work(struct lagg_work *, void *);
 static void	lacp_dump_lacpdutlv(const struct lacpdu_peerinfo *,
 		const struct lacpdu_peerinfo *,
 		  

CVS commit: src/sys/net/lagg

2023-11-21 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Wed Nov 22 03:52:58 UTC 2023

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

Log Message:
lagg(4): Added logs about LACP processing


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/net/lagg/if_lagg_lacp.c

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

2023-11-21 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Wed Nov 22 03:52:58 UTC 2023

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

Log Message:
lagg(4): Added logs about LACP processing


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/net/lagg/if_lagg_lacp.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_lacp.c
diff -u src/sys/net/lagg/if_lagg_lacp.c:1.28 src/sys/net/lagg/if_lagg_lacp.c:1.29
--- src/sys/net/lagg/if_lagg_lacp.c:1.28	Wed Nov 22 03:49:13 2023
+++ src/sys/net/lagg/if_lagg_lacp.c	Wed Nov 22 03:52:58 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg_lacp.c,v 1.28 2023/11/22 03:49:13 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg_lacp.c,v 1.29 2023/11/22 03:52:58 yamaguchi Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.28 2023/11/22 03:49:13 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.29 2023/11/22 03:52:58 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_lagg.h"
@@ -2077,8 +2077,11 @@ lacp_disable_distributing(struct lacp_so
 
 	KASSERT(LACP_LOCKED(lsc));
 
-	LACP_DPRINTF((lsc, lacpp, "distributing disabled\n"));
-	CLR(lacpp->lp_actor.lpi_state, LACP_STATE_DISTRIBUTING);
+	if (ISSET(lacpp->lp_actor.lpi_state, LACP_STATE_DISTRIBUTING)) {
+		LAGG_LOG(lsc->lsc_softc, LOG_INFO,
+		"disable distributing on %s\n", LACP_PORT_XNAME(lacpp));
+		CLR(lacpp->lp_actor.lpi_state, LACP_STATE_DISTRIBUTING);
+	}
 
 	s = pserialize_read_enter();
 	act = LACP_PORTMAP_ACTIVE(lsc);
@@ -2105,7 +2108,8 @@ lacp_enable_distributing(struct lacp_sof
 
 	KASSERT(lacp_isactive(lsc, lacpp));
 
-	LACP_DPRINTF((lsc, lacpp, "distributing enabled\n"));
+	LAGG_LOG(lsc->lsc_softc, LOG_INFO,
+	"enable distributing on %s\n", LACP_PORT_XNAME(lacpp));
 	SET(lacpp->lp_actor.lpi_state, LACP_STATE_DISTRIBUTING);
 	lacp_suppress_distributing(lsc);
 	lacp_update_portmap(lsc);
@@ -2365,6 +2369,8 @@ static void
 lacp_selected_update(struct lacp_softc *lsc, struct lacp_aggregator *la)
 {
 	struct lacp_port *lacpp;
+	enum lacp_selected next_selected;
+	const char *msg;
 	size_t nselected;
 	uint64_t linkspeed;
 
@@ -2377,23 +2383,31 @@ lacp_selected_update(struct lacp_softc *
 	linkspeed = lacpp->lp_linkspeed;
 	nselected = 0;
 	LIST_FOREACH(lacpp, &la->la_ports, lp_entry_la) {
-		if (nselected >= lsc->lsc_max_ports ||
-		(!lsc->lsc_multi_linkspeed && linkspeed != lacpp->lp_linkspeed)) {
-			if (lacpp->lp_selected == LACP_SELECTED)
-lacpp->lp_selected = LACP_STANDBY;
+		if (lacpp->lp_selected == LACP_UNSELECTED)
+			continue;
+
+		next_selected = LACP_SELECTED;
+		msg = " is selected";
+
+		if (nselected >= lsc->lsc_max_ports) {
+			next_selected = LACP_STANDBY;
+			msg = " is standby because of too many active ports";
 		}
 
-		switch (lacpp->lp_selected) {
-		case LACP_STANDBY:
-			lacpp->lp_selected = LACP_SELECTED;
-			/* fall through */
-		case LACP_SELECTED:
-			nselected++;
-			break;
-		default:
-			/* do nothing */
-			break;
+		if (!lsc->lsc_multi_linkspeed &&
+		linkspeed != lacpp->lp_linkspeed) {
+			next_selected = LACP_STANDBY;
+			msg = " is standby because of link speed mismatch";
+		}
+
+		if (lacpp->lp_selected != next_selected) {
+			lacpp->lp_selected = next_selected;
+			LAGG_LOG(lsc->lsc_softc, LOG_INFO,
+			"%s%s\n", LACP_PORT_XNAME(lacpp), msg);
 		}
+
+		if (lacpp->lp_selected == LACP_SELECTED)
+			nselected++;
 	}
 }
 



CVS commit: src/sys/net/lagg

2023-11-27 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Tue Nov 28 05:28:37 UTC 2023

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

Log Message:
lagg(4): Fix missing IFNET_LOCK acquirement


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/net/lagg/if_lagg.c
cvs rdiff -u -r1.7 -r1.8 src/sys/net/lagg/if_laggproto.c
cvs rdiff -u -r1.19 -r1.20 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

2023-11-27 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Tue Nov 28 05:28:37 UTC 2023

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

Log Message:
lagg(4): Fix missing IFNET_LOCK acquirement


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/net/lagg/if_lagg.c
cvs rdiff -u -r1.7 -r1.8 src/sys/net/lagg/if_laggproto.c
cvs rdiff -u -r1.19 -r1.20 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.54 src/sys/net/lagg/if_lagg.c:1.55
--- src/sys/net/lagg/if_lagg.c:1.54	Wed Nov 22 03:49:13 2023
+++ src/sys/net/lagg/if_lagg.c	Tue Nov 28 05:28:37 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.54 2023/11/22 03:49:13 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.55 2023/11/28 05:28:37 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.54 2023/11/22 03:49:13 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.55 2023/11/28 05:28:37 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -114,7 +114,7 @@ static const struct lagg_proto lagg_prot
 		.pr_startport = lagg_common_startport,
 		.pr_stopport = lagg_common_stopport,
 		.pr_portstat = lagg_fail_portstat,
-		.pr_linkstate = lagg_common_linkstate,
+		.pr_linkstate = lagg_common_linkstate_ifnet_locked,
 		.pr_ioctl = lagg_fail_ioctl,
 	},
 	[LAGG_PROTO_LOADBALANCE] = {
@@ -128,7 +128,7 @@ static const struct lagg_proto lagg_prot
 		.pr_startport = lagg_lb_startport,
 		.pr_stopport = lagg_lb_stopport,
 		.pr_portstat = lagg_lb_portstat,
-		.pr_linkstate = lagg_common_linkstate,
+		.pr_linkstate = lagg_common_linkstate_ifnet_locked,
 	},
 };
 

Index: src/sys/net/lagg/if_laggproto.c
diff -u src/sys/net/lagg/if_laggproto.c:1.7 src/sys/net/lagg/if_laggproto.c:1.8
--- src/sys/net/lagg/if_laggproto.c:1.7	Wed Nov 22 03:49:13 2023
+++ src/sys/net/lagg/if_laggproto.c	Tue Nov 28 05:28:37 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_laggproto.c,v 1.7 2023/11/22 03:49:13 yamaguchi Exp $	*/
+/*	$NetBSD: if_laggproto.c,v 1.8 2023/11/28 05:28:37 yamaguchi Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_laggproto.c,v 1.7 2023/11/22 03:49:13 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_laggproto.c,v 1.8 2023/11/28 05:28:37 yamaguchi Exp $");
 
 #include 
 #include 
@@ -114,6 +114,8 @@ static struct lagg_port *
 static void	lagg_fail_linkspeed_work(struct lagg_work *, void *);
 static void	lagg_lb_linkspeed_work(struct lagg_work*,
 		void *);
+static void	lagg_common_linkstate(struct lagg_proto_softc *,
+		struct lagg_port *);
 
 static inline struct lagg_portmap *
 lagg_portmap_active(struct lagg_portmaps *maps)
@@ -364,9 +366,19 @@ lagg_common_stopport(struct lagg_proto_s
 		pport->lpp_active = false;
 	}
 }
+static void
+lagg_common_linkstate(struct lagg_proto_softc *psc, struct lagg_port *lp)
+{
+
+	IFNET_ASSERT_UNLOCKED(lp->lp_ifp);
+
+	IFNET_LOCK(lp->lp_ifp);
+	lagg_common_linkstate_ifnet_locked(psc, lp);
+	IFNET_UNLOCK(lp->lp_ifp);
+}
 
 void
-lagg_common_linkstate(struct lagg_proto_softc *psc, struct lagg_port *lp)
+lagg_common_linkstate_ifnet_locked(struct lagg_proto_softc *psc, struct lagg_port *lp)
 {
 	struct lagg_proto_port *pport;
 	struct ifnet *ifp, *ifp_port;
@@ -379,6 +391,8 @@ lagg_common_linkstate(struct lagg_proto_
 	is_active = lagg_portactive(lp);
 	ifp_port = lp->lp_ifp;
 
+	KASSERT(IFNET_LOCKED(ifp_port));
+
 	LAGG_PROTO_LOCK(psc);
 	if (!pport->lpp_running ||
 	pport->lpp_active == is_active) {

Index: src/sys/net/lagg/if_laggproto.h
diff -u src/sys/net/lagg/if_laggproto.h:1.19 src/sys/net/lagg/if_laggproto.h:1.20
--- src/sys/net/lagg/if_laggproto.h:1.19	Wed Nov 22 03:49:13 2023
+++ src/sys/net/lagg/if_laggproto.h	Tue Nov 28 05:28:37 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_laggproto.h,v 1.19 2023/11/22 03:49:13 yamaguchi Exp $	*/
+/*	$NetBSD: if_laggproto.h,v 1.20 2023/11/28 05:28:37 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2021 Internet Initiative Japan Inc.
@@ -298,7 +298,7 @@ void		lagg_common_startport(struct lagg_
 		struct lagg_port *);
 void		lagg_common_stopport(struct lagg_proto_softc *,
 		struct lagg_port *);
-void		lagg_common_linkstate(struct lagg_proto_softc *,
+void		lagg_common_linkstate_ifnet_locked(struct lagg_proto_softc *,
 		struct lagg_port *);
 
 int		lagg_none_attach(struct lagg_softc *,



CVS commit: src/sys/net/lagg

2023-11-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Fri Dec  1 06:18:02 UTC 2023

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

Log Message:
lagg(4): use sadl for lagg(4) configured by a user


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 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/sys/net/lagg

2023-11-30 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Fri Dec  1 06:18:02 UTC 2023

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

Log Message:
lagg(4): use sadl for lagg(4) configured by a user


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 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.55 src/sys/net/lagg/if_lagg.c:1.56
--- src/sys/net/lagg/if_lagg.c:1.55	Tue Nov 28 05:28:37 2023
+++ src/sys/net/lagg/if_lagg.c	Fri Dec  1 06:18:02 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.55 2023/11/28 05:28:37 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.56 2023/12/01 06:18:02 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.55 2023/11/28 05:28:37 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.56 2023/12/01 06:18:02 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2229,13 +2229,20 @@ lagg_port_setup(struct lagg_softc *sc,
 	struct ifnet *ifp;
 	u_char if_type;
 	int error;
-	bool stopped, is_1st_port;
+	bool stopped, use_lagg_sadl;
 
 	KASSERT(LAGG_LOCKED(sc));
 	IFNET_ASSERT_UNLOCKED(ifp_port);
 
 	ifp = &sc->sc_if;
-	is_1st_port = SIMPLEQ_EMPTY(&sc->sc_ports);
+
+	use_lagg_sadl = true;
+	if (SIMPLEQ_EMPTY(&sc->sc_ports) &&
+	ifp_port->if_type == IFT_ETHER) {
+		if (lagg_lladdr_equal(CLLADDR(ifp->if_sadl),
+		sc->sc_lladdr_rand))
+			use_lagg_sadl = false;
+	}
 
 	if (&sc->sc_if == ifp_port) {
 		LAGG_DPRINTF(sc, "cannot add a lagg to itself as a port\n");
@@ -2303,11 +2310,14 @@ lagg_port_setup(struct lagg_softc *sc,
 	ifp_port->if_ioctl = lagg_port_ioctl;
 	ifp_port->_if_input = lagg_input_ethernet;
 	ifp_port->if_output = lagg_port_output;
-	if (is_1st_port) {
+
+	/* update Link address */
+	if (use_lagg_sadl) {
+		lagg_port_setsadl(lp, CLLADDR(ifp->if_sadl));
+	} else {
+		/* update if_type in if_sadl */
 		if (lp->lp_iftype != ifp_port->if_type)
 			lagg_port_setsadl(lp, NULL);
-	} else {
-		lagg_port_setsadl(lp, CLLADDR(ifp->if_sadl));
 	}
 
 	error = lagg_setmtu(ifp_port, ifp->if_mtu);
@@ -2328,13 +2338,9 @@ lagg_port_setup(struct lagg_softc *sc,
 	/* setup of ifp_port is complete */
 	IFNET_UNLOCK(ifp_port);
 
-	if (is_1st_port) {
-		if (lp->lp_iftype == IFT_ETHER &&
-		lagg_lladdr_equal(sc->sc_lladdr_rand,
-		CLLADDR(ifp->if_sadl))) {
-			lagg_if_setsadl(sc, lp->lp_lladdr);
-		}
-	}
+	/* copy sadl from added port to lagg */
+	if (!use_lagg_sadl)
+		lagg_if_setsadl(sc, lp->lp_lladdr);
 
 	SIMPLEQ_INSERT_TAIL(&sc->sc_ports, lp, lp_entry);
 	sc->sc_nports++;



CVS commit: src/sys/net/lagg

2023-12-01 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Fri Dec  1 09:27:18 UTC 2023

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

Log Message:
lagg(4): eliminate unnecessary reset by the change of if_flags


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 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/sys/net/lagg

2023-12-01 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Fri Dec  1 09:27:18 UTC 2023

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

Log Message:
lagg(4): eliminate unnecessary reset by the change of if_flags


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 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.56 src/sys/net/lagg/if_lagg.c:1.57
--- src/sys/net/lagg/if_lagg.c:1.56	Fri Dec  1 06:18:02 2023
+++ src/sys/net/lagg/if_lagg.c	Fri Dec  1 09:27:17 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.56 2023/12/01 06:18:02 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.57 2023/12/01 09:27:17 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.56 2023/12/01 06:18:02 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.57 2023/12/01 09:27:17 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -722,7 +722,6 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd
 			if_stop(ifp, 1);
 			break;
 		case IFF_UP:
-		case IFF_UP | IFF_RUNNING:
 			error = if_init(ifp);
 			break;
 		}



CVS commit: src/sys/net/lagg

2024-04-04 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Apr  4 07:29:35 UTC 2024

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

Log Message:
lagg(4): update link speed when a physical interface is removed


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/net/lagg/if_laggproto.c

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

2024-04-04 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Apr  4 07:29:35 UTC 2024

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

Log Message:
lagg(4): update link speed when a physical interface is removed


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/net/lagg/if_laggproto.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_laggproto.c
diff -u src/sys/net/lagg/if_laggproto.c:1.8 src/sys/net/lagg/if_laggproto.c:1.9
--- src/sys/net/lagg/if_laggproto.c:1.8	Tue Nov 28 05:28:37 2023
+++ src/sys/net/lagg/if_laggproto.c	Thu Apr  4 07:29:35 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_laggproto.c,v 1.8 2023/11/28 05:28:37 yamaguchi Exp $	*/
+/*	$NetBSD: if_laggproto.c,v 1.9 2024/04/04 07:29:35 yamaguchi Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_laggproto.c,v 1.8 2023/11/28 05:28:37 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_laggproto.c,v 1.9 2024/04/04 07:29:35 yamaguchi Exp $");
 
 #include 
 #include 
@@ -365,6 +365,8 @@ lagg_common_stopport(struct lagg_proto_s
 
 		pport->lpp_active = false;
 	}
+
+	lagg_workq_add(psc->psc_workq, &psc->psc_work_linkspeed);
 }
 static void
 lagg_common_linkstate(struct lagg_proto_softc *psc, struct lagg_port *lp)



CVS commit: src/sys/net/lagg

2024-04-04 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Apr  4 07:31:10 UTC 2024

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

Log Message:
lagg(4): fix missing update of the number of active ports


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/net/lagg/if_laggproto.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_laggproto.c
diff -u src/sys/net/lagg/if_laggproto.c:1.9 src/sys/net/lagg/if_laggproto.c:1.10
--- src/sys/net/lagg/if_laggproto.c:1.9	Thu Apr  4 07:29:35 2024
+++ src/sys/net/lagg/if_laggproto.c	Thu Apr  4 07:31:10 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_laggproto.c,v 1.9 2024/04/04 07:29:35 yamaguchi Exp $	*/
+/*	$NetBSD: if_laggproto.c,v 1.10 2024/04/04 07:31:10 yamaguchi Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_laggproto.c,v 1.9 2024/04/04 07:29:35 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_laggproto.c,v 1.10 2024/04/04 07:31:10 yamaguchi Exp $");
 
 #include 
 #include 
@@ -674,6 +674,8 @@ lagg_lb_stopport(struct lagg_proto_softc
 		n++;
 	}
 
+	pm_next->pm_nports = n;
+
 	lagg_portmap_switch(&lb->lb_pmaps);
 	pserialize_perform(psc->psc_psz);
 	LAGG_PROTO_UNLOCK(psc);



CVS commit: src/sys/net/lagg

2024-04-04 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Apr  4 07:31:10 UTC 2024

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

Log Message:
lagg(4): fix missing update of the number of active ports


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/net/lagg/if_laggproto.c

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

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

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

Log Message:
lagg(4): Added 0 length check


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/net/lagg/if_laggproto.c

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

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

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

Log Message:
lagg(4): Added 0 length check


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/net/lagg/if_laggproto.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_laggproto.c
diff -u src/sys/net/lagg/if_laggproto.c:1.10 src/sys/net/lagg/if_laggproto.c:1.11
--- src/sys/net/lagg/if_laggproto.c:1.10	Thu Apr  4 07:31:10 2024
+++ src/sys/net/lagg/if_laggproto.c	Thu Apr  4 07:35:01 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_laggproto.c,v 1.10 2024/04/04 07:31:10 yamaguchi Exp $	*/
+/*	$NetBSD: if_laggproto.c,v 1.11 2024/04/04 07:35:01 yamaguchi Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_laggproto.c,v 1.10 2024/04/04 07:31:10 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_laggproto.c,v 1.11 2024/04/04 07:35:01 yamaguchi Exp $");
 
 #include 
 #include 
@@ -695,14 +695,18 @@ lagg_lb_transmit(struct lagg_proto_softc
 	int s;
 
 	lb = psc->psc_ctx;
-	hash  = lagg_hashmbuf(psc->psc_softc, m);
+	hash = lagg_hashmbuf(psc->psc_softc, m);
 
 	s = pserialize_read_enter();
 
 	pm = lagg_portmap_active(&lb->lb_pmaps);
-	hash %= pm->pm_nports;
-	lp0 = pm->pm_ports[hash];
-	lp = lagg_link_active(psc, lp0->lp_proto_ctx, &psref);
+	if (__predict_true(pm->pm_nports != 0)) {
+		hash %= pm->pm_nports;
+		lp0 = pm->pm_ports[hash];
+		lp = lagg_link_active(psc, lp0->lp_proto_ctx, &psref);
+	} else {
+		lp = NULL;
+	}
 
 	pserialize_read_exit(s);
 



CVS commit: src/sys/net/lagg

2024-04-04 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Apr  4 07:40:39 UTC 2024

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

Log Message:
lagg(4): Added LACP_READY state for logging
when a port turns SELECTED or UNSELECTED


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/net/lagg/if_lagg_lacp.c

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

2024-04-04 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Apr  4 07:40:39 UTC 2024

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

Log Message:
lagg(4): Added LACP_READY state for logging
when a port turns SELECTED or UNSELECTED


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/net/lagg/if_lagg_lacp.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_lacp.c
diff -u src/sys/net/lagg/if_lagg_lacp.c:1.29 src/sys/net/lagg/if_lagg_lacp.c:1.30
--- src/sys/net/lagg/if_lagg_lacp.c:1.29	Wed Nov 22 03:52:58 2023
+++ src/sys/net/lagg/if_lagg_lacp.c	Thu Apr  4 07:40:38 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg_lacp.c,v 1.29 2023/11/22 03:52:58 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg_lacp.c,v 1.30 2024/04/04 07:40:38 yamaguchi Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.29 2023/11/22 03:52:58 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.30 2024/04/04 07:40:38 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_lagg.h"
@@ -75,6 +75,7 @@ enum {
 
 enum lacp_selected {
 	LACP_UNSELECTED,
+	LACP_READY,
 	LACP_STANDBY,
 	LACP_SELECTED,
 };
@@ -2457,7 +2458,7 @@ lacp_select(struct lacp_softc *lsc, stru
 	LACP_DPRINTF((lsc, lacpp, "aggregator lagid=%s\n", buf));
 
 	lacpp->lp_aggregator = la;
-	lacpp->lp_selected = LACP_STANDBY;
+	lacpp->lp_selected = LACP_READY;
 
 	LIST_FOREACH(lacpp0, &la->la_ports, lp_entry_la) {
 		if (lacp_port_priority_max(lacpp0, lacpp) == lacpp) {



CVS commit: src/sys/net/lagg

2024-04-04 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Apr  4 07:45:57 UTC 2024

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

Log Message:
lagg(4): added log on detaching a port from SELECTED state to STANDBY


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/net/lagg/if_lagg_lacp.c

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

2024-04-04 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Apr  4 07:45:57 UTC 2024

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

Log Message:
lagg(4): added log on detaching a port from SELECTED state to STANDBY


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/net/lagg/if_lagg_lacp.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_lacp.c
diff -u src/sys/net/lagg/if_lagg_lacp.c:1.30 src/sys/net/lagg/if_lagg_lacp.c:1.31
--- src/sys/net/lagg/if_lagg_lacp.c:1.30	Thu Apr  4 07:40:38 2024
+++ src/sys/net/lagg/if_lagg_lacp.c	Thu Apr  4 07:45:57 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg_lacp.c,v 1.30 2024/04/04 07:40:38 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg_lacp.c,v 1.31 2024/04/04 07:45:57 yamaguchi Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.30 2024/04/04 07:40:38 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.31 2024/04/04 07:45:57 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_lagg.h"
@@ -2317,6 +2317,10 @@ lacp_sm_mux(struct lacp_softc *lsc, stru
 			break;
 		case LACP_MUX_ATTACHED:
 			if (selected != LACP_SELECTED) {
+if (selected == LACP_STANDBY)
+	LAGG_LOG(lsc->lsc_softc, LOG_INFO,
+	"detaching %s\n",
+	LACP_PORT_XNAME(lacpp));
 next_state = LACP_MUX_DETACHED;
 			} else if (lacp_isactive(lsc, lacpp) && p_sync) {
 next_state = LACP_MUX_COLLECTING;



CVS commit: src/sys/net/lagg

2024-04-04 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Apr  4 07:49:06 UTC 2024

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

Log Message:
acquire LAGG_PROTO_LOCK instead of pserialize read section


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/net/lagg/if_laggproto.c

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

2024-04-04 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Apr  4 07:49:06 UTC 2024

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

Log Message:
acquire LAGG_PROTO_LOCK instead of pserialize read section


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/net/lagg/if_laggproto.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_laggproto.c
diff -u src/sys/net/lagg/if_laggproto.c:1.11 src/sys/net/lagg/if_laggproto.c:1.12
--- src/sys/net/lagg/if_laggproto.c:1.11	Thu Apr  4 07:35:01 2024
+++ src/sys/net/lagg/if_laggproto.c	Thu Apr  4 07:49:06 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_laggproto.c,v 1.11 2024/04/04 07:35:01 yamaguchi Exp $	*/
+/*	$NetBSD: if_laggproto.c,v 1.12 2024/04/04 07:49:06 yamaguchi Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_laggproto.c,v 1.11 2024/04/04 07:35:01 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_laggproto.c,v 1.12 2024/04/04 07:49:06 yamaguchi Exp $");
 
 #include 
 #include 
@@ -65,9 +65,8 @@ struct lagg_proto_softc {
  * Locking notes:
  * - Items of struct lagg_proto_softc is protected by
  *   psc_lock (an adaptive mutex)
- * - psc_ports is protected by pserialize (psc_psz)
- *   - Updates of psc_ports is serialized by sc_lock in
- * struct lagg_softc
+ * - psc_ports is protected by pselialize (psc_psz) and
+ *   it updates exclusively by LAGG_PROTO_LOCK.
  * - Other locking notes are described in if_laggproto.h
  */
 
@@ -751,21 +750,18 @@ lagg_lb_linkspeed_work(struct lagg_work 
 	struct lagg_proto_softc *psc = xpsc;
 	struct lagg_proto_port *pport;
 	uint64_t linkspeed, l;
-	int s;
 
 	linkspeed = 0;
 
-	s = pserialize_read_enter();
+	LAGG_PROTO_LOCK(psc); /* acquired to refer lpp_linkspeed */
 	PSLIST_READER_FOREACH(pport, &psc->psc_ports,
 	struct lagg_proto_port, lpp_entry) {
 		if (pport->lpp_active) {
-			LAGG_PROTO_LOCK(psc);
 			l = pport->lpp_linkspeed;
-			LAGG_PROTO_UNLOCK(psc);
 			linkspeed = MAX(linkspeed, l);
 		}
 	}
-	pserialize_read_exit(s);
+	LAGG_PROTO_UNLOCK(psc);
 
 	LAGG_LOCK(psc->psc_softc);
 	lagg_set_linkspeed(psc->psc_softc, linkspeed);



CVS commit: src/sys/net/lagg

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

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

Log Message:
lagg(4): Remove unnecessary LAGG_LOCK holding while lagg_proto_detach()
to avoid deadlock in workqueue_wait due to LAGG_LOCK holding

lagg_proto_detach dose not need to hold LAGG_LOCK because only one
context can access to a detaching protocol after sc->sc_var is updated.
But it was held without any reason. And it had caused a deadlock by
holding LAGG_LOCK in caller of workqueue_wait
and waiting for the lock in worker.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/net/lagg/if_lagg.c
cvs rdiff -u -r1.31 -r1.32 src/sys/net/lagg/if_lagg_lacp.c

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

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

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

Log Message:
lagg(4): Remove unnecessary LAGG_LOCK holding while lagg_proto_detach()
to avoid deadlock in workqueue_wait due to LAGG_LOCK holding

lagg_proto_detach dose not need to hold LAGG_LOCK because only one
context can access to a detaching protocol after sc->sc_var is updated.
But it was held without any reason. And it had caused a deadlock by
holding LAGG_LOCK in caller of workqueue_wait
and waiting for the lock in worker.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/net/lagg/if_lagg.c
cvs rdiff -u -r1.31 -r1.32 src/sys/net/lagg/if_lagg_lacp.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.58 src/sys/net/lagg/if_lagg.c:1.59
--- src/sys/net/lagg/if_lagg.c:1.58	Thu Apr  4 07:55:32 2024
+++ src/sys/net/lagg/if_lagg.c	Thu Apr  4 08:20:20 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.58 2024/04/04 07:55:32 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.59 2024/04/04 08:20:20 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.58 2024/04/04 07:55:32 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.59 2024/04/04 08:20:20 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1649,11 +1649,9 @@ lagg_pr_attach(struct lagg_softc *sc, la
 {
 	struct lagg_variant *newvar, *oldvar;
 	struct lagg_proto_softc *psc;
-	bool cleanup_oldvar;
 	int error;
 
 	error = 0;
-	cleanup_oldvar = false;
 	newvar = kmem_alloc(sizeof(*newvar), KM_SLEEP);
 
 	LAGG_LOCK(sc);
@@ -1661,32 +1659,28 @@ lagg_pr_attach(struct lagg_softc *sc, la
 
 	if (oldvar != NULL && oldvar->lv_proto == pr) {
 		error = 0;
-		goto done;
+		goto failed;
 	}
 
 	error = lagg_proto_attach(sc, pr, &psc);
 	if (error != 0)
-		goto done;
+		goto failed;
 
 	newvar->lv_proto = pr;
 	newvar->lv_psc = psc;
-
 	lagg_variant_update(sc, newvar);
-	newvar = NULL;
+	lagg_set_linkspeed(sc, 0);
+	LAGG_UNLOCK(sc);
 
 	if (oldvar != NULL) {
 		lagg_proto_detach(oldvar);
-		cleanup_oldvar = true;
+		kmem_free(oldvar, sizeof(*oldvar));
 	}
 
-	lagg_set_linkspeed(sc, 0);
-done:
-	LAGG_UNLOCK(sc);
+	return 0;
 
-	if (newvar != NULL)
-		kmem_free(newvar, sizeof(*newvar));
-	if (cleanup_oldvar)
-		kmem_free(oldvar, sizeof(*oldvar));
+failed:
+	kmem_free(newvar, sizeof(*newvar));
 
 	return error;
 }
@@ -1697,15 +1691,14 @@ lagg_pr_detach(struct lagg_softc *sc)
 	struct lagg_variant *var;
 
 	LAGG_LOCK(sc);
-
 	var = sc->sc_var;
 	atomic_store_release(&sc->sc_var, NULL);
 	pserialize_perform(sc->sc_psz);
+	LAGG_UNLOCK(sc);
 
 	if (var != NULL)
 		lagg_proto_detach(var);
 
-	LAGG_UNLOCK(sc);
 
 	if (var != NULL)
 		kmem_free(var, sizeof(*var));

Index: src/sys/net/lagg/if_lagg_lacp.c
diff -u src/sys/net/lagg/if_lagg_lacp.c:1.31 src/sys/net/lagg/if_lagg_lacp.c:1.32
--- src/sys/net/lagg/if_lagg_lacp.c:1.31	Thu Apr  4 07:45:57 2024
+++ src/sys/net/lagg/if_lagg_lacp.c	Thu Apr  4 08:20:20 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg_lacp.c,v 1.31 2024/04/04 07:45:57 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg_lacp.c,v 1.32 2024/04/04 08:20:20 yamaguchi Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.31 2024/04/04 07:45:57 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.32 2024/04/04 08:20:20 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_lagg.h"
@@ -536,11 +536,12 @@ lacp_detach(struct lagg_proto_softc *xls
 	struct lacp_softc *lsc = (struct lacp_softc *)xlsc;
 	struct lagg_softc *sc __diagused = lsc->lsc_softc;
 
-	KASSERT(LAGG_LOCKED(lsc->lsc_softc));
 	KASSERT(TAILQ_EMPTY(&lsc->lsc_aggregators));
 	KASSERT(SIMPLEQ_EMPTY(&sc->sc_ports));
 
+	LAGG_LOCK(lsc->lsc_softc);
 	lacp_down(xlsc);
+	LAGG_UNLOCK(lsc->lsc_softc);
 
 	lagg_workq_wait(lsc->lsc_workq, &lsc->lsc_work_rcvdu);
 	evcnt_detach(&lsc->lsc_mgethdr_failed);



CVS commit: src/sys/net/lagg

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

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

Log Message:
added missing LAGG_UNLOCK()


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 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/sys/net/lagg

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

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

Log Message:
added missing LAGG_UNLOCK()


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 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.59 src/sys/net/lagg/if_lagg.c:1.60
--- src/sys/net/lagg/if_lagg.c:1.59	Thu Apr  4 08:20:20 2024
+++ src/sys/net/lagg/if_lagg.c	Thu Apr  4 08:22:17 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.59 2024/04/04 08:20:20 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.60 2024/04/04 08:22:17 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.59 2024/04/04 08:20:20 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.60 2024/04/04 08:22:17 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1680,6 +1680,7 @@ lagg_pr_attach(struct lagg_softc *sc, la
 	return 0;
 
 failed:
+	LAGG_UNLOCK(sc);
 	kmem_free(newvar, sizeof(*newvar));
 
 	return error;



CVS commit: src/sys/net/lagg

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

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

Log Message:
lagg(4): added size check to SIOCSLAGG

pointed out by ozaki-r@, thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 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.60 src/sys/net/lagg/if_lagg.c:1.61
--- src/sys/net/lagg/if_lagg.c:1.60	Thu Apr  4 08:22:17 2024
+++ src/sys/net/lagg/if_lagg.c	Thu Apr  4 08:26:32 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.60 2024/04/04 08:22:17 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.61 2024/04/04 08:26:32 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.60 2024/04/04 08:22:17 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.61 2024/04/04 08:26:32 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -693,7 +693,10 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd
 			break;
 
 		nports = laggreq.lrq_nports;
-		if (nports > 0) {
+		if (nports > LAGG_MAX_PORTS) {
+			error = ENOMEM;
+			break;
+		} else if (nports > 0) {
 			allocsiz = sizeof(struct lagg_req)
 			+ sizeof(struct laggreqport) * nports;
 			buf = kmem_alloc(allocsiz, KM_SLEEP);



CVS commit: src/sys/net/lagg

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

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

Log Message:
lagg(4): added size check to SIOCSLAGG

pointed out by ozaki-r@, thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 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/sys/net/lagg

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

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

Log Message:
lagg(4): move comment about IFF_PROMISC

pointed out by ozaki-r@, thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 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/sys/net/lagg

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

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

Log Message:
lagg(4): move comment about IFF_PROMISC

pointed out by ozaki-r@, thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 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.61 src/sys/net/lagg/if_lagg.c:1.62
--- src/sys/net/lagg/if_lagg.c:1.61	Thu Apr  4 08:26:32 2024
+++ src/sys/net/lagg/if_lagg.c	Thu Apr  4 08:29:25 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.61 2024/04/04 08:26:32 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.62 2024/04/04 08:29:25 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.61 2024/04/04 08:26:32 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.62 2024/04/04 08:29:25 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1139,11 +1139,6 @@ lagg_input_ethernet(struct ifnet *ifp_po
 
 	ifp = &lp->lp_softc->sc_if;
 
-	/*
-	 * Drop promiscuously received packets
-	 * if we are not in promiscuous mode.
-	 */
-
 	if (__predict_false(m->m_len < (int)sizeof(*eh))) {
 		if ((m = m_pullup(m, sizeof(*eh))) == NULL) {
 			if_statinc(ifp, if_ierrors);
@@ -1166,6 +1161,10 @@ lagg_input_ethernet(struct ifnet *ifp_po
 
 		if_statinc(ifp_port, if_imcasts);
 	} else {
+		/*
+		 * Drop promiscuously received packets
+		 * if we are not in promiscuous mode.
+		 */
 		if ((ifp->if_flags & IFF_PROMISC) == 0 &&
 		(ifp_port->if_flags & IFF_PROMISC) != 0 &&
 		memcmp(CLLADDR(ifp->if_sadl), eh->ether_dhost,



CVS commit: src/sys/net/lagg

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

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

Log Message:
lagg(4): added NULL check for pfil_run_hooks

pointed out by ozaki-r@, thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 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/sys/net/lagg

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

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

Log Message:
lagg(4): added NULL check for pfil_run_hooks

pointed out by ozaki-r@, thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 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.62 src/sys/net/lagg/if_lagg.c:1.63
--- src/sys/net/lagg/if_lagg.c:1.62	Thu Apr  4 08:29:25 2024
+++ src/sys/net/lagg/if_lagg.c	Thu Apr  4 08:31:58 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.62 2024/04/04 08:29:25 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.63 2024/04/04 08:31:58 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.62 2024/04/04 08:29:25 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.63 2024/04/04 08:31:58 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1068,8 +1068,12 @@ lagg_output(struct lagg_softc *sc, struc
 	mflags = m->m_flags;
 
 	error = pfil_run_hooks(ifp->if_pfil, &m, ifp, PFIL_OUT);
-	if (error != 0)
+	if (error != 0) {
+		if (m != NULL) {
+			m_freem(m);
+		}
 		return;
+	}
 	bpf_mtap(ifp, m, BPF_D_OUT);
 
 	error = lagg_port_xmit(lp, m);
@@ -1175,8 +1179,13 @@ lagg_input_ethernet(struct ifnet *ifp_po
 	if_statadd(ifp_port, if_ibytes, m->m_pkthdr.len);
 
 	if (pfil_run_hooks(ifp_port->if_pfil, &m,
-	ifp_port, PFIL_IN) != 0)
+	ifp_port, PFIL_IN) != 0) {
+		if (m != NULL) {
+			m_freem(m);
+			m = NULL;
+		}
 		goto out;
+	}
 
 	m = lagg_proto_input(lp->lp_softc, lp, m);
 	if (m != NULL) {



CVS commit: src/sys/net/lagg

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

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

Log Message:
lagg(4): change errno

suggested by ozaki-r@, thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/net/lagg/if_lagg.c
cvs rdiff -u -r1.32 -r1.33 src/sys/net/lagg/if_lagg_lacp.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.63 src/sys/net/lagg/if_lagg.c:1.64
--- src/sys/net/lagg/if_lagg.c:1.63	Thu Apr  4 08:31:58 2024
+++ src/sys/net/lagg/if_lagg.c	Thu Apr  4 08:36:03 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.63 2024/04/04 08:31:58 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.64 2024/04/04 08:36:03 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.63 2024/04/04 08:31:58 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.64 2024/04/04 08:36:03 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1027,7 +1027,7 @@ lagg_tx_common(struct ifnet *ifp, struct
 	} else {
 		m_freem(m);
 		if_statinc(ifp, if_oerrors);
-		error = ENOBUFS;
+		error = EIO;
 	}
 
 	lagg_variant_putref(var, &psref);

Index: src/sys/net/lagg/if_lagg_lacp.c
diff -u src/sys/net/lagg/if_lagg_lacp.c:1.32 src/sys/net/lagg/if_lagg_lacp.c:1.33
--- src/sys/net/lagg/if_lagg_lacp.c:1.32	Thu Apr  4 08:20:20 2024
+++ src/sys/net/lagg/if_lagg_lacp.c	Thu Apr  4 08:36:03 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg_lacp.c,v 1.32 2024/04/04 08:20:20 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg_lacp.c,v 1.33 2024/04/04 08:36:03 yamaguchi Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.32 2024/04/04 08:20:20 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.33 2024/04/04 08:36:03 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_lagg.h"
@@ -640,7 +640,7 @@ lacp_transmit(struct lagg_proto_softc *x
 	if (__predict_false(lsc->lsc_suppress_distributing)) {
 		LACP_DPRINTF((lsc, NULL, "waiting transit\n"));
 		m_freem(m);
-		return ENOBUFS;
+		return EBUSY;
 	}
 
 	lp = lacp_select_tx_port(lsc, m, &psref);



CVS commit: src/sys/net/lagg

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

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

Log Message:
lagg(4): change errno

suggested by ozaki-r@, thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/net/lagg/if_lagg.c
cvs rdiff -u -r1.32 -r1.33 src/sys/net/lagg/if_lagg_lacp.c

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



  1   2   >