Russ Dill | 2 Feb 2005 08:11
Picon
Favicon

Re: udhcp patches/ endianess


> So unless I am very much mistaken, this is correct for both
> cases.

Why not keep the known, working crc algorithm? Its not as if the code is
doing the calculation very often and on very much data.

> As you have pointed out in a previous e-mail: I have the source and
> can twist that to my liking (for instance, I like working timeout
> algorithms and I dislike sending out packets containing 302
> meaningless zero octets.

Some clients and server barf on packets that don't have the full payload
size. Most of the stuff in udhcp is there for a pretty good reason.
Rainer Weikusat | 2 Feb 2005 19:32

Re: udhcp patches/ endianess

Russ Dill <Russ.Dill <at> asu.edu> writes:
>> So unless I am very much mistaken, this is correct for both
>> cases.
>
> Why not keep the known, working crc algorithm?

<nitpicking>
This isn't a CRC algorithm.
</>

> Its not as if the code is doing the calculation very often and on
> very much data.

If you have cycles to waste, what keeps you from using the 'known to be
working' code, which is known to be working, because it's copied out
of UNIX Network Programming, with RWS having copied it out of a
'public domain' ping program? Nothing. Maybe one day gcc will come
down on you badly because of the undefined and implementation
defined constructs used in the code, but this, too, is entirely your
problem. It certainly won't be mine, because I don't feel inclined to
add more compiler versions to the zoo I am already maintaining on my
machine to accomodate various other 'known to be working' pieces of
legacy code.

And there is the additional issue that someone might be tempted to use
the code to calculate IP checksum for other types of datagrams, which
will work nicely as long as the sum does not exceed the value 2^31,
thereby affecting the sign bit of the int32_t and turning the 'fold'
loop into an endless loop, which is an effect that I would rather
prevent than fix (and people will mindlessly copy to code out of
(Continue reading)

Russ Dill | 4 Feb 2005 10:58
Picon
Favicon

Re: udhcp patches/ endianess

On Wed, 2005-02-02 at 19:32 +0100, Rainer Weikusat wrote:
> Russ Dill <Russ.Dill <at> asu.edu> writes:
> >> So unless I am very much mistaken, this is correct for both
> >> cases.
> >
> > Why not keep the known, working crc algorithm?
> 
> <nitpicking>
> This isn't a CRC algorithm.
> </>

If it doesn't work for big-endian...leads me to believe it isn't very
well fielded and tested.

> 
> And there is the additional issue that someone might be tempted to use
> the code to calculate IP checksum for other types of datagrams, which
> will work nicely as long as the sum does not exceed the value 2^31,
> thereby affecting the sign bit of the int32_t and turning the 'fold'
> loop into an endless loop, which is an effect that I would rather
> prevent than fix (and people will mindlessly copy to code out of
> there). 

then why not just change the singed int to an unsigned one?

> > Some clients and server barf on packets that don't have the full payload
> > size.
> 
> There is no such thing as the 'full DHCP payload size' anymore (since
> 1997). ISC uses 300 as minimum payload size, probably for
(Continue reading)

Rainer Weikusat | 4 Feb 2005 19:59

Re: udhcp patches/ endianess

Russ Dill <Russ.Dill <at> asu.edu> writes:
> On Wed, 2005-02-02 at 19:32 +0100, Rainer Weikusat wrote:
>> Russ Dill <Russ.Dill <at> asu.edu> writes:
>> >> So unless I am very much mistaken, this is correct for both
>> >> cases.
>> >
>> > Why not keep the known, working crc algorithm?
>> 
>> <nitpicking>
>> This isn't a CRC algorithm.
>> </>
>
> If it doesn't work for big-endian...leads me to believe it isn't very
> well fielded and tested.

You haven't looked at the actual code, right? There is a single place
in the whole algortihm where endianess actually matters and that's
where the 'left over octet' is added. The RFC states that it should be
padded with a zero octet 'to the right', meaning the following memory
layout should be simulated:

	<left over octet> 0

This sequence is to be added as 16 bit quantity, using whatever
endianess the machine calculating the sum happens to have. There are two
obvious solutions:

	a) use a memory buffer to store data octet and pad in the
	order given above and add the 16 bit quantity you get by doing so.

(Continue reading)


Gmane