From owner-freebsd-net@FreeBSD.ORG Fri May 6 14:11: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 DD071106567E for ; Fri, 6 May 2011 14:11: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 B424F8FC13 for ; Fri, 6 May 2011 14:11:00 +0000 (UTC) Received: by iyj12 with SMTP id 12so3812436iyj.13 for ; Fri, 06 May 2011 07:11:00 -0700 (PDT) MIME-Version: 1.0 Received: by 10.231.186.85 with SMTP id cr21mr2273134ibb.164.1304689755917; Fri, 06 May 2011 06:49:15 -0700 (PDT) Received: by 10.231.33.8 with HTTP; Fri, 6 May 2011 06:49:15 -0700 (PDT) X-Originating-IP: [196.215.131.152] Date: Fri, 6 May 2011 15:49:15 +0200 Message-ID: From: Cole To: freebsd-net@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Subject: 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 14:11:00 -0000 Hi. 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. In my kernel module I am using pfil_add_hook to hook into the outgoing packets, and from there I am inspecting and modifying the packets as needed. My function definition for the function I pass to pfil_add_hook is the default one as follows: chkoutput(void *arg, struct mbuf **m, struct ifnet *ifp, int dir, struct inpcb *inp) I was wondering if it is possible to somehow get access to the TCP state for the tcp stream for the mbuf/packet I have received and if I can modify the th_seq to match my new values, or if I will need to keep my own state information for any streams I modify and then update the outgoing packets th_seq values as needed? Any information or help will be gladly appreciated. Regards /Cole