From owner-freebsd-hackers@FreeBSD.ORG Mon Jan 8 22:38:40 2007 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 45C1216A412 for ; Mon, 8 Jan 2007 22:38:40 +0000 (UTC) (envelope-from lgusenet@be-well.ilk.org) Received: from mail3.sea5.speakeasy.net (mail3.sea5.speakeasy.net [69.17.117.5]) by mx1.freebsd.org (Postfix) with ESMTP id 23B7613C467 for ; Mon, 8 Jan 2007 22:38:40 +0000 (UTC) (envelope-from lgusenet@be-well.ilk.org) Received: (qmail 31805 invoked from network); 8 Jan 2007 22:12:00 -0000 Received: from dsl092-078-145.bos1.dsl.speakeasy.net (HELO be-well.ilk.org) ([66.92.78.145]) (envelope-sender ) by mail3.sea5.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 8 Jan 2007 22:12:00 -0000 Received: by be-well.ilk.org (Postfix, from userid 1147) id 03AC82842F; Mon, 8 Jan 2007 17:11:58 -0500 (EST) To: freebsd-hackers@freebsd.org References: <20070108203211.GF41066@nerds.org.uk> <45A2BEEE.5010202@elischer.org> From: Lowell Gilbert Date: Mon, 08 Jan 2007 17:11:58 -0500 In-Reply-To: <45A2BEEE.5010202@elischer.org> (Julian Elischer's message of "Mon, 08 Jan 2007 14:00:14 -0800") Message-ID: <44hcv188y9.fsf@be-well.ilk.org> User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailman-Approved-At: Tue, 09 Jan 2007 01:53:46 +0000 Subject: Re: TCP Checksums in mbufs X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jan 2007 22:38:40 -0000 Julian Elischer 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...]