From owner-freebsd-net Tue Oct 31 18:22:43 2000 Delivered-To: freebsd-net@freebsd.org Received: from iguana.aciri.org (iguana.aciri.org [192.150.187.36]) by hub.freebsd.org (Postfix) with ESMTP id 1B4E437B479 for ; Tue, 31 Oct 2000 18:22:40 -0800 (PST) Received: (from rizzo@localhost) by iguana.aciri.org (8.9.3/8.9.3) id SAA08552; Tue, 31 Oct 2000 18:22:28 -0800 (PST) (envelope-from rizzo) From: Luigi Rizzo Message-Id: <200011010222.SAA08552@iguana.aciri.org> Subject: Re: bdg_forward In-Reply-To: <200010312114.QAA21225@cholla.INRS-Telecom.UQuebec.CA> from Tarik Alj at "Oct 31, 2000 4:14:55 pm" To: aljtarik@inrs-telecom.uquebec.ca Date: Tue, 31 Oct 2000 18:22:28 -0800 (PST) Cc: freebsd-net@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL43 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org > Hi all, Hi, there is a trick there to save one extra copy of the packet (the trick is copied by the multicast forwarding code). What you would would write is: for (ifp = first_if; ifp != NULL; ifp = ifp->next) { if (interface_needs_a_copy(ifp, pkt)) { x = copy_of(pkt); IF_ENQUEUE(ifp, pkt) } } mfree(pkt); but it is more efficient to delay the copy (and the forwarding) until you are really sure that you have to do it. The current code is suboptimal but tries to achieve the above by delaying the copy by one loop. It could be written slightly better (but at the price of slightly more obfuscation) and delay the copy until you find that the second matching interface. cheers luigi ----------------------------------+----------------------------------------- Luigi RIZZO, luigi@iet.unipi.it . ACIRI/ICSI (on leave from Univ. di Pisa) http://www.iet.unipi.it/~luigi/ . 1947 Center St, Berkeley CA 94704 Phone: (510) 666 2927 ----------------------------------+----------------------------------------- > I would like some clarification on something that happens in bdg_forward > when forwarding broadcast frames (such as ARP requests). In the beginning of the > code last is initialized to NULL, so that if a frame arrives on an iface whose > index is higher than 1 it will not be forwarded on the interface with index 1 > because the if test after the for(;;) loop will fail. Is this meant to be this > way? And if so, could someone explain to me why? > I am working with bridge.c v1.16, thanks in advance, > > -Tarik. > > > > > > 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