History log of /openbsd-current/sys/net/if_trunk.h
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.31 13-May-2024 jsg

remove prototypes with no matching function
ok mpi@


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE OPENBSD_7_5_BASE
# 1.30 22-Jul-2020 dlg

deprecate interface input handler lists, just use one input function.

the interface input handler lists were originally set up to help
us during the intial mpsafe network stack work. at the time not all
the virtual ethernet interfaces (vlan, svlan, bridge, trunk, etc)
were mpsafe, so we wanted a way to avoid them by default, and only
take the kernel lock hit when they were specifically enabled on the
interface. since then, they have been fixed up to be mpsafe.

i could leave the list in place, but it has some semantic problems.
because virtual interfaces filter packets based on the order they
were attached to the parent interface, you can get packets taken
away in surprising ways, especially when you reboot and netstart
does something different to what you did by hand. by hardcoding the
order that things like vlan and bridge get to look at packets, we
can document the behaviour and get consistency.

it also means we can get rid of a use of SRPs which were difficult
to replace with SMRs. the interface input handler list is an SRPL,
which we would like to deprecate. it turns out that you can sleep
during stack processing, which you're not supposed to do with SRPs
or SMRs, but SRPs are a lot more forgiving and it worked.

lastly, it turns out that this code is faster than the input list
handling, so lots of winning all around.

special thanks to hrvoje popovski and aaron bieber for testing.
this has been in snaps as part of a larger diff for over a week.


Revision tags: OPENBSD_6_7_BASE
# 1.29 07-Nov-2019 dlg

turn the linkstate hooks into a task list, like the detach hooks.

this is largely mechanical, except for carp. this moves the addition
of the carp link state hook after we're committed to using the new
interface as a carpdev. because the add can't fail, we avoid a
complicated unwind dance. also, this tweaks the carp linkstate hook
so it only updates the relevant carp interface, not all of the
carpdevs on the parent.

hrvoje popovski has tested an early version of this diff and it's
generally ok, but there's some splasserts that this diff fires that
i'll fix in an upcoming diff.

ok claudio@


# 1.28 06-Nov-2019 dlg

replace the hooks used with if_detachhooks with a task list.

the main semantic change is that things registering detach hooks
have to allocate and set a task structure that then gets added to
the list. this means if the task is allocated up front (eg, as part
of carps softc or bridges port structure), it avoids the possibility
that adding a hook can fail. a lot of drivers weren't checking for
failure, and unwinding state in the event of failure in other parts
was error prone.

while doing this i discovered that the list operations have to be
in a particular order, but drivers weren't doing that consistently
either. this diff wraps the list ops up so you have to seriously
go out of your way to screw them up.

ive also sprinkled some NET_ASSERT_LOCKED around the list operations
so we can make sure there's no potential for the list to be corrupted,
especially while it's being run.

hrvoje popovski has tested this a bit, and some issues he discovered
have been fixed.

ok sashan@


Revision tags: OPENBSD_6_6_BASE
# 1.27 29-Apr-2019 dlg

tr_unit is unused, so gc it


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.26 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.25 23-Sep-2015 mikeb

Remove trunk watchdog code since it doesn't do anything useful
and we want to limit the number of different places where we
access trunk port pointers.

trunk_watchdog should be never called as we don't set up it's
if_timer and trunk_port_watchdog just calls the if_watchdog
from the underlying interface.

It's possible that this is no longer needed due to if_slowtimo/
if_watchdog changes done earlier.

ok mpi


# 1.24 10-Sep-2015 dlg

move the if input handler list to an SRP list.

instead of having every driver that manipulates the ifih list
understand SRPLs, this moves that processing into if_ih_insert and
if_ih_remove functions.

we rely on the kernel lock to serialise the modifications to the
list.

tested by mpi@
ok mpi@ claudio@ mikeb@


Revision tags: OPENBSD_5_8_BASE
# 1.23 26-May-2015 mpi

Now that the Ethernet header is always passed as part of the mbuf, kill
the second (unused) argument of the input packet handlers.

ok dlg@


# 1.22 14-May-2015 mpi

Allocate the input packet handler as part of the trunk_port structure
since they have the same lifetime.

Requested by and ok dlg@


# 1.21 13-May-2015 mpi

Get rid of the last "#if NTRUNK" by overwriting trunk ports' output
function.

ok claudio@, reyk@


# 1.20 11-May-2015 mpi

Take trunk(4) out of ether_input().

Each physical interface of a trunk now gets a specific ifih (interface
input handler) that runs before ether_input().

Tested by sthen@, dlg@, Theo Buehler and <mxb AT alumni.chalmers DOT se>

ok sthen@, dlg@


Revision tags: OPENBSD_5_7_BASE
# 1.19 04-Dec-2014 tedu

use siphash for trunk loadbalancing. ok deraadt


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.18 18-Nov-2013 mpi

Convert trunk(4) to use a detachhook, discussed at b2k13 with many.

While here add a comment explaining detach hooks' order of execution when
destroying/detaching an interface.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.17 04-Jul-2011 claudio

LINK_STATE cleanup. It is no longer needed to special case carp(4).
LINK_STATE_IS_UP() does the trick now for all cases.
OK henning@ deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.16 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.15 13-Jun-2008 mpf

Treat LINK_STATE_UNKNOWN as LINK_STATE_UP.
This restores the old behaviour where we were checking for != LINK_STATE_DOWN.
Fixes the ethernet to wireless failover feature and also allows trunk(4)
to be used within qemu.
Tested by sturm@.
OK reyk@. "grumble, we should fix more drivers' link state handling" brad@


