Home | History | Annotate | only in /src/sys/net/lagg
History log of /src/sys/net/lagg
RevisionDateAuthorComments
 1.1 17-May-2021  yamaguchi branches: 1.1.2; 1.1.6;
Add a new link-aggregation pseudo interface named lagg(4)

- FreeBSD's lagg(4) based implementation
- MP-safe and MP-scalable
 1.1.6.2 17-Jun-2021  thorpej Sync w/ HEAD.
 1.1.6.1 17-May-2021  thorpej file Makefile was added on branch thorpej-i2c-spi-conf on 2021-06-17 04:46:35 +0000
 1.1.2.2 31-May-2021  cjep sync with head
 1.1.2.1 17-May-2021  cjep file Makefile was added on branch cjep_staticlib_x on 2021-05-31 22:15:21 +0000
 1.4 31-Mar-2022  yamaguchi Added a kernel option to run LACP on a half duplex interface
 1.3 16-Nov-2021  yamaguchi Added a kernel option to set SYNC bit of LACP
while the lagg interface is in STANDBY state
 1.2 12-Oct-2021  yamaguchi lagg: update capabilities of ifnet and ethercom

Commonly capabilities of all child interface are configured
to a lagg interface.
 1.1 17-May-2021  yamaguchi branches: 1.1.2; 1.1.6;
Add a new link-aggregation pseudo interface named lagg(4)

- FreeBSD's lagg(4) based implementation
- MP-safe and MP-scalable
 1.1.6.2 17-Jun-2021  thorpej Sync w/ HEAD.
 1.1.6.1 17-May-2021  thorpej file files.lagg was added on branch thorpej-i2c-spi-conf on 2021-06-17 04:46:35 +0000
 1.1.2.2 31-May-2021  cjep sync with head
 1.1.2.1 17-May-2021  cjep file files.lagg was added on branch cjep_staticlib_x on 2021-05-31 22:15:21 +0000
 1.74 30-Jul-2025  ozaki-r lagg: fix locking against myself in lagg_linkstate_changed

Since if.c v1.535 linkstate processing is done with IFNET_LOCK held, so
lagg doesn't need to take it by itself anymore.

Reported by mlelstv@
Acked by yamaguchi@
 1.73 25-Apr-2025  andvar s/cahanged/changed/ in comment.
 1.72 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.71 29-Jun-2024  riastradh branches: 1.71.2;
if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.70 05-Apr-2024  yamaguchi lagg(4): Added vlan check
 1.69 05-Apr-2024  yamaguchi lagg(4): release lock before pserialize_perform() if possible
 1.68 05-Apr-2024  yamaguchi lagg(4): added __predict_true
 1.67 04-Apr-2024  yamaguchi Added comments to lagg(4)
 1.66 04-Apr-2024  yamaguchi lagg(4): replace NULL check with KASSERT because lp_softc is always non-NULL
 1.65 04-Apr-2024  yamaguchi lagg(4): increase output packets and bytes only if no error occurred

pointed out by ozaki-r@, thanks.
 1.64 04-Apr-2024  yamaguchi lagg(4): change errno

suggested by ozaki-r@, thanks.
 1.63 04-Apr-2024  yamaguchi lagg(4): added NULL check for pfil_run_hooks

pointed out by ozaki-r@, thanks.
 1.62 04-Apr-2024  yamaguchi lagg(4): move comment about IFF_PROMISC

pointed out by ozaki-r@, thanks.
 1.61 04-Apr-2024  yamaguchi lagg(4): added size check to SIOCSLAGG

pointed out by ozaki-r@, thanks.
 1.60 04-Apr-2024  yamaguchi added missing LAGG_UNLOCK()
 1.59 04-Apr-2024  yamaguchi 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.
 1.58 04-Apr-2024  yamaguchi lagg(4): use flexible array member
 1.57 01-Dec-2023  yamaguchi lagg(4): eliminate unnecessary reset by the change of if_flags
 1.56 01-Dec-2023  yamaguchi lagg(4): use sadl for lagg(4) configured by a user
 1.55 28-Nov-2023  yamaguchi lagg(4): Fix missing IFNET_LOCK acquirement
 1.54 22-Nov-2023  yamaguchi Set the fastest linkspeed in each physical interface to lagg(4)
 1.53 22-Nov-2023  yamaguchi Set ETHERCAP_VLAN_HWTAGGING on lagg(4)
that doesn't has physical interfaces
 1.52 22-Nov-2023  yamaguchi lagg(4): Fix missing pfil_run_hooks() and bpf_mtap()
 1.51 18-Oct-2023  yamaguchi copy MTU of lagg to a interface added to lagg
even if the interface is the first member of the lagg

This change breaks ATF test case for lagg MTU
 1.50 16-Oct-2023  yamaguchi Fix missing IFNET_LOCK holding while destroy the lagg interface
 1.49 16-Oct-2023  yamaguchi lagg(4): release LAGG_LOCK before mtu changing

PR kern/57650
 1.48 26-Jun-2022  riastradh branches: 1.48.4;
lagg(4): Safely handle misaligned mbufs.

Optimizing for non-strict-alignment architectures -- without falling
afoul of alignment sanitizers or overeager compilers -- is left as an
exercise for the reader.

PR kern/56894
 1.47 04-Apr-2022  martin Avoid signed/unsigned comparision by casting the sizeof expression.
 1.46 04-Apr-2022  yamaguchi Move input processing of lagg(4) before ether_input
to get rid of dependence.

This implementation is similar with that of bridge(4).
 1.45 01-Apr-2022  yamaguchi lagg(4): reimplement add and delete port

The IFNET_LOCK for the adding or deleting port became to
be held the whole time while the ifnet of the port is changed.
 1.44 31-Mar-2022  yamaguchi rename lagg_enqueue to lagg_output

NFC
 1.43 31-Mar-2022  yamaguchi Use ether_ioctl to change mtu of lagg(4)
 1.42 31-Mar-2022  yamaguchi Use addlog(4) for putting 2 messages to one line
 1.41 31-Mar-2022  yamaguchi Make lagg interface specified "laggproto none" able to up
 1.40 31-Mar-2022  yamaguchi added log when ifpromisc is failed
 1.39 31-Mar-2022  yamaguchi Set flags related to MTU on adding l2tp(4) to lagg(4)
 1.38 31-Mar-2022  yamaguchi fix coding style
 1.37 31-Mar-2022  yamaguchi lagg(4): remove duplicated bpf_mtap
 1.36 31-Mar-2022  yamaguchi Change error code to ENOBUFS on lack of buffer memory

pointed out by k-goda@IIJ
 1.35 31-Mar-2022  yamaguchi Fix missing freeing resource related to protocol

pointed out by k-goda@IIJ
 1.34 31-Mar-2022  yamaguchi Switch ifp->if_output along with configuring ifp->if_lagg

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

