From 4b7039e3c0492537a1a88cc7d7736de1b078acf0 Mon Sep 17 00:00:00 2001 From: reyk Date: Wed, 6 Aug 2008 17:04:28 +0000 Subject: [PATCH] fix trunk breakage that sneaked in with the lacp diff: - don't use in-kernel IFMEDIA ioctls in lacp and remove two KASSERTs that caused reliable panics - the lacp key can be locally assigned and we don't need to query the media subtype here. - unbreak failover/loadbalance/broadcast status handling. Reported by brad@ ok deraadt@ --- sys/net/if_trunk.c | 4 +++- sys/net/trunklacp.c | 22 ++++------------------ 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/sys/net/if_trunk.c b/sys/net/if_trunk.c index e09648a8b58..2bff6485767 100644 --- a/sys/net/if_trunk.c +++ b/sys/net/if_trunk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_trunk.c,v 1.47 2008/07/30 10:15:35 mpf Exp $ */ +/* $OpenBSD: if_trunk.c,v 1.48 2008/08/06 17:04:28 reyk Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Reyk Floeter @@ -599,11 +599,13 @@ trunk_port2req(struct trunk_port *tp, struct trunk_reqport *rp) case TRUNK_PROTO_ROUNDROBIN: case TRUNK_PROTO_LOADBALANCE: case TRUNK_PROTO_BROADCAST: + rp->rp_flags = tp->tp_flags; if (TRUNK_PORTACTIVE(tp)) rp->rp_flags |= TRUNK_PORT_ACTIVE; break; case TRUNK_PROTO_LACP: + rp->rp_flags = 0; /* LACP has a different definition of active */ if (lacp_isactive(tp)) rp->rp_flags |= TRUNK_PORT_ACTIVE; diff --git a/sys/net/trunklacp.c b/sys/net/trunklacp.c index 92fe9f2fde9..f79146a726b 100644 --- a/sys/net/trunklacp.c +++ b/sys/net/trunklacp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trunklacp.c,v 1.2 2008/06/15 19:00:57 mpf Exp $ */ +/* $OpenBSD: trunklacp.c,v 1.3 2008/08/06 17:04:28 reyk Exp $ */ /* $NetBSD: ieee8023ad_lacp.c,v 1.3 2005/12/11 12:24:54 christos Exp $ */ /* $FreeBSD:ieee8023ad_lacp.c,v 1.15 2008/03/16 19:25:30 thompsa Exp $ */ @@ -514,7 +514,6 @@ lacp_port_create(struct trunk_port *tp) struct lacp_port *lp; struct ifnet *ifp = tp->tp_if; struct ifreq ifr; - struct ifmediareq ifmr; int error; int active = 1; /* XXX should be configurable */ @@ -552,11 +551,6 @@ lacp_port_create(struct trunk_port *tp) lp->lp_aggregator = NULL; lacp_sm_rx_set_expired(lp); - bzero((char *)&ifmr, sizeof(ifmr)); - error = (*ifp->if_ioctl)(ifp, SIOCGIFMEDIA, (caddr_t)&ifmr); - if (error == 0) - lp->lp_media = ifmr.ifm_active; - lacp_linkstate(tp); return (0); @@ -870,7 +864,6 @@ lacp_aggregator_bandwidth(struct lacp_aggregator *la) } speed = lp->lp_ifp->if_baudrate; - speed = ifmedia_baudrate(lp->lp_media); speed *= la->la_nports; if (speed == 0) { LACP_DPRINTF((lp, "speed 0? media=0x%x nports=%d\n", @@ -987,7 +980,6 @@ lacp_compose_key(struct lacp_port *lp) { struct trunk_port *tp = lp->lp_trunk; struct trunk_softc *sc = tp->tp_trunk; - u_int media = lp->lp_media; u_int16_t key; if ((lp->lp_state & LACP_STATE_AGGREGATION) == 0) { @@ -1003,16 +995,10 @@ lacp_compose_key(struct lacp_port *lp) /* bit 15: 1 */ key |= 0x8000; } else { - u_int subtype = IFM_SUBTYPE(media); - - KASSERT(IFM_TYPE(media) == IFM_ETHER); - KASSERT((media & IFM_FDX) != 0); - - /* bit 0..4: IFM_SUBTYPE */ - key = subtype; - /* bit 5..14: (some bits of) if_index of trunk device */ - key |= 0x7fe0 & ((sc->tr_ac.ac_if.if_index) << 5); + /* bit 0..14: (some bits of) if_index of trunk device */ + key = sc->tr_ac.ac_if.if_index; /* bit 15: 0 */ + key &= ~0x8000; } return (htons(key)); } -- 2.20.1