Date: Thu, 9 May 2002 08:27:08 -0700 From: Luigi Rizzo <rizzo@icir.org> To: Archie Cobbs <archie@dellroad.org> Cc: freebsd-net@FreeBSD.org Subject: Re: Transmitting packets when not IFF_UP Message-ID: <20020509082708.A87490@iguana.icir.org> In-Reply-To: <200205081902.g48J2aZ24545@arch20m.dellroad.org> References: <200205081902.g48J2aZ24545@arch20m.dellroad.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020509082708.A87490>