win-pvdrivers

changeset 763:9866a1812579 0.11.0.207

Fix a network bug where trailing bytes on the ethernet frame caused bad checksums on the RX path
author James Harper <james.harper@bendigoit.com.au>
date Sun Jan 17 15:08:23 2010 +1100 (2010-01-17)
parents b7bd812a615d
children 7e756e306e3d
files xennet/xennet_rx.c
line diff
     1.1 --- a/xennet/xennet_rx.c	Sat Jan 16 22:21:03 2010 +1100
     1.2 +++ b/xennet/xennet_rx.c	Sun Jan 17 15:08:23 2010 +1100
     1.3 @@ -321,6 +321,7 @@ XenNet_SumPacketData(
     1.4    PUCHAR buffer;
     1.5    PMDL mdl;
     1.6    UINT total_length;
     1.7 +  UINT data_length;
     1.8    UINT buffer_length;
     1.9    USHORT buffer_offset;
    1.10    ULONG csum;
    1.11 @@ -335,10 +336,12 @@ XenNet_SumPacketData(
    1.12    ASSERT(mdl);
    1.13  
    1.14    ip4_length = GET_NET_PUSHORT(&buffer[XN_HDR_SIZE + 2]);
    1.15 -
    1.16 -  if ((USHORT)(ip4_length + XN_HDR_SIZE) != total_length)
    1.17 +  data_length = ip4_length + XN_HDR_SIZE;
    1.18 +  
    1.19 +  if ((USHORT)data_length > total_length)
    1.20    {
    1.21      KdPrint((__DRIVER_NAME "     Size Mismatch %d (ip4_length + XN_HDR_SIZE) != %d (total_length)\n", ip4_length + XN_HDR_SIZE, total_length));
    1.22 +    return FALSE;
    1.23    }
    1.24  
    1.25    switch (pi->ip_proto)
    1.26 @@ -371,7 +374,7 @@ XenNet_SumPacketData(
    1.27    
    1.28    csum_span = FALSE;
    1.29    buffer_offset = i = XN_HDR_SIZE + pi->ip4_header_length;
    1.30 -  while (i < total_length)
    1.31 +  while (i < data_length)
    1.32    {
    1.33      /* don't include the checksum field itself in the calculation */
    1.34      if ((pi->ip_proto == 6 && i == XN_HDR_SIZE + pi->ip4_header_length + 16) || (pi->ip_proto == 17 && i == XN_HDR_SIZE + pi->ip4_header_length + 6))