1
0
mirror of https://github.com/openbsd/src.git synced 2026-05-01 17:46:35 +00:00

remove lacp support from trunk(4)

lacp is better supported by aggr(4). users of lacp in trunk(4)
should migrate to aggr(4).

trunk(4) and the lacp support inside it is one of the last chunks
of code that still requires the netlock in the ethernet stack. the
last time i tried to fix this i ended up writing aggr(4), and nothing
about this code has improved since then. the other protos such as
failover and loadbalance are trivial in comparison and will be easy
to improve in the future.

discussed with and no objections from many
This commit is contained in:
dlg
2026-01-12 04:38:15 +00:00
parent 01b5bc711c
commit cfbde9ac9b
3 changed files with 17 additions and 178 deletions

View File

@@ -1,4 +1,4 @@
.\" $OpenBSD: trunk.4,v 1.31 2020/08/24 07:34:00 kn Exp $
.\" $OpenBSD: trunk.4,v 1.32 2026/01/12 04:38:15 dlg Exp $
.\"
.\" Copyright (c) 2005, 2006 Reyk Floeter <reyk@openbsd.org>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: August 24 2020 $
.Dd $Mdocdate: January 12 2026 $
.Dt TRUNK 4
.Os
.Sh NAME
@@ -38,7 +38,6 @@ command.
The driver currently supports the trunk protocols
.Ic broadcast ,
.Ic failover ,
.Ic lacp ,
.Ic loadbalance ,
.Ic none ,
and
@@ -58,17 +57,6 @@ If the master port becomes unavailable,
the next active port is used.
The first interface added is the master port;
any interfaces added after that are used as failover devices.
.It Ic lacp
Uses the IEEE 802.3ad (renamed to 802.1AX in 2014)
Link Aggregation Control Protocol (LACP)
and the Marker Protocol
to increase link speed and provide redundancy.
LACP trunk groups are composed of ports of the same speed,
set to full-duplex operation.
This protocol requires a switch which supports LACP.
By default, the LACP implementation uses active-mode LACP,
slow timeout, and 0x8000 (medium) priority as system and port
priorities.
.It Ic loadbalance
Distributes outgoing traffic through all active ports
and accepts incoming traffic from any active port.
@@ -90,6 +78,12 @@ The configuration can be done at runtime or by setting up a
.Xr hostname.if 5
configuration file for
.Xr netstart 8 .
.Pp
.Nm
does not implement
IEEE 802.1AX (formerly 802.3ad) Link Aggregation,
it is supported by
.Xr aggr 4 .
.Sh EXAMPLES
Create a simple round robin trunk with two
.Xr bge 4
@@ -113,6 +107,7 @@ device will be used:
192.168.1.1 netmask 255.255.255.0
.Ed
.Sh SEE ALSO
.Xr aggr 4 ,
.Xr inet 4 ,
.Xr hostname.if 5 ,
.Xr ifconfig 8 ,
@@ -122,6 +117,10 @@ The
.Nm
device first appeared in
.Ox 3.8 .
Support for 802.3ad Link Aggregation was added in
.Ox 4.4
and removed in
.Ox 7.9 .
.Sh AUTHORS
The
.Nm

View File

