Date: Wed, 8 May 2002 12:02:36 -0700 (PDT) From: Archie Cobbs <archie@dellroad.org> To: freebsd-net@freebsd.org Subject: Transmitting packets when not IFF_UP Message-ID: <200205081902.g48J2aZ24545@arch20m.dellroad.org>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200205081902.g48J2aZ24545>