Re: Unexpected behavior after altering inetsw[] switch table

[ Available lists | Index of freebsd-net | Month of Jun 2006 | Week of 11 Jun 2006 | Raw email | View thread | Wrap long lines | Reply | Tag ]
From
Max Laier <max@love2party.net>
Date
11 Jun 2006 11:08:44
Subject
Re: Unexpected behavior after altering inetsw[] switch table
Message-ID
200606111308.28468.max@love2party.net

In reply to
References to
Replies
Referenced by

[ Hide this part ]
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@freebsd.org
\ / Max Laier | ICQ #67774661
X http://pf4freebsd.love2party.net/ | mlaier@EFnet
/ \ ASCII Ribbon Campaign | Against HTML Mail and News


[ Show this part (application/pgp-signature) ]

Elapsed time: 0.120 seconds