Revision tags: OPENBSD_4_3_BASE
# 1.14 22-Oct-2007 pyr

Add a broadcast mode to trunk(4). This mode sends frames on all
ports and receives frame on any port. This allows interaction with
some L2 configurations.
with input and ok reyk@


# 1.13 06-Sep-2007 reyk

bump the copyright while touching these files


Revision tags: OPENBSD_4_2_BASE
# 1.12 26-Apr-2007 reyk

extend the trunk protocol API with some additional callbacks required
for future work. also move the repeated tx start code into a common
function.

parts of it are merged from FreeBSD's trunk(4) port. oh, wait... they
renamed it to 'lagg(4)' because a little green guy from Cizzco-Eeeh
told them "trunk is for VLANs, trunk is for VLANs". Bad FreeBSD, don't
listen to the little green guy from Cizzco-Eeeh!

ok claudio@


Revision tags: OPENBSD_4_1_BASE
# 1.11 31-Jan-2007 reyk

handle the full duplex link state in trunk(4). load sharing trunks
with at least two ports are always handled as full fuplex links. this
change will allow trunks as edge ports in a rstp bridge(4).

ok brad@ pyr@


Revision tags: OPENBSD_4_0_BASE
# 1.10 28-May-2006 reyk

check if the interface is active and UP. some, but not all, network
drivers report an active link state even if the interface is DOWN.
this should fix trunk with various ethernet devices.

ok brad@


# 1.9 23-May-2006 reyk

add


# 1.8 20-May-2006 reyk

bump copyright


Revision tags: OPENBSD_3_9_BASE
# 1.7 09-Feb-2006 reyk

remove trailing ',' in enum declaration


# 1.6 18-Dec-2005 reyk

Update my e-mail address in the copyright statement, no binary changes.


# 1.5 27-Nov-2005 mcbride

Make the trunk interface link state depend on the link states of the
trunkports (link is UP as long as at least one of the trunkports is up)

ok reyk@


# 1.4 03-Oct-2005 reyk

add a simple active "failover" trunk mode. port priorities will be
added later, currently the master port will always be the default
(active) port and the the next active port will be used as the
failover port.

ok brad@


# 1.3 10-Sep-2005 reyk

update the trunk(4) driver

- add multicast support by passing multicast addresses to the ports.
this is a requirement for carp(4) over trunk(4).

- support the smallest common interface capabilities. ie., this adds
support for VLAN MTUs if all attached ports have this capability.

- add a port_destroy callback to the trunk protocol. this fixes a
potential crash if the master port has been detached while running.

discussed with deraadt@, brad@ and some others.


Revision tags: OPENBSD_3_8_BASE
# 1.2 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.1 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.30 22-Jul-2020 dlg

deprecate interface input handler lists, just use one input function.

the interface input handler lists were originally set up to help
us during the intial mpsafe network stack work. at the time not all
the virtual ethernet interfaces (vlan, svlan, bridge, trunk, etc)
were mpsafe, so we wanted a way to avoid them by default, and only
take the kernel lock hit when they were specifically enabled on the
interface. since then, they have been fixed up to be mpsafe.

i could leave the list in place, but it has some semantic problems.
because virtual interfaces filter packets based on the order they
were attached to the parent interface, you can get packets taken
away in surprising ways, especially when you reboot and netstart
does something different to what you did by hand. by hardcoding the
order that things like vlan and bridge get to look at packets, we
can document the behaviour and get consistency.

it also means we can get rid of a use of SRPs which were difficult
to replace with SMRs. the interface input handler list is an SRPL,
which we would like to deprecate. it turns out that you can sleep
during stack processing, which you're not supposed to do with SRPs
or SMRs, but SRPs are a lot more forgiving and it worked.

lastly, it turns out that this code is faster than the input list
handling, so lots of winning all around.

special thanks to hrvoje popovski and aaron bieber for testing.
this has been in snaps as part of a larger diff for over a week.


Revision tags: OPENBSD_6_7_BASE
# 1.29 07-Nov-2019 dlg

turn the linkstate hooks into a task list, like the detach hooks.

this is largely mechanical, except for carp. this moves the addition
of the carp link state hook after we're committed to using the new
interface as a carpdev. because the add can't fail, we avoid a
complicated unwind dance. also, this tweaks the carp linkstate hook
so it only updates the relevant carp interface, not all of the
carpdevs on the parent.

hrvoje popovski has tested an early version of this diff and it's
generally ok, but there's some splasserts that this diff fires that
i'll fix in an upcoming diff.

ok claudio@


# 1.28 06-Nov-2019 dlg

replace the hooks used with if_detachhooks with a task list.

the main semantic change is that things registering detach hooks
have to allocate and set a task structure that then gets added to
the list. this means if the task is allocated up front (eg, as part
of carps softc or bridges port structure), it avoids the possibility
that adding a hook can fail. a lot of drivers weren't checking for
failure, and unwinding state in the event of failure in other parts
was error prone.

while doing this i discovered that the list operations have to be
in a particular order, but drivers weren't doing that consistently
either. this diff wraps the list ops up so you have to seriously
go out of your way to screw them up.

ive also sprinkled some NET_ASSERT_LOCKED around the list operations
so we can make sure there's no potential for the list to be corrupted,
especially while it's being run.

hrvoje popovski has tested this a bit, and some issues he discovered
have been fixed.

ok sashan@


Revision tags: OPENBSD_6_6_BASE
# 1.27 29-Apr-2019 dlg

tr_unit is unused, so gc it


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.26 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.25 23-Sep-2015 mikeb

Remove trunk watchdog code since it doesn't do anything useful
and we want to limit the number of different places where we
access trunk port pointers.

