From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KJsbW-0008J4-Br for qemu-devel@nongnu.org; Fri, 18 Jul 2008 12:14:46 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KJsbV-0008Iq-IO for qemu-devel@nongnu.org; Fri, 18 Jul 2008 12:14:46 -0400 Received: from [199.232.76.173] (port=34275 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KJsbV-0008In-Dm for qemu-devel@nongnu.org; Fri, 18 Jul 2008 12:14:45 -0400 Received: from mail.gmx.net ([213.165.64.20]:45746) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1KJsbU-0003ge-SH for qemu-devel@nongnu.org; Fri, 18 Jul 2008 12:14:45 -0400 Message-ID: <043901c8e8f1$6150b260$0201a8c0@zeug> From: "Sebastian Herbszt" References: <200807171812.41200.jkim@FreeBSD.org> Date: Fri, 18 Jul 2008 18:12:59 +0200 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH] networking using libpcap Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jung-uk Kim Cc: Juergen Lock , qemu-devel@nongnu.org Jung-uk Kim wrote: > Since someone showed interest, I updated my patches against trunk. :-) > > http://people.freebsd.org/~jkim/qemu-pcap-20080717.diff > > I turned it off by default for now. If you want to enable it, do: > > configure --enable-pcap To avoid confusion please change the pcap probe to error instead of silently setting pcap=no. Take a look at audio_drv_probe. >> Works perfect for me and allows access to the local Ethernet right >> out of the box, very much unlike tap and bridging. The attached >> version applies to trunk. >> >> I have modified (e.g. got rid of threads) the original patch from >> the forum and am using it here on Windows. It works fine but >> performance is pretty low. > > *After* applying the new patch: > > cp -p vl.c vl.c.orig > sed -e 's/#ifdef PCAP_SET_FILTER/#if 1/g' vl.c > vl.c.tmp > mv vl.c.tmp vl.c > > and try again? BTW, I have no real experience with WinPcap, so don't > kill me if it does not work for you. ;-) Using pcap_setfilter helps and colinux (conet-bridged-daemon) does use one too. Currently your filter is "ether dst 52:54:00:12:34:56 or ((broadcast or multicast) and not ether src 52:54:00:12:34:56)". The filter used by colinux is "(ether dst 00:ff:81:24:00:00) or (ether broadcast or multicast) or (ip broadcast or multicast)". The "and not ether src 52:54:00:12:34:56" part in your filter prevents the VM from seeing own packets. It doesn't reply to own "ping broadcast" where it does in colinux and VMware Server. >> +ifdef CONFIG_PCAP >> +LIBS+=-lpcap >> +endif >> >> On Windows it should be -lwpcap. > > Thanks for the tip! > >> + if ((fd = pcap_get_selectable_fd(s->handle)) < 0) { >> + fprintf(stderr, "qemu: pcap_get_selectable_fd failed\n"); >> + goto fail; >> + } >> + qemu_set_fd_handler(fd, pcap_send, NULL, s); >> >> pcap_get_selectable_fd() is not available on Windows. I just put >> pcap_send() in main_loop_wait(). > > I added WinPcap API support from WinPcap manual pages but I have no > way of checking. Can you try the patch and letting me know? Since you use the winpcap win32 only parts there is the following warning: vl.c: In function `net_pcap_init': vl.c:4247: warning: implicit declaration of function `pcap_getevent' vl.c:4247: warning: assignment makes pointer from integer without a cast You can avoid it by defining WPCAP in vl.c: #if defined(CONFIG_PCAP) #ifdef _WIN32 #define WPCAP 1 #endif #include #endif I noticed that if no ifname is passed you try to get one with pcap_lookupdev. This is broken on winpcap, please see http://www.winpcap.org/pipermail/winpcap-bugs/2006-May/000220.html I am not sure if pcap_lookupdev() gets you the "right" interface on non-win32, so maybe just require ifname (tap does it too)? Otherwise it seems to compile and run fine. - Sebastian