Date: Thu, 9 May 2002 09:52:54 -0700 (PDT) From: Archie Cobbs <archie@dellroad.org> To: Luigi Rizzo <rizzo@icir.org> Cc: freebsd-net@FreeBSD.org Subject: Re: Transmitting packets when not IFF_UP Message-ID: <200205091652.g49Gqs102639@arch20m.dellroad.org> In-Reply-To: <20020509082708.A87490@iguana.icir.org> "from Luigi Rizzo at May 9, 2002 08:27:08 am"
next in thread | previous in thread | raw e-mail | index | archive | help
Luigi Rizzo writes: > > 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. Probably so.. Also, I think a fix that is more consistent with the current code is to do this check within the ng_ether(4) node instead of in ether_output_frame(), because everybody else who calls ether_output_frame() already does this check (pointed out by Guido van Rooj). But longer term it may make sense to fold all of these checks into ether_output_frame(). Below is a replacement patch. > 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 ? No-- I've always wondered about that, e.g., the difference between IFF_UP and IFF_RUNNING... -Archie __________________________________________________________________________ Archie Cobbs * Packet Design * http://www.packetdesign.com Index: sys/netgraph/ng_ether.c =================================================================== RCS file: /home/ncvs/src/sys/netgraph/ng_ether.c,v retrieving revision 1.22 diff -u -r1.22 ng_ether.c --- ng_ether.c 5 Feb 2002 18:27:30 -0000 1.22 +++ ng_ether.c 9 May 2002 16:51:29 -0000 @@ -627,6 +627,14 @@ ng_ether_rcv_lower(node_p node, struct mbuf *m, meta_p meta) { const priv_p priv = NG_NODE_PRIVATE(node); + struct ifnet *const ifp = priv->ifp; + + /* Check whether interface is ready for packets */ + if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) { + NG_FREE_M(m); + NG_FREE_META(meta); + return (ENETDOWN); + } /* Make sure header is fully pulled up */ if (m->m_pkthdr.len < sizeof(struct ether_header)) { @@ -642,14 +650,14 @@ /* Drop in the MAC address if desired */ if (priv->autoSrcAddr) { - bcopy((IFP2AC(priv->ifp))->ac_enaddr, + bcopy((IFP2AC(ifp))->ac_enaddr, mtod(m, struct ether_header *)->ether_shost, ETHER_ADDR_LEN); } /* Send it on its way */ NG_FREE_META(meta); - return ether_output_frame(priv->ifp, m); + return ether_output_frame(ifp, m); } /* 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?200205091652.g49Gqs102639>