trunk_watchdog should be never called as we don't set up it's
if_timer and trunk_port_watchdog just calls the if_watchdog
from the underlying interface.

It's possible that this is no longer needed due to if_slowtimo/
if_watchdog changes done earlier.

ok mpi


# 1.24 10-Sep-2015 dlg

move the if input handler list to an SRP list.

instead of having every driver that manipulates the ifih list
understand SRPLs, this moves that processing into if_ih_insert and
if_ih_remove functions.

we rely on the kernel lock to serialise the modifications to the
list.

tested by mpi@
ok mpi@ claudio@ mikeb@


Revision tags: OPENBSD_5_8_BASE
# 1.23 26-May-2015 mpi

Now that the Ethernet header is always passed as part of the mbuf, kill
the second (unused) argument of the input packet handlers.

ok dlg@


# 1.22 14-May-2015 mpi

Allocate the input packet handler as part of the trunk_port structure
since they have the same lifetime.

Requested by and ok dlg@


# 1.21 13-May-2015 mpi

Get rid of the last "#if NTRUNK" by overwriting trunk ports' output
function.

ok claudio@, reyk@


# 1.20 11-May-2015 mpi

Take trunk(4) out of ether_input().

Each physical interface of a trunk now gets a specific ifih (interface
input handler) that runs before ether_input().

Tested by sthen@, dlg@, Theo Buehler and <mxb AT alumni.chalmers DOT se>

ok sthen@, dlg@


Revision tags: OPENBSD_5_7_BASE
# 1.19 04-Dec-2014 tedu

use siphash for trunk loadbalancing. ok deraadt


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.18 18-Nov-2013 mpi

Convert trunk(4) to use a detachhook, discussed at b2k13 with many.

While here add a comment explaining detach hooks' order of execution when
destroying/detaching an interface.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.17 04-Jul-2011 claudio

LINK_STATE cleanup. It is no longer needed to special case carp(4).
LINK_STATE_IS_UP() does the trick now for all cases.
OK henning@ deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.16 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.15 13-Jun-2008 mpf

Treat LINK_STATE_UNKNOWN as LINK_STATE_UP.
This restores the old behaviour where we were checking for != LINK_STATE_DOWN.
Fixes the ethernet to wireless failover feature and also allows trunk(4)
to be used within qemu.
Tested by sturm@.
OK reyk@. "grumble, we should fix more drivers' link state handling" brad@


Revision tags: OPENBSD_4_3_BASE
# 1.14 22-Oct-2007 pyr

Add a broadcast mode to trunk(4). This mode sends frames on all
ports and receives frame on any port. This allows interaction with
some L2 configurations.
with input and ok reyk@


# 1.13 06-Sep-2007 reyk

bump the copyright while touching these files


Revision tags: OPENBSD_4_2_BASE
# 1.12 26-Apr-2007 reyk

extend the trunk protocol API with some additional callbacks required
for future work. also move the repeated tx start code into a common
function.

parts of it are merged from FreeBSD's trunk(4) port. oh, wait... they
renamed it to 'lagg(4)' because a little green guy from Cizzco-Eeeh
told them "trunk is for VLANs, trunk is for VLANs". Bad FreeBSD, don't
listen to the little green guy from Cizzco-Eeeh!

ok claudio@


Revision tags: OPENBSD_4_1_BASE
# 1.11 31-Jan-2007 reyk

handle the full duplex link state in trunk(4). load sharing trunks
with at least two ports are always handled as full fuplex links. this
change will allow trunks as edge ports in a rstp bridge(4).

ok brad@ pyr@


Revision tags: OPENBSD_4_0_BASE
# 1.10 28-May-2006 reyk

check if the interface is active and UP. some, but not all, network
drivers report an active link state even if the interface is DOWN.
this should fix trunk with various ethernet devices.

ok brad@


# 1.9 23-May-2006 reyk

add


# 1.8 20-May-2006 reyk

bump copyright


Revision tags: OPENBSD_3_9_BASE
# 1.7 09-Feb-2006 reyk

remove trailing ',' in enum declaration


# 1.6 18-Dec-2005 reyk

Update my e-mail address in the copyright statement, no binary changes.


# 1.5 27-Nov-2005 mcbride

Make the trunk interface link state depend on the link states of the
trunkports (link is UP as long as at least one of the trunkports is up)

ok reyk@


# 1.4 03-Oct-2005 reyk

add a simple active "failover" trunk mode. port priorities will be
added later, currently the master port will always be the default
(active) port and the the next active port will be used as the
failover port.

ok brad@


# 1.3 10-Sep-2005 reyk

update the trunk(4) driver

- add multicast support by passing multicast addresses to the ports.
this is a requirement for carp(4) over trunk(4).

- support the smallest common interface capabilities. ie., this adds
support for VLAN MTUs if all attached ports have this capability.

- add a port_destroy callback to the trunk protocol. this fixes a
potential crash if the master port has been detached while running.

discussed with deraadt@, brad@ and some others.


Revision tags: OPENBSD_3_8_BASE
# 1.2 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.1 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.29 07-Nov-2019 dlg

turn the linkstate hooks into a task list, like the detach hooks.

this is largely mechanical, except for carp. this moves the addition
of the carp link state hook after we're committed to using the new
interface as a carpdev. because the add can't fail, we avoid a
complicated unwind dance. also, this tweaks the carp linkstate hook
so it only updates the relevant carp interface, not all of the
carpdevs on the parent.

hrvoje popovski has tested an early version of this diff and it's
generally ok, but there's some splasserts that this diff fires that
i'll fix in an upcoming diff.

ok claudio@


