From owner-freebsd-hackers@FreeBSD.ORG Mon Jan 8 22:00:22 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 7699016A412 for ; Mon, 8 Jan 2007 22:00:22 +0000 (UTC) (envelope-from julian@elischer.org) Received: from outQ.internet-mail-service.net (outQ.internet-mail-service.net [216.240.47.240]) by mx1.freebsd.org (Postfix) with ESMTP id 0616C13C45B for ; Mon, 8 Jan 2007 22:00:21 +0000 (UTC) (envelope-from julian@elischer.org) Received: from shell.idiom.com (HELO idiom.com) (216.240.47.20) by out.internet-mail-service.net (qpsmtpd/0.32) with ESMTP; Mon, 08 Jan 2007 13:41:52 -0800 Received: from [10.251.23.190] (nat.ironport.com [63.251.108.100]) by idiom.com (8.12.11/8.12.11) with ESMTP id l08M0Fjf004811; Mon, 8 Jan 2007 14:00:16 -0800 (PST) (envelope-from julian@elischer.org) Message-ID: <45A2BEEE.5010202@elischer.org> Date: Mon, 08 Jan 2007 14:00:14 -0800 From: Julian Elischer User-Agent: Thunderbird 1.5.0.9 (Macintosh/20061207) MIME-Version: 1.0 To: Lee Brotherston References: <20070108203211.GF41066@nerds.org.uk> In-Reply-To: <20070108203211.GF41066@nerds.org.uk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org 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:00:22 -0000 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. 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 :-)