[ECOS] Re: EDOSK-2674 ethernet drivers -TCP problem

Andrew Lunn andrew@lunn.ch
Fri Dec 5 08:54:00 GMT 2003


Hi Yoshinori

> @@ -803,7 +803,7 @@
>  
>          CYG_ASSERT(0 == (len & 1) || (i == (sg_len-1)), "odd length");
>          CYG_ASSERT( sdata, "No sg data pointer here" );
> -        while(len >= sizeof(*sdata)) {
> +        while(len > 0) {
>              put_data(sc, *sdata++);
>              len -= sizeof(*sdata);
>          }
 
I don't know this chip at all, im just reading the code and deciding
if to commit your patch. sizeof(*sdata) is 2. The original code will
exist the loop when len == 0 or 1 and in these cases *sdata points to
the end of the packet, or the last byte. Your change means it will
exit when len == 0 or -1 and in these cases, *sdata points to the end
of the packet, or one byte after the end of the packet.

So when len is odd, the original code *sdate points to the last byte
and your code *sdata points to some junk after the end of the packet.
The code that follows is:

   control = 0;
    if ( 1 & plen ) {
        // Need to set ODD flag and insert the data
        unsigned char onebyte = *(unsigned char*)sdata;
        control = onebyte;
        control |= LAN91CXX_CONTROLBYTE_ODD;
    }

ie if we have an odd length packet, get the last byte at *sdata and
put it into a control word.

It looks to me your change causes random junk to be in the control
word.

Am i reading this wrong? 

   Thanks
        Andrew

-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss



More information about the Ecos-discuss mailing list