CVS commit: src/sbin/ifconfig
Module Name:src Committed By: yamaguchi Date: Tue Apr 9 08:53:08 UTC 2024 Modified Files: src/sbin/ifconfig: lagg.c Log Message: lagg(4): allocate memory for struct lagg_req by calloc(3) to fix build error on clang To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sbin/ifconfig/lagg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/ifconfig/lagg.c diff -u src/sbin/ifconfig/lagg.c:1.7 src/sbin/ifconfig/lagg.c:1.8 --- src/sbin/ifconfig/lagg.c:1.7 Mon Apr 8 00:50:49 2024 +++ src/sbin/ifconfig/lagg.c Tue Apr 9 08:53:08 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: lagg.c,v 1.7 2024/04/08 00:50:49 yamaguchi Exp $ */ +/* $NetBSD: lagg.c,v 1.8 2024/04/09 08:53:08 yamaguchi Exp $ */ /* * Copyright (c) 2021 Internet Initiative Japan Inc. @@ -28,7 +28,7 @@ #include #if !defined(lint) -__RCSID("$NetBSD: lagg.c,v 1.7 2024/04/08 00:50:49 yamaguchi Exp $"); +__RCSID("$NetBSD: lagg.c,v 1.8 2024/04/09 08:53:08 yamaguchi Exp $"); #endif /* !defined(lint) */ #include @@ -393,15 +393,13 @@ setlaggproto(prop_dictionary_t env, prop static int setlaggport(prop_dictionary_t env, prop_dictionary_t oenv __unused) { - struct { - struct lagg_req req; - struct laggreqport port[1]; - } _req; struct lagg_req *req; struct laggreqport *rp; const char *ifname; enum lagg_ioctl ioc; int64_t lpcmd, pri; + int rv; + size_t sz; if (!prop_dictionary_get_string(env, "laggport", &ifname)) { if (lagg_debug) @@ -410,11 +408,15 @@ setlaggport(prop_dictionary_t env, prop_ return -1; } - memset(&_req, 0, sizeof(_req)); - req = (struct lagg_req *)&_req; - rp = &req->lrq_reqports[0]; - req->lrq_nports = 1; + sz = sizeof(*req) + sizeof(req->lrq_reqports[0]) * 1; + req = calloc(1, sz); + if (req == NULL) { + errno = ENOBUFS; + return -1; + } + req->lrq_nports = 1; + rp = &req->lrq_reqports[0]; strlcpy(rp->rp_portname, ifname, sizeof(rp->rp_portname)); ioc = LAGGIOC_NOCMD; @@ -433,15 +435,16 @@ setlaggport(prop_dictionary_t env, prop_ if (ioc != LAGGIOC_NOCMD) { req->lrq_ioctl = ioc; - if (indirect_ioctl(env, SIOCSLAGG, req) == -1) { - if (lagg_debug) { -warn("cmd=%d", ioc); - } - return -1; - } + rv = indirect_ioctl(env, SIOCSLAGG, req); + if (lagg_debug && rv == -1) + warn("cmd=%d", ioc); + } else { + rv = 0; } - return 0; + free(req); + + return rv; } static int
CVS commit: src/sbin/ifconfig
Module Name:src Committed By: yamaguchi Date: Tue Apr 9 08:53:08 UTC 2024 Modified Files: src/sbin/ifconfig: lagg.c Log Message: lagg(4): allocate memory for struct lagg_req by calloc(3) to fix build error on clang To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sbin/ifconfig/lagg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/ifconfig
Module Name:src Committed By: yamaguchi Date: Mon Apr 8 04:29:52 UTC 2024 Modified Files: src/sbin/ifconfig: ifconfig.8 Log Message: Added documents about parameters related to lagg(4) PR misc/58125 To generate a diff of this commit: cvs rdiff -u -r1.125 -r1.126 src/sbin/ifconfig/ifconfig.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/ifconfig/ifconfig.8 diff -u src/sbin/ifconfig/ifconfig.8:1.125 src/sbin/ifconfig/ifconfig.8:1.126 --- src/sbin/ifconfig/ifconfig.8:1.125 Sun Mar 26 01:04:16 2023 +++ src/sbin/ifconfig/ifconfig.8 Mon Apr 8 04:29:52 2024 @@ -1,4 +1,4 @@ -.\" $NetBSD: ifconfig.8,v 1.125 2023/03/26 01:04:16 mlelstv Exp $ +.\" $NetBSD: ifconfig.8,v 1.126 2024/04/08 04:29:52 yamaguchi Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -614,6 +614,40 @@ Remove from the .Xr agr 4 interface. +.It Cm laggport Ar interface Oo Cm pri Ar n Oc +Add the interface named by +.Ar interface +as a port of the +.Xr lagg 4 +interface, +and set the priority of +.Ar interface +to +.Ar n . +.It Cm -laggport Ar interface +Remove the interface named by +.Ar interface +from the +.Xr lagg 4 +interface. +.It Cm laggproto Ar proto +Set the aggregation protocol of +.Xr lagg 4 . +The default is +.Li none . +The available options are +.Li failover , +.Li lacp , +.Li loadbalance , +and +.Li none . +.It Cm laggportpri Ar interface Ar n +If the interface id a +.Xr lagg 4 +pseudo-interface, set the priority of +.Ar interface +to +.Ar n .It Cm eee Enable IEEE 802.3az Energy Efficiency Ethernet function. .It Cm -eee @@ -899,6 +933,7 @@ tried to alter an interface's configurat .Sh SEE ALSO .Xr netstat 1 , .Xr agr 4 , +.Xr lagg 4 , .Xr carp 4 , .Xr ifmedia 4 , .Xr netintro 4 ,
CVS commit: src/sbin/ifconfig
Module Name:src Committed By: yamaguchi Date: Mon Apr 8 04:29:52 UTC 2024 Modified Files: src/sbin/ifconfig: ifconfig.8 Log Message: Added documents about parameters related to lagg(4) PR misc/58125 To generate a diff of this commit: cvs rdiff -u -r1.125 -r1.126 src/sbin/ifconfig/ifconfig.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/ifconfig
Module Name:src Committed By: yamaguchi Date: Mon Apr 8 00:50:49 UTC 2024 Modified Files: src/sbin/ifconfig: lagg.c Log Message: lagg(4): fix missing initialization of the number of array pointed out by martin@, thanks. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sbin/ifconfig/lagg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/ifconfig
Module Name:src Committed By: yamaguchi Date: Mon Apr 8 00:50:49 UTC 2024 Modified Files: src/sbin/ifconfig: lagg.c Log Message: lagg(4): fix missing initialization of the number of array pointed out by martin@, thanks. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sbin/ifconfig/lagg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/ifconfig/lagg.c diff -u src/sbin/ifconfig/lagg.c:1.6 src/sbin/ifconfig/lagg.c:1.7 --- src/sbin/ifconfig/lagg.c:1.6 Thu Apr 4 08:01:55 2024 +++ src/sbin/ifconfig/lagg.c Mon Apr 8 00:50:49 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: lagg.c,v 1.6 2024/04/04 08:01:55 yamaguchi Exp $ */ +/* $NetBSD: lagg.c,v 1.7 2024/04/08 00:50:49 yamaguchi Exp $ */ /* * Copyright (c) 2021 Internet Initiative Japan Inc. @@ -28,7 +28,7 @@ #include #if !defined(lint) -__RCSID("$NetBSD: lagg.c,v 1.6 2024/04/04 08:01:55 yamaguchi Exp $"); +__RCSID("$NetBSD: lagg.c,v 1.7 2024/04/08 00:50:49 yamaguchi Exp $"); #endif /* !defined(lint) */ #include @@ -413,6 +413,7 @@ setlaggport(prop_dictionary_t env, prop_ memset(&_req, 0, sizeof(_req)); req = (struct lagg_req *)&_req; rp = &req->lrq_reqports[0]; + req->lrq_nports = 1; strlcpy(rp->rp_portname, ifname, sizeof(rp->rp_portname)); ioc = LAGGIOC_NOCMD;
CVS commit: src/tests/net/if_lagg
Module Name:src Committed By: yamaguchi Date: Fri Apr 5 07:04:17 UTC 2024 Modified Files: src/tests/net/if_lagg: t_lagg.sh Log Message: lagg(4) test: Fix typo and old comment To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/tests/net/if_lagg/t_lagg.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/net/if_lagg/t_lagg.sh diff -u src/tests/net/if_lagg/t_lagg.sh:1.10 src/tests/net/if_lagg/t_lagg.sh:1.11 --- src/tests/net/if_lagg/t_lagg.sh:1.10 Wed Oct 18 06:41:00 2023 +++ src/tests/net/if_lagg/t_lagg.sh Fri Apr 5 07:04:17 2024 @@ -1,4 +1,4 @@ -# $NetBSD: t_lagg.sh,v 1.10 2023/10/18 06:41:00 yamaguchi Exp $ +# $NetBSD: t_lagg.sh,v 1.11 2024/04/05 07:04:17 yamaguchi Exp $ # # Copyright (c) 2021 Internet Initiative Japan Inc. # All rights reserved. @@ -214,7 +214,7 @@ lagg_ifconfig_body() lagg_ifconfig_cleanup() { - $DEBG && dump + $DEBUG && dump cleanup } @@ -392,7 +392,7 @@ lagg_mtu_body() atf_check -s exit:0 -o match:"mtu *$mtu_big" rump.ifconfig shmif1 atf_check -s exit:0 -o match:"mtu *$mtu_small" rump.ifconfig shmif2 - # copy MTU from 1st port + # copy MTU to 1st added port $atf_ifconfig lagg0 laggport shmif0 atf_check -s exit:0 -o match:"mtu *$mtu_lagg" rump.ifconfig lagg0 atf_check -s exit:0 -o match:"mtu *$mtu_lagg" rump.ifconfig shmif0
CVS commit: src/tests/net/if_lagg
Module Name:src Committed By: yamaguchi Date: Fri Apr 5 07:04:17 UTC 2024 Modified Files: src/tests/net/if_lagg: t_lagg.sh Log Message: lagg(4) test: Fix typo and old comment To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/tests/net/if_lagg/t_lagg.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/net/lagg
Module Name:src Committed By: yamaguchi Date: Fri Apr 5 06:51:41 UTC 2024 Modified Files: src/sys/net/lagg: if_laggproto.c Log Message: lagg(4): Fix missing destroy for list and entry To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 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.14 src/sys/net/lagg/if_laggproto.c:1.15 --- src/sys/net/lagg/if_laggproto.c:1.14 Fri Apr 5 06:37:29 2024 +++ src/sys/net/lagg/if_laggproto.c Fri Apr 5 06:51:41 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_laggproto.c,v 1.14 2024/04/05 06:37:29 yamaguchi Exp $ */ +/* $NetBSD: if_laggproto.c,v 1.15 2024/04/05 06:51:41 yamaguchi Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-NetBSD @@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_laggproto.c,v 1.14 2024/04/05 06:37:29 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_laggproto.c,v 1.15 2024/04/05 06:51:41 yamaguchi Exp $"); #include #include @@ -206,6 +206,7 @@ lagg_proto_free(struct lagg_proto_softc pserialize_destroy(psc->psc_psz); mutex_destroy(&psc->psc_lock); lagg_workq_destroy(psc->psc_workq); + PSLIST_DESTROY(&psc->psc_ports); if (psc->psc_ctxsiz > 0) kmem_free(psc->psc_ctx, psc->psc_ctxsiz); @@ -321,6 +322,10 @@ lagg_proto_remove_port(struct lagg_proto PSLIST_WRITER_REMOVE(pport, lpp_entry); LAGG_PROTO_UNLOCK(psc); pserialize_perform(psc->psc_psz); + + /* re-initialize for reuse */ + PSLIST_ENTRY_DESTROY(pport, lpp_entry); + PSLIST_ENTRY_INIT(pport, lpp_entry); } void
CVS commit: src/sys/net/lagg
Module Name:src Committed By: yamaguchi Date: Fri Apr 5 06:51:41 UTC 2024 Modified Files: src/sys/net/lagg: if_laggproto.c Log Message: lagg(4): Fix missing destroy for list and entry To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 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
Module Name:src Committed By: yamaguchi Date: Fri Apr 5 06:48:23 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg.c Log Message: lagg(4): Added vlan check To generate a diff of this commit: cvs rdiff -u -r1.69 -r1.70 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
Module Name:src Committed By: yamaguchi Date: Fri Apr 5 06:48:23 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg.c Log Message: lagg(4): Added vlan check To generate a diff of this commit: cvs rdiff -u -r1.69 -r1.70 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.69 src/sys/net/lagg/if_lagg.c:1.70 --- src/sys/net/lagg/if_lagg.c:1.69 Fri Apr 5 06:37:29 2024 +++ src/sys/net/lagg/if_lagg.c Fri Apr 5 06:48:22 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_lagg.c,v 1.69 2024/04/05 06:37:29 yamaguchi Exp $ */ +/* $NetBSD: if_lagg.c,v 1.70 2024/04/05 06:48:22 yamaguchi Exp $ */ /* * Copyright (c) 2005, 2006 Reyk Floeter @@ -20,7 +20,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.69 2024/04/05 06:37:29 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.70 2024/04/05 06:48:22 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -2267,6 +2267,9 @@ lagg_port_setup(struct lagg_softc *sc, switch (ifp_port->if_type) { case IFT_ETHER: case IFT_L2TP: + if (VLAN_ATTACHED((struct ethercom *)ifp_port)) + return EBUSY; + if_type = IFT_IEEE8023ADLAG; break; default:
CVS commit: src/sys/net/lagg
Module Name:src Committed By: yamaguchi Date: Fri Apr 5 06:37:29 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg.c if_laggproto.c Log Message: lagg(4): release lock before pserialize_perform() if possible To generate a diff of this commit: cvs rdiff -u -r1.68 -r1.69 src/sys/net/lagg/if_lagg.c cvs rdiff -u -r1.13 -r1.14 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_lagg.c diff -u src/sys/net/lagg/if_lagg.c:1.68 src/sys/net/lagg/if_lagg.c:1.69 --- src/sys/net/lagg/if_lagg.c:1.68 Fri Apr 5 06:05:37 2024 +++ src/sys/net/lagg/if_lagg.c Fri Apr 5 06:37:29 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_lagg.c,v 1.68 2024/04/05 06:05:37 yamaguchi Exp $ */ +/* $NetBSD: if_lagg.c,v 1.69 2024/04/05 06:37:29 yamaguchi Exp $ */ /* * Copyright (c) 2005, 2006 Reyk Floeter @@ -20,7 +20,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.68 2024/04/05 06:05:37 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.69 2024/04/05 06:37:29 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1705,8 +1705,8 @@ lagg_pr_detach(struct lagg_softc *sc) LAGG_LOCK(sc); var = sc->sc_var; atomic_store_release(&sc->sc_var, NULL); - pserialize_perform(sc->sc_psz); LAGG_UNLOCK(sc); + pserialize_perform(sc->sc_psz); if (var != NULL) lagg_proto_detach(var); Index: src/sys/net/lagg/if_laggproto.c diff -u src/sys/net/lagg/if_laggproto.c:1.13 src/sys/net/lagg/if_laggproto.c:1.14 --- src/sys/net/lagg/if_laggproto.c:1.13 Fri Apr 5 06:23:48 2024 +++ src/sys/net/lagg/if_laggproto.c Fri Apr 5 06:37:29 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_laggproto.c,v 1.13 2024/04/05 06:23:48 yamaguchi Exp $ */ +/* $NetBSD: if_laggproto.c,v 1.14 2024/04/05 06:37:29 yamaguchi Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-NetBSD @@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_laggproto.c,v 1.13 2024/04/05 06:23:48 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_laggproto.c,v 1.14 2024/04/05 06:37:29 yamaguchi Exp $"); #include #include @@ -319,8 +319,8 @@ lagg_proto_remove_port(struct lagg_proto LAGG_PROTO_LOCK(psc); PSLIST_WRITER_REMOVE(pport, lpp_entry); - pserialize_perform(psc->psc_psz); LAGG_PROTO_UNLOCK(psc); + pserialize_perform(psc->psc_psz); } void @@ -646,8 +646,8 @@ lagg_lb_startport(struct lagg_proto_soft pm_next->pm_nports = n; lagg_portmap_switch(&lb->lb_pmaps); - pserialize_perform(psc->psc_psz); LAGG_PROTO_UNLOCK(psc); + pserialize_perform(psc->psc_psz); } void @@ -675,8 +675,8 @@ lagg_lb_stopport(struct lagg_proto_softc pm_next->pm_nports = n; lagg_portmap_switch(&lb->lb_pmaps); - pserialize_perform(psc->psc_psz); LAGG_PROTO_UNLOCK(psc); + pserialize_perform(psc->psc_psz); lagg_common_stopport(psc, lp); }
CVS commit: src/sys/net/lagg
Module Name:src Committed By: yamaguchi Date: Fri Apr 5 06:37:29 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg.c if_laggproto.c Log Message: lagg(4): release lock before pserialize_perform() if possible To generate a diff of this commit: cvs rdiff -u -r1.68 -r1.69 src/sys/net/lagg/if_lagg.c cvs rdiff -u -r1.13 -r1.14 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
Module Name:src Committed By: yamaguchi Date: Fri Apr 5 06:31:37 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg_lacp.c Log Message: lagg(4): move reply limitation to recive processing To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 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.42 src/sys/net/lagg/if_lagg_lacp.c:1.43 --- src/sys/net/lagg/if_lagg_lacp.c:1.42 Fri Apr 5 06:21:02 2024 +++ src/sys/net/lagg/if_lagg_lacp.c Fri Apr 5 06:31:37 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_lagg_lacp.c,v 1.42 2024/04/05 06:21:02 yamaguchi Exp $ */ +/* $NetBSD: if_lagg_lacp.c,v 1.43 2024/04/05 06:31:37 yamaguchi Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-NetBSD @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.42 2024/04/05 06:21:02 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.43 2024/04/05 06:31:37 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_lagg.h" @@ -1360,10 +1360,6 @@ lacp_port_need_to_tell(struct lacp_port if (!ISSET(lacpp->lp_flags, LACP_PORT_NTT)) return false; - if (ppsratecheck(&lacpp->lp_last_lacpdu, &lacpp->lp_lacpdu_sent, - (LACP_SENDDU_PPS / LACP_FAST_PERIODIC_TIME)) == 0) - return false; - return true; } @@ -1988,8 +1984,14 @@ lacp_sm_rx_update_ntt(struct lacp_softc if (lacp_compare_peerinfo(&actor, my_pi) != 0 || !LACP_STATE_EQ(lacpp->lp_actor.lpi_state, my_pi->lpi_state, LACP_STATE_ACTIVITY | LACP_STATE_SYNC | LACP_STATE_AGGREGATION)) { - LACP_DPRINTF((lsc, lacpp, "assert ntt\n")); - lacp_sm_assert_ntt(lacpp); + if (ppsratecheck(&lacpp->lp_last_lacpdu, &lacpp->lp_lacpdu_sent, + (LACP_SENDDU_PPS / LACP_FAST_PERIODIC_TIME)) == 0) { + LACP_DPRINTF((lsc, lacpp, + "skip ntt due to rate limit")); + } else { + LACP_DPRINTF((lsc, lacpp, "assert ntt\n")); + lacp_sm_assert_ntt(lacpp); + } } }
CVS commit: src/sys/net/lagg
Module Name:src Committed By: yamaguchi Date: Fri Apr 5 06:31:37 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg_lacp.c Log Message: lagg(4): move reply limitation to recive processing To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 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
Module Name:src Committed By: yamaguchi Date: Fri Apr 5 06:23:48 UTC 2024 Modified Files: src/sys/net/lagg: if_laggproto.c Log Message: lagg(4): remove unnecessary masking pointed out by ozaki-r@, thanks. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 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.12 src/sys/net/lagg/if_laggproto.c:1.13 --- src/sys/net/lagg/if_laggproto.c:1.12 Thu Apr 4 07:49:06 2024 +++ src/sys/net/lagg/if_laggproto.c Fri Apr 5 06:23:48 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_laggproto.c,v 1.12 2024/04/04 07:49:06 yamaguchi Exp $ */ +/* $NetBSD: if_laggproto.c,v 1.13 2024/04/05 06:23:48 yamaguchi Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-NetBSD @@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_laggproto.c,v 1.12 2024/04/04 07:49:06 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_laggproto.c,v 1.13 2024/04/05 06:23:48 yamaguchi Exp $"); #include #include @@ -132,7 +132,6 @@ lagg_portmap_next(struct lagg_portmaps * size_t i; i = atomic_load_consume(&maps->maps_activepmap); - i &= 0x1; i ^= 0x1; return &maps->maps_pmap[i];
CVS commit: src/sys/net/lagg
Module Name:src Committed By: yamaguchi Date: Fri Apr 5 06:23:48 UTC 2024 Modified Files: src/sys/net/lagg: if_laggproto.c Log Message: lagg(4): remove unnecessary masking pointed out by ozaki-r@, thanks. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 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
Module Name:src Committed By: yamaguchi Date: Fri Apr 5 06:21:02 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg_lacp.c Log Message: lagg(4): set suppress at the same time with distribution state To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 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.41 src/sys/net/lagg/if_lagg_lacp.c:1.42 --- src/sys/net/lagg/if_lagg_lacp.c:1.41 Fri Apr 5 06:19:28 2024 +++ src/sys/net/lagg/if_lagg_lacp.c Fri Apr 5 06:21:02 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_lagg_lacp.c,v 1.41 2024/04/05 06:19:28 yamaguchi Exp $ */ +/* $NetBSD: if_lagg_lacp.c,v 1.42 2024/04/05 06:21:02 yamaguchi Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-NetBSD @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.41 2024/04/05 06:19:28 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.42 2024/04/05 06:21:02 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_lagg.h" @@ -2560,19 +2560,23 @@ lacp_suppress_distributing(struct lacp_s { struct lacp_aggregator *la; struct lacp_port *lacpp; + bool marker_scheduled; KASSERT(LACP_LOCKED(lsc)); la = lsc->lsc_aggregator; + marker_scheduled = false; LIST_FOREACH(lacpp, &la->la_ports, lp_entry_la) { if (ISSET(lacpp->lp_actor.lpi_state, LACP_STATE_DISTRIBUTING)) { lagg_workq_add(lsc->lsc_workq, &lacpp->lp_work_marker); + marker_scheduled = true; } } + lsc->lsc_suppress_distributing = marker_scheduled; LACP_PTIMER_ARM(lsc, LACP_PTIMER_DISTRIBUTING, LACP_TRANSIT_DELAY); } @@ -2659,7 +2663,6 @@ lacp_marker_work(struct lagg_work *lw, v return; } SET(lacpp->lp_flags, LACP_PORT_MARK); - lsc->lsc_suppress_distributing = true; lp = lacpp->lp_laggport; bound = curlwp_bind(); lagg_port_getref(lp, &psref);
CVS commit: src/sys/net/lagg
Module Name:src Committed By: yamaguchi Date: Fri Apr 5 06:21:02 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg_lacp.c Log Message: lagg(4): set suppress at the same time with distribution state To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 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
Module Name:src Committed By: yamaguchi Date: Fri Apr 5 06:19:28 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg_lacp.c Log Message: added missing workq_wait for lacp_tick_work() To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 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.40 src/sys/net/lagg/if_lagg_lacp.c:1.41 --- src/sys/net/lagg/if_lagg_lacp.c:1.40 Fri Apr 5 06:16:32 2024 +++ src/sys/net/lagg/if_lagg_lacp.c Fri Apr 5 06:19:28 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_lagg_lacp.c,v 1.40 2024/04/05 06:16:32 yamaguchi Exp $ */ +/* $NetBSD: if_lagg_lacp.c,v 1.41 2024/04/05 06:19:28 yamaguchi Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-NetBSD @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.40 2024/04/05 06:16:32 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.41 2024/04/05 06:19:28 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_lagg.h" @@ -544,6 +544,7 @@ lacp_detach(struct lagg_proto_softc *xls LAGG_UNLOCK(lsc->lsc_softc); lagg_workq_wait(lsc->lsc_workq, &lsc->lsc_work_rcvdu); + lagg_workq_wait(lsc->lsc_workq, &lsc->lsc_work_tick); evcnt_detach(&lsc->lsc_mgethdr_failed); evcnt_detach(&lsc->lsc_mpullup_failed); evcnt_detach(&lsc->lsc_badlacpdu);
CVS commit: src/sys/net/lagg
Module Name:src Committed By: yamaguchi Date: Fri Apr 5 06:19:28 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg_lacp.c Log Message: added missing workq_wait for lacp_tick_work() To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 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
Module Name:src Committed By: yamaguchi Date: Fri Apr 5 06:16:32 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg_lacp.c Log Message: lagg(4): added check of LACP running state for safety When LACP stops, the handler of callout do nothing because all port is already detached from lacp. Therefore, the added checks are just for safety. To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 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.39 src/sys/net/lagg/if_lagg_lacp.c:1.40 --- src/sys/net/lagg/if_lagg_lacp.c:1.39 Fri Apr 5 06:11:16 2024 +++ src/sys/net/lagg/if_lagg_lacp.c Fri Apr 5 06:16:32 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_lagg_lacp.c,v 1.39 2024/04/05 06:11:16 yamaguchi Exp $ */ +/* $NetBSD: if_lagg_lacp.c,v 1.40 2024/04/05 06:16:32 yamaguchi Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-NetBSD @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.39 2024/04/05 06:11:16 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.40 2024/04/05 06:16:32 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_lagg.h" @@ -1491,10 +1491,16 @@ lacp_tick(void *xlsc) lsc = xlsc; - lagg_workq_add(lsc->lsc_workq, &lsc->lsc_work_tick); - LACP_LOCK(lsc); + + if (!lsc->lsc_running) { + LACP_UNLOCK(lsc); + return; + } + + lagg_workq_add(lsc->lsc_workq, &lsc->lsc_work_tick); callout_schedule(&lsc->lsc_tick, hz); + LACP_UNLOCK(lsc); } @@ -1548,6 +1554,11 @@ lacp_tick_work(struct lagg_work *lw __un sc = lsc->lsc_softc; LACP_LOCK(lsc); + if (!lsc->lsc_running) { + LACP_UNLOCK(lsc); + return; + } + lacp_run_prototimers(lsc); LACP_UNLOCK(lsc);
CVS commit: src/sys/net/lagg
Module Name:src Committed By: yamaguchi Date: Fri Apr 5 06:16:32 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg_lacp.c Log Message: lagg(4): added check of LACP running state for safety When LACP stops, the handler of callout do nothing because all port is already detached from lacp. Therefore, the added checks are just for safety. To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 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
Module Name:src Committed By: yamaguchi Date: Fri Apr 5 06:11:16 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg_lacp.c Log Message: fix missing LACP_LOCK To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 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.38 src/sys/net/lagg/if_lagg_lacp.c:1.39 --- src/sys/net/lagg/if_lagg_lacp.c:1.38 Fri Apr 5 06:07:36 2024 +++ src/sys/net/lagg/if_lagg_lacp.c Fri Apr 5 06:11:16 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_lagg_lacp.c,v 1.38 2024/04/05 06:07:36 yamaguchi Exp $ */ +/* $NetBSD: if_lagg_lacp.c,v 1.39 2024/04/05 06:11:16 yamaguchi Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-NetBSD @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.38 2024/04/05 06:07:36 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.39 2024/04/05 06:11:16 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_lagg.h" @@ -1444,10 +1444,13 @@ lacp_sm_tx_work(struct lagg_work *lw, vo lsc = xlsc; lacpp = container_of(lw, struct lacp_port, lp_work_smtx); - if (lsc->lsc_stop_lacpdu) + LACP_LOCK(lsc); + + if (lsc->lsc_stop_lacpdu) { + LACP_UNLOCK(lsc); return; + } - LACP_LOCK(lsc); m = lacp_lacpdu_mbuf(lsc, lacpp); if (m == NULL) { LACP_UNLOCK(lsc);
CVS commit: src/sys/net/lagg
Module Name:src Committed By: yamaguchi Date: Fri Apr 5 06:11:16 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg_lacp.c Log Message: fix missing LACP_LOCK To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 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
Module Name:src Committed By: yamaguchi Date: Fri Apr 5 06:07:37 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg_lacp.c Log Message: lagg(4): added missing pserialize_read_enter To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 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
Module Name:src Committed By: yamaguchi Date: Fri Apr 5 06:07:37 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg_lacp.c Log Message: lagg(4): added missing pserialize_read_enter To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 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.37 src/sys/net/lagg/if_lagg_lacp.c:1.38 --- src/sys/net/lagg/if_lagg_lacp.c:1.37 Thu Apr 4 09:19:42 2024 +++ src/sys/net/lagg/if_lagg_lacp.c Fri Apr 5 06:07:36 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_lagg_lacp.c,v 1.37 2024/04/04 09:19:42 yamaguchi Exp $ */ +/* $NetBSD: if_lagg_lacp.c,v 1.38 2024/04/05 06:07:36 yamaguchi Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-NetBSD @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.37 2024/04/04 09:19:42 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.38 2024/04/05 06:07:36 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_lagg.h" @@ -1290,7 +1290,7 @@ lacp_rcvdu_work(struct lagg_work *lw __u struct lagg_port *lp; struct mbuf *m; uint8_t subtype; - int bound, s; + int bound, s0, s1; bound = curlwp_bind(); @@ -1299,23 +1299,26 @@ lacp_rcvdu_work(struct lagg_work *lw __u if (m == NULL) break; - ifp = m_get_rcvif(m, &s); + ifp = m_get_rcvif(m, &s0); if (ifp == NULL) { m_freem(m); lsc->lsc_norcvif.ev_count++; continue; } + s1 = pserialize_read_enter(); lp = atomic_load_consume(&ifp->if_lagg); if (lp == NULL) { - m_put_rcvif(ifp, &s); + pserialize_read_exit(s1); + m_put_rcvif(ifp, &s0); m_freem(m); lsc->lsc_norcvif.ev_count++; continue; } lagg_port_getref(lp, &psref_lp); - m_put_rcvif(ifp, &s); + pserialize_read_exit(s1); + m_put_rcvif(ifp, &s0); m_copydata(m, sizeof(struct ether_header), sizeof(subtype), &subtype);
CVS commit: src/sys/net/lagg
Module Name:src Committed By: yamaguchi Date: Fri Apr 5 06:05:37 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg.c Log Message: lagg(4): added __predict_true To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 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.67 src/sys/net/lagg/if_lagg.c:1.68 --- src/sys/net/lagg/if_lagg.c:1.67 Thu Apr 4 09:19:42 2024 +++ src/sys/net/lagg/if_lagg.c Fri Apr 5 06:05:37 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_lagg.c,v 1.67 2024/04/04 09:19:42 yamaguchi Exp $ */ +/* $NetBSD: if_lagg.c,v 1.68 2024/04/05 06:05:37 yamaguchi Exp $ */ /* * Copyright (c) 2005, 2006 Reyk Floeter @@ -20,7 +20,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.67 2024/04/04 09:19:42 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.68 2024/04/05 06:05:37 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -3010,7 +3010,7 @@ lagg_chg_sadl(struct ifnet *ifp, const u } /* Activate the next Link-Level address */ - if (ifa_next != ifp->if_dl) { + if (__predict_true(ifa_next != ifp->if_dl)) { /* save the current address */ ifa_cur = ifp->if_dl; if (ifa_cur != NULL)
CVS commit: src/sys/net/lagg
Module Name:src Committed By: yamaguchi Date: Fri Apr 5 06:05:37 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg.c Log Message: lagg(4): added __predict_true To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 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
Module Name:src Committed By: yamaguchi Date: Thu Apr 4 09:19:43 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg.c if_lagg_lacp.c Log Message: Added comments to lagg(4) To generate a diff of this commit: cvs rdiff -u -r1.66 -r1.67 src/sys/net/lagg/if_lagg.c cvs rdiff -u -r1.36 -r1.37 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.66 src/sys/net/lagg/if_lagg.c:1.67 --- src/sys/net/lagg/if_lagg.c:1.66 Thu Apr 4 08:50:58 2024 +++ src/sys/net/lagg/if_lagg.c Thu Apr 4 09:19:42 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_lagg.c,v 1.66 2024/04/04 08:50:58 yamaguchi Exp $ */ +/* $NetBSD: if_lagg.c,v 1.67 2024/04/04 09:19:42 yamaguchi Exp $ */ /* * Copyright (c) 2005, 2006 Reyk Floeter @@ -20,7 +20,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.66 2024/04/04 08:50:58 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.67 2024/04/04 09:19:42 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -2165,6 +2165,7 @@ lagg_port_setsadl(struct lagg_port *lp, if (ifp_port->if_init != NULL) { error = 0; + /* Apply updated ifp_port->if_sadl to the device */ if (ISSET(ifp_port->if_flags, IFF_RUNNING)) error = if_init(ifp_port); @@ -2929,7 +2930,9 @@ lagg_chg_sadl(struct ifnet *ifp, const u error = 0; ifa_lla = NULL; + /* Renew all AF_LINK address to update sdl_type */ while (1) { + /* find a Link-Level address that has the previous sdl_type */ s = pserialize_read_enter(); IFADDR_READER_FOREACH(ifa_cur, ifp) { sdl = satocsdl(ifa_cur->ifa_addr); @@ -2945,7 +2948,10 @@ lagg_chg_sadl(struct ifnet *ifp, const u if (ifa_cur == NULL) break; - + /* + * create a new address that has new sdl_type, + * and copy address from the previous. + */ ifa_next = if_dl_create(ifp, &nsdl); if (ifa_next == NULL) { error = ENOMEM; @@ -2957,6 +2963,7 @@ lagg_chg_sadl(struct ifnet *ifp, const u CLLADDR(sdl), ifp->if_addrlen); ifa_insert(ifp, ifa_next); + /* the next Link-Level address is already set */ if (ifa_lla == NULL && memcmp(CLLADDR(sdl), lla, lla_len) == 0) { ifa_lla = ifa_next; @@ -2972,6 +2979,7 @@ lagg_chg_sadl(struct ifnet *ifp, const u ifafree(ifa_cur); } + /* remove the old address */ ifaref(ifa_cur); ifa_release(ifa_cur, &psref_cur); ifa_remove(ifp, ifa_cur); @@ -2981,6 +2989,7 @@ lagg_chg_sadl(struct ifnet *ifp, const u ifa_release(ifa_next, &psref_next); } + /* acquire or create the next Link-Level address */ if (ifa_lla != NULL) { ifa_next = ifa_lla; @@ -3000,13 +3009,19 @@ lagg_chg_sadl(struct ifnet *ifp, const u ifa_insert(ifp, ifa_next); } + /* Activate the next Link-Level address */ if (ifa_next != ifp->if_dl) { + /* save the current address */ ifa_cur = ifp->if_dl; if (ifa_cur != NULL) ifa_acquire(ifa_cur, &psref_cur); if_activate_sadl(ifp, ifa_next, nsdl); + /* + * free the saved address after switching, + * if the address is not if_hwdl. + */ if (ifa_cur != NULL) { if (ifa_cur != ifp->if_hwdl) { ifaref(ifa_cur); Index: src/sys/net/lagg/if_lagg_lacp.c diff -u src/sys/net/lagg/if_lagg_lacp.c:1.36 src/sys/net/lagg/if_lagg_lacp.c:1.37 --- src/sys/net/lagg/if_lagg_lacp.c:1.36 Thu Apr 4 09:09:24 2024 +++ src/sys/net/lagg/if_lagg_lacp.c Thu Apr 4 09:19:42 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_lagg_lacp.c,v 1.36 2024/04/04 09:09:24 yamaguchi Exp $ */ +/* $NetBSD: if_lagg_lacp.c,v 1.37 2024/04/04 09:19:42 yamaguchi Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-NetBSD @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.36 2024/04/04 09:09:24 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.37 2024/04/04 09:19:42 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_lagg.h" @@ -2718,6 +2718,12 @@ lacp_dump_markertlv(const struct markerd } } +/* + * lacp_linkstate: + * callback on link state changed. + * enable, disable or reset LACP processing on the physical port. + */ + static void lacp_linkstate(struct lagg_proto_softc *xlsc, struct lagg_port *lp) {
CVS commit: src/sys/net/lagg
Module Name:src Committed By: yamaguchi Date: Thu Apr 4 09:19:43 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg.c if_lagg_lacp.c Log Message: Added comments to lagg(4) To generate a diff of this commit: cvs rdiff -u -r1.66 -r1.67 src/sys/net/lagg/if_lagg.c cvs rdiff -u -r1.36 -r1.37 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
Module Name:src Committed By: yamaguchi Date: Thu Apr 4 09:09:24 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg_lacp.c Log Message: lagg(4): move allocate memory before ioctl To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 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.35 src/sys/net/lagg/if_lagg_lacp.c:1.36 --- src/sys/net/lagg/if_lagg_lacp.c:1.35 Thu Apr 4 08:54:52 2024 +++ src/sys/net/lagg/if_lagg_lacp.c Thu Apr 4 09:09:24 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_lagg_lacp.c,v 1.35 2024/04/04 08:54:52 yamaguchi Exp $ */ +/* $NetBSD: if_lagg_lacp.c,v 1.36 2024/04/04 09:09:24 yamaguchi Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-NetBSD @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.35 2024/04/04 08:54:52 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.36 2024/04/04 09:09:24 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_lagg.h" @@ -674,6 +674,10 @@ lacp_allocport(struct lagg_proto_softc * KASSERT(LAGG_LOCKED(sc)); KASSERT(IFNET_LOCKED(lp->lp_ifp)); + lacpp = kmem_zalloc(sizeof(*lacpp), KM_NOSLEEP); + if (lacpp == NULL) + return ENOMEM; + lacp_mcastaddr(&ifr, lp->lp_ifp->if_xname); error = lp->lp_ioctl(lp->lp_ifp, SIOCADDMULTI, (void *)&ifr); @@ -687,13 +691,10 @@ lacp_allocport(struct lagg_proto_softc * default: LAGG_LOG(sc, LOG_ERR, "SIOCADDMULTI failed on %s\n", lp->lp_ifp->if_xname); + kmem_free(lacpp, sizeof(*lacpp)); return error; } - lacpp = kmem_zalloc(sizeof(*lacpp), KM_NOSLEEP); - if (lacpp == NULL) - return ENOMEM; - lacpp->lp_added_multi = added_multi; lagg_work_set(&lacpp->lp_work_smtx, lacp_sm_tx_work, lsc); lagg_work_set(&lacpp->lp_work_marker, lacp_marker_work, lsc);
CVS commit: src/sys/net/lagg
Module Name:src Committed By: yamaguchi Date: Thu Apr 4 09:09:24 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg_lacp.c Log Message: lagg(4): move allocate memory before ioctl To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 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
Module Name:src Committed By: yamaguchi Date: Thu Apr 4 08:54:52 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg_lacp.c Log Message: Added KASSERT for LACP_LOCK To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 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.34 src/sys/net/lagg/if_lagg_lacp.c:1.35 --- src/sys/net/lagg/if_lagg_lacp.c:1.34 Thu Apr 4 08:53:14 2024 +++ src/sys/net/lagg/if_lagg_lacp.c Thu Apr 4 08:54:52 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_lagg_lacp.c,v 1.34 2024/04/04 08:53:14 yamaguchi Exp $ */ +/* $NetBSD: if_lagg_lacp.c,v 1.35 2024/04/04 08:54:52 yamaguchi Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-NetBSD @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.34 2024/04/04 08:53:14 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.35 2024/04/04 08:54:52 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_lagg.h" @@ -1496,6 +1496,8 @@ lacp_run_timers(struct lacp_softc *lsc, { size_t i; + KASSERT(LACP_LOCKED(lsc)); + for (i = 0; i < LACP_NTIMER; i++) { KASSERT(lacpp->lp_timer[i] >= 0); @@ -1814,6 +1816,8 @@ static void lacp_port_disable(struct lacp_softc *lsc, struct lacp_port *lacpp) { + KASSERT(LACP_LOCKED(lsc)); + if (ISSET(lacpp->lp_actor.lpi_state, LACP_STATE_AGGREGATION)) LACP_DPRINTF((lsc, lacpp, "enable -> disable\n")); @@ -1829,6 +1833,8 @@ lacp_port_enable(struct lacp_softc *lsc struct lacp_port *lacpp) { + KASSERT(LACP_LOCKED(lsc)); + if (!ISSET(lacpp->lp_actor.lpi_state, LACP_STATE_AGGREGATION)) LACP_DPRINTF((lsc, lacpp, "disable -> enable\n")); @@ -1840,6 +1846,8 @@ static void lacp_sm_rx_timer(struct lacp_softc *lsc, struct lacp_port *lacpp) { + KASSERT(LACP_LOCKED(lsc)); + if (!ISSET(lacpp->lp_actor.lpi_state, LACP_STATE_EXPIRED)) { /* CURRENT -> EXPIRED */ LACP_DPRINTF((lsc, lacpp, "CURRENT -> EXPIRED\n")); @@ -1855,6 +1863,7 @@ static void lacp_sm_ptx_timer(struct lacp_softc *lsc __unused, struct lacp_port *lacpp) { + KASSERT(LACP_LOCKED(lsc)); lacp_sm_assert_ntt(lacpp); } @@ -1902,6 +1911,7 @@ lacp_sm_mux_timer(struct lacp_softc *lsc { char buf[LACP_SYSTEMIDSTR_LEN] __LACPDEBUGUSED; + KASSERT(LACP_LOCKED(lsc)); KASSERT(lacpp->lp_pending > 0); LACP_AGGREGATOR_STR(lacpp->lp_aggregator, buf, sizeof(buf));
CVS commit: src/sys/net/lagg
Module Name:src Committed By: yamaguchi Date: Thu Apr 4 08:54:52 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg_lacp.c Log Message: Added KASSERT for LACP_LOCK To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 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
Module Name:src Committed By: yamaguchi Date: Thu Apr 4 08:53:14 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg_lacp.c Log Message: lagg(4): Use CTASSERT To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 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.33 src/sys/net/lagg/if_lagg_lacp.c:1.34 --- src/sys/net/lagg/if_lagg_lacp.c:1.33 Thu Apr 4 08:36:03 2024 +++ src/sys/net/lagg/if_lagg_lacp.c Thu Apr 4 08:53:14 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_lagg_lacp.c,v 1.33 2024/04/04 08:36:03 yamaguchi Exp $ */ +/* $NetBSD: if_lagg_lacp.c,v 1.34 2024/04/04 08:53:14 yamaguchi Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-NetBSD @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.33 2024/04/04 08:36:03 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.34 2024/04/04 08:53:14 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_lagg.h" @@ -380,7 +380,7 @@ lacp_mcastaddr(struct ifreq *ifr, const ifr->ifr_addr.sa_len = sizeof(ifr->ifr_addr); ifr->ifr_addr.sa_family = AF_UNSPEC; - KASSERT(sizeof(ifr->ifr_addr) >= sizeof(addr)); + CTASSERT(sizeof(ifr->ifr_addr) >= sizeof(addr)); memcpy(&ifr->ifr_addr.sa_data, addr, sizeof(addr)); }
CVS commit: src/sys/net/lagg
Module Name:src Committed By: yamaguchi Date: Thu Apr 4 08:53:14 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg_lacp.c Log Message: lagg(4): Use CTASSERT To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 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
Module Name:src Committed By: yamaguchi Date: Thu Apr 4 08:50:58 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg.c Log Message: lagg(4): replace NULL check with KASSERT because lp_softc is always non-NULL To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 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
Module Name:src Committed By: yamaguchi Date: Thu Apr 4 08:50:58 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg.c Log Message: lagg(4): replace NULL check with KASSERT because lp_softc is always non-NULL To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 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.65 src/sys/net/lagg/if_lagg.c:1.66 --- src/sys/net/lagg/if_lagg.c:1.65 Thu Apr 4 08:38:22 2024 +++ src/sys/net/lagg/if_lagg.c Thu Apr 4 08:50:58 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_lagg.c,v 1.65 2024/04/04 08:38:22 yamaguchi Exp $ */ +/* $NetBSD: if_lagg.c,v 1.66 2024/04/04 08:50:58 yamaguchi Exp $ */ /* * Copyright (c) 2005, 2006 Reyk Floeter @@ -20,7 +20,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.65 2024/04/04 08:38:22 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.66 2024/04/04 08:50:58 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -2711,10 +2711,11 @@ lagg_port_ioctl(struct ifnet *ifp, u_lon int error = 0; u_int ifflags; - if ((lp = ifp->if_lagg) == NULL || - (sc = lp->lp_softc) == NULL) { + if ((lp = ifp->if_lagg) == NULL) goto fallback; - } + + sc = lp->lp_softc; + KASSERT(sc != NULL); KASSERT(IFNET_LOCKED(lp->lp_ifp)); @@ -2786,12 +2787,9 @@ lagg_ifdetach(void *xifp_port) if (lp == NULL) { pserialize_read_exit(s); return; - } - - sc = lp->lp_softc; - if (sc == NULL) { - pserialize_read_exit(s); - return; + } else { + sc = lp->lp_softc; + KASSERT(sc != NULL); } pserialize_read_exit(s);
CVS commit: src/sys/net/lagg
Module Name:src Committed By: yamaguchi Date: Thu Apr 4 08:38:22 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg.c Log Message: lagg(4): increase output packets and bytes only if no error occurred pointed out by ozaki-r@, thanks. To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 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.64 src/sys/net/lagg/if_lagg.c:1.65 --- src/sys/net/lagg/if_lagg.c:1.64 Thu Apr 4 08:36:03 2024 +++ src/sys/net/lagg/if_lagg.c Thu Apr 4 08:38:22 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_lagg.c,v 1.64 2024/04/04 08:36:03 yamaguchi Exp $ */ +/* $NetBSD: if_lagg.c,v 1.65 2024/04/04 08:38:22 yamaguchi Exp $ */ /* * Copyright (c) 2005, 2006 Reyk Floeter @@ -20,7 +20,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.64 2024/04/04 08:36:03 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.65 2024/04/04 08:38:22 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1080,14 +1080,14 @@ lagg_output(struct lagg_softc *sc, struc if (error) { /* mbuf is already freed */ if_statinc(ifp, if_oerrors); + } else { + net_stat_ref_t nsr = IF_STAT_GETREF(ifp); + if_statinc_ref(nsr, if_opackets); + if_statadd_ref(nsr, if_obytes, len); + if (mflags & M_MCAST) + if_statinc_ref(nsr, if_omcasts); + IF_STAT_PUTREF(ifp); } - - net_stat_ref_t nsr = IF_STAT_GETREF(ifp); - if_statinc_ref(nsr, if_opackets); - if_statadd_ref(nsr, if_obytes, len); - if (mflags & M_MCAST) - if_statinc_ref(nsr, if_omcasts); - IF_STAT_PUTREF(ifp); } static struct mbuf *
CVS commit: src/sys/net/lagg
Module Name:src Committed By: yamaguchi Date: Thu Apr 4 08:38:22 UTC 2024 Modified Files: src/sys/net/lagg: if_lagg.c Log Message: lagg(4): increase output packets and bytes only if no error occurred pointed out by ozaki-r@, thanks. To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 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
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.
CVS commit: src/sys/net/lagg
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
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
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
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
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
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
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
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
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
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
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/sbin/ifconfig
Module Name:src Committed By: yamaguchi Date: Thu Apr 4 08:01:55 UTC 2024 Modified Files: src/sbin/ifconfig: lagg.c Log Message: ifconfig: remove optional space To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sbin/ifconfig/lagg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/ifconfig/lagg.c diff -u src/sbin/ifconfig/lagg.c:1.5 src/sbin/ifconfig/lagg.c:1.6 --- src/sbin/ifconfig/lagg.c:1.5 Thu Apr 4 07:55:32 2024 +++ src/sbin/ifconfig/lagg.c Thu Apr 4 08:01:55 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: lagg.c,v 1.5 2024/04/04 07:55:32 yamaguchi Exp $ */ +/* $NetBSD: lagg.c,v 1.6 2024/04/04 08:01:55 yamaguchi Exp $ */ /* * Copyright (c) 2021 Internet Initiative Japan Inc. @@ -28,7 +28,7 @@ #include #if !defined(lint) -__RCSID("$NetBSD: lagg.c,v 1.5 2024/04/04 07:55:32 yamaguchi Exp $"); +__RCSID("$NetBSD: lagg.c,v 1.6 2024/04/04 08:01:55 yamaguchi Exp $"); #endif /* !defined(lint) */ #include @@ -279,7 +279,7 @@ getlagg(prop_dictionary_t env) if (errno != ENOBUFS) break; - nports = req->lrq_nports + 3; /* 3: additional space */ + nports = req->lrq_nports; } if (req != NULL) {
CVS commit: src/sbin/ifconfig
Module Name:src Committed By: yamaguchi Date: Thu Apr 4 08:01:55 UTC 2024 Modified Files: src/sbin/ifconfig: lagg.c Log Message: ifconfig: remove optional space To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sbin/ifconfig/lagg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: yamaguchi Date: Thu Apr 4 07:55:32 UTC 2024 Modified Files: src/sbin/ifconfig: lagg.c src/sys/net/lagg: if_lagg.c if_lagg.h Log Message: lagg(4): use flexible array member To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sbin/ifconfig/lagg.c cvs rdiff -u -r1.57 -r1.58 src/sys/net/lagg/if_lagg.c cvs rdiff -u -r1.3 -r1.4 src/sys/net/lagg/if_lagg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/ifconfig/lagg.c diff -u src/sbin/ifconfig/lagg.c:1.4 src/sbin/ifconfig/lagg.c:1.5 --- src/sbin/ifconfig/lagg.c:1.4 Wed Dec 6 05:57:39 2023 +++ src/sbin/ifconfig/lagg.c Thu Apr 4 07:55:32 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: lagg.c,v 1.4 2023/12/06 05:57:39 yamaguchi Exp $ */ +/* $NetBSD: lagg.c,v 1.5 2024/04/04 07:55:32 yamaguchi Exp $ */ /* * Copyright (c) 2021 Internet Initiative Japan Inc. @@ -28,7 +28,7 @@ #include #if !defined(lint) -__RCSID("$NetBSD: lagg.c,v 1.4 2023/12/06 05:57:39 yamaguchi Exp $"); +__RCSID("$NetBSD: lagg.c,v 1.5 2024/04/04 07:55:32 yamaguchi Exp $"); #endif /* !defined(lint) */ #include @@ -393,7 +393,11 @@ setlaggproto(prop_dictionary_t env, prop static int setlaggport(prop_dictionary_t env, prop_dictionary_t oenv __unused) { - struct lagg_req req; + struct { + struct lagg_req req; + struct laggreqport port[1]; + } _req; + struct lagg_req *req; struct laggreqport *rp; const char *ifname; enum lagg_ioctl ioc; @@ -406,9 +410,10 @@ setlaggport(prop_dictionary_t env, prop_ return -1; } - memset(&req, 0, sizeof(req)); - req.lrq_nports = 1; - rp = &req.lrq_reqports[0]; + memset(&_req, 0, sizeof(_req)); + req = (struct lagg_req *)&_req; + rp = &req->lrq_reqports[0]; + strlcpy(rp->rp_portname, ifname, sizeof(rp->rp_portname)); ioc = LAGGIOC_NOCMD; @@ -426,8 +431,8 @@ setlaggport(prop_dictionary_t env, prop_ } if (ioc != LAGGIOC_NOCMD) { - req.lrq_ioctl = ioc; - if (indirect_ioctl(env, SIOCSLAGG, &req) == -1) { + req->lrq_ioctl = ioc; + if (indirect_ioctl(env, SIOCSLAGG, req) == -1) { if (lagg_debug) { warn("cmd=%d", ioc); } Index: src/sys/net/lagg/if_lagg.c diff -u src/sys/net/lagg/if_lagg.c:1.57 src/sys/net/lagg/if_lagg.c:1.58 --- src/sys/net/lagg/if_lagg.c:1.57 Fri Dec 1 09:27:17 2023 +++ src/sys/net/lagg/if_lagg.c Thu Apr 4 07:55:32 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_lagg.c,v 1.57 2023/12/01 09:27:17 yamaguchi Exp $ */ +/* $NetBSD: if_lagg.c,v 1.58 2024/04/04 07:55:32 yamaguchi Exp $ */ /* * Copyright (c) 2005, 2006 Reyk Floeter @@ -20,7 +20,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.57 2023/12/01 09:27:17 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.58 2024/04/04 07:55:32 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -693,7 +693,7 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd break; nports = laggreq.lrq_nports; - if (nports > 1) { + if (nports > 0) { allocsiz = sizeof(struct lagg_req) + sizeof(struct laggreqport) * nports; buf = kmem_alloc(allocsiz, KM_SLEEP); Index: src/sys/net/lagg/if_lagg.h diff -u src/sys/net/lagg/if_lagg.h:1.3 src/sys/net/lagg/if_lagg.h:1.4 --- src/sys/net/lagg/if_lagg.h:1.3 Mon Nov 8 06:29:16 2021 +++ src/sys/net/lagg/if_lagg.h Thu Apr 4 07:55:32 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_lagg.h,v 1.3 2021/11/08 06:29:16 yamaguchi Exp $ */ +/* $NetBSD: if_lagg.h,v 1.4 2024/04/04 07:55:32 yamaguchi Exp $ */ /* * Copyright (c) 2005, 2006 Reyk Floeter @@ -184,7 +184,7 @@ struct lagg_req { lagg_proto lrq_proto; size_t lrq_nports; struct laggreqproto lrq_reqproto; - struct laggreqport lrq_reqports[1]; + struct laggreqport lrq_reqports[]; }; #define SIOCGLAGG SIOCGIFGENERIC
CVS commit: src
Module Name:src Committed By: yamaguchi Date: Thu Apr 4 07:55:32 UTC 2024 Modified Files: src/sbin/ifconfig: lagg.c src/sys/net/lagg: if_lagg.c if_lagg.h Log Message: lagg(4): use flexible array member To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sbin/ifconfig/lagg.c cvs rdiff -u -r1.57 -r1.58 src/sys/net/lagg/if_lagg.c cvs rdiff -u -r1.3 -r1.4 src/sys/net/lagg/if_lagg.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
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
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
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
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
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
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
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
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
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
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
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
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/sbin/ifconfig
Module Name:src Committed By: yamaguchi Date: Wed Dec 6 05:57:39 UTC 2023 Modified Files: src/sbin/ifconfig: lagg.c Log Message: Fix "ifconfig lagg* lagglacp -maxports" command This command clears the setting of the maximum number of lacp active ports. The command was accepted but it did not work until this change. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sbin/ifconfig/lagg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/ifconfig/lagg.c diff -u src/sbin/ifconfig/lagg.c:1.3 src/sbin/ifconfig/lagg.c:1.4 --- src/sbin/ifconfig/lagg.c:1.3 Thu Mar 31 01:53:22 2022 +++ src/sbin/ifconfig/lagg.c Wed Dec 6 05:57:39 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: lagg.c,v 1.3 2022/03/31 01:53:22 yamaguchi Exp $ */ +/* $NetBSD: lagg.c,v 1.4 2023/12/06 05:57:39 yamaguchi Exp $ */ /* * Copyright (c) 2021 Internet Initiative Japan Inc. @@ -28,7 +28,7 @@ #include #if !defined(lint) -__RCSID("$NetBSD: lagg.c,v 1.3 2022/03/31 01:53:22 yamaguchi Exp $"); +__RCSID("$NetBSD: lagg.c,v 1.4 2023/12/06 05:57:39 yamaguchi Exp $"); #endif /* !defined(lint) */ #include @@ -132,27 +132,35 @@ struct piface laggportpri_if = PIFACE_I static const struct kwinst lagglacpkw[] = { {.k_word = "dumpdu", .k_key = "lacpdumpdu", - .k_type = KW_T_INT, .k_int = LAGGLACPOPT_DUMPDU} + .k_type = KW_T_INT, .k_int = LAGGLACPOPT_DUMPDU, + .k_exec = setlagglacp} , {.k_word = "-dumpdu", .k_key = "lacpdumpdu", - .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_DUMPDU} + .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_DUMPDU, + .k_exec = setlagglacp} , {.k_word = "stopdu", .k_key = "lacpstopdu", - .k_type = KW_T_INT, .k_int = LAGGLACPOPT_STOPDU} + .k_type = KW_T_INT, .k_int = LAGGLACPOPT_STOPDU, + .k_exec = setlagglacp} , {.k_word = "-stopdu", .k_key = "lacpstopdu", - .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_STOPDU} + .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_STOPDU, + .k_exec = setlagglacp} , {.k_word = "optimistic", .k_key = "lacpoptimistic", - .k_type = KW_T_INT, .k_int = LAGGLACPOPT_OPTIMISTIC} + .k_type = KW_T_INT, .k_int = LAGGLACPOPT_OPTIMISTIC, + .k_exec = setlagglacp} , {.k_word = "-optimistic", .k_key = "lacpoptimistic", - .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_OPTIMISTIC} + .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_OPTIMISTIC, + .k_exec = setlagglacp} , {.k_word = "maxports", .k_nextparser = &lagglacpmaxports.pi_parser} , {.k_word = "-maxports", .k_key = "lacpmaxports", - .k_type = KW_T_INT, .k_int = 0} + .k_type = KW_T_INT, .k_int = 0, .k_exec = setlagglacpmaxports} , {.k_word = "multi-linkspeed", .k_key = "lacpmultils", - .k_type = KW_T_INT, .k_int = LAGGLACPOPT_MULTILS} + .k_type = KW_T_INT, .k_int = LAGGLACPOPT_MULTILS, + .k_exec = setlagglacp} , {.k_word = "-multi-linkspeed", .k_key = "lacpmultils", - .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_MULTILS} + .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_MULTILS, + .k_exec = setlagglacp} }; struct pkw lagglacp = PKW_INITIALIZER(&lagglacp, "lagg-lacp-option", - setlagglacp, NULL, lagglacpkw, __arraycount(lagglacpkw), + NULL, NULL, lagglacpkw, __arraycount(lagglacpkw), &lagglacp_root.pb_parser); static const struct kwinst laggfailkw[] = {
CVS commit: src/sbin/ifconfig
Module Name:src Committed By: yamaguchi Date: Wed Dec 6 05:57:39 UTC 2023 Modified Files: src/sbin/ifconfig: lagg.c Log Message: Fix "ifconfig lagg* lagglacp -maxports" command This command clears the setting of the maximum number of lacp active ports. The command was accepted but it did not work until this change. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sbin/ifconfig/lagg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/net/lagg
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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/tests/net/if_vlan
Module Name:src Committed By: yamaguchi Date: Thu Nov 2 09:50:50 UTC 2023 Modified Files: src/tests/net/if_vlan: t_vlan.sh Log Message: Added the test for vlan over l2tp To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/tests/net/if_vlan/t_vlan.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/net/if_vlan/t_vlan.sh diff -u src/tests/net/if_vlan/t_vlan.sh:1.24 src/tests/net/if_vlan/t_vlan.sh:1.25 --- src/tests/net/if_vlan/t_vlan.sh:1.24 Thu Aug 19 03:27:05 2021 +++ src/tests/net/if_vlan/t_vlan.sh Thu Nov 2 09:50:50 2023 @@ -1,4 +1,4 @@ -# $NetBSD: t_vlan.sh,v 1.24 2021/08/19 03:27:05 yamaguchi Exp $ +# $NetBSD: t_vlan.sh,v 1.25 2023/11/02 09:50:50 yamaguchi Exp $ # # Copyright (c) 2016 Internet Initiative Japan Inc. # All rights reserved. @@ -1035,6 +1035,139 @@ vlan_promisc_cleanup() cleanup } +vlan_l2tp_body_common() +{ + local atf_ifconfig="atf_check -s exit:0 rump.ifconfig" + + local af=$1 + local ping_cmd="rump.ping -c 1" + local pfx=24 + local local0=$IP_LOCAL0 + local local1=$IP_LOCAL1 + local remote0=$IP_REMOTE0 + local remote1=$IP_REMOTE1 + local sysctl_param="net.inet.ip.dad_count=0" + local vid0=10 + local vid1=11 + + local l2tp_laddr=10.222.222.1 + local l2tp_lsession=1001 + local l2tp_raddr=10.222.222.2 + local l2tp_rsession=1002 + + if [ x"$af" = x"inet6" ]; then + ping_cmd="rump.ping6 -c 1" + rumplib="netinet6" + pfx=64 + local0=$IP6_LOCAL0 + local1=$IP6_LOCAL1 + remote0=$IP6_REMOTE0 + remote1=$IP6_REMOTE1 + sysctl_param="net.inet6.ip6.dad_count=0" + fi + + rump_server_add_iface $SOCK_LOCAL shmif0 $BUS + rump_server_add_iface $SOCK_LOCAL l2tp0 + rump_server_add_iface $SOCK_LOCAL vlan0 + rump_server_add_iface $SOCK_LOCAL vlan1 + + rump_server_add_iface $SOCK_REMOTE shmif0 $BUS + rump_server_add_iface $SOCK_REMOTE l2tp0 + rump_server_add_iface $SOCK_REMOTE vlan0 + rump_server_add_iface $SOCK_REMOTE vlan1 + + export RUMP_SERVER=$SOCK_LOCAL + atf_check -s exit:0 -o ignore rump.sysctl -w $sysctl_param + $atf_ifconfig shmif0 $l2tp_laddr/24 + $atf_ifconfig l2tp0 tunnel $l2tp_laddr $l2tp_raddr + $atf_ifconfig l2tp0 session $l2tp_lsession $l2tp_rsession + $atf_ifconfig l2tp0 up + + export RUMP_SERVER=$SOCK_REMOTE + atf_check -s exit:0 -o ignore rump.sysctl -w $sysctl_param + $atf_ifconfig shmif0 $l2tp_raddr/24 + $atf_ifconfig l2tp0 tunnel $l2tp_raddr $l2tp_laddr + $atf_ifconfig l2tp0 session $l2tp_rsession $l2tp_lsession + $atf_ifconfig l2tp0 up + + # configure vlans on l2tp(4) + export RUMP_SERVER=$SOCK_LOCAL + $atf_ifconfig vlan0 vlan $vid0 vlanif l2tp0 + $atf_ifconfig vlan0 $af $local0/$pfx + $atf_ifconfig vlan1 vlan $vid1 vlanif l2tp0 + $atf_ifconfig vlan1 $af $local1/$pfx + export RUMP_SERVER=$SOCK_REMOTE + $atf_ifconfig vlan0 vlan $vid0 vlanif l2tp0 + $atf_ifconfig vlan0 $af $remote0/$pfx + $atf_ifconfig vlan1 vlan $vid1 vlanif l2tp0 + $atf_ifconfig vlan1 $af $remote1/$pfx + + # test for VLAN frame transfer + export RUMP_SERVER=$SOCK_LOCAL + atf_check -s exit:0 -o ignore $ping_cmd $remote0 + atf_check -s exit:0 -o ignore $ping_cmd $remote1 + + # unconfig vlans + export RUMP_SERVER=$SOCK_LOCAL + $atf_ifconfig vlan0 -vlanif + export RUMP_SERVER=$SOCK_REMOTE + $atf_ifconfig vlan0 -vlanif + + # remove l2tp0 that has vlan1 + export RUMP_SERVER=$SOCK_LOCAL + $atf_ifconfig l2tp0 destroy + export RUMP_SERVER=$SOCK_REMOTE + $atf_ifconfig l2tp0 destroy +} + +atf_test_case vlan_l2tp cleanup +vlan_l2tp_head() +{ + + atf_set "descr" "tests of vlan(IPv4) over l2tp(IPv4)" + atf_set "require.progs" "rump_server" +} + +vlan_l2tp_body() +{ + + rump_server_start $SOCK_LOCAL vlan l2tp + rump_server_start $SOCK_REMOTE vlan l2tp + + vlan_l2tp_body_common "inet" +} + +vlan_l2tp_cleanup() +{ + + $DEBUG && dump + cleanup +} + +atf_test_case vlan_l2tp6 cleanup +vlan_l2tp6_head() +{ + + atf_set "descr" "tests of vlan(IPv6) over l2tp(IPv4)" + atf_set "require.progs" "rump_server" +} + +vlan_l2tp6_body() +{ + + rump_server_start $SOCK_LOCAL vlan l2tp netinet6 + rump_server_start $SOCK_REMOTE vlan l2tp netinet6 + + vlan_l2tp_body_common "inet6" +} + +vlan_l2tp6_cleanup() +{ + + $DEBUG && dump + cleanup +} + atf_init_test_cases() { @@ -1046,6 +1179,7 @@ atf_init_test_cases() atf_add_test_case vlan_bridge atf_add_test_case vlan_multicast atf_add_test_case vlan_promisc + atf_add_test_case vlan_l2tp atf_add_test_case vlan_create_destroy6 atf_add_test_case vlan_basic6 @@ -1054,4 +1188,5 @@ atf_init_test_cases() atf_add_test_case vlan_configs6 atf_add_test_case vlan_bridge6 atf_add_test_case vlan_multicast6 + atf_add_test_case vlan_l2tp6 }
CVS commit: src/tests/net/if_vlan
Module Name:src Committed By: yamaguchi Date: Thu Nov 2 09:50:50 UTC 2023 Modified Files: src/tests/net/if_vlan: t_vlan.sh Log Message: Added the test for vlan over l2tp To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/tests/net/if_vlan/t_vlan.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Thu Nov 2 09:48:29 UTC 2023 Modified Files: src/sys/net: if_vlan.c Log Message: Support vlan(4) over l2tp(4) To generate a diff of this commit: cvs rdiff -u -r1.170 -r1.171 src/sys/net/if_vlan.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_vlan.c diff -u src/sys/net/if_vlan.c:1.170 src/sys/net/if_vlan.c:1.171 --- src/sys/net/if_vlan.c:1.170 Mon Jun 20 08:14:48 2022 +++ src/sys/net/if_vlan.c Thu Nov 2 09:48:29 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: if_vlan.c,v 1.170 2022/06/20 08:14:48 yamaguchi Exp $ */ +/* $NetBSD: if_vlan.c,v 1.171 2023/11/02 09:48:29 yamaguchi Exp $ */ /* * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc. @@ -78,7 +78,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.170 2022/06/20 08:14:48 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.171 2023/11/02 09:48:29 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -97,6 +97,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v #include #include #include +#include #include #include #include @@ -149,6 +150,7 @@ struct ifvlan_linkmib { struct ifvlan { struct ethercom ifv_ec; + uint8_t ifv_lladdr[ETHER_ADDR_LEN]; struct ifvlan_linkmib *ifv_mib; /* * reader must use vlan_getref_linkmib() * instead of direct dereference @@ -189,6 +191,15 @@ const struct vlan_multisw vlan_ether_mul .vmsw_purgemulti = vlan_ether_purgemulti, }; +static void vlan_multi_nothing(struct ifvlan *); +static int vlan_multi_nothing_ifreq(struct ifvlan *, struct ifreq *); + +const struct vlan_multisw vlan_nothing_multisw = { + .vmsw_addmulti = vlan_multi_nothing_ifreq, + .vmsw_delmulti = vlan_multi_nothing_ifreq, + .vmsw_purgemulti = vlan_multi_nothing, +}; + static int vlan_clone_create(struct if_clone *, int); static int vlan_clone_destroy(struct ifnet *); static int vlan_config(struct ifvlan *, struct ifnet *, uint16_t); @@ -327,6 +338,9 @@ vlan_clone_create(struct if_clone *ifc, mib = kmem_zalloc(sizeof(struct ifvlan_linkmib), KM_SLEEP); ifp = &ifv->ifv_if; LIST_INIT(&ifv->ifv_mc_listhead); + cprng_fast(ifv->ifv_lladdr, sizeof(ifv->ifv_lladdr)); + ifv->ifv_lladdr[0] &= 0xFE; /* clear I/G bit */ + ifv->ifv_lladdr[0] |= 0x02; /* set G/L bit */ mib->ifvm_ifvlan = ifv; mib->ifvm_p = NULL; @@ -394,7 +408,10 @@ vlan_config(struct ifvlan *ifv, struct i struct ifvlan_linkmib *omib = NULL; struct ifvlan_linkmib *checkmib; struct psref_target *nmib_psref = NULL; + struct ethercom *ec; const uint16_t vid = EVL_VLANOFTAG(tag); + const uint8_t *lla; + u_char ifv_iftype; int error = 0; int idx; bool omib_cleanup = false; @@ -428,69 +445,79 @@ vlan_config(struct ifvlan *ifv, struct i switch (p->if_type) { case IFT_ETHER: - { - struct ethercom *ec = (void *)p; - nmib->ifvm_msw = &vlan_ether_multisw; nmib->ifvm_mintu = ETHERMIN; - error = ether_add_vlantag(p, tag, NULL); - if (error != 0) - goto done; - - if (ec->ec_capenable & ETHERCAP_VLAN_MTU) { - nmib->ifvm_mtufudge = 0; - } else { - /* - * Fudge the MTU by the encapsulation size. This - * makes us incompatible with strictly compliant - * 802.1Q implementations, but allows us to use - * the feature with other NetBSD - * implementations, which might still be useful. - */ - nmib->ifvm_mtufudge = ETHER_VLAN_ENCAP_LEN; - } - /* - * If the parent interface can do hardware-assisted - * VLAN encapsulation, then propagate its hardware- - * assisted checksumming flags and tcp segmentation - * offload. + * We inherit the parent's Ethernet address. */ - if (ec->ec_capabilities & ETHERCAP_VLAN_HWTAGGING) { - ifp->if_capabilities = p->if_capabilities & - (IFCAP_TSOv4 | IFCAP_TSOv6 | -IFCAP_CSUM_IPv4_Tx | IFCAP_CSUM_IPv4_Rx | -IFCAP_CSUM_TCPv4_Tx | IFCAP_CSUM_TCPv4_Rx | -IFCAP_CSUM_UDPv4_Tx | IFCAP_CSUM_UDPv4_Rx | -IFCAP_CSUM_TCPv6_Tx | IFCAP_CSUM_TCPv6_Rx | -IFCAP_CSUM_UDPv6_Tx | IFCAP_CSUM_UDPv6_Rx); - } + lla = CLLADDR(p->if_sadl); /* - * We inherit the parent's Ethernet address. + * Inherit the if_type from the parent. This allows us + * to participate in bridges of that type. */ - ether_ifattach(ifp, CLLADDR(p->if_sadl)); - ifp->if_hdrlen = sizeof(struct ether_vlan_header); /* XXX? */ + ifv_iftype = p->if_type; + break; + + case IFT_L2TP: + nmib->ifvm_msw = &vlan_nothing_multisw; + nmib->ifvm_mintu = ETHERMIN; + /* use random Ethernet address. */ + lla = ifv->ifv_lladdr; + ifv_iftype = IFT_ETHER; break; - } default: error = EPROTONOSUPPORT; goto done; } + error = ether_add_vlantag(p, tag, NULL); + if (error != 0) + goto done; + + ec = (struct ethercom *)p; + if (ec->ec_capenable & ETHERCAP_VLAN_MTU) { + nmib->ifvm_mtufudge = 0; + } else { + /* + * Fudge the MTU by the encapsulation size. This + * makes u
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Thu Nov 2 09:48:29 UTC 2023 Modified Files: src/sys/net: if_vlan.c Log Message: Support vlan(4) over l2tp(4) To generate a diff of this commit: cvs rdiff -u -r1.170 -r1.171 src/sys/net/if_vlan.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
Module Name:src Committed By: yamaguchi Date: Thu Nov 2 09:43:46 UTC 2023 Modified Files: src/sys/net: if_l2tp.c Log Message: l2tp(4): use ether_ifattach() to initialize ethercom To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/net/if_l2tp.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/if_l2tp.c diff -u src/sys/net/if_l2tp.c:1.48 src/sys/net/if_l2tp.c:1.49 --- src/sys/net/if_l2tp.c:1.48 Sat Sep 3 02:47:59 2022 +++ src/sys/net/if_l2tp.c Thu Nov 2 09:43:46 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: if_l2tp.c,v 1.48 2022/09/03 02:47:59 thorpej Exp $ */ +/* $NetBSD: if_l2tp.c,v 1.49 2023/11/02 09:43:46 yamaguchi Exp $ */ /* * Copyright (c) 2017 Internet Initiative Japan Inc. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.48 2022/09/03 02:47:59 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.49 2023/11/02 09:43:46 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -281,6 +281,12 @@ int l2tpattach0(struct l2tp_softc *sc) { + sc->l2tp_ec.ec_capabilities = 0; + sc->l2tp_ec.ec_capabilities |= ETHERCAP_VLAN_MTU; + sc->l2tp_ec.ec_capabilities |= ETHERCAP_JUMBO_MTU; + + ether_ifattach(&sc->l2tp_ec.ec_if, NULL); + sc->l2tp_ec.ec_if.if_addrlen = 0; sc->l2tp_ec.ec_if.if_mtu= L2TP_MTU; sc->l2tp_ec.ec_if.if_flags = IFF_POINTOPOINT|IFF_MULTICAST|IFF_SIMPLEX; @@ -296,23 +302,6 @@ l2tpattach0(struct l2tp_softc *sc) sc->l2tp_ec.ec_if._if_input = ether_input; IFQ_SET_READY(&sc->l2tp_ec.ec_if.if_snd); -#ifdef MBUFTRACE - struct ethercom *ec = &sc->l2tp_ec; - struct ifnet *ifp = &sc->l2tp_ec.ec_if; - - strlcpy(ec->ec_tx_mowner.mo_name, ifp->if_xname, - sizeof(ec->ec_tx_mowner.mo_name)); - strlcpy(ec->ec_tx_mowner.mo_descr, "tx", - sizeof(ec->ec_tx_mowner.mo_descr)); - strlcpy(ec->ec_rx_mowner.mo_name, ifp->if_xname, - sizeof(ec->ec_rx_mowner.mo_name)); - strlcpy(ec->ec_rx_mowner.mo_descr, "rx", - sizeof(ec->ec_rx_mowner.mo_descr)); - MOWNER_ATTACH(&ec->ec_tx_mowner); - MOWNER_ATTACH(&ec->ec_rx_mowner); - ifp->if_mowner = &ec->ec_tx_mowner; -#endif - /* XXX * It may improve performance to use if_initialize()/if_register() * so that l2tp_input() calls if_input() instead of @@ -322,7 +311,6 @@ l2tpattach0(struct l2tp_softc *sc) if_attach(&sc->l2tp_ec.ec_if); if_link_state_change(&sc->l2tp_ec.ec_if, LINK_STATE_DOWN); if_alloc_sadl(&sc->l2tp_ec.ec_if); - bpf_attach(&sc->l2tp_ec.ec_if, DLT_EN10MB, sizeof(struct ether_header)); return 0; } @@ -351,6 +339,8 @@ l2tp_clone_destroy(struct ifnet *ifp) struct l2tp_softc *sc = container_of(ifp, struct l2tp_softc, l2tp_ec.ec_if); + ether_ifdetach(ifp); + l2tp_clear_session(sc); l2tp_delete_tunnel(&sc->l2tp_ec.ec_if); /* @@ -369,8 +359,6 @@ l2tp_clone_destroy(struct ifnet *ifp) LIST_REMOVE(sc, l2tp_list); mutex_exit(&l2tp_softcs.lock); - bpf_detach(ifp); - if_detach(ifp); if_tunnel_free_ro_percpu(sc->l2tp_ro_percpu);
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Thu Nov 2 09:43:46 UTC 2023 Modified Files: src/sys/net: if_l2tp.c Log Message: l2tp(4): use ether_ifattach() to initialize ethercom To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/net/if_l2tp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: yamaguchi Date: Thu Nov 2 09:40:47 UTC 2023 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixv.c src/sys/net: if_ethersubr.c Log Message: Use ether_bpf_mtap only when the device supports vlan harware tagging The function is bpf_mtap() for ethernet devices and *currently* it is just handling VLAN tag stripped by the hardware. To generate a diff of this commit: cvs rdiff -u -r1.346 -r1.347 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.193 -r1.194 src/sys/dev/pci/ixgbe/ixv.c cvs rdiff -u -r1.325 -r1.326 src/sys/net/if_ethersubr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.346 src/sys/dev/pci/ixgbe/ixgbe.c:1.347 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.346 Thu Nov 2 05:07:57 2023 +++ src/sys/dev/pci/ixgbe/ixgbe.c Thu Nov 2 09:40:47 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.346 2023/11/02 05:07:57 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.347 2023/11/02 09:40:47 yamaguchi Exp $ */ /** @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ixgbe.c,v 1.346 2023/11/02 05:07:57 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ixgbe.c,v 1.347 2023/11/02 09:40:47 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1411,14 +1411,10 @@ ixgbe_setup_interface(device_t dev, stru if_initialize(ifp); sc->ipq = if_percpuq_create(&sc->osdep.ec.ec_if); - ether_ifattach(ifp, sc->hw.mac.addr); - aprint_normal_dev(dev, "Ethernet address %s\n", - ether_sprintf(sc->hw.mac.addr)); /* * We use per TX queue softint, so if_deferred_start_init() isn't * used. */ - ether_set_ifflags_cb(ec, ixgbe_ifflags_cb); sc->max_frame_size = ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN; @@ -1442,6 +1438,11 @@ ixgbe_setup_interface(device_t dev, stru /* Enable the above capabilities by default */ ec->ec_capenable = ec->ec_capabilities; + ether_ifattach(ifp, sc->hw.mac.addr); + aprint_normal_dev(dev, "Ethernet address %s\n", + ether_sprintf(sc->hw.mac.addr)); + ether_set_ifflags_cb(ec, ixgbe_ifflags_cb); + /* * Don't turn this on by default, if vlans are * created on another pseudo device (eg. lagg) Index: src/sys/dev/pci/ixgbe/ixv.c diff -u src/sys/dev/pci/ixgbe/ixv.c:1.193 src/sys/dev/pci/ixgbe/ixv.c:1.194 --- src/sys/dev/pci/ixgbe/ixv.c:1.193 Thu Nov 2 05:07:57 2023 +++ src/sys/dev/pci/ixgbe/ixv.c Thu Nov 2 09:40:47 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ixv.c,v 1.193 2023/11/02 05:07:57 msaitoh Exp $ */ +/* $NetBSD: ixv.c,v 1.194 2023/11/02 09:40:47 yamaguchi Exp $ */ /** @@ -35,7 +35,7 @@ /*$FreeBSD: head/sys/dev/ixgbe/if_ixv.c 331224 2018-03-19 20:55:05Z erj $*/ #include -__KERNEL_RCSID(0, "$NetBSD: ixv.c,v 1.193 2023/11/02 05:07:57 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ixv.c,v 1.194 2023/11/02 09:40:47 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1678,14 +1678,10 @@ ixv_setup_interface(device_t dev, struct if_initialize(ifp); sc->ipq = if_percpuq_create(&sc->osdep.ec.ec_if); - ether_ifattach(ifp, sc->hw.mac.addr); - aprint_normal_dev(dev, "Ethernet address %s\n", - ether_sprintf(sc->hw.mac.addr)); /* * We use per TX queue softint, so if_deferred_start_init() isn't * used. */ - ether_set_ifflags_cb(ec, ixv_ifflags_cb); sc->max_frame_size = ifp->if_mtu + IXGBE_MTU_HDR; @@ -1709,6 +1705,11 @@ ixv_setup_interface(device_t dev, struct /* Enable the above capabilities by default */ ec->ec_capenable = ec->ec_capabilities; + ether_ifattach(ifp, sc->hw.mac.addr); + aprint_normal_dev(dev, "Ethernet address %s\n", + ether_sprintf(sc->hw.mac.addr)); + ether_set_ifflags_cb(ec, ixv_ifflags_cb); + /* Don't enable LRO by default */ #if 0 /* NetBSD doesn't support LRO yet */ Index: src/sys/net/if_ethersubr.c diff -u src/sys/net/if_ethersubr.c:1.325 src/sys/net/if_ethersubr.c:1.326 --- src/sys/net/if_ethersubr.c:1.325 Thu Nov 2 09:36:27 2023 +++ src/sys/net/if_ethersubr.c Thu Nov 2 09:40:47 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ethersubr.c,v 1.325 2023/11/02 09:36:27 yamaguchi Exp $ */ +/* $NetBSD: if_ethersubr.c,v 1.326 2023/11/02 09:40:47 yamaguchi Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.325 2023/11/02 09:36:27 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.326 2023/11/02 09:40:47 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1051,7 +1051,8 @@ ether_ifattach(struct ifnet *ifp, const ifp->if_mtu = ETHERMTU; ifp->if_output = ether_output; ifp->_if_input = ether_input; - ifp->if_bpf_mtap = ether_bpf_mtap; + if (ec->ec_capabilities & ETHERCAP_VLAN_HWTAGGING) + ifp->if_b
CVS commit: src/sys
Module Name:src Committed By: yamaguchi Date: Thu Nov 2 09:40:47 UTC 2023 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixv.c src/sys/net: if_ethersubr.c Log Message: Use ether_bpf_mtap only when the device supports vlan harware tagging The function is bpf_mtap() for ethernet devices and *currently* it is just handling VLAN tag stripped by the hardware. To generate a diff of this commit: cvs rdiff -u -r1.346 -r1.347 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.193 -r1.194 src/sys/dev/pci/ixgbe/ixv.c cvs rdiff -u -r1.325 -r1.326 src/sys/net/if_ethersubr.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
Module Name:src Committed By: yamaguchi Date: Thu Nov 2 09:36:28 UTC 2023 Modified Files: src/sys/net: if_ethersubr.c Log Message: Added NULL check To generate a diff of this commit: cvs rdiff -u -r1.324 -r1.325 src/sys/net/if_ethersubr.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/if_ethersubr.c diff -u src/sys/net/if_ethersubr.c:1.324 src/sys/net/if_ethersubr.c:1.325 --- src/sys/net/if_ethersubr.c:1.324 Fri Oct 20 08:35:09 2023 +++ src/sys/net/if_ethersubr.c Thu Nov 2 09:36:27 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ethersubr.c,v 1.324 2023/10/20 08:35:09 msaitoh Exp $ */ +/* $NetBSD: if_ethersubr.c,v 1.325 2023/11/02 09:36:27 yamaguchi Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.324 2023/10/20 08:35:09 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.325 2023/11/02 09:36:27 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1041,7 +1041,7 @@ ether_ifattach(struct ifnet *ifp, const struct ethercom *ec = (struct ethercom *)ifp; char xnamebuf[HOOKNAMSIZ]; - if (ETHER_IS_MULTICAST(lla)) + if (lla != NULL && ETHER_IS_MULTICAST(lla)) aprint_error("The multicast bit is set in the MAC address. " "It's wrong.\n");
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Thu Nov 2 09:36:28 UTC 2023 Modified Files: src/sys/net: if_ethersubr.c Log Message: Added NULL check To generate a diff of this commit: cvs rdiff -u -r1.324 -r1.325 src/sys/net/if_ethersubr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.