* [Qemu-devel] bug in pcnet patch?
@ 2005-09-05 9:10 Zhai, Edwin
0 siblings, 0 replies; only message in thread
From: Zhai, Edwin @ 2005-09-05 9:10 UTC (permalink / raw)
To: qemu-devel; +Cc: Zhai, Edwin
[-- Attachment #1: Type: text/plain, Size: 584 bytes --]
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
[-- Attachment #2: qemu-ifup --]
[-- Type: text/plain, Size: 135 bytes --]
#!/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
[-- Attachment #3: pcnet_fix.patch --]
[-- Type: text/x-patch, Size: 820 bytes --]
--- 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))
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-09-05 9:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-05 9:10 [Qemu-devel] bug in pcnet patch? Zhai, Edwin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).