# 1.28 06-Nov-2019 dlg

replace the hooks used with if_detachhooks with a task list.

the main semantic change is that things registering detach hooks
have to allocate and set a task structure that then gets added to
the list. this means if the task is allocated up front (eg, as part
of carps softc or bridges port structure), it avoids the possibility
that adding a hook can fail. a lot of drivers weren't checking for
failure, and unwinding state in the event of failure in other parts
was error prone.

while doing this i discovered that the list operations have to be
in a particular order, but drivers weren't doing that consistently
either. this diff wraps the list ops up so you have to seriously
go out of your way to screw them up.

ive also sprinkled some NET_ASSERT_LOCKED around the list operations
so we can make sure there's no potential for the list to be corrupted,
especially while it's being run.

hrvoje popovski has tested this a bit, and some issues he discovered
have been fixed.

ok sashan@


Revision tags: OPENBSD_6_6_BASE
# 1.27 29-Apr-2019 dlg

tr_unit is unused, so gc it


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.26 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.25 23-Sep-2015 mikeb

Remove trunk watchdog code since it doesn't do anything useful
and we want to limit the number of different places where we
access trunk port pointers.

trunk_watchdog should be never called as we don't set up it's
if_timer and trunk_port_watchdog just calls the if_watchdog
from the underlying interface.

It's possible that this is no longer needed due to if_slowtimo/
if_watchdog changes done earlier.

ok mpi


# 1.24 10-Sep-2015 dlg

move the if input handler list to an SRP list.

instead of having every driver that manipulates the ifih list
understand SRPLs, this moves that processing into if_ih_insert and
if_ih_remove functions.

we rely on the kernel lock to serialise the modifications to the
list.

tested by mpi@
ok mpi@ claudio@ mikeb@


Revision tags: OPENBSD_5_8_BASE
# 1.23 26-May-2015 mpi

Now that the Ethernet header is always passed as part of the mbuf, kill
the second (unused) argument of the input packet handlers.

ok dlg@


# 1.22 14-May-2015 mpi

Allocate the input packet handler as part of the trunk_port structure
since they have the same lifetime.

Requested by and ok dlg@


# 1.21 13-May-2015 mpi

Get rid of the last "#if NTRUNK" by overwriting trunk ports' output
function.

ok claudio@, reyk@


# 1.20 11-May-2015 mpi

Take trunk(4) out of ether_input().

Each physical interface of a trunk now gets a specific ifih (interface
input handler) that runs before ether_input().

Tested by sthen@, dlg@, Theo Buehler and <mxb AT alumni.chalmers DOT se>

ok sthen@, dlg@


Revision tags: OPENBSD_5_7_BASE
# 1.19 04-Dec-2014 tedu

use siphash for trunk loadbalancing. ok deraadt


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.18 18-Nov-2013 mpi

Convert trunk(4) to use a detachhook, discussed at b2k13 with many.

While here add a comment explaining detach hooks' order of execution when
destroying/detaching an interface.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.17 04-Jul-2011 claudio

LINK_STATE cleanup. It is no longer needed to special case carp(4).
LINK_STATE_IS_UP() does the trick now for all cases.
OK henning@ deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.16 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.15 13-Jun-2008 mpf

Treat LINK_STATE_UNKNOWN as LINK_STATE_UP.
This restores the old behaviour where we were checking for != LINK_STATE_DOWN.
Fixes the ethernet to wireless failover feature and also allows trunk(4)
to be used within qemu.
Tested by sturm@.
OK reyk@. "grumble, we should fix more drivers' link state handling" brad@


Revision tags: OPENBSD_4_3_BASE
# 1.14 22-Oct-2007 pyr

Add a broadcast mode to trunk(4). This mode sends frames on all
ports and receives frame on any port. This allows interaction with
some L2 configurations.
with input and ok reyk@


# 1.13 06-Sep-2007 reyk

bump the copyright while touching these files


Revision tags: OPENBSD_4_2_BASE
# 1.12 26-Apr-2007 reyk

extend the trunk protocol API with some additional callbacks required
for future work. also move the repeated tx start code into a common
function.

parts of it are merged from FreeBSD's trunk(4) port. oh, wait... they
renamed it to 'lagg(4)' because a little green guy from Cizzco-Eeeh
told them "trunk is for VLANs, trunk is for VLANs". Bad FreeBSD, don't
listen to the little green guy from Cizzco-Eeeh!

ok claudio@


Revision tags: OPENBSD_4_1_BASE
# 1.11 31-Jan-2007 reyk

handle the full duplex link state in trunk(4). load sharing trunks
with at least two ports are always handled as full fuplex links. this
change will allow trunks as edge ports in a rstp bridge(4).

ok brad@ pyr@


Revision tags: OPENBSD_4_0_BASE
# 1.10 28-May-2006 reyk

check if the interface is active and UP. some, but not all, network
drivers report an active link state even if the interface is DOWN.
this should fix trunk with various ethernet devices.

ok brad@


# 1.9 23-May-2006 reyk

add


# 1.8 20-May-2006 reyk

bump copyright


Revision tags: OPENBSD_3_9_BASE
# 1.7 09-Feb-2006 reyk

remove trailing ',' in enum declaration


# 1.6 18-Dec-2005 reyk

Update my e-mail address in the copyright statement, no binary changes.


# 1.5 27-Nov-2005 mcbride

Make the trunk interface link state depend on the link states of the
trunkports (link is UP as long as at least one of the trunkports is up)

ok reyk@


# 1.4 03-Oct-2005 reyk

add a simple active "failover" trunk mode. port priorities will be
added later, currently the master port will always be the default
(active) port and the the next active port will be used as the
failover port.

