qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] bug in pcnet patch?


From: Zhai, Edwin
Subject: [Qemu-devel] bug in pcnet patch?
Date: Mon, 05 Sep 2005 17:10:32 +0800
User-agent: Mozilla Thunderbird 1.0.6 (X11/20050716)

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

#!/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
--- 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)) 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]