Re: NetBSD and sysmon

From: Jared Mauch (jared@sysmon.org)
Date: Tue Jun 11 2002 - 15:02:21 EDT


On Tue, Jun 11, 2002 at 09:01:00PM +0200, Bengt Gördén wrote:
> On Tue, Jun 11, 2002 at 08:40:32AM -0400, Jared Mauch wrote:
>
> > Ok..
> >
> > try this icmp.c instead.
> >
> > That should fix it.
>
> Nope. But we have a guy at our work that is multilingual when it comes
> to computer-languages and I asked him to help out. 10h later he comes
> up with this. (He's name is Björn Danielsson, bd@sunet.se).

        Excellent.

        can I assume that fixes your problem? if so, i'll
release a new version of sysmon here in a few hours
to solve this. It's been a massive phantom issue i've
been chasing for a long time.

        - Jared

> There is nothing wrong with the in_cksum() algorithm, and there was
> nothing wrong with the earlier version of it. The problem was that
> when the pingdata structures were re-used after the first ping,
> the previous checksum field was not cleared before the new checksum
> calculation, resulting in an incorrect checksum. This patch fixes that:
>
> ----------------------------------------------------------------
> *** icmp.c~ 2002/06/11 17:26:48
> --- icmp.c 2002/06/11 17:28:12
> ***************
> *** 417,422 ****
> --- 417,423 ----
> localdata->icp = (struct ICMPHDR *)localdata->outpack;/* cast it */
> localdata->icp->ICMP_TYPE = ICMP_ECHO; /* It's an ICMP_ECHO */
> localdata->icp->ICMP_CODE = 0; /* icmp_code subtype */
> + localdata->icp->ICMP_CHECKSUM = 0;
>
> /* put the sequence in the packet */
> localdata->icp->ICMP_SEQ = localdata->packetsent;
> ----------------------------------------------------------------
>
> I found another strange thing which I think is a bug, but it turned
> out to have nothing to do with the checksum problem. The outgoing
> icmp packets are 136 bytes, while ICMP_PACKET_SIZE (used for reading)
> is set to 60. So I made the following change in pinger_v4():
>
> ----------------------------------------------------------------
> *** icmp.c~ 2002/06/11 15:00:50
> --- icmp.c 2002/06/11 17:26:48
> ***************
> *** 426,432 ****
>
> CLR(localdata->icp->ICMP_SEQ % 1024); /* Clear it */
>
> ! cc = (128+ICMP_PHDR_LEN); /* skips ICMP portion */
>
> /* compute ICMP checksum here */
> localdata->icp->ICMP_CHECKSUM = in_cksum((u_short *)localdata->icp, cc);
> --- 426,432 ----
>
> CLR(localdata->icp->ICMP_SEQ % 1024); /* Clear it */
>
> ! cc = ICMP_PACKET_SIZE;
>
> /* compute ICMP checksum here */
> localdata->icp->ICMP_CHECKSUM = in_cksum((u_short *)localdata->icp, cc);
> ----------------------------------------------------------------
>
> Even if this has no other effect, it should at least save some bandwidth.
>
> --
> Björn Danielsson KTHNOC <bd@sunet.se>
>
>
>
>
>
> --
>
> /Bengan
>
> Bengt Görden
> KTHNOC/SUNET/NORDUnet
> http://www.sunet.se/~bengan

-- 
Jared Mauch  | pgp key available via finger from jared@puck.nether.net
clue++;      | http://puck.nether.net/~jared/  My statements are only mine.



This archive was generated by hypermail 2b29 : Sun Aug 04 2002 - 04:14:07 EDT