kernel module, TCP state, and mbuf question

Cole cole at opteqint.net
Fri May 6 17:08:00 UTC 2011


On 6 May 2011 18:09, John-Mark Gurney <jmg at funkthat.com> 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?  Where 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


More information about the freebsd-net mailing list