This missing order is pointed out by k-goda@IIJ
 1.33 31-Mar-2022  yamaguchi Added missing NULL check

pointed out by k-goda@IIJ
 1.32 31-Mar-2022  yamaguchi lagg(4): commonize the error handling
 1.31 31-Mar-2022  yamaguchi lagg(4): fix typo

pointed out by k-goda@IIJ
 1.30 12-Jan-2022  yamaguchi Fix to call lacp_linkstate with IFNET_LOCK held

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

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

Exception: Not in kern_pmf.c, for the kind of silly reason that it
avoids having kern_pmf.c refer to symbols defined only in net; this
avoids a pain in the rump.
 1.27 31-Dec-2021  riastradh sys: Use if_stop wrapper function.

Exception: Not in kern_pmf.c, for the kind of silly reason that it
avoids having kern_pmf.c refer to symbols defined only in net; this
avoids a pain in the rump.
 1.26 15-Nov-2021  yamaguchi introduced APIs to configure VLAN TAG to ethernet devices
 1.25 12-Nov-2021  yamaguchi Configure vlan to an added interface after setting ifnet::if_lagg

The configuration uses ioctl of the interface, and the ioctl
for port (lagg_port_ioctl) needs ifnet:::if_lagg setting.
 1.24 12-Nov-2021  yamaguchi lagg: Add vid to vlanid_list in ethercom
 1.23 12-Nov-2021  yamaguchi Fix the wrong check of interface type

- lp->lp_iftype: original ifnet::if_type
- lp->lp_ifp->if_type: current ifnet::if_type
- always IFT_IEEE8023ADLAG
 1.22 12-Nov-2021  yamaguchi lagg: Notify the changes of capenables of interface
to child interfaces
 1.21 11-Nov-2021  yamaguchi lagg: Use promiscuous mode instead of if_init() to avoid panic
when the interface has no if_init()
 1.20 08-Nov-2021  yamaguchi remove unused ioctl command named SIOCGLAGGPORT
to get status of l2tp(4) added to lagg

NOTE:
SIOCGLAGGPORT is based on FreeBSD implementation.
And, currently, it is not used in NetBSD kernel/userland.
 1.19 08-Nov-2021  yamaguchi lagg: renew MAC addresses to change the value of interface type

The interface type(ifnet::if_type) is changed on adding to lagg(4)
and deleting from it.
 1.18 08-Nov-2021  yamaguchi Update the MAC address of all child interface
when that of lagg is changed.
 1.17 22-Oct-2021  yamaguchi lagg: change hash logic to generate the same value
when pairs of source and destination are the same
 1.16 19-Oct-2021  yamaguchi lagg: reject a vlan interface that is not configured

The vlan I/F has no MAC address used in LACP.
 1.15 19-Oct-2021  yamaguchi lagg: support l2tp(4) aggregation

- Accept "ifconfig lagg* laggport l2tp*"
- Set promiscuous mode when the added interface is l2tp*
- check IFF_UP in addition to IFF_RUNNING on
SIOCSIFFLAGS to a child interface.
 1.14 19-Oct-2021  yamaguchi lagg: clear I/G bitg and set G/L bit in a generated MAC address
 1.13 12-Oct-2021  yamaguchi Set a port interface of lagg(4) in promiscuous mode
when the lagg(4) is in promiscuous mode.
 1.12 12-Oct-2021  yamaguchi lagg: update capabilities of ifnet and ethercom

Commonly capabilities of all child interface are configured
to a lagg interface.
 1.11 05-Oct-2021  yamaguchi Drop unicast packets that are not for us
when lagg(4) is not in promisc
 1.10 30-Sep-2021  yamaguchi lagg: Register lagg_ifdetach to ether_ifdetach hook
 1.9 30-Sep-2021  yamaguchi Make a link-layer address of lagg(4) configurable by ifconfig(8)

lagg(4) uses a configured link-layer (MAC) address instead
of a random MAC address generated on creating.
The configured MAC address is copied to all child interface
and used for a system id of LACP.
 1.8 30-Sep-2021  yamaguchi Fix to acquire LAGG_LOCK without psref
to remove possibility of deadlock

the deadlock maybe happened between lagg_ifdetach()
and lagg_delport()

1. lagg_ifdetach calls psref_target_acquire()
2. lagg_delport calls LAGG_LOCK()
3. lagg_ifdetach calls LAGG_LOCK()
- wait for lagg_delport
4. lagg_delport calls psref_target_destroy()
- wait for lagg_ifdetach
 1.7 30-Sep-2021  yamaguchi lagg: Register lagg_linkstate_changed to link-state change hook
 1.6 13-Jul-2021  ozaki-r lagg: fix typo for ALTQ
 1.5 16-Jun-2021  riastradh branches: 1.5.2;
if_attach and if_initialize cannot fail, don't test return value

These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:

https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html

However, this spawned many seldom- or never-tested error branches,
which are risky to have around. And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:

https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html

So there is no longer any reason for if_initialize to fail. (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)

There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint. This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken. However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.

(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)

Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.
 1.4 24-May-2021  thorpej branches: 1.4.2;
Move __KERNEL_RCSID() to the traditional location.
 1.3 24-May-2021  yamaguchi Added missing copyright and license notice

pointed out by thorpej@n.o., Thanks.
 1.2 19-May-2021  rillig if_lagg: fix format string incompatibility

In struct ifnet, the member if_mtu has type uint64_t, which differs from
struct ifreq, where the member ifru_mtu has type int.
 1.1 17-May-2021  yamaguchi Add a new link-aggregation pseudo interface named lagg(4)

