From: Patrick McHardy <kaber@trash.net>
To: Jan Engelhardt <jengelh@medozas.de>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH 8/9] netfilter: xtables: inclusion of xt_TEE
Date: Wed, 17 Mar 2010 14:55:25 +0100 [thread overview]
Message-ID: <4BA0DF4D.5000504@trash.net> (raw)
In-Reply-To: <alpine.LSU.2.01.1003171437440.6297@obet.zrqbmnf.qr>
Jan Engelhardt wrote:
> On Wednesday 2010-03-17 14:35, Patrick McHardy wrote:
>> Jan Engelhardt wrote:
>>> +static void tee_tg_send(struct sk_buff *skb)
>>> +{
>>> + const struct dst_entry *dst = skb_dst(skb);
>>> + const struct net_device *dev = dst->dev;
>>> + unsigned int hh_len = LL_RESERVED_SPACE(dev);
>>> +
>>> + /* Be paranoid, rather than too clever. */
>>> + if (unlikely(skb_headroom(skb) < hh_len && dev->header_ops != NULL)) {
>>> + struct sk_buff *skb2;
>>> +
>>> + skb2 = skb_realloc_headroom(skb, LL_RESERVED_SPACE(dev));
>>> + if (skb2 == NULL) {
>>> + kfree_skb(skb);
>>> + return;
>>> + }
>>> + if (skb->sk != NULL)
>>> + skb_set_owner_w(skb2, skb->sk);
>>> + kfree_skb(skb);
>>> + skb = skb2;
>>> + }
>>> +
>>> + if (dst->hh != NULL) {
>>> + neigh_hh_output(dst->hh, skb);
>>> + } else if (dst->neighbour != NULL) {
>>> + dst->neighbour->output(skb);
>>> + } else {
>>> + if (net_ratelimit())
>>> + pr_debug(KBUILD_MODNAME
>>> + "no hdr & no neighbour cache!\n");
>>> + kfree_skb(skb);
>>> + }
>>> +}
>> Remind me again why we need this duplicated output function?
>
> You did not yet approve of the reentrancy patch :-)
>
> There is a comment block further below (at: "Normally, we would just use
> ip_local_out.", quoted below) that explains the exact reasons.
>>>> + /*
>>>> + * Normally, we would just use ip_local_out. Because iph->check is
>>>> + * already correct, we could take a shortcut and call dst_output
>>>> + * [forwards to ip_output] directly. ip_output however will invoke
>>>> + * Netfilter hooks and cause reentrancy. So we skip that too and go
>>>> + * directly to ip_finish_output. Since we should not do XFRM, control
>>>> + * passes to ip_finish_output2. That function is not exported, so it is
>>>> + * copied here as tee_ip_direct_send.
>>>> + *
>>>> + * We do no XFRM on the cloned packet on purpose! The choice of
>>>> + * iptables match options will control whether the raw packet or the
>>>> + * transformed version is cloned.
>>>> + *
>>>> + * Also on purpose, no fragmentation is done, to preserve the
>>>> + * packet as best as possible.
>>>> + */
You can use dst_output() and set IPSKB_REROUTED to skip the hook
invocation. This will potentially perform fragmentation however.
>
>>> + if (par->hooknum == NF_INET_LOCAL_IN) {
>>> + struct iphdr *iph = ip_hdr(skb);
>>> +
>>> + iph->check = 0;
>>> + iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl);
>>> + }
>> I guess it might make sense to decrease the TTL by one to
>> avoid TEE loops between two hosts.
>
> Sounds like a good idea. If the TTL of an incoming packet is already 1,
> the administrator could use careful TTL boosting aka. -j HL/TTL --hl-inc 1.
>
> Just one thing: as packets are manually sent out by xt_TEE currently,
> is there any routing/output code left that still checks for ->ttl == 0
> when it was decreased just before the hooknum check?
No, that's only done in the forward path.
next prev parent reply other threads:[~2010-03-17 13:55 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-17 13:18 nf-next: checks and three modules Jan Engelhardt
2010-03-17 13:18 ` [PATCH 1/9] netfilter: xtables: do without explicit XT_ALIGN Jan Engelhardt
2010-03-17 13:18 ` [PATCH 2/9] netfilter: xtables: slightly more detailed checkentry return values Jan Engelhardt
2010-03-17 13:39 ` Patrick McHardy
2010-03-17 14:05 ` Jan Engelhardt
2010-03-17 14:16 ` Patrick McHardy
2010-03-17 14:27 ` Jan Engelhardt
2010-03-17 14:36 ` Patrick McHardy
2010-03-17 14:40 ` Patrick McHardy
2010-03-17 21:54 ` Jan Engelhardt
2010-03-18 11:14 ` Patrick McHardy
2010-03-17 13:18 ` [PATCH 3/9] netfilter: xtables: restrict TCPMSS to mangle table as intended Jan Engelhardt
2010-03-17 13:30 ` Patrick McHardy
2010-03-17 13:34 ` Jan Engelhardt
2010-03-17 13:36 ` Patrick McHardy
2010-03-17 13:18 ` [PATCH 4/9] netfilter: xtables: clean up xt_mac match routine Jan Engelhardt
2010-03-17 13:19 ` [PATCH 5/9] netfilter: xtables: limit xt_mac to ethernet devices Jan Engelhardt
2010-03-17 13:31 ` Patrick McHardy
2010-03-17 13:37 ` Jan Engelhardt
2010-03-17 13:40 ` Patrick McHardy
2010-03-17 13:19 ` [PATCH 6/9] netfilter: xtables: resort osf kconfig text Jan Engelhardt
2010-03-17 13:19 ` [PATCH 7/9] netfilter: xtables: inclusion of xt_SYSRQ Jan Engelhardt
2010-03-17 13:56 ` Patrick McHardy
2010-03-17 14:11 ` John Haxby
2010-03-17 14:43 ` Patrick McHardy
2010-03-20 1:47 ` Jan Engelhardt
2010-03-22 15:14 ` John Haxby
2010-03-22 16:49 ` Patrick McHardy
2010-03-17 14:21 ` Jan Engelhardt
2010-03-17 14:24 ` Patrick McHardy
2010-03-17 13:19 ` [PATCH 8/9] netfilter: xtables: inclusion of xt_TEE Jan Engelhardt
2010-03-17 13:35 ` Patrick McHardy
2010-03-17 13:43 ` Jan Engelhardt
2010-03-17 13:55 ` Patrick McHardy [this message]
2010-03-23 1:55 ` Jan Engelhardt
2010-03-23 11:57 ` Patrick McHardy
2010-03-26 2:39 ` Jan Engelhardt
2010-03-20 2:03 ` Jan Engelhardt
2010-03-22 16:58 ` Patrick McHardy
2010-03-22 17:45 ` Jan Engelhardt
2010-03-23 12:04 ` Patrick McHardy
2010-03-23 12:29 ` Jan Engelhardt
2010-03-23 12:38 ` Patrick McHardy
2010-03-23 12:46 ` Jan Engelhardt
2010-03-23 13:45 ` Patrick McHardy
2010-03-17 13:19 ` [PATCH 9/9] netfilter: xtables: inclusion of xt_condition Jan Engelhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4BA0DF4D.5000504@trash.net \
--to=kaber@trash.net \
--cc=jengelh@medozas.de \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.