ok brad@


# 1.3 10-Sep-2005 reyk

update the trunk(4) driver

- add multicast support by passing multicast addresses to the ports.
this is a requirement for carp(4) over trunk(4).

- support the smallest common interface capabilities. ie., this adds
support for VLAN MTUs if all attached ports have this capability.

- add a port_destroy callback to the trunk protocol. this fixes a
potential crash if the master port has been detached while running.

discussed with deraadt@, brad@ and some others.


Revision tags: OPENBSD_3_8_BASE
# 1.2 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.1 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.28 06-Nov-2019 dlg

replace the hooks used with if_detachhooks with a task list.

the main semantic change is that things registering detach hooks
have to allocate and set a task structure that then gets added to
the list. this means if the task is allocated up front (eg, as part
of carps softc or bridges port structure), it avoids the possibility
that adding a hook can fail. a lot of drivers weren't checking for
failure, and unwinding state in the event of failure in other parts
was error prone.

while doing this i discovered that the list operations have to be
in a particular order, but drivers weren't doing that consistently
either. this diff wraps the list ops up so you have to seriously
go out of your way to screw them up.

ive also sprinkled some NET_ASSERT_LOCKED around the list operations
so we can make sure there's no potential for the list to be corrupted,
especially while it's being run.

hrvoje popovski has tested this a bit, and some issues he discovered
have been fixed.

ok sashan@


Revision tags: OPENBSD_6_6_BASE
# 1.27 29-Apr-2019 dlg

tr_unit is unused, so gc it


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.26 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.25 23-Sep-2015 mikeb

Remove trunk watchdog code since it doesn't do anything useful
and we want to limit the number of different places where we
access trunk port pointers.

trunk_watchdog should be never called as we don't set up it's
if_timer and trunk_port_watchdog just calls the if_watchdog
from the underlying interface.

It's possible that this is no longer needed due to if_slowtimo/
if_watchdog changes done earlier.

ok mpi


# 1.24 10-Sep-2015 dlg

move the if input handler list to an SRP list.

instead of having every driver that manipulates the ifih list
understand SRPLs, this moves that processing into if_ih_insert and
if_ih_remove functions.

we rely on the kernel lock to serialise the modifications to the
list.

tested by mpi@
ok mpi@ claudio@ mikeb@


Revision tags: OPENBSD_5_8_BASE
# 1.23 26-May-2015 mpi

Now that the Ethernet header is always passed as part of the mbuf, kill
the second (unused) argument of the input packet handlers.

ok dlg@


# 1.22 14-May-2015 mpi

Allocate the input packet handler as part of the trunk_port structure
since they have the same lifetime.

Requested by and ok dlg@


# 1.21 13-May-2015 mpi

Get rid of the last "#if NTRUNK" by overwriting trunk ports' output
function.

ok claudio@, reyk@


# 1.20 11-May-2015 mpi

Take trunk(4) out of ether_input().

Each physical interface of a trunk now gets a specific ifih (interface
input handler) that runs before ether_input().

Tested by sthen@, dlg@, Theo Buehler and <mxb AT alumni.chalmers DOT se>

ok sthen@, dlg@


Revision tags: OPENBSD_5_7_BASE
# 1.19 04-Dec-2014 tedu

use siphash for trunk loadbalancing. ok deraadt


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.18 18-Nov-2013 mpi

Convert trunk(4) to use a detachhook, discussed at b2k13 with many.

While here add a comment explaining detach hooks' order of execution when
destroying/detaching an interface.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.17 04-Jul-2011 claudio

LINK_STATE cleanup. It is no longer needed to special case carp(4).
LINK_STATE_IS_UP() does the trick now for all cases.
OK henning@ deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.16 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.15 13-Jun-2008 mpf

Treat LINK_STATE_UNKNOWN as LINK_STATE_UP.
This restores the old behaviour where we were checking for != LINK_STATE_DOWN.
Fixes the ethernet to wireless failover feature and also allows trunk(4)
to be used within qemu.
Tested by sturm@.
OK reyk@. "grumble, we should fix more drivers' link state handling" brad@


Revision tags: OPENBSD_4_3_BASE
# 1.14 22-Oct-2007 pyr

Add a broadcast mode to trunk(4). This mode sends frames on all
ports and receives frame on any port. This allows interaction with
some L2 configurations.
with input and ok reyk@


# 1.13 06-Sep-2007 reyk

bump the copyright while touching these files


Revision tags: OPENBSD_4_2_BASE
# 1.12 26-Apr-2007 reyk

extend the trunk protocol API with some additional callbacks required
for future work. also move the repeated tx start code into a common
function.

parts of it are merged from FreeBSD's trunk(4) port. oh, wait... they
renamed it to 'lagg(4)' because a little green guy from Cizzco-Eeeh
told them "trunk is for VLANs, trunk is for VLANs". Bad FreeBSD, don't
listen to the little green guy from Cizzco-Eeeh!

ok claudio@


Revision tags: OPENBSD_4_1_BASE
# 1.11 31-Jan-2007 reyk

handle the full duplex link state in trunk(4). load sharing trunks
with at least two ports are always handled as full fuplex links. this
change will allow trunks as edge ports in a rstp bridge(4).

ok brad@ pyr@


Revision tags: OPENBSD_4_0_BASE
# 1.10 28-May-2006 reyk

check if the interface is active and UP. some, but not all, network
drivers report an active link state even if the interface is DOWN.
this should fix trunk with various ethernet devices.

ok brad@


# 1.9 23-May-2006 reyk

add


# 1.8 20-May-2006 reyk

bump copyright