- FreeBSD's lagg(4) based implementation
- MP-safe and MP-scalable
 1.4.2.2 31-May-2021  cjep sync with head
 1.4.2.1 24-May-2021  cjep file if_lagg.c was added on branch cjep_staticlib_x on 2021-05-31 22:15:21 +0000
 1.5.2.3 01-Aug-2021  thorpej Sync with HEAD.
 1.5.2.2 17-Jun-2021  thorpej Sync w/ HEAD.
 1.5.2.1 16-Jun-2021  thorpej file if_lagg.c was added on branch thorpej-i2c-spi-conf on 2021-06-17 04:46:35 +0000
 1.48.4.5 01-Aug-2025  martin Pull up following revision(s) (requested by ozaki-r in ticket #1144):

sys/net/lagg/if_lagg.c: revision 1.74

lagg: fix locking against myself in lagg_linkstate_changed

Since if.c v1.535 linkstate processing is done with IFNET_LOCK held, so
lagg doesn't need to take it by itself anymore.

Reported by mlelstv@
Acked by yamaguchi@
 1.48.4.4 03-Oct-2024  martin Pull up following revision(s) (requested by rin in ticket #916):

sys/net/lagg/if_laggproto.c: revision 1.15
sys/net/lagg/if_lagg_lacp.c: revision 1.36
sys/net/lagg/if_laggproto.c: revision 1.16
sys/net/lagg/if_lagg_lacp.c: revision 1.37
sys/net/lagg/if_lagg_lacp.c: revision 1.38
sys/net/lagg/if_lagg_lacp.c: revision 1.39
sys/net/lagg/if_lagg.c: revision 1.54
sys/net/lagg/if_lagg.c: revision 1.55
sys/net/lagg/if_lagg.c: revision 1.59
sys/net/lagg/if_lagg.c: revision 1.70
sys/net/lagg/if_laggproto.h: revision 1.19
sys/net/lagg/if_lagg_lacp.c: revision 1.28
sys/net/lagg/if_lagg_lacp.c: revision 1.29
sys/net/lagg/if_laggproto.c: revision 1.7
sys/net/lagg/if_lagg_lacp.h: revision 1.5
sys/net/lagg/if_laggproto.c: revision 1.8
sys/net/lagg/if_laggproto.c: revision 1.9
sys/net/lagg/if_lagg_lacp.c: revision 1.40
sys/net/lagg/if_lagg_lacp.c: revision 1.41
sys/net/lagg/if_lagg_lacp.c: revision 1.42
sys/net/lagg/if_lagg_lacp.c: revision 1.43
tests/net/if_lagg/t_lagg.sh: revision 1.11
sys/net/lagg/if_lagg.c: revision 1.60
sys/net/lagg/if_lagg.c: revision 1.62
sys/net/lagg/if_lagg.c: revision 1.63
sys/net/lagg/if_lagg.c: revision 1.64
sys/net/lagg/if_laggproto.h: revision 1.20
sys/net/lagg/if_lagg.c: revision 1.65
sys/net/lagg/if_lagg.c: revision 1.66
sys/net/lagg/if_lagg.c: revision 1.67
sys/net/lagg/if_lagg_lacp.c: revision 1.30
sys/net/lagg/if_lagg.c: revision 1.68
sys/net/lagg/if_laggproto.c: revision 1.10
sys/net/lagg/if_lagg_lacp.c: revision 1.31
sys/net/lagg/if_lagg.c: revision 1.69
sys/net/lagg/if_laggproto.c: revision 1.11
sys/net/lagg/if_lagg_lacp.c: revision 1.32
sys/net/lagg/if_laggproto.c: revision 1.12
sys/net/lagg/if_lagg_lacp.c: revision 1.33
sys/net/lagg/if_laggproto.c: revision 1.13
sys/net/lagg/if_lagg_lacp.c: revision 1.34
sys/net/lagg/if_laggproto.c: revision 1.14
sys/net/lagg/if_lagg_lacp.c: revision 1.35

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

lagg(4): Added logs about LACP processing

lagg(4): Fix missing IFNET_LOCK acquirement

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

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

lagg(4): Added 0 length check

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

lagg(4): added log on detaching a port from SELECTED state to STANDBY
acquire LAGG_PROTO_LOCK instead of pserialize read section

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.
added missing LAGG_UNLOCK()

lagg(4): move comment about IFF_PROMISC
pointed out by ozaki-r@, thanks.

lagg(4): added NULL check for pfil_run_hooks
pointed out by ozaki-r@, thanks.

lagg(4): change errno
suggested by ozaki-r@, thanks.

lagg(4): increase output packets and bytes only if no error occurred
pointed out by ozaki-r@, thanks.

lagg(4): replace NULL check with KASSERT because lp_softc is always non-NULL

lagg(4): Use CTASSERT
Added KASSERT for LACP_LOCK

lagg(4): move allocate memory before ioctl
Added comments to lagg(4)

lagg(4): added __predict_true

lagg(4): added missing pserialize_read_enter
fix missing LACP_LOCK

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.
added missing workq_wait for lacp_tick_work()

lagg(4): set suppress at the same time with distribution state

lagg(4): remove unnecessary masking
pointed out by ozaki-r@, thanks.

lagg(4): move reply limitation to recive processing

lagg(4): release lock before pserialize_perform() if possible

lagg(4): Added vlan check

lagg(4): Fix missing destroy for list and entry

lagg(4) test: Fix typo and old comment

lagg: fill name of workqueue correctly
Found by KASSERT failure for DIAGNOSTIC kernel.
Authored by ozaki-r@.
 1.48.4.3 12-Dec-2023  martin Pull up following revision(s) (requested by yamaguchi in ticket #491):

sys/net/lagg/if_lagg.c: revision 1.56
sys/net/lagg/if_lagg.c: revision 1.57
sbin/ifconfig/lagg.c: revision 1.4

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

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

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.
 1.48.4.2 27-Nov-2023  martin Pull up following revision(s) (requested by yamaguchi in ticket #476):

sys/net/lagg/if_lagg.c: revision 1.52
sys/net/lagg/if_lagg.c: revision 1.53
sys/net/lagg/if_lagg_lacp.c: revision 1.26
sys/net/lagg/if_lagg_lacp.c: revision 1.27

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

Update sending interval when the partner's state is changed

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

Set ETHERCAP_VLAN_HWTAGGING on lagg(4)
that doesn't has physical interfaces
 1.48.4.1 19-Oct-2023  martin Pull up following revision(s) (requested by yamaguchi in ticket #429):

sys/net/lagg/if_lagg.c: revision 1.50
sys/net/lagg/if_lagg.c: revision 1.51
tests/net/if_lagg/t_lagg.sh: revision 1.10
sys/net/lagg/if_lagg.c: revision 1.49
tests/net/if_lagg/t_lagg.sh: revision 1.9
share/man/man4/lagg.4: revision 1.5

lagg(4): release LAGG_LOCK before mtu changing
PR kern/57650

Make the lagg interface up before change its MTU
This change is related to PR kern/57650

Fix missing IFNET_LOCK holding while destroy the lagg interface
copy MTU of lagg to a interface added to lagg
even if the interface is the first member of the lagg

This change breaks ATF test case for lagg MTU

Update the test case for MTU of lag to adapt new behavior

Update lagg(4) manual
1. corrected the wrong example
- lagg(4) can not add multiple port and set its priority at once
- This is the restriction of ifconfig(8)
2. adapted to changed behavior related to MTU
- Changed not to copy MTU of the 1st physical interface
to lagg(4) to prevent locking against myself
 1.71.2.1 02-Aug-2025  perseant Sync with HEAD
 1.4 04-Apr-2024  yamaguchi lagg(4): use flexible array member
 1.3 08-Nov-2021  yamaguchi remove unused ioctl command named SIOCGLAGGPORT
to get status of l2tp(4) added to lagg

NOTE:
SIOCGLAGGPORT is based on FreeBSD implementation.
And, currently, it is not used in NetBSD kernel/userland.
 1.2 24-May-2021  yamaguchi branches: 1.2.2; 1.2.6;
Added missing copyright and license notice

pointed out by thorpej@n.o., Thanks.
 1.1 17-May-2021  yamaguchi Add a new link-aggregation pseudo interface named lagg(4)

- FreeBSD's lagg(4) based implementation
- MP-safe and MP-scalable
 1.2.6.2 17-Jun-2021  thorpej Sync w/ HEAD.
 1.2.6.1 24-May-2021  thorpej file if_lagg.h was added on branch thorpej-i2c-spi-conf on 2021-06-17 04:46:35 +0000
 1.2.2.2 31-May-2021  cjep sync with head
 1.2.2.1 24-May-2021  cjep file if_lagg.h was added on branch cjep_staticlib_x on 2021-05-31 22:15:21 +0000
 1.43 05-Apr-2024  yamaguchi lagg(4): move reply limitation to recive processing
 1.42 05-Apr-2024  yamaguchi lagg(4): set suppress at the same time with distribution state
 1.41 05-Apr-2024  yamaguchi added missing workq_wait for lacp_tick_work()
 1.40 05-Apr-2024  yamaguchi 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.
 1.39 05-Apr-2024  yamaguchi fix missing LACP_LOCK
 1.38 05-Apr-2024  yamaguchi lagg(4): added missing pserialize_read_enter
 1.37 04-Apr-2024  yamaguchi Added comments to lagg(4)
 1.36 04-Apr-2024  yamaguchi lagg(4): move allocate memory before ioctl
 1.35 04-Apr-2024  yamaguchi Added KASSERT for LACP_LOCK
 1.34 04-Apr-2024  yamaguchi lagg(4): Use CTASSERT
 1.33 04-Apr-2024  yamaguchi lagg(4): change errno

suggested by ozaki-r@, thanks.
 1.32 04-Apr-2024  yamaguchi 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.
 1.31 04-Apr-2024  yamaguchi lagg(4): added log on detaching a port from SELECTED state to STANDBY
 1.30 04-Apr-2024  yamaguchi lagg(4): Added LACP_READY state for logging
when a port turns SELECTED or UNSELECTED
 1.29 22-Nov-2023  yamaguchi lagg(4): Added logs about LACP processing
 1.28 22-Nov-2023  yamaguchi Set the fastest linkspeed in each physical interface to lagg(4)
 1.27 22-Nov-2023  yamaguchi Update sending interval when the partner's state is changed
 1.26 22-Nov-2023  yamaguchi Change LACPDU sending interval by TIMEOUT bit in partner's state
 1.25 10-Apr-2022  andvar branches: 1.25.4;
fix various typos in comments and output/log messages.
 1.24 04-Apr-2022  yamaguchi Fix missing m_reset_rcvif for allocated mbuf
 1.23 04-Apr-2022  yamaguchi Move input processing of lagg(4) before ether_input
to get rid of dependence.

This implementation is similar with that of bridge(4).
 1.22 01-Apr-2022  yamaguchi lagg(4): reimplement add and delete port

The IFNET_LOCK for the adding or deleting port became to
be held the whole time while the ifnet of the port is changed.
 1.21 31-Mar-2022  yamaguchi rename lagg_enqueue to lagg_output

NFC
 1.20 31-Mar-2022  yamaguchi Use addlog(4) for putting 2 messages to one line
 1.19 31-Mar-2022  yamaguchi update state of aggregator on multi-speed changing
 1.18 31-Mar-2022  yamaguchi handle LACPDU and MarkerDU in thread context

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

pointed out by k-goda@IIJ
 1.17 31-Mar-2022  yamaguchi fix coding style
 1.16 31-Mar-2022  yamaguchi Added length check for safety

pointed out by k-goda@IIJ
 1.15 31-Mar-2022  yamaguchi Added missing kmem_free

pointed out by k-goda@IIJ
 1.14 31-Mar-2022  yamaguchi Added a kernel option to run LACP on a half duplex interface
 1.13 16-Jan-2022  rillig lagg: remove stray semicolon

No binary change.
 1.12 12-Jan-2022  yamaguchi Fix to call lacp_linkstate with IFNET_LOCK held

Network stack calls lacp_linkstate through lagg_port_ioctl when
doing "ifconfig up" or "ifconfig down" to an interface that is
a member of lagg(4). And IFNET_LOCK in the member interface
is held while the ioctl.
Therefore, lacp_linkstate is renamed to
lacp_linkstate_ifnet_locked, and always called with IFNET_LOCK
held. It avoids locking agains myself.
 1.11 06-Jan-2022  riastradh lagg(4): Take lock as required around if ioctl.

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

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

ok yamaguchi
 1.10 31-Dec-2021  riastradh sys: Use if_ioctl wrapper function.
 1.9 30-Nov-2021  yamaguchi Move net/agr/ieee8023_slowprotocols.h to net/ether_slowprotocols.h

Definitions related to slowprotocols are duplicated between
agr/ieee8023ad_slowprotocols.h and lagg/if_lagg_lacp.h
Therefore, the contents are moved to added file.

Note: currently, there are just LACP and Marker protocol,
however slowprotocols is independent of them.
 1.8 16-Nov-2021  yamaguchi Added a kernel option to set SYNC bit of LACP
while the lagg interface is in STANDBY state
 1.7 16-Nov-2021  yamaguchi Set SYNC bit of LACPDU when the interface is on STANDBY state
 1.6 19-Oct-2021  yamaguchi lagg: support l2tp(4) aggregation

- Accept "ifconfig lagg* laggport l2tp*"
- Set promiscuous mode when the added interface is l2tp*
- check IFF_UP in addition to IFF_RUNNING on
SIOCSIFFLAGS to a child interface.
 1.5 02-Oct-2021  mrg avoid set-but-unused-variable warnings.
 1.4 30-Sep-2021  yamaguchi Make a link-layer address of lagg(4) configurable by ifconfig(8)

lagg(4) uses a configured link-layer (MAC) address instead
of a random MAC address generated on creating.
The configured MAC address is copied to all child interface
and used for a system id of LACP.
 1.3 30-Jun-2021  yamaguchi lagg: fix an uninitialize variable

pointed out by tnn@n.o., thanks.
 1.2 18-May-2021  hannken branches: 1.2.2; 1.2.6;
Make this compile without DIAGNOSTIC.
 1.1 17-May-2021  yamaguchi Add a new link-aggregation pseudo interface named lagg(4)

- FreeBSD's lagg(4) based implementation
- MP-safe and MP-scalable
 1.2.6.3 01-Aug-2021  thorpej Sync with HEAD.
 1.2.6.2 17-Jun-2021  thorpej Sync w/ HEAD.
 1.2.6.1 18-May-2021  thorpej file if_lagg_lacp.c was added on branch thorpej-i2c-spi-conf on 2021-06-17 04:46:35 +0000
 1.2.2.2 31-May-2021  cjep sync with head
 1.2.2.1 18-May-2021  cjep file if_lagg_lacp.c was added on branch cjep_staticlib_x on 2021-05-31 22:15:21 +0000
 1.25.4.2 03-Oct-2024  martin Pull up following revision(s) (requested by rin in ticket #916):

sys/net/lagg/if_laggproto.c: revision 1.15
sys/net/lagg/if_lagg_lacp.c: revision 1.36
sys/net/lagg/if_laggproto.c: revision 1.16
sys/net/lagg/if_lagg_lacp.c: revision 1.37
sys/net/lagg/if_lagg_lacp.c: revision 1.38
sys/net/lagg/if_lagg_lacp.c: revision 1.39
sys/net/lagg/if_lagg.c: revision 1.54
sys/net/lagg/if_lagg.c: revision 1.55
sys/net/lagg/if_lagg.c: revision 1.59
sys/net/lagg/if_lagg.c: revision 1.70
sys/net/lagg/if_laggproto.h: revision 1.19
sys/net/lagg/if_lagg_lacp.c: revision 1.28
sys/net/lagg/if_lagg_lacp.c: revision 1.29
sys/net/lagg/if_laggproto.c: revision 1.7
sys/net/lagg/if_lagg_lacp.h: revision 1.5
sys/net/lagg/if_laggproto.c: revision 1.8
sys/net/lagg/if_laggproto.c: revision 1.9
sys/net/lagg/if_lagg_lacp.c: revision 1.40
sys/net/lagg/if_lagg_lacp.c: revision 1.41
sys/net/lagg/if_lagg_lacp.c: revision 1.42
sys/net/lagg/if_lagg_lacp.c: revision 1.43
tests/net/if_lagg/t_lagg.sh: revision 1.11
sys/net/lagg/if_lagg.c: revision 1.60
sys/net/lagg/if_lagg.c: revision 1.62
sys/net/lagg/if_lagg.c: revision 1.63
sys/net/lagg/if_lagg.c: revision 1.64
sys/net/lagg/if_laggproto.h: revision 1.20
sys/net/lagg/if_lagg.c: revision 1.65
sys/net/lagg/if_lagg.c: revision 1.66
sys/net/lagg/if_lagg.c: revision 1.67
sys/net/lagg/if_lagg_lacp.c: revision 1.30
sys/net/lagg/if_lagg.c: revision 1.68
sys/net/lagg/if_laggproto.c: revision 1.10
sys/net/lagg/if_lagg_lacp.c: revision 1.31
sys/net/lagg/if_lagg.c: revision 1.69
sys/net/lagg/if_laggproto.c: revision 1.11
sys/net/lagg/if_lagg_lacp.c: revision 1.32
sys/net/lagg/if_laggproto.c: revision 1.12
sys/net/lagg/if_lagg_lacp.c: revision 1.33
sys/net/lagg/if_laggproto.c: revision 1.13
sys/net/lagg/if_lagg_lacp.c: revision 1.34
sys/net/lagg/if_laggproto.c: revision 1.14
sys/net/lagg/if_lagg_lacp.c: revision 1.35

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

lagg(4): Added logs about LACP processing

lagg(4): Fix missing IFNET_LOCK acquirement

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

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

lagg(4): Added 0 length check

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

lagg(4): added log on detaching a port from SELECTED state to STANDBY
acquire LAGG_PROTO_LOCK instead of pserialize read section

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.
added missing LAGG_UNLOCK()

lagg(4): move comment about IFF_PROMISC
pointed out by ozaki-r@, thanks.

lagg(4): added NULL check for pfil_run_hooks
pointed out by ozaki-r@, thanks.

lagg(4): change errno
suggested by ozaki-r@, thanks.

lagg(4): increase output packets and bytes only if no error occurred
pointed out by ozaki-r@, thanks.

lagg(4): replace NULL check with KASSERT because lp_softc is always non-NULL

lagg(4): Use CTASSERT
Added KASSERT for LACP_LOCK

lagg(4): move allocate memory before ioctl
Added comments to lagg(4)

lagg(4): added __predict_true

lagg(4): added missing pserialize_read_enter
fix missing LACP_LOCK

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.
added missing workq_wait for lacp_tick_work()

lagg(4): set suppress at the same time with distribution state

lagg(4): remove unnecessary masking
pointed out by ozaki-r@, thanks.

lagg(4): move reply limitation to recive processing

lagg(4): release lock before pserialize_perform() if possible

lagg(4): Added vlan check

lagg(4): Fix missing destroy for list and entry

lagg(4) test: Fix typo and old comment

lagg: fill name of workqueue correctly
Found by KASSERT failure for DIAGNOSTIC kernel.
Authored by ozaki-r@.
 1.25.4.1 27-Nov-2023  martin Pull up following revision(s) (requested by yamaguchi in ticket #476):

sys/net/lagg/if_lagg.c: revision 1.52
sys/net/lagg/if_lagg.c: revision 1.53
sys/net/lagg/if_lagg_lacp.c: revision 1.26
sys/net/lagg/if_lagg_lacp.c: revision 1.27

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

Update sending interval when the partner's state is changed

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

Set ETHERCAP_VLAN_HWTAGGING on lagg(4)
that doesn't has physical interfaces
 1.5 22-Nov-2023  yamaguchi Set the fastest linkspeed in each physical interface to lagg(4)
 1.4 31-Mar-2022  yamaguchi branches: 1.4.4;
handle LACPDU and MarkerDU in thread context

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

pointed out by k-goda@IIJ
 1.3 30-Nov-2021  yamaguchi Move net/agr/ieee8023_slowprotocols.h to net/ether_slowprotocols.h

Definitions related to slowprotocols are duplicated between
agr/ieee8023ad_slowprotocols.h and lagg/if_lagg_lacp.h
Therefore, the contents are moved to added file.

Note: currently, there are just LACP and Marker protocol,
however slowprotocols is independent of them.
 1.2 24-May-2021  yamaguchi branches: 1.2.2; 1.2.6;
Added missing copyright and license notice

pointed out by thorpej@n.o., Thanks.
 1.1 17-May-2021  yamaguchi Add a new link-aggregation pseudo interface named lagg(4)

- FreeBSD's lagg(4) based implementation
- MP-safe and MP-scalable
 1.2.6.2 17-Jun-2021  thorpej Sync w/ HEAD.
 1.2.6.1 24-May-2021  thorpej file if_lagg_lacp.h was added on branch thorpej-i2c-spi-conf on 2021-06-17 04:46:35 +0000
 1.2.2.2 31-May-2021  cjep sync with head
 1.2.2.1 24-May-2021  cjep file if_lagg_lacp.h was added on branch cjep_staticlib_x on 2021-05-31 22:15:21 +0000
 1.4.4.1 03-Oct-2024  martin Pull up following revision(s) (requested by rin in ticket #916):

sys/net/lagg/if_laggproto.c: revision 1.15
sys/net/lagg/if_lagg_lacp.c: revision 1.36
sys/net/lagg/if_laggproto.c: revision 1.16
sys/net/lagg/if_lagg_lacp.c: revision 1.37
sys/net/lagg/if_lagg_lacp.c: revision 1.38
sys/net/lagg/if_lagg_lacp.c: revision 1.39
sys/net/lagg/if_lagg.c: revision 1.54
sys/net/lagg/if_lagg.c: revision 1.55
sys/net/lagg/if_lagg.c: revision 1.59
sys/net/lagg/if_lagg.c: revision 1.70
sys/net/lagg/if_laggproto.h: revision 1.19
sys/net/lagg/if_lagg_lacp.c: revision 1.28
sys/net/lagg/if_lagg_lacp.c: revision 1.29
sys/net/lagg/if_laggproto.c: revision 1.7
sys/net/lagg/if_lagg_lacp.h: revision 1.5
sys/net/lagg/if_laggproto.c: revision 1.8
sys/net/lagg/if_laggproto.c: revision 1.9
sys/net/lagg/if_lagg_lacp.c: revision 1.40
sys/net/lagg/if_lagg_lacp.c: revision 1.41
sys/net/lagg/if_lagg_lacp.c: revision 1.42
sys/net/lagg/if_lagg_lacp.c: revision 1.43
tests/net/if_lagg/t_lagg.sh: revision 1.11
sys/net/lagg/if_lagg.c: revision 1.60
sys/net/lagg/if_lagg.c: revision 1.62
sys/net/lagg/if_lagg.c: revision 1.63
sys/net/lagg/if_lagg.c: revision 1.64
sys/net/lagg/if_laggproto.h: revision 1.20
sys/net/lagg/if_lagg.c: revision 1.65
sys/net/lagg/if_lagg.c: revision 1.66
sys/net/lagg/if_lagg.c: revision 1.67
sys/net/lagg/if_lagg_lacp.c: revision 1.30
sys/net/lagg/if_lagg.c: revision 1.68
sys/net/lagg/if_laggproto.c: revision 1.10
sys/net/lagg/if_lagg_lacp.c: revision 1.31
sys/net/lagg/if_lagg.c: revision 1.69
sys/net/lagg/if_laggproto.c: revision 1.11
sys/net/lagg/if_lagg_lacp.c: revision 1.32
sys/net/lagg/if_laggproto.c: revision 1.12
sys/net/lagg/if_lagg_lacp.c: revision 1.33
sys/net/lagg/if_laggproto.c: revision 1.13
sys/net/lagg/if_lagg_lacp.c: revision 1.34
sys/net/lagg/if_laggproto.c: revision 1.14
sys/net/lagg/if_lagg_lacp.c: revision 1.35

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

lagg(4): Added logs about LACP processing

lagg(4): Fix missing IFNET_LOCK acquirement

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

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

lagg(4): Added 0 length check

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

lagg(4): added log on detaching a port from SELECTED state to STANDBY
acquire LAGG_PROTO_LOCK instead of pserialize read section

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.
added missing LAGG_UNLOCK()

lagg(4): move comment about IFF_PROMISC
pointed out by ozaki-r@, thanks.

lagg(4): added NULL check for pfil_run_hooks
pointed out by ozaki-r@, thanks.

lagg(4): change errno
suggested by ozaki-r@, thanks.

lagg(4): increase output packets and bytes only if no error occurred
pointed out by ozaki-r@, thanks.

lagg(4): replace NULL check with KASSERT because lp_softc is always non-NULL

lagg(4): Use CTASSERT
Added KASSERT for LACP_LOCK

lagg(4): move allocate memory before ioctl
Added comments to lagg(4)

lagg(4): added __predict_true

lagg(4): added missing pserialize_read_enter
fix missing LACP_LOCK

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.
added missing workq_wait for lacp_tick_work()

lagg(4): set suppress at the same time with distribution state

lagg(4): remove unnecessary masking
pointed out by ozaki-r@, thanks.

lagg(4): move reply limitation to recive processing

lagg(4): release lock before pserialize_perform() if possible

lagg(4): Added vlan check

lagg(4): Fix missing destroy for list and entry

lagg(4) test: Fix typo and old comment

lagg: fill name of workqueue correctly
Found by KASSERT failure for DIAGNOSTIC kernel.
Authored by ozaki-r@.
 1.16 26-Sep-2024  rin lagg: fill name of workqueue correctly

Found by KASSERT failure for DIAGNOSTIC kernel.

Authored by ozaki-r@.
 1.15 05-Apr-2024  yamaguchi branches: 1.15.2;
lagg(4): Fix missing destroy for list and entry
 1.14 05-Apr-2024  yamaguchi lagg(4): release lock before pserialize_perform() if possible
 1.13 05-Apr-2024  yamaguchi lagg(4): remove unnecessary masking

pointed out by ozaki-r@, thanks.
 1.12 04-Apr-2024  yamaguchi acquire LAGG_PROTO_LOCK instead of pserialize read section
 1.11 04-Apr-2024  yamaguchi lagg(4): Added 0 length check
 1.10 04-Apr-2024  yamaguchi lagg(4): fix missing update of the number of active ports
 1.9 04-Apr-2024  yamaguchi lagg(4): update link speed when a physical interface is removed
 1.8 28-Nov-2023  yamaguchi lagg(4): Fix missing IFNET_LOCK acquirement
 1.7 22-Nov-2023  yamaguchi Set the fastest linkspeed in each physical interface to lagg(4)
 1.6 31-Mar-2022  yamaguchi branches: 1.6.4;
rename lagg_enqueue to lagg_output

NFC
 1.5 31-Mar-2022  yamaguchi Make lagg interface specified "laggproto none" able to up
 1.4 31-Mar-2022  yamaguchi set active when the port is distributing
 1.3 31-Mar-2022  yamaguchi lagg(4): use KASSERT
 1.2 24-May-2021  thorpej branches: 1.2.2; 1.2.6;
Remove leading blank line.
 1.1 17-May-2021  yamaguchi Add a new link-aggregation pseudo interface named lagg(4)

- FreeBSD's lagg(4) based implementation
- MP-safe and MP-scalable
 1.2.6.2 17-Jun-2021  thorpej Sync w/ HEAD.
 1.2.6.1 24-May-2021  thorpej file if_laggproto.c was added on branch thorpej-i2c-spi-conf on 2021-06-17 04:46:35 +0000
 1.2.2.2 31-May-2021  cjep sync with head
 1.2.2.1 24-May-2021  cjep file if_laggproto.c was added on branch cjep_staticlib_x on 2021-05-31 22:15:21 +0000
 1.6.4.1 03-Oct-2024  martin Pull up following revision(s) (requested by rin in ticket #916):

sys/net/lagg/if_laggproto.c: revision 1.15
sys/net/lagg/if_lagg_lacp.c: revision 1.36
sys/net/lagg/if_laggproto.c: revision 1.16
sys/net/lagg/if_lagg_lacp.c: revision 1.37
sys/net/lagg/if_lagg_lacp.c: revision 1.38
sys/net/lagg/if_lagg_lacp.c: revision 1.39
sys/net/lagg/if_lagg.c: revision 1.54
sys/net/lagg/if_lagg.c: revision 1.55
sys/net/lagg/if_lagg.c: revision 1.59
sys/net/lagg/if_lagg.c: revision 1.70
sys/net/lagg/if_laggproto.h: revision 1.19
sys/net/lagg/if_lagg_lacp.c: revision 1.28
sys/net/lagg/if_lagg_lacp.c: revision 1.29
sys/net/lagg/if_laggproto.c: revision 1.7
sys/net/lagg/if_lagg_lacp.h: revision 1.5
sys/net/lagg/if_laggproto.c: revision 1.8
sys/net/lagg/if_laggproto.c: revision 1.9
sys/net/lagg/if_lagg_lacp.c: revision 1.40
sys/net/lagg/if_lagg_lacp.c: revision 1.41
sys/net/lagg/if_lagg_lacp.c: revision 1.42
sys/net/lagg/if_lagg_lacp.c: revision 1.43
tests/net/if_lagg/t_lagg.sh: revision 1.11
sys/net/lagg/if_lagg.c: revision 1.60
sys/net/lagg/if_lagg.c: revision 1.62
sys/net/lagg/if_lagg.c: revision 1.63
sys/net/lagg/if_lagg.c: revision 1.64
sys/net/lagg/if_laggproto.h: revision 1.20
sys/net/lagg/if_lagg.c: revision 1.65
sys/net/lagg/if_lagg.c: revision 1.66
sys/net/lagg/if_lagg.c: revision 1.67
sys/net/lagg/if_lagg_lacp.c: revision 1.30
sys/net/lagg/if_lagg.c: revision 1.68
sys/net/lagg/if_laggproto.c: revision 1.10
sys/net/lagg/if_lagg_lacp.c: revision 1.31
sys/net/lagg/if_lagg.c: revision 1.69
sys/net/lagg/if_laggproto.c: revision 1.11
sys/net/lagg/if_lagg_lacp.c: revision 1.32
sys/net/lagg/if_laggproto.c: revision 1.12
sys/net/lagg/if_lagg_lacp.c: revision 1.33
sys/net/lagg/if_laggproto.c: revision 1.13
sys/net/lagg/if_lagg_lacp.c: revision 1.34
sys/net/lagg/if_laggproto.c: revision 1.14
sys/net/lagg/if_lagg_lacp.c: revision 1.35

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

lagg(4): Added logs about LACP processing

lagg(4): Fix missing IFNET_LOCK acquirement

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

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

lagg(4): Added 0 length check

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

lagg(4): added log on detaching a port from SELECTED state to STANDBY
acquire LAGG_PROTO_LOCK instead of pserialize read section

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.
added missing LAGG_UNLOCK()

lagg(4): move comment about IFF_PROMISC
pointed out by ozaki-r@, thanks.

lagg(4): added NULL check for pfil_run_hooks
pointed out by ozaki-r@, thanks.

lagg(4): change errno
suggested by ozaki-r@, thanks.

lagg(4): increase output packets and bytes only if no error occurred
pointed out by ozaki-r@, thanks.

lagg(4): replace NULL check with KASSERT because lp_softc is always non-NULL

lagg(4): Use CTASSERT
Added KASSERT for LACP_LOCK

lagg(4): move allocate memory before ioctl
Added comments to lagg(4)

lagg(4): added __predict_true

lagg(4): added missing pserialize_read_enter
fix missing LACP_LOCK

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.
added missing workq_wait for lacp_tick_work()

lagg(4): set suppress at the same time with distribution state

lagg(4): remove unnecessary masking
pointed out by ozaki-r@, thanks.

lagg(4): move reply limitation to recive processing

lagg(4): release lock before pserialize_perform() if possible

lagg(4): Added vlan check

lagg(4): Fix missing destroy for list and entry

lagg(4) test: Fix typo and old comment

lagg: fill name of workqueue correctly
Found by KASSERT failure for DIAGNOSTIC kernel.
Authored by ozaki-r@.
 1.15.2.1 02-Aug-2025  perseant Sync with HEAD
 1.20 28-Nov-2023  yamaguchi lagg(4): Fix missing IFNET_LOCK acquirement
 1.19 22-Nov-2023  yamaguchi Set the fastest linkspeed in each physical interface to lagg(4)
 1.18 26-Jun-2022  riastradh branches: 1.18.4; 1.18.8;
lagg(4): Safely handle misaligned mbufs.

Optimizing for non-strict-alignment architectures -- without falling
afoul of alignment sanitizers or overeager compilers -- is left as an
exercise for the reader.

PR kern/56894
 1.17 24-May-2022  andvar fix various typos in comment, documentation and log messages.
 1.16 04-Apr-2022  yamaguchi Move input processing of lagg(4) before ether_input
to get rid of dependence.

This implementation is similar with that of bridge(4).
 1.15 31-Mar-2022  yamaguchi rename lagg_enqueue to lagg_output

NFC
 1.14 31-Mar-2022  yamaguchi Use addlog(4) for putting 2 messages to one line
 1.13 31-Mar-2022  yamaguchi Make lagg interface specified "laggproto none" able to up
 1.12 31-Mar-2022  yamaguchi added log when ifpromisc is failed
 1.11 31-Mar-2022  yamaguchi fix coding style
 1.10 12-Jan-2022  yamaguchi Fix to call lacp_linkstate with IFNET_LOCK held

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

- Accept "ifconfig lagg* laggport l2tp*"
- Set promiscuous mode when the added interface is l2tp*
- check IFF_UP in addition to IFF_RUNNING on
SIOCSIFFLAGS to a child interface.
 1.8 12-Oct-2021  yamaguchi Set a port interface of lagg(4) in promiscuous mode
when the lagg(4) is in promiscuous mode.
 1.7 12-Oct-2021  yamaguchi lagg: update capabilities of ifnet and ethercom

Commonly capabilities of all child interface are configured
to a lagg interface.
 1.6 30-Sep-2021  yamaguchi lagg: Register lagg_ifdetach to ether_ifdetach hook
 1.5 30-Sep-2021  yamaguchi Make a link-layer address of lagg(4) configurable by ifconfig(8)

lagg(4) uses a configured link-layer (MAC) address instead
of a random MAC address generated on creating.
The configured MAC address is copied to all child interface
and used for a system id of LACP.
 1.4 30-Sep-2021  yamaguchi lagg: Register lagg_linkstate_changed to link-state change hook
 1.3 24-May-2021  yamaguchi branches: 1.3.2; 1.3.6;
Added missing copyright and license notice

pointed out by thorpej@n.o., Thanks.
 1.2 19-May-2021  rillig if_lagg: fix Clang build

Clang is stricter than GCC when it comes to nonliteral format strings.

sys/net/lagg/if_lagg.c:2372:12: error:
format string is not a string literal [-Werror,-Wformat-nonliteral]
 1.1 17-May-2021  yamaguchi Add a new link-aggregation pseudo interface named lagg(4)

- FreeBSD's lagg(4) based implementation
- MP-safe and MP-scalable
 1.3.6.2 17-Jun-2021  thorpej Sync w/ HEAD.
 1.3.6.1 24-May-2021  thorpej file if_laggproto.h was added on branch thorpej-i2c-spi-conf on 2021-06-17 04:46:35 +0000
 1.3.2.2 31-May-2021  cjep sync with head
 1.3.2.1 24-May-2021  cjep file if_laggproto.h was added on branch cjep_staticlib_x on 2021-05-31 22:15:21 +0000
 1.18.8.1 16-Nov-2023  thorpej if_transmit_lock() and if_enqueue() are equivalent. if_enqueue() is
a better name, so collapse everything down to that and garbage-collect
if_transmit_lock().
 1.18.4.1 03-Oct-2024  martin Pull up following revision(s) (requested by rin in ticket #916):

sys/net/lagg/if_laggproto.c: revision 1.15
sys/net/lagg/if_lagg_lacp.c: revision 1.36
sys/net/lagg/if_laggproto.c: revision 1.16
sys/net/lagg/if_lagg_lacp.c: revision 1.37
sys/net/lagg/if_lagg_lacp.c: revision 1.38
sys/net/lagg/if_lagg_lacp.c: revision 1.39
sys/net/lagg/if_lagg.c: revision 1.54
sys/net/lagg/if_lagg.c: revision 1.55
sys/net/lagg/if_lagg.c: revision 1.59
sys/net/lagg/if_lagg.c: revision 1.70
sys/net/lagg/if_laggproto.h: revision 1.19
sys/net/lagg/if_lagg_lacp.c: revision 1.28
sys/net/lagg/if_lagg_lacp.c: revision 1.29
sys/net/lagg/if_laggproto.c: revision 1.7
sys/net/lagg/if_lagg_lacp.h: revision 1.5
sys/net/lagg/if_laggproto.c: revision 1.8
sys/net/lagg/if_laggproto.c: revision 1.9
sys/net/lagg/if_lagg_lacp.c: revision 1.40
sys/net/lagg/if_lagg_lacp.c: revision 1.41
sys/net/lagg/if_lagg_lacp.c: revision 1.42
sys/net/lagg/if_lagg_lacp.c: revision 1.43
tests/net/if_lagg/t_lagg.sh: revision 1.11
sys/net/lagg/if_lagg.c: revision 1.60
sys/net/lagg/if_lagg.c: revision 1.62
sys/net/lagg/if_lagg.c: revision 1.63
sys/net/lagg/if_lagg.c: revision 1.64
sys/net/lagg/if_laggproto.h: revision 1.20
sys/net/lagg/if_lagg.c: revision 1.65
sys/net/lagg/if_lagg.c: revision 1.66
sys/net/lagg/if_lagg.c: revision 1.67
sys/net/lagg/if_lagg_lacp.c: revision 1.30
sys/net/lagg/if_lagg.c: revision 1.68
sys/net/lagg/if_laggproto.c: revision 1.10
sys/net/lagg/if_lagg_lacp.c: revision 1.31
sys/net/lagg/if_lagg.c: revision 1.69
sys/net/lagg/if_laggproto.c: revision 1.11
sys/net/lagg/if_lagg_lacp.c: revision 1.32
sys/net/lagg/if_laggproto.c: revision 1.12
sys/net/lagg/if_lagg_lacp.c: revision 1.33
sys/net/lagg/if_laggproto.c: revision 1.13
sys/net/lagg/if_lagg_lacp.c: revision 1.34
sys/net/lagg/if_laggproto.c: revision 1.14
sys/net/lagg/if_lagg_lacp.c: revision 1.35

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

lagg(4): Added logs about LACP processing

lagg(4): Fix missing IFNET_LOCK acquirement

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

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

lagg(4): Added 0 length check

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

lagg(4): added log on detaching a port from SELECTED state to STANDBY
acquire LAGG_PROTO_LOCK instead of pserialize read section

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.
added missing LAGG_UNLOCK()

lagg(4): move comment about IFF_PROMISC
pointed out by ozaki-r@, thanks.

lagg(4): added NULL check for pfil_run_hooks
pointed out by ozaki-r@, thanks.

lagg(4): change errno
suggested by ozaki-r@, thanks.

lagg(4): increase output packets and bytes only if no error occurred
pointed out by ozaki-r@, thanks.

lagg(4): replace NULL check with KASSERT because lp_softc is always non-NULL

lagg(4): Use CTASSERT
Added KASSERT for LACP_LOCK

lagg(4): move allocate memory before ioctl
Added comments to lagg(4)

lagg(4): added __predict_true

lagg(4): added missing pserialize_read_enter
fix missing LACP_LOCK

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.
added missing workq_wait for lacp_tick_work()

lagg(4): set suppress at the same time with distribution state

lagg(4): remove unnecessary masking
pointed out by ozaki-r@, thanks.

lagg(4): move reply limitation to recive processing

lagg(4): release lock before pserialize_perform() if possible

lagg(4): Added vlan check

lagg(4): Fix missing destroy for list and entry

lagg(4) test: Fix typo and old comment

lagg: fill name of workqueue correctly
Found by KASSERT failure for DIAGNOSTIC kernel.
Authored by ozaki-r@.
 1.6 04-Apr-2022  yamaguchi Move input processing of lagg(4) before ether_input
to get rid of dependence.

This implementation is similar with that of bridge(4).
 1.5 31-Mar-2022  yamaguchi fix coding style
 1.4 30-Sep-2021  yamaguchi lagg: Register lagg_ifdetach to ether_ifdetach hook
 1.3 30-Sep-2021  yamaguchi lagg: Register lagg_linkstate_changed to link-state change hook
 1.2 24-May-2021  yamaguchi branches: 1.2.2; 1.2.6;
Added missing copyright and license notice

pointed out by thorpej@n.o., Thanks.
 1.1 17-May-2021  yamaguchi Add a new link-aggregation pseudo interface named lagg(4)

- FreeBSD's lagg(4) based implementation
- MP-safe and MP-scalable
 1.2.6.2 17-Jun-2021  thorpej Sync w/ HEAD.
 1.2.6.1 24-May-2021  thorpej file if_laggvar.h was added on branch thorpej-i2c-spi-conf on 2021-06-17 04:46:35 +0000
 1.2.2.2 31-May-2021  cjep sync with head
 1.2.2.1 24-May-2021  cjep file if_laggvar.h was added on branch cjep_staticlib_x on 2021-05-31 22:15:21 +0000

RSS XML Feed