From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ECD5a-00055m-Ep for qemu-devel@nongnu.org; Mon, 05 Sep 2005 05:16:31 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ECD5C-0004XD-Iy for qemu-devel@nongnu.org; Mon, 05 Sep 2005 05:16:07 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ECD4v-0003SJ-V4 for qemu-devel@nongnu.org; Mon, 05 Sep 2005 05:15:50 -0400 Received: from [134.134.136.17] (helo=orsfmr003.jf.intel.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1ECD4C-0006se-7z for qemu-devel@nongnu.org; Mon, 05 Sep 2005 05:15:04 -0400 Received: from orsfmr100.jf.intel.com (orsfmr100.jf.intel.com [10.7.209.16]) by orsfmr003.jf.intel.com (8.12.10/8.12.10/d: major-outer.mc, v 1.1 2004/09/17 17:50:56 root Exp $) with ESMTP id j859BCVa028573 for ; Mon, 5 Sep 2005 09:11:12 GMT Received: from orsmsxvs040.jf.intel.com (orsmsxvs040.jf.intel.com [192.168.65.206]) by orsfmr100.jf.intel.com (8.12.10/8.12.10/d: major-inner.mc, v 1.2 2004/09/17 18:05:01 root Exp $) with SMTP id j859ApJ5020530 for ; Mon, 5 Sep 2005 09:11:11 GMT Message-ID: <431C0B88.4060303@intel.com> Date: Mon, 05 Sep 2005 17:10:32 +0800 From: "Zhai, Edwin" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------090607080901050101070400" Subject: [Qemu-devel] bug in pcnet patch? Reply-To: edwin.zhai@intel.com, qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "Zhai, Edwin" This is a multi-part message in MIME format. --------------090607080901050101070400 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit hi, i have found that guest and host can't communicate with each other with pcnet patch, but ne2000 is okey. (http://dad-answers.com/qemu/patches/AMD-PCNET-II/qemu-pcnet.patch6.gz) reproduce steps -- use attached qemu-ifup and do a "ifconfig eth0 172.20.0.2 up" in guest after boot. the ping between guest and host doesn't work. root cause is that arp packet from tun interface (42 bytes) is small than the minimal size(60 bytes) and is droped by guest pcnet driver. attached patch(borrowed from ne2000) just expend the packet when size < 60. any comments? thanks, edwin --------------090607080901050101070400 Content-Type: text/plain; name="qemu-ifup" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="qemu-ifup" #!/bin/sh echo $* #test for pcnet's bug ifconfig $1 172.20.0.1 up route add -net 172.20.0.0 netmask 255.255.0.0 gw 172.20.0.1 dev $1 --------------090607080901050101070400 Content-Type: text/x-patch; name="pcnet_fix.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="pcnet_fix.patch" --- a/hw/pcnet.c Thu Sep 1 21:30:51 2005 +++ b/hw/pcnet.c Mon Sep 5 09:55:33 2005 @@ -380,10 +380,13 @@ return sizeof(s->buffer)-16; } +#define MIN_BUF_SIZE 60 + static void pcnet_receive(void *opaque, const uint8_t *buf, int size) { PCNetState *s = opaque; int is_padr = 0, is_bcast = 0, is_ladr = 0; + uint8_t buf1[60]; if (CSR_DRX(s) || CSR_STOP(s) || CSR_SPND(s) || !size) return; @@ -391,6 +394,14 @@ #ifdef PCNET_DEBUG printf("pcnet_receive size=%d\n", size); #endif + + /* if too small buffer, then expand it */ + if (size < MIN_BUF_SIZE) { + memcpy(buf1, buf, size); + memset(buf1 + size, 0, MIN_BUF_SIZE - size); + buf = buf1; + size = MIN_BUF_SIZE; + } if (CSR_PROM(s) || (is_padr=padr_match(s, buf, size)) --------------090607080901050101070400--