Kern Mod and TCP retrasmit problem

Cole cole at opteqint.net
Tue May 17 12:22:17 UTC 2011


Hi.

Ive written a kernel module that modifies the data of outgoing TCP
packets. I use pfil_hook to insert my module into the outgoing packet
stream. Depending on the data, the size of data in the TCP packet may
change, either increasing or decreasing. When modifying the data size,
I update the mbuf len, the pkthdr len, the size in the IP header, as
well as modifying the TCP checksum. I also update the tcpcb->snd_nxt,
and tcpcb->snd_max values.

The problem I am having at the moment is only when I modify the packet
and the data size decreases. Whenever the data size increases I dont
have a problem. However, when the data size decreases, the TCP
architecture tries to retransmit the missing data. i.e. if original
data in the TCP packet is 30 bytes in size, and i modify it and it is
now only 18 bytes in size, then the box retransmits the missing 12
bytes that it thought never got transmitted.

This is where my problem lies, im trying to find out what variable or
structure I need to update so that the box doesnt think that it needs
to retransmit those missing bytes. Ive been looking at the tcbcb
structure in netinet/tcp_var.h and I cannot seem to see any values
inside this structure that point to the data size of the packet. Ive
also looked at tcp_output.c and I see that theres functions that use
tcpcb->sackhint to see if theres missing bytes. However when examing
those in the kernel module of the outgoing packet, the pointer is
always NULL.

If anyone has any ideas or suggestions, I would be glad to hear.

Thanks
/Cole


More information about the freebsd-net mailing list