Ping issue in 1.20+
Giovanni Vallesi - TeeBX
giovanni.v at teebx.com
Sun Jun 30 19:00:46 UTC 2013
Il 28/06/2013 1.04, Denys Vlasenko ha scritto:
>> Please add debugging prints to inet_cksum() function - for one,
>> > let's find out the value of nleft, addr[0], and the return value.
>> > (IOW, let's find out whether we checksum over the correct buffer,
>> > and whether we produce the same xsum we see in tcpdump.)
> For example, this way:
>
>
> uint16_t FAST_FUNC inet_cksum(uint16_t *addr, int nleft)
> {
> /*
> * Our algorithm is simple, using a 32 bit accumulator,
> * we add sequential 16 bit words to it, and at the end, fold
> * back all the carry bits from the top 16 bits into the lower
> * 16 bits.
> */
> unsigned sum = 0;
> char string[nleft*2 + 2];
> int z = nleft;
> bin2hex(string, (void*)addr, nleft)[0] = 0;
> while (nleft> 1) {
> sum += *addr++;
> nleft -= 2;
> }
>
> /* Mop up an odd byte, if necessary */
> if (nleft == 1) {
> if (BB_LITTLE_ENDIAN)
> sum += *(uint8_t*)addr;
> else
> sum += *(uint8_t*)addr<< 8;
> }
>
> /* Add back carry outs from top 16 bits to low 16 bits */
> sum = (sum>> 16) + (sum& 0xffff); /* add hi 16 to low 16 */
> sum += (sum>> 16); /* add carry */
>
> bb_error_msg("inet_cksum(%s,%d)=0x%x", string, z, (unsigned)(uint16_t)~sum);
> return (uint16_t)~sum;
> }
>
> When I run it, I see:
>
> # ./busybox ping -c2 10.0.0.138
> PING 10.0.0.138 (10.0.0.138): 56 data bytes
> ping: inet_cksum(080000001f29000038717f2500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,64)=0x4021
> 64 bytes from 10.0.0.138: seq=0 ttl=254 time=3.116 ms
> ping: inet_cksum(080000001f29000117b48e2500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,64)=0xfc32
> 64 bytes from 10.0.0.138: seq=1 ttl=254 time=2.747 ms
Thanks Denys,
I patched ping.c source according to your suggestion... but I think the
output is of little use because the (I guess) contains non printable
chars so the terminals strips them:
~ # ping -c3 172.31.255.1
PING 172.31.255.1 (172.31.255.1): 56 data bytes
ping: inet_cksum(,64)=0xa786
64 bytes from 172.31.255.1: seq=0 ttl=62 time=1.097 ms
ping: inet_cksum(,64)=0xb851
ping: inet_cksum,64)=0x603c
--- 172.31.255.1 ping statistics ---
3 packets transmitted, 1 packets received, 66% packet loss
round-trip min/avg/max = 1.097/1.097/1.097 ms
What else I can do to help in debugging?
I tried also removing the endianess test, forcing le, same issue.
Also I tried changing if (nleft == 1) to if (nleft) like it was before
1.20. I think its a big change because any integer >0 compare to true in
the second case. No luck.
@Tito: you asked about the config.
No problem, no secrets, but because I am new here I'd like to know if is
allowed to attach the file, put it inline or??
Thanks again to everyone.
--
TeeBX VoIP communication platform (coming soon)
http://code.google.com/p/teebx/
-----------------------------------------------
Lightweight++ Business Friendly++ Open++
More information about the busybox
mailing list