lkml.org 
[lkml]   [2003]   [Sep]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: Incremental update of TCP Checksum
Date
On Tuesday 16 September 2003 04:32 pm, Vishwas Raman wrote:

> As mentioned in RFC1624, I did the following.
> void changePacket(struct sk_buff* skb)
> {
> struct tcphdr *tcpHdr = skb->h.th;
>
> // Verifying the tcp checksum works here...
>
> __u16 oldDoff = tcpHeader->doff;
> tcpHeader->doff += 1;
>
> // Formula from RFC1624 is HC' = ~(C + (-m) + m')
> // where HC - old checksum in header
> // C - one's complement sum of old header
> // HC' - new checksum in header
> // C' - one's complement sum of new header
> // m - old value of a 16-bit field
> // m' - new value of a 16-bit field
>
> long cksum = (~(tcpHdr->check))&0xffff;
> cksum += (__u16)~oldDoff;
^ should be a -

> cksum += tcpHeader->doff;
> while (cksum >> 16)
> {
> cksum = (cksum & 0xffff) + (cksum >> 16);
> }
> tcpHeader->check = ~cksum;
>
> // Verifying tcp checksum here fails with bad cksum
> }

--
Leo Mauro
Network Security
Simon Bolivar University
Caracas, Venezuela

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

\
 
 \ /
  Last update: 2005-03-22 13:48    [W:0.051 / U:1.964 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site