tcp checksum problems.

Mark Stacey (heathclf@skynet.csn.ul.ie)
Wed, 18 Feb 1998 20:47:00 +0000 (GMT)


Hi all,

I seem to be having trouble with incorrectly generating checksums for
outgoing packets.

What I'm trying to do is to construct a packet containing a SYN, FIN and
a normal TCP/IP packet except for a new option. For example (tcpdump):

host1 > host2: SFP 4261243538:4261243950(400) win 16080 <mss
536,nop,nop,cc 2> (DF)

This packet gets sent out, but nothing is received in return. I'm
taking that this means that the checksum was incorrect and the packet is
being dropped. What I want to know is what am I doing wrong, and how I can
fix it, or at least determine that the checksum is incorrect.

The following is an idea of what is happening in the do_tcp_sendmsg
function in the ./net/ipv4/tcp.c file. (2.0.32):

tmp = tcp_build_header(skb->h.th, sk, seglen-copy);
if (tmp < 0)
{
sock_wfree(sk, skb);
if (copied)
return(copied);
return(tmp);
}

/* code to calculate whether SYN or FIN should be sent */
.
.
/* code to generate MSS and CC options */
/* one CC option adds on 8 bytes, plus an MSS option (4 bytes) */
ptr = skb_put(skb,12);
skb->h.th->doff = (sizeof(struct tcphdr) + 12)/4;
ptr[0] = 2;
ptr[1] = 4;
ptr[2] = (sk->mtu) >> 8;
ptr[3] = (sk->mtu) & 0xff;

tcp_build_cc_options(sk,(unsigned char*)(ptr+4));
skb->csum = csum_partial(ptr, 12, 0);

/* back to the original TCP/IP implementation and calc checksum */

skb->csum = csum_partial_copy_fromuser(from,
skb_put(skb,copy), copy, 0);

Can anyone make any suggestions? I've tried a number of combinations of
pointer values and where I generate the checksum. I've also replaced the 0
in the last function call with "skb->csum" but to no avail.

Thanks

Mark Stacey

... and that's my two cents.

knowledge, n.:
Things you believe.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu