ia64/xen-unstable

changeset 6736:4b2c87242ad3

Fix bug that service os & vmx guest can't communicate with
each other. The bug was physical packets smaller than
minimal packet size of 60 bytes were gettign thrown away.
Hence ARP traffic for example was dropped.

Signed-off-by: Edwin Zhai <edwin.zhai@intel.com>
Signed-off-by: Xiaofeng Ling <xiaofeng.ling@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Sat Sep 10 14:17:02 2005 +0000 (2005-09-10)
parents 5c49ed1145cc
children a8f01a0a9559
files tools/ioemu/hw/pcnet.c
line diff
     1.1 --- a/tools/ioemu/hw/pcnet.c	Fri Sep 09 15:11:18 2005 -0800
     1.2 +++ b/tools/ioemu/hw/pcnet.c	Sat Sep 10 14:17:02 2005 +0000
     1.3 @@ -380,10 +380,13 @@ static int pcnet_can_receive(void *opaqu
     1.4      return sizeof(s->buffer)-16;
     1.5  }
     1.6  
     1.7 +#define MIN_BUF_SIZE 60
     1.8 +
     1.9  static void pcnet_receive(void *opaque, const uint8_t *buf, int size)
    1.10  {
    1.11      PCNetState *s = opaque;
    1.12      int is_padr = 0, is_bcast = 0, is_ladr = 0;
    1.13 +    uint8_t buf1[60];
    1.14  
    1.15      if (CSR_DRX(s) || CSR_STOP(s) || CSR_SPND(s) || !size)
    1.16          return;
    1.17 @@ -392,6 +395,14 @@ static void pcnet_receive(void *opaque, 
    1.18      printf("pcnet_receive size=%d\n", size);
    1.19  #endif
    1.20  
    1.21 +    /* if too small buffer, then expand it */
    1.22 +    if (size < MIN_BUF_SIZE) {
    1.23 +        memcpy(buf1, buf, size);
    1.24 +        memset(buf1 + size, 0, MIN_BUF_SIZE - size);
    1.25 +        buf = buf1;
    1.26 +        size = MIN_BUF_SIZE;
    1.27 +    }
    1.28 +
    1.29      if (CSR_PROM(s) 
    1.30          || (is_padr=padr_match(s, buf, size)) 
    1.31          || (is_bcast=padr_bcast(s, buf, size))