@@ -1,4 +1,4 @@
# $OpenBSD: files,v 1.748 2025/11/14 01:55:07 jcs Exp $
# $OpenBSD: files,v 1.749 2026/01/12 04:38:15 dlg Exp $
# $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
@@ -868,7 +868,6 @@ file net/slcompress.c ppp
file net/if_enc.c enc
file net/if_gre.c gre needs-count
file net/if_trunk.c trunk
file net/trunklacp.c trunk
file net/if_aggr.c aggr
file net/if_tpmr.c tpmr
file net/if_mpe.c mpe

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: if_trunk.c,v 1.159 2025/12/02 03:24:19 dlg Exp $ */
/* $OpenBSD: if_trunk.c,v 1.160 2026/01/12 04:38:15 dlg Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 Reyk Floeter <reyk@openbsd.org>
@@ -42,7 +42,6 @@
#endif
#include <net/if_trunk.h>
#include <net/trunklacp.h>
#include "bpfilter.h"
#if NBPFILTER > 0
@@ -125,13 +124,6 @@ int trunk_bcast_start(struct trunk_softc *, struct mbuf *);
int trunk_bcast_input(struct trunk_softc *, struct trunk_port *,
struct mbuf *);
/* 802.3ad LACP */
int trunk_lacp_attach(struct trunk_softc *);
int trunk_lacp_detach(struct trunk_softc *);
int trunk_lacp_start(struct trunk_softc *, struct mbuf *);
int trunk_lacp_input(struct trunk_softc *, struct trunk_port *,
struct mbuf *);
/* Trunk protocol table */
static const struct {
enum trunk_proto ti_proto;
@@ -141,7 +133,6 @@ static const struct {
{ TRUNK_PROTO_FAILOVER, trunk_fail_attach },
{ TRUNK_PROTO_LOADBALANCE, trunk_lb_attach },
{ TRUNK_PROTO_BROADCAST, trunk_bcast_attach },
{ TRUNK_PROTO_LACP, trunk_lacp_attach },
{ TRUNK_PROTO_NONE, NULL }
};
@@ -606,11 +597,6 @@ trunk_port2req(struct trunk_port *tp, struct trunk_reqport *rp)
if (TRUNK_PORTACTIVE(tp))
rp->rp_flags |= TRUNK_PORT_ACTIVE;
break;
case TRUNK_PROTO_LACP:
/* LACP has a different definition of active */
rp->rp_flags = lacp_port_status(tp);
break;
default:
break;
}
@@ -622,11 +608,8 @@ trunk_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
struct trunk_softc *tr = (struct trunk_softc *)ifp->if_softc;
struct trunk_reqall *ra = (struct trunk_reqall *)data;
struct trunk_reqport *rp = (struct trunk_reqport *)data, rpbuf;
struct trunk_opts *tro = (struct trunk_opts *)data;
struct ifreq *ifr = (struct ifreq *)data;
struct lacp_softc *lsc;
struct trunk_port *tp;
struct lacp_port *lp;
struct ifnet *tpif;
int i, error = 0;
@@ -710,16 +693,7 @@ trunk_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
break;
case SIOCGTRUNKOPTS:
/* Only LACP trunks have options atm */
if (tro->to_proto != TRUNK_PROTO_LACP) {
error = EPROTONOSUPPORT;
break;
}
lsc = LACP_SOFTC(tr);
tro->to_lacpopts.lacp_mode = lsc->lsc_mode;
tro->to_lacpopts.lacp_timeout = lsc->lsc_timeout;
tro->to_lacpopts.lacp_prio = lsc->lsc_sys_prio;
tro->to_lacpopts.lacp_portprio = lsc->lsc_port_prio;
tro->to_lacpopts.lacp_ifqprio = lsc->lsc_ifq_prio;
error = EPROTONOSUPPORT;
break;
case SIOCSTRUNKOPTS:
if ((error = suser(curproc)) != 0) {
@@ -727,74 +701,7 @@ trunk_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
break;
}
/* Only LACP trunks have options atm */
if (tro->to_proto != TRUNK_PROTO_LACP) {
error = EPROTONOSUPPORT;
break;
}
lsc = LACP_SOFTC(tr);
switch(tro->to_opts) {
case TRUNK_OPT_LACP_MODE:
/*
* Ensure mode changes occur immediately
* on all ports
*/
lsc->lsc_mode = tro->to_lacpopts.lacp_mode;
if (lsc->lsc_mode == 0) {
LIST_FOREACH(lp, &lsc->lsc_ports,
lp_next)
lp->lp_state &=
~LACP_STATE_ACTIVITY;
} else {
LIST_FOREACH(lp, &lsc->lsc_ports,
lp_next)
lp->lp_state |=
LACP_STATE_ACTIVITY;
}
break;
case TRUNK_OPT_LACP_TIMEOUT:
/*
* Ensure timeout changes occur immediately
* on all ports
*/
lsc->lsc_timeout =
tro->to_lacpopts.lacp_timeout;
if (lsc->lsc_timeout == 0) {
LIST_FOREACH(lp, &lsc->lsc_ports,
lp_next)
lp->lp_state &=
~LACP_STATE_TIMEOUT;
} else {
LIST_FOREACH(lp, &lsc->lsc_ports,
lp_next)
lp->lp_state |=
LACP_STATE_TIMEOUT;
}
break;
case TRUNK_OPT_LACP_SYS_PRIO:
if (tro->to_lacpopts.lacp_prio == 0) {
error = EINVAL;
break;
}
lsc->lsc_sys_prio = tro->to_lacpopts.lacp_prio;
break;
case TRUNK_OPT_LACP_PORT_PRIO:
if (tro->to_lacpopts.lacp_portprio == 0) {
error = EINVAL;
break;
}
lsc->lsc_port_prio =
tro->to_lacpopts.lacp_portprio;
break;
case TRUNK_OPT_LACP_IFQ_PRIO:
if (tro->to_lacpopts.lacp_ifqprio >
IFQ_MAXPRIO) {
error = EINVAL;
break;
}
lsc->lsc_ifq_prio =
tro->to_lacpopts.lacp_ifqprio;
break;
}
error = EPROTONOSUPPORT;
break;
case SIOCGTRUNKPORT:
if (rp->rp_portname[0] == '\0' ||
@@ -1682,69 +1589,3 @@ trunk_bcast_input(struct trunk_softc *tr, struct trunk_port *tp, struct mbuf *m)
{
return (0);
}
/*
* 802.3ad LACP
*/
int
trunk_lacp_attach(struct trunk_softc *tr)
{
struct trunk_port *tp;
int error;
tr->tr_detach = trunk_lacp_detach;
tr->tr_port_create = lacp_port_create;
tr->tr_port_destroy = lacp_port_destroy;
tr->tr_linkstate = lacp_linkstate;
tr->tr_start = trunk_lacp_start;
tr->tr_input = trunk_lacp_input;
tr->tr_init = lacp_init;
tr->tr_stop = lacp_stop;
tr->tr_req = lacp_req;
tr->tr_portreq = lacp_portreq;
error = lacp_attach(tr);
if (error)
return (error);
SLIST_FOREACH(tp, &tr->tr_ports, tp_entries)
lacp_port_create(tp);
return (error);
}
int
trunk_lacp_detach(struct trunk_softc *tr)
{
struct trunk_port *tp;
int error;
SLIST_FOREACH(tp, &tr->tr_ports, tp_entries)
lacp_port_destroy(tp);
/* unlocking is safe here */
error = lacp_detach(tr);
return (error);
}
int
trunk_lacp_start(struct trunk_softc *tr, struct mbuf *m)
{
struct trunk_port *tp;
tp = lacp_select_tx_port(tr, m);
if (tp == NULL) {
m_freem(m);
return (EBUSY);
}
return (if_enqueue(tp->tp_if, m));
}
int
trunk_lacp_input(struct trunk_softc *tr, struct trunk_port *tp, struct mbuf *m)
{
return (lacp_input(tp, m));
}