From owner-freebsd-net Wed May 8 12:15: 9 2002 Delivered-To: freebsd-net@freebsd.org Received: from InterJet.dellroad.org (adsl-63-194-81-26.dsl.snfc21.pacbell.net [63.194.81.26]) by hub.freebsd.org (Postfix) with ESMTP id 55C2137B400 for ; Wed, 8 May 2002 12:15:03 -0700 (PDT) Received: from arch20m.dellroad.org (arch20m.dellroad.org [10.1.1.20]) by InterJet.dellroad.org (8.9.1a/8.9.1) with ESMTP id MAA25047 for ; Wed, 8 May 2002 12:02:36 -0700 (PDT) Received: (from archie@localhost) by arch20m.dellroad.org (8.11.6/8.11.6) id g48J2aZ24545 for freebsd-net@freebsd.org; Wed, 8 May 2002 12:02:36 -0700 (PDT) (envelope-from archie) From: Archie Cobbs Message-Id: <200205081902.g48J2aZ24545@arch20m.dellroad.org> Subject: Transmitting packets when not IFF_UP To: freebsd-net@freebsd.org Date: Wed, 8 May 2002 12:02:36 -0700 (PDT) X-Mailer: ELM [version 2.4ME+ PL88 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org Several people using netgraph for bridging, PPPoE, or whatever have encountered the problem where transmitting a packet out an interface that is not marked IFF_UP causes a panic. This is because many drivers were written with the assumption that this would never happen. To fix this once and for all I'd like to commit the patch below. Comments and reviews warmly appreciated... Thanks, -Archie __________________________________________________________________________ Archie Cobbs * Packet Design * http://www.packetdesign.com Index: sys/net/if_ethersubr.c =================================================================== RCS file: /home/ncvs/src/sys/net/if_ethersubr.c,v retrieving revision 1.110 diff -u -U8 -r1.110 if_ethersubr.c --- if_ethersubr.c 4 Apr 2002 05:42:09 -0000 1.110 +++ if_ethersubr.c 8 May 2002 19:01:56 -0000 @@ -372,16 +372,22 @@ */ int ether_output_frame(ifp, m) struct ifnet *ifp; struct mbuf *m; { int error = 0; + /* Don't send packet if the interface is not up */ + if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) { + m_freem(m); + return (ENETDOWN); + } + if (BDG_ACTIVE(ifp) ) { struct ether_header *eh; /* a ptr suffices */ m->m_pkthdr.rcvif = NULL; eh = mtod(m, struct ether_header *); m_adj(m, ETHER_HDR_LEN); m = bdg_forward_ptr(m, eh, ifp); if (m != NULL) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message