Revision tags: OPENBSD_3_9_BASE
# 1.7 09-Feb-2006 reyk

remove trailing ',' in enum declaration


# 1.6 18-Dec-2005 reyk

Update my e-mail address in the copyright statement, no binary changes.


# 1.5 27-Nov-2005 mcbride

Make the trunk interface link state depend on the link states of the
trunkports (link is UP as long as at least one of the trunkports is up)

ok reyk@


# 1.4 03-Oct-2005 reyk

add a simple active "failover" trunk mode. port priorities will be
added later, currently the master port will always be the default
(active) port and the the next active port will be used as the
failover port.

ok brad@


# 1.3 10-Sep-2005 reyk

update the trunk(4) driver

- add multicast support by passing multicast addresses to the ports.
this is a requirement for carp(4) over trunk(4).

- support the smallest common interface capabilities. ie., this adds
support for VLAN MTUs if all attached ports have this capability.

- add a port_destroy callback to the trunk protocol. this fixes a
potential crash if the master port has been detached while running.

discussed with deraadt@, brad@ and some others.


Revision tags: OPENBSD_3_8_BASE
# 1.2 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.1 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.27 29-Apr-2019 dlg

tr_unit is unused, so gc it


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.26 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.25 23-Sep-2015 mikeb

Remove trunk watchdog code since it doesn't do anything useful
and we want to limit the number of different places where we
access trunk port pointers.

trunk_watchdog should be never called as we don't set up it's
if_timer and trunk_port_watchdog just calls the if_watchdog
from the underlying interface.

It's possible that this is no longer needed due to if_slowtimo/
if_watchdog changes done earlier.

ok mpi


# 1.24 10-Sep-2015 dlg

move the if input handler list to an SRP list.

instead of having every driver that manipulates the ifih list
understand SRPLs, this moves that processing into if_ih_insert and
if_ih_remove functions.

we rely on the kernel lock to serialise the modifications to the
list.

tested by mpi@
ok mpi@ claudio@ mikeb@


Revision tags: OPENBSD_5_8_BASE
# 1.23 26-May-2015 mpi

Now that the Ethernet header is always passed as part of the mbuf, kill
the second (unused) argument of the input packet handlers.

ok dlg@


# 1.22 14-May-2015 mpi

Allocate the input packet handler as part of the trunk_port structure
since they have the same lifetime.

Requested by and ok dlg@


# 1.21 13-May-2015 mpi

Get rid of the last "#if NTRUNK" by overwriting trunk ports' output
function.

ok claudio@, reyk@


# 1.20 11-May-2015 mpi

Take trunk(4) out of ether_input().

Each physical interface of a trunk now gets a specific ifih (interface
input handler) that runs before ether_input().

Tested by sthen@, dlg@, Theo Buehler and <mxb AT alumni.chalmers DOT se>

ok sthen@, dlg@


Revision tags: OPENBSD_5_7_BASE
# 1.19 04-Dec-2014 tedu

use siphash for trunk loadbalancing. ok deraadt


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.18 18-Nov-2013 mpi

Convert trunk(4) to use a detachhook, discussed at b2k13 with many.

While here add a comment explaining detach hooks' order of execution when
destroying/detaching an interface.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.17 04-Jul-2011 claudio

LINK_STATE cleanup. It is no longer needed to special case carp(4).
LINK_STATE_IS_UP() does the trick now for all cases.
OK henning@ deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.16 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.15 13-Jun-2008 mpf

Treat LINK_STATE_UNKNOWN as LINK_STATE_UP.
This restores the old behaviour where we were checking for != LINK_STATE_DOWN.
Fixes the ethernet to wireless failover feature and also allows trunk(4)
to be used within qemu.
Tested by sturm@.
OK reyk@. "grumble, we should fix more drivers' link state handling" brad@


Revision tags: OPENBSD_4_3_BASE
# 1.14 22-Oct-2007 pyr

Add a broadcast mode to trunk(4). This mode sends frames on all
ports and receives frame on any port. This allows interaction with
some L2 configurations.
with input and ok reyk@


# 1.13 06-Sep-2007 reyk

bump the copyright while touching these files


Revision tags: OPENBSD_4_2_BASE
# 1.12 26-Apr-2007 reyk

extend the trunk protocol API with some additional callbacks required
for future work. also move the repeated tx start code into a common
function.

parts of it are merged from FreeBSD's trunk(4) port. oh, wait... they
renamed it to 'lagg(4)' because a little green guy from Cizzco-Eeeh
told them "trunk is for VLANs, trunk is for VLANs". Bad FreeBSD, don't
listen to the little green guy from Cizzco-Eeeh!

ok claudio@


Revision tags: OPENBSD_4_1_BASE
# 1.11 31-Jan-2007 reyk

handle the full duplex link state in trunk(4). load sharing trunks
with at least two ports are always handled as full fuplex links. this
change will allow trunks as edge ports in a rstp bridge(4).

ok brad@ pyr@


Revision tags: OPENBSD_4_0_BASE
# 1.10 28-May-2006 reyk

check if the interface is active and UP. some, but not all, network
drivers report an active link state even if the interface is DOWN.
this should fix trunk with various ethernet devices.

ok brad@


# 1.9 23-May-2006 reyk

add


# 1.8 20-May-2006 reyk

bump copyright


Revision tags: OPENBSD_3_9_BASE
# 1.7 09-Feb-2006 reyk

remove trailing ',' in enum declaration


# 1.6 18-Dec-2005 reyk

Update my e-mail address in the copyright statement, no binary changes.


# 1.5 27-Nov-2005 mcbride

