From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1F7bqQ-0006A3-HD for qemu-devel@nongnu.org; Fri, 10 Feb 2006 12:14:06 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1F7bqP-000692-BI for qemu-devel@nongnu.org; Fri, 10 Feb 2006 12:14:05 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1F7bqO-00068h-QI for qemu-devel@nongnu.org; Fri, 10 Feb 2006 12:14:05 -0500 Received: from [128.8.10.163] (helo=po1.wam.umd.edu) by monty-python.gnu.org with esmtp (Exim 4.52) id 1F7buD-00063Z-4b for qemu-devel@nongnu.org; Fri, 10 Feb 2006 12:18:01 -0500 Date: Fri, 10 Feb 2006 12:09:32 -0500 From: "Jim C. Brown" Subject: Re: [Qemu-devel] vde-inject 0.0.1 Message-ID: <20060210170932.GA22586@jbrown.mylinuxbox.org> References: <20060208231325.GA28610@jbrown.mylinuxbox.org> <20060209053953.GA13800@jbrown.mylinuxbox.org> <200602101234.10853.a_mulyadi@softhome.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200602101234.10853.a_mulyadi@softhome.net> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mulyadi Santosa Cc: qemu-devel@nongnu.org On Fri, Feb 10, 2006 at 12:34:10PM +0700, Mulyadi Santosa wrote: > Hi Jim > > It's me again. here I send you another patch for the vde_pcap_inject.c. > Nothing fancy here, I only did: > - move out "open" and "close" from relay() and put them on main() > before entering for() loop. IMHO, this will make file operation a bit > faster This one I've thought about myself. Your way makes vde_pcap_inject more efficient. My way makes it usable if vde_pcap_inject is run before the kernel module is loaded. The idea is that vde_pcap_inject can be used everywhere vde_pcap can be, but in addition if you have vde-inject then it can and will make use of that as well. > > - I use __builtin_expect magic to optimize the "if" condition before > writing to /proc/vdeinject. here, inside relay() we assume that > vdeinject is likely exist. > What is __buiultin_expect() ? I've never seen it before. Your tests to make sure the fd is valid are unnecessary. perror() causes vde_pcap_inject to abort with an error, so any code called later on is guarranteed that fd is valid. Of course this means that vde_pcap_inject can only be used in combo with vde-inject, which I'm not sure is a good thing. E.g. a freeBSD host lacks vde-inject, so this would make vde_pcap_inject linux-specific. > PS: I can't check it thoroughly since my libpcap version (0.7.2, default > on Redhat 9. Yes I know it is old) doesn't have > pcap_get_selectable_fd(), so I can't compile it. > Change it to pcap_fileno(), and it should compile and work identically. (The difference is that pcap_get_selectable_fd() adds some basic sanity checks to make sure the fd is selectable before returning it. See http://www.tcpdump.org/lists/workers/2004/06/msg00093.html for more information.) I'll probably add an #ifdef for this. > regards > > Mulyadi -- Infinite complexity begets infinite beauty. Infinite precision begets infinite perfection.