From owner-freebsd-net Thu May 9 8:27:17 2002 Delivered-To: freebsd-net@freebsd.org Received: from iguana.icir.org (iguana.icir.org [192.150.187.36]) by hub.freebsd.org (Postfix) with ESMTP id A29DF37B408 for ; Thu, 9 May 2002 08:27:11 -0700 (PDT) Received: (from rizzo@localhost) by iguana.icir.org (8.11.6/8.11.3) id g49FR8W89051; Thu, 9 May 2002 08:27:08 -0700 (PDT) (envelope-from rizzo) Date: Thu, 9 May 2002 08:27:08 -0700 From: Luigi Rizzo To: Archie Cobbs Cc: freebsd-net@FreeBSD.org Subject: Re: Transmitting packets when not IFF_UP Message-ID: <20020509082708.A87490@iguana.icir.org> References: <200205081902.g48J2aZ24545@arch20m.dellroad.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200205081902.g48J2aZ24545@arch20m.dellroad.org> User-Agent: Mutt/1.3.23i 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 On Wed, May 08, 2002 at 12:02:36PM -0700, Archie Cobbs wrote: > 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 sounds more or less ok, but then the same check should be added to bridge.c which possibly calls if_start. This said, do you have any reference or docs on the exact meaning of the various IFF_* flags, so we can give a sweep at the code and try to make things consistent and possibly centralised -- e.g. should we move the check for IFF_UP|IFF_RUNNING to IF_ENQUEUE (or whatever it is called in -current) so we do not need to bother in the drivers ? cheers luigi > 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 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message