From owner-freebsd-net@FreeBSD.ORG Fri May 6 17:08:00 2011 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7B147106566C for ; Fri, 6 May 2011 17:08:00 +0000 (UTC) (envelope-from cole@opteqint.net) Received: from mail-iy0-f182.google.com (mail-iy0-f182.google.com [209.85.210.182]) by mx1.freebsd.org (Postfix) with ESMTP id 520118FC08 for ; Fri, 6 May 2011 17:07:59 +0000 (UTC) Received: by iyj12 with SMTP id 12so4006633iyj.13 for ; Fri, 06 May 2011 10:07:59 -0700 (PDT) MIME-Version: 1.0 Received: by 10.231.186.85 with SMTP id cr21mr2437005ibb.164.1304701679533; Fri, 06 May 2011 10:07:59 -0700 (PDT) Received: by 10.231.33.8 with HTTP; Fri, 6 May 2011 10:07:59 -0700 (PDT) X-Originating-IP: [196.215.131.152] In-Reply-To: <20110506160937.GN90732@funkthat.com> References: <20110506160937.GN90732@funkthat.com> Date: Fri, 6 May 2011 19:07:59 +0200 Message-ID: From: Cole To: freebsd-net@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: kernel module, TCP state, and mbuf question X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 May 2011 17:08:00 -0000 On 6 May 2011 18:09, John-Mark Gurney wrote: > Cole wrote this message on Fri, May 06, 2011 at 15:49 +0200: >> Im currently working on a kernel module to modify data on tcp sessions >> leaving and coming into the box. And I have this working. However I've >> run into the issue where I am now breaking the TCP state. >> When I modify the data in the tcp packets, the size of that data may >> change, meaning that I have to then update the packet size and so >> forth. Now this works for the first packet with data inside it, but >> the rest of the packets leaving on this TCP stream then have the error >> where their sequence number is now wrong. i.e. If I modify the data, >> and the new data size is then less than that of the original packet, >> that means the next sequence number of the out going packet will >> actually be higher than it should be, and the other side will think it >> has missed a packet somewhere. > > Why not keep a delta sequence number and always update the sequence > number by this delta? =A0Where the delta is the number of bytes > added/removed from the stream? > > Seems easier than reaching into the TCP structure. Yeah, that would be me keeping my own state of what the next sequence number should be. I was just wondering how difficult it would be to get to the actual TCP stream state for a given mbuf and to update the next sequence number there if need be. So that is the module is unloaded all the streams will continue to function and it wont kill anything. Regards /Cole