Make the trunk interface link state depend on the link states of the
trunkports (link is UP as long as at least one of the trunkports is up)

ok reyk@


# 1.4 03-Oct-2005 reyk

add a simple active "failover" trunk mode. port priorities will be
added later, currently the master port will always be the default
(active) port and the the next active port will be used as the
failover port.

ok brad@


# 1.3 10-Sep-2005 reyk

update the trunk(4) driver

- add multicast support by passing multicast addresses to the ports.
this is a requirement for carp(4) over trunk(4).

- support the smallest common interface capabilities. ie., this adds
support for VLAN MTUs if all attached ports have this capability.

- add a port_destroy callback to the trunk protocol. this fixes a
potential crash if the master port has been detached while running.

discussed with deraadt@, brad@ and some others.


Revision tags: OPENBSD_3_8_BASE
# 1.2 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.1 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.26 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.25 23-Sep-2015 mikeb

Remove trunk watchdog code since it doesn't do anything useful
and we want to limit the number of different places where we
access trunk port pointers.

trunk_watchdog should be never called as we don't set up it's
if_timer and trunk_port_watchdog just calls the if_watchdog
from the underlying interface.

It's possible that this is no longer needed due to if_slowtimo/
if_watchdog changes done earlier.

ok mpi


# 1.24 10-Sep-2015 dlg

move the if input handler list to an SRP list.

instead of having every driver that manipulates the ifih list
understand SRPLs, this moves that processing into if_ih_insert and
if_ih_remove functions.

we rely on the kernel lock to serialise the modifications to the
list.

tested by mpi@
ok mpi@ claudio@ mikeb@


Revision tags: OPENBSD_5_8_BASE
# 1.23 26-May-2015 mpi

Now that the Ethernet header is always passed as part of the mbuf, kill
the second (unused) argument of the input packet handlers.

ok dlg@


# 1.22 14-May-2015 mpi

Allocate the input packet handler as part of the trunk_port structure
since they have the same lifetime.

Requested by and ok dlg@


# 1.21 13-May-2015 mpi

Get rid of the last "#if NTRUNK" by overwriting trunk ports' output
function.

ok claudio@, reyk@


# 1.20 11-May-2015 mpi

Take trunk(4) out of ether_input().

Each physical interface of a trunk now gets a specific ifih (interface
input handler) that runs before ether_input().

Tested by sthen@, dlg@, Theo Buehler and <mxb AT alumni.chalmers DOT se>

ok sthen@, dlg@


Revision tags: OPENBSD_5_7_BASE
# 1.19 04-Dec-2014 tedu

use siphash for trunk loadbalancing. ok deraadt


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.18 18-Nov-2013 mpi

Convert trunk(4) to use a detachhook, discussed at b2k13 with many.

While here add a comment explaining detach hooks' order of execution when
destroying/detaching an interface.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.17 04-Jul-2011 claudio

LINK_STATE cleanup. It is no longer needed to special case carp(4).
LINK_STATE_IS_UP() does the trick now for all cases.
OK henning@ deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.16 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.15 13-Jun-2008 mpf

Treat LINK_STATE_UNKNOWN as LINK_STATE_UP.
This restores the old behaviour where we were checking for != LINK_STATE_DOWN.
Fixes the ethernet to wireless failover feature and also allows trunk(4)
to be used within qemu.
Tested by sturm@.
OK reyk@. "grumble, we should fix more drivers' link state handling" brad@


Revision tags: OPENBSD_4_3_BASE
# 1.14 22-Oct-2007 pyr

Add a broadcast mode to trunk(4). This mode sends frames on all
ports and receives frame on any port. This allows interaction with
some L2 configurations.
with input and ok reyk@


# 1.13 06-Sep-2007 reyk

bump the copyright while touching these files


Revision tags: OPENBSD_4_2_BASE
# 1.12 26-Apr-2007 reyk

extend the trunk protocol API with some additional callbacks required
for future work. also move the repeated tx start code into a common
function.

parts of it are merged from FreeBSD's trunk(4) port. oh, wait... they
renamed it to 'lagg(4)' because a little green guy from Cizzco-Eeeh
told them "trunk is for VLANs, trunk is for VLANs". Bad FreeBSD, don't
listen to the little green guy from Cizzco-Eeeh!

ok claudio@


Revision tags: OPENBSD_4_1_BASE
# 1.11 31-Jan-2007 reyk

handle the full duplex link state in trunk(4). load sharing trunks
with at least two ports are always handled as full fuplex links. this
change will allow trunks as edge ports in a rstp bridge(4).

ok brad@ pyr@


Revision tags: OPENBSD_4_0_BASE
# 1.10 28-May-2006 reyk

check if the interface is active and UP. some, but not all, network
drivers report an active link state even if the interface is DOWN.
this should fix trunk with various ethernet devices.

ok brad@


# 1.9 23-May-2006 reyk

add


# 1.8 20-May-2006 reyk

bump copyright


Revision tags: OPENBSD_3_9_BASE
# 1.7 09-Feb-2006 reyk

remove trailing ',' in enum declaration


# 1.6 18-Dec-2005 reyk

Update my e-mail address in the copyright statement, no binary changes.


# 1.5 27-Nov-2005 mcbride

Make the trunk interface link state depend on the link states of the
trunkports (link is UP as long as at least one of the trunkports is up)

ok reyk@


# 1.4 03-Oct-2005 reyk

add a simple active "failover" trunk mode. port priorities will be
added later, currently the master port will always be the default
(active) port and the the next active port will be used as the
failover port.

ok brad@


# 1.3 10-Sep-2005 reyk

update the trunk(4) driver

