Re: Why is TCP checksum calc split between init & complete fns?

From: Andi Kleen (ak@suse.de)
Date: Tue Aug 22 2000 - 07:25:32 EST


On Tue, Aug 22, 2000 at 09:41:33PM +1000, Mark James wrote:
> kuznet@ms2.inr.ac.ru wrote:
>
> > > If I want to run a TCP checksum (pseudo header + TCP header + data)
> > > independently of the current TCP code, should I just do:
> > >
> > > tcp_v4_check( skb->h.th,skb->len,skb->nh.iph->saddr,skb->nh.iph->daddr,
> > > csum_partial((char *)skb->h.th, skb->len, 0))
> > > );
> >
> > Yes.
>
> OK, thanks. If anyone out there knows, I'd still like to find out
> why this is normally only done for TCP packets <= 68 bytes.
>
>
> > > or do I need to call tcp_v4_checksum_init followed by tcp_checksum_complete?
> >
> > In no curcumstances. This function modify skb head.
>
> Which function mods the head? As far as I can see, for big packets the
> "init" function puts the pseudo-header checksum in skb->csum, while the
> "complete" function (include/net/tcp.h not net/ipv4/tcp.c -- my apologies)
> checks the rest of the packet. Why the split?

Some hardware can generate skb->csum and set skb->ip_summed == CHECKSUM_HW
In this case only the checksum of the pseudo header is needed, and it makes
sense to check early instead of doing it while copying to user in the fast
path (some drivers are clever enough to know about the pseudo header too,
they set CHECKSUM_NONE after the check, but that is generally regarded as a
layer violation)

-Andi
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Aug 23 2000 - 21:00:06 EST