Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 08 Jan 2007 17:11:58 -0500
From:      Lowell Gilbert <lgusenet@be-well.ilk.org>
To:        freebsd-hackers@freebsd.org
Subject:   Re: TCP Checksums in mbufs
Message-ID:  <44hcv188y9.fsf@be-well.ilk.org>
In-Reply-To: <45A2BEEE.5010202@elischer.org> (Julian Elischer's message of "Mon, 08 Jan 2007 14:00:14 -0800")
References:  <20070108203211.GF41066@nerds.org.uk> <45A2BEEE.5010202@elischer.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Julian Elischer <julian@elischer.org> writes:

> Lee Brotherston wrote:
>> Hi,
>>
>> I have a bit of code I have written that uses pfil to access network
>> traffic as it passes between interfaces on a FreeBSD router.  One of
>> the functions it performs is some incredibly basic rewrites of certain
>> packets (keeping the same length, so no issues about sequence
>> numbers), but it does alter the payload.
>>
>> I just wanted to check what is the "proper" way to be going about
>> recalculating the checksums on the packet?  I can write a function to
>> do this and write this into the packet stored in the mbuf directly,
>> however I wasn't sure if there was a more acceptable method such as
>> flagging it to be re-checksum'd as it's routed, or to offload the
>> computation to the NIC or something?
>>
>> Any thoughts, suggestions, etc very welcome!
>>
>> By the way, I'm not subscribed to the list right now, so I'd
>> appreciate it if people could CC me on replies.
>>
>> Many thanks
>>
>>   Lee
>
> there is an algorythm to recalculate the tcp/ip
> checksum when you replace a byte. you subtract the old value from the
> csum and add the new one, but not quite a as easy as that.

Actually, it is as easy as that.  And it's exactly the way this kind
of case is usually handled.

> I think it's given in one of the RFCs but  I think it may also
> be used in the tcpmss port, or possibly the mss fixup code in ppp.
> I know I've used it somewhere but forget where :-)

RFC 1071, but that doesn't include the code.  Just the one-sentence
explanation of what to do.  [And several more sentences of
explanation...]  



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?44hcv188y9.fsf>