- add multicast support by passing multicast addresses to the ports.
this is a requirement for carp(4) over trunk(4).

- support the smallest common interface capabilities. ie., this adds
support for VLAN MTUs if all attached ports have this capability.

- add a port_destroy callback to the trunk protocol. this fixes a
potential crash if the master port has been detached while running.

discussed with deraadt@, brad@ and some others.


Revision tags: OPENBSD_3_8_BASE
# 1.2 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.1 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.25 23-Sep-2015 mikeb

Remove trunk watchdog code since it doesn't do anything useful
and we want to limit the number of different places where we
access trunk port pointers.

trunk_watchdog should be never called as we don't set up it's
if_timer and trunk_port_watchdog just calls the if_watchdog
from the underlying interface.

It's possible that this is no longer needed due to if_slowtimo/
if_watchdog changes done earlier.

ok mpi


# 1.24 10-Sep-2015 dlg

move the if input handler list to an SRP list.

instead of having every driver that manipulates the ifih list
understand SRPLs, this moves that processing into if_ih_insert and
if_ih_remove functions.

we rely on the kernel lock to serialise the modifications to the
list.

tested by mpi@
ok mpi@ claudio@ mikeb@


Revision tags: OPENBSD_5_8_BASE
# 1.23 26-May-2015 mpi

Now that the Ethernet header is always passed as part of the mbuf, kill
the second (unused) argument of the input packet handlers.

ok dlg@


# 1.22 14-May-2015 mpi

Allocate the input packet handler as part of the trunk_port structure
since they have the same lifetime.

Requested by and ok dlg@


# 1.21 13-May-2015 mpi

Get rid of the last "#if NTRUNK" by overwriting trunk ports' output
function.

ok claudio@, reyk@


# 1.20 11-May-2015 mpi

Take trunk(4) out of ether_input().

Each physical interface of a trunk now gets a specific ifih (interface
input handler) that runs before ether_input().

Tested by sthen@, dlg@, Theo Buehler and <mxb AT alumni.chalmers DOT se>

ok sthen@, dlg@


Revision tags: OPENBSD_5_7_BASE
# 1.19 04-Dec-2014 tedu

use siphash for trunk loadbalancing. ok deraadt


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.18 18-Nov-2013 mpi

Convert trunk(4) to use a detachhook, discussed at b2k13 with many.

While here add a comment explaining detach hooks' order of execution when
destroying/detaching an interface.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.17 04-Jul-2011 claudio

LINK_STATE cleanup. It is no longer needed to special case carp(4).
LINK_STATE_IS_UP() does the trick now for all cases.
OK henning@ deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.16 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.15 13-Jun-2008 mpf

Treat LINK_STATE_UNKNOWN as LINK_STATE_UP.
This restores the old behaviour where we were checking for != LINK_STATE_DOWN.
Fixes the ethernet to wireless failover feature and also allows trunk(4)
to be used within qemu.
Tested by sturm@.
OK reyk@. "grumble, we should fix more drivers' link state handling" brad@


Revision tags: OPENBSD_4_3_BASE
# 1.14 22-Oct-2007 pyr

Add a broadcast mode to trunk(4). This mode sends frames on all
ports and receives frame on any port. This allows interaction with
some L2 configurations.
with input and ok reyk@


# 1.13 06-Sep-2007 reyk

bump the copyright while touching these files


Revision tags: OPENBSD_4_2_BASE
# 1.12 26-Apr-2007 reyk

extend the trunk protocol API with some additional callbacks required
for future work. also move the repeated tx start code into a common
function.

parts of it are merged from FreeBSD's trunk(4) port. oh, wait... they
renamed it to 'lagg(4)' because a little green guy from Cizzco-Eeeh
told them "trunk is for VLANs, trunk is for VLANs". Bad FreeBSD, don't
listen to the little green guy from Cizzco-Eeeh!

ok claudio@


Revision tags: OPENBSD_4_1_BASE
# 1.11 31-Jan-2007 reyk

handle the full duplex link state in trunk(4). load sharing trunks
with at least two ports are always handled as full fuplex links. this
change will allow trunks as edge ports in a rstp bridge(4).

ok brad@ pyr@


Revision tags: OPENBSD_4_0_BASE
# 1.10 28-May-2006 reyk

check if the interface is active and UP. some, but not all, network
drivers report an active link state even if the interface is DOWN.
this should fix trunk with various ethernet devices.

ok brad@


# 1.9 23-May-2006 reyk

add


# 1.8 20-May-2006 reyk

bump copyright


Revision tags: OPENBSD_3_9_BASE
# 1.7 09-Feb-2006 reyk

remove trailing ',' in enum declaration


# 1.6 18-Dec-2005 reyk

Update my e-mail address in the copyright statement, no binary changes.


# 1.5 27-Nov-2005 mcbride

Make the trunk interface link state depend on the link states of the
trunkports (link is UP as long as at least one of the trunkports is up)

ok reyk@


# 1.4 03-Oct-2005 reyk

add a simple active "failover" trunk mode. port priorities will be
added later, currently the master port will always be the default
(active) port and the the next active port will be used as the
failover port.

ok brad@


# 1.3 10-Sep-2005 reyk

update the trunk(4) driver

- add multicast support by passing multicast addresses to the ports.
this is a requirement for carp(4) over trunk(4).

- support the smallest common interface capabilities. ie., this adds
support for VLAN MTUs if all attached ports have this capability.

- add a port_destroy callback to the trunk protocol. this fixes a
potential crash if the master port has been detached while running.

discussed with deraadt@, brad@ and some others.


Revision tags: OPENBSD_3_8_BASE
# 1.2 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.1 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@