Replace ifnet::if_agriprivate with ifnet::if_lagg
agr(4) and lagg(4) can not be used on the same interface so that if_agrprivate and if_lagg are not used at the same time. For resolve this wasteful, if_lagg is used in not only lagg(4) but also agr(4). After this modification, if_lagg has 3 states: 1. if_lagg == NULL - Both agr(4) and lagg(4) are not running on the interface 2. if_lagg != NULL && ifp->if_type != IFT_IEEE8023ADLAG - agr(4) is running on the I/F 3. if_lagg != NULL && ifp->if_type == IFT_IEEE8023ADLAG - lagg(4) is running on the I/F
This commit is contained in:
parent
5256dbbccb
commit
5efe2d40a7
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ieee8023ad_lacp.c,v 1.11 2020/01/29 04:30:41 thorpej Exp $ */
|
||||
/* $NetBSD: ieee8023ad_lacp.c,v 1.12 2021/09/30 03:15:25 yamaguchi Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c)2005 YAMAMOTO Takashi,
|
||||
|
@ -27,7 +27,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ieee8023ad_lacp.c,v 1.11 2020/01/29 04:30:41 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ieee8023ad_lacp.c,v 1.12 2021/09/30 03:15:25 yamaguchi Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/callout.h>
|
||||
|
@ -97,7 +97,7 @@ ieee8023ad_lacp_input(struct ifnet *ifp, struct mbuf *m)
|
|||
struct lacp_port *lp;
|
||||
int error = 0;
|
||||
|
||||
port = ifp->if_agrprivate; /* XXX race with agr_remport. */
|
||||
port = ifp->if_lagg; /* XXX race with agr_remport. */
|
||||
if (__predict_false(port->port_flags & AGRPORT_DETACHING)) {
|
||||
goto bad;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ieee8023ad_marker.c,v 1.4 2007/02/22 06:20:16 thorpej Exp $ */
|
||||
/* $NetBSD: ieee8023ad_marker.c,v 1.5 2021/09/30 03:15:25 yamaguchi Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c)2005 YAMAMOTO Takashi,
|
||||
|
@ -27,7 +27,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ieee8023ad_marker.c,v 1.4 2007/02/22 06:20:16 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ieee8023ad_marker.c,v 1.5 2021/09/30 03:15:25 yamaguchi Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/callout.h>
|
||||
|
@ -60,7 +60,7 @@ ieee8023ad_marker_input(struct ifnet *ifp, struct mbuf *m)
|
|||
struct agr_port *port;
|
||||
int error = 0;
|
||||
|
||||
port = ifp->if_agrprivate; /* XXX race with agr_remport. */
|
||||
port = ifp->if_lagg; /* XXX race with agr_remport. */
|
||||
KASSERT(port);
|
||||
if (__predict_false(port->port_flags & AGRPORT_DETACHING)) {
|
||||
goto bad;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_agr.c,v 1.52 2021/08/02 12:56:25 andvar Exp $ */
|
||||
/* $NetBSD: if_agr.c,v 1.53 2021/09/30 03:15:25 yamaguchi Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c)2005 YAMAMOTO Takashi,
|
||||
|
@ -27,7 +27,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_agr.c,v 1.52 2021/08/02 12:56:25 andvar Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_agr.c,v 1.53 2021/09/30 03:15:25 yamaguchi Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_inet.h"
|
||||
|
@ -151,7 +151,7 @@ agr_input(struct ifnet *ifp_port, struct mbuf *m)
|
|||
struct agr_port *port;
|
||||
struct ifnet *ifp;
|
||||
|
||||
port = ifp_port->if_agrprivate;
|
||||
port = ifp_port->if_lagg;
|
||||
KASSERT(port);
|
||||
ifp = port->port_agrifp;
|
||||
if ((port->port_flags & AGRPORT_COLLECTING) == 0) {
|
||||
|
@ -234,7 +234,7 @@ agrport_ioctl(struct agr_port *port, u_long cmd, void *arg)
|
|||
{
|
||||
struct ifnet *ifp = port->port_ifp;
|
||||
|
||||
KASSERT(ifp->if_agrprivate == (void *)port);
|
||||
KASSERT(ifp->if_lagg == (void *)port);
|
||||
KASSERT(ifp->if_ioctl == agr_ioctl_filter);
|
||||
|
||||
return (*port->port_ioctl)(ifp, cmd, arg);
|
||||
|
@ -542,7 +542,7 @@ agr_addport(struct ifnet *ifp, struct ifnet *ifp_port)
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (ifp_port->if_agrprivate) {
|
||||
if (ifp_port->if_lagg) {
|
||||
error = EBUSY;
|
||||
goto out;
|
||||
}
|
||||
|
@ -623,7 +623,7 @@ agr_addport(struct ifnet *ifp, struct ifnet *ifp_port)
|
|||
AGR_LOCK(sc);
|
||||
|
||||
port->port_ifp = ifp_port;
|
||||
ifp_port->if_agrprivate = port;
|
||||
ifp_port->if_lagg = port;
|
||||
port->port_agrifp = ifp;
|
||||
TAILQ_INSERT_TAIL(&sc->sc_ports, port, port_q);
|
||||
sc->sc_nports++;
|
||||
|
@ -686,12 +686,12 @@ agr_remport(struct ifnet *ifp, struct ifnet *ifp_port)
|
|||
struct agr_port *port;
|
||||
int error = 0;
|
||||
|
||||
if (ifp_port->if_agrprivate == NULL) {
|
||||
if (ifp_port->if_lagg == NULL) {
|
||||
error = ENOENT;
|
||||
return error;
|
||||
}
|
||||
|
||||
port = ifp_port->if_agrprivate;
|
||||
port = ifp_port->if_lagg;
|
||||
if (port->port_agrifp != ifp) {
|
||||
error = EINVAL;
|
||||
return error;
|
||||
|
@ -786,7 +786,7 @@ agrport_cleanup(struct agr_softc *sc, struct agr_port *port)
|
|||
|
||||
AGR_LOCK(sc);
|
||||
if ((port->port_flags & AGRPORT_ATTACHED)) {
|
||||
ifp_port->if_agrprivate = NULL;
|
||||
ifp_port->if_lagg = NULL;
|
||||
|
||||
TAILQ_REMOVE(&sc->sc_ports, port, port_q);
|
||||
sc->sc_nports--;
|
||||
|
@ -823,7 +823,7 @@ agr_ioctl_multi(struct ifnet *ifp, u_long cmd, struct ifreq *ifr)
|
|||
static int
|
||||
agr_ioctl_filter(struct ifnet *ifp, u_long cmd, void *arg)
|
||||
{
|
||||
struct agr_port *port = ifp->if_agrprivate;
|
||||
struct agr_port *port = ifp->if_lagg;
|
||||
int error;
|
||||
|
||||
KASSERT(port);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if.c,v 1.490 2021/09/21 14:57:26 christos Exp $ */
|
||||
/* $NetBSD: if.c,v 1.491 2021/09/30 03:15:25 yamaguchi Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -90,7 +90,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.490 2021/09/21 14:57:26 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.491 2021/09/30 03:15:25 yamaguchi Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_inet.h"
|
||||
|
@ -2408,7 +2408,7 @@ if_link_state_change_process(struct ifnet *ifp, int link_state)
|
|||
#endif
|
||||
|
||||
#if NLAGG > 0
|
||||
if (ifp->if_lagg != NULL)
|
||||
if (ifp->if_type == IFT_IEEE8023ADLAG)
|
||||
lagg_linkstate_changed(ifp);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if.h,v 1.292 2021/08/09 20:49:10 andvar Exp $ */
|
||||
/* $NetBSD: if.h,v 1.293 2021/09/30 03:15:25 yamaguchi Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -380,8 +380,7 @@ typedef struct ifnet {
|
|||
/* a: */
|
||||
struct mowner *if_mowner; /* ?: who owns mbufs for this interface */
|
||||
|
||||
void *if_agrprivate; /* ?: used only when #if NAGR > 0 */
|
||||
void *if_lagg; /* ?: used only when #if NLAGG > 0 */
|
||||
void *if_lagg; /* :: lagg or agr structure */
|
||||
void *if_npf_private;/* ?: associated NPF context */
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_ethersubr.c,v 1.293 2021/05/17 04:07:43 yamaguchi Exp $ */
|
||||
/* $NetBSD: if_ethersubr.c,v 1.294 2021/09/30 03:15:25 yamaguchi Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
|
@ -61,7 +61,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.293 2021/05/17 04:07:43 yamaguchi Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.294 2021/09/30 03:15:25 yamaguchi Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_inet.h"
|
||||
|
@ -651,6 +651,9 @@ ether_input(struct ifnet *ifp, struct mbuf *m)
|
|||
size_t ehlen;
|
||||
static int earlypkts;
|
||||
int isr = 0;
|
||||
#if NAGR > 0
|
||||
void *agrprivate;
|
||||
#endif
|
||||
|
||||
KASSERT(!cpu_intr_p());
|
||||
KASSERT((m->m_flags & M_PKTHDR) != 0);
|
||||
|
@ -753,7 +756,12 @@ ether_input(struct ifnet *ifp, struct mbuf *m)
|
|||
}
|
||||
|
||||
#if NAGR > 0
|
||||
if (ifp->if_agrprivate &&
|
||||
if (ifp->if_type != IFT_IEEE8023ADLAG) {
|
||||
agrprivate = ifp->if_lagg;
|
||||
} else {
|
||||
agrprivate = NULL;
|
||||
}
|
||||
if (agrprivate != NULL &&
|
||||
__predict_true(etype != ETHERTYPE_SLOWPROTOCOLS)) {
|
||||
m->m_flags &= ~M_PROMISC;
|
||||
agr_input(ifp, m);
|
||||
|
@ -843,14 +851,14 @@ ether_input(struct ifnet *ifp, struct mbuf *m)
|
|||
switch (subtype) {
|
||||
#if NAGR > 0
|
||||
case SLOWPROTOCOLS_SUBTYPE_LACP:
|
||||
if (ifp->if_agrprivate) {
|
||||
if (agrprivate != NULL) {
|
||||
ieee8023ad_lacp_input(ifp, m);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case SLOWPROTOCOLS_SUBTYPE_MARKER:
|
||||
if (ifp->if_agrprivate) {
|
||||
if (agrprivate != NULL) {
|
||||
ieee8023ad_marker_input(ifp, m);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue