Unexpected behavior after altering inetsw[] switch table
Max Laier
max at love2party.net
Sun Jun 11 11:08:44 UTC 2006
On Sunday 11 June 2006 02:36, Shaun Colley wrote:
> I'm writing a kernel module whose job is to modify the inetsw[] switch
> table for the IPPROTO_TCP protocol. The pr_output hook for TCP needs to
> be changed, such that my own custom tcp_output function will be called
> when transmitting TCP packets. The reason for doing this is so that I can
> do some modification on TCP packets before they are transmitted, but the
> semantics of this are not important.
>
> The part of the module of interest is:
>
> ---
> switch (what) {
> case MOD_LOAD: /* kldload */
> uprintf("Skeleton KLD loaded.\n");
> old_handler = inetsw[ip_protox[IPPROTO_TCP]].pr_output;
> inetsw[ip_protox[IPPROTO_TCP]].pr_output = (pr_output_t
> *)my_tcp_output; break;
> case MOD_UNLOAD:
> uprintf("Skeleton KLD unloaded.\n");
> inetsw[ip_protox[IPPROTO_TCP]].pr_output = old_handler;
> break;
> default:
> err = EINVAL;
> break;
> }
> ---
>
> my_tcp_output is a hacked version of tcp_output.
As you can see in netinet/in_proto.c, tcp does not use pr_output, but calls
tcp_output() directly where needed. Depending on what you want to achive it
might be enough to hack up tcp_usr_send() and replace tcp_usrreqs.pru_send
instead. Replaceing tcp_output() is not easily possible. You could start
with telling us what you *really* want to do so we can point you to a
workable option.
<snipp>
--
/"\ Best regards, | mlaier at freebsd.org
\ / Max Laier | ICQ #67774661
X http://pf4freebsd.love2party.net/ | mlaier at EFnet
/ \ ASCII Ribbon Campaign | Against HTML Mail and News
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-net/attachments/20060611/299b20cb/attachment.pgp
More information about the freebsd-net
mailing list