From owner-freebsd-net Thu May 9 10: 0:51 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 679F537B417 for ; Thu, 9 May 2002 10:00:21 -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 JAA32451; Thu, 9 May 2002 09:52:56 -0700 (PDT) Received: (from archie@localhost) by arch20m.dellroad.org (8.11.6/8.11.6) id g49Gqs102639; Thu, 9 May 2002 09:52:55 -0700 (PDT) (envelope-from archie) From: Archie Cobbs Message-Id: <200205091652.g49Gqs102639@arch20m.dellroad.org> Subject: Re: Transmitting packets when not IFF_UP In-Reply-To: <20020509082708.A87490@iguana.icir.org> "from Luigi Rizzo at May 9, 2002 08:27:08 am" To: Luigi Rizzo Date: Thu, 9 May 2002 09:52:54 -0700 (PDT) Cc: freebsd-net@FreeBSD.org 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 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