* [PATCH] xtables-addons: xt_RAWNAT: skb writable part might not include whole l4 header (ipv4 case).
@ 2013-05-05 18:05 Dmitry Popov
2013-05-05 18:24 ` Dmitry Popov
0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Popov @ 2013-05-05 18:05 UTC (permalink / raw)
To: Jan Engelhardt; +Cc: netfilter-devel
Consider TCP/IPv4 packet with IP options:
sizeof(*iph) + sizeof(struct tcphdr) is not enough to include tcp checksum.
It may hurt if this packet is fragmented.
Therefore we should use iph->ihl * 4 instead of sizeof(*iph).
Signed-off-by: Dmitry Popov <dp@highloadlab.com>
---
extensions/xt_RAWNAT.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/extensions/xt_RAWNAT.c b/extensions/xt_RAWNAT.c
index a52e614..858f911 100644
--- a/extensions/xt_RAWNAT.c
+++ b/extensions/xt_RAWNAT.c
@@ -109,7 +109,7 @@ static void rawnat4_update_l4(struct sk_buff *skb, __be32 oldip, __be32 newip)
static unsigned int rawnat4_writable_part(const struct iphdr *iph)
{
- unsigned int wlen = sizeof(*iph);
+ unsigned int wlen = iph->ihl * 4;
switch (iph->protocol) {
case IPPROTO_TCP:
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] xtables-addons: xt_RAWNAT: skb writable part might not include whole l4 header (ipv4 case).
2013-05-05 18:05 [PATCH] xtables-addons: xt_RAWNAT: skb writable part might not include whole l4 header (ipv4 case) Dmitry Popov
@ 2013-05-05 18:24 ` Dmitry Popov
2013-05-08 11:32 ` Jan Engelhardt
0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Popov @ 2013-05-05 18:24 UTC (permalink / raw)
To: Dmitry Popov; +Cc: Jan Engelhardt, netfilter-devel
Also, shouldn't xt_RAWNAT depend on nf_defrag_ipv4 module?
xt_RAWNAT may work with ip fragments in PREROUTING chain, changing ip payload
(believing it's tcp/udp checksum) in fragment is harmful.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] xtables-addons: xt_RAWNAT: skb writable part might not include whole l4 header (ipv4 case).
2013-05-05 18:24 ` Dmitry Popov
@ 2013-05-08 11:32 ` Jan Engelhardt
2013-05-08 15:12 ` Dmitry Popov
0 siblings, 1 reply; 7+ messages in thread
From: Jan Engelhardt @ 2013-05-08 11:32 UTC (permalink / raw)
To: Dmitry Popov; +Cc: netfilter-devel
On Sunday 2013-05-05 20:24, Dmitry Popov wrote:
>Also, shouldn't xt_RAWNAT depend on nf_defrag_ipv4 module?
Dunno. Being a module for really "raw" nf_conntrack-less static NAT, I
feel no reason to make it hard-depend on nf_defrag, and instead leave it
up to the user whether or not to load nf_defrag.
With nf_nat having gained IPv6 support, I also feel less inclined to
keep xt_RAWNAT around.
(In the meantime, your patch is applied.)
>xt_RAWNAT may work with ip fragments in PREROUTING chain, changing ip payload
>(believing it's tcp/udp checksum) in fragment is harmful.
I would tend to just ignore the fragment case for now, like many other
modules. Comments against?
diff --git a/extensions/xt_RAWNAT.c b/extensions/xt_RAWNAT.c
index 858f911..0a24e77 100644
--- a/extensions/xt_RAWNAT.c
+++ b/extensions/xt_RAWNAT.c
@@ -87,6 +87,13 @@ static void rawnat4_update_l4(struct sk_buff *skb, __be32 oldip, __be32 newip)
struct udphdr *udph;
bool cond;
+ /*
+ * We do not really deal with fragments. On the first packet, we can attempt
+ * to modify the L4 header, otherwise just ignore the data.
+ */
+ if ((iph->frag_off & htons(IP_OFFSET)) == 0)
+ return;
+
switch (iph->protocol) {
case IPPROTO_TCP:
tcph = transport_hdr;
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] xtables-addons: xt_RAWNAT: skb writable part might not include whole l4 header (ipv4 case).
2013-05-08 11:32 ` Jan Engelhardt
@ 2013-05-08 15:12 ` Dmitry Popov
2013-05-08 21:32 ` Jan Engelhardt
0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Popov @ 2013-05-08 15:12 UTC (permalink / raw)
To: Jan Engelhardt; +Cc: netfilter-devel
On Wed, 8 May 2013 13:32:57 +0200 (CEST)
Jan Engelhardt <jengelh@inai.de> wrote:
> >Also, shouldn't xt_RAWNAT depend on nf_defrag_ipv4 module?
>
> Dunno. Being a module for really "raw" nf_conntrack-less static NAT, I
> feel no reason to make it hard-depend on nf_defrag, and instead leave it
> up to the user whether or not to load nf_defrag.
>
> I would tend to just ignore the fragment case for now, like many other
> modules. Comments against?
>
Yes, I think it's a better idea. The only argument against may be a
security hole if someone relies on xt_RAWNAT and doesn't use nf_defrag.
Though it's a poor argument imho.
> With nf_nat having gained IPv6 support, I also feel less inclined to
> keep xt_RAWNAT around.
>
nf_nat depends on conntrack and conntrack brings a huge overhead to
such a simple task like NAT. xt_RAWNAT simply solves NAT problem, it
definitely has to stay.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] xtables-addons: xt_RAWNAT: skb writable part might not include whole l4 header (ipv4 case).
2013-05-08 15:12 ` Dmitry Popov
@ 2013-05-08 21:32 ` Jan Engelhardt
2013-05-13 9:50 ` Dmitry Popov
0 siblings, 1 reply; 7+ messages in thread
From: Jan Engelhardt @ 2013-05-08 21:32 UTC (permalink / raw)
To: Dmitry Popov; +Cc: netfilter-devel
On Wednesday 2013-05-08 17:12, Dmitry Popov wrote:
>
>> With nf_nat having gained IPv6 support, I also feel less inclined to
>> keep xt_RAWNAT around.
>
>nf_nat depends on conntrack and conntrack brings a huge overhead to
>such a simple task like NAT. xt_RAWNAT simply solves NAT problem, it
>definitely has to stay.
The only way to solve the NAT problem is to do without it.
Full NAT is not simple at all, it requires DPI.
RAWNAT is just a dumb l3addr replacer and does not help
getting multi-connection sessions (such as 959ish FTP) going.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] xtables-addons: xt_RAWNAT: skb writable part might not include whole l4 header (ipv4 case).
2013-05-08 21:32 ` Jan Engelhardt
@ 2013-05-13 9:50 ` Dmitry Popov
2013-05-15 15:04 ` Pablo Neira Ayuso
0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Popov @ 2013-05-13 9:50 UTC (permalink / raw)
To: Jan Engelhardt; +Cc: netfilter-devel
On Wed, 8 May 2013 23:32:16 +0200 (CEST)
Jan Engelhardt <jengelh@inai.de> wrote:
> The only way to solve the NAT problem is to do without it.
> Full NAT is not simple at all, it requires DPI.
> RAWNAT is just a dumb l3addr replacer and does not help
> getting multi-connection sessions (such as 959ish FTP) going.
Well, in means of full nat - yes. I have no statistics of how people use
nf_nat/xt_RAWNAT, but in my tasks I have a lot of packets that do not need DPI.
xt_RAWNAT works great and nf_nat led to packet loss. It probably was because
of main conntrack lock. Yes, I read it was removed not long ago, and haven't
tested it since then, but anyway I do not want to use such a monster just to
change 2-3 fields of packet. Just an use case, decision is up to you =).
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] xtables-addons: xt_RAWNAT: skb writable part might not include whole l4 header (ipv4 case).
2013-05-13 9:50 ` Dmitry Popov
@ 2013-05-15 15:04 ` Pablo Neira Ayuso
0 siblings, 0 replies; 7+ messages in thread
From: Pablo Neira Ayuso @ 2013-05-15 15:04 UTC (permalink / raw)
To: Dmitry Popov; +Cc: Jan Engelhardt, netfilter-devel
On Mon, May 13, 2013 at 01:50:20PM +0400, Dmitry Popov wrote:
> On Wed, 8 May 2013 23:32:16 +0200 (CEST)
> Jan Engelhardt <jengelh@inai.de> wrote:
>
> > The only way to solve the NAT problem is to do without it.
> > Full NAT is not simple at all, it requires DPI.
> > RAWNAT is just a dumb l3addr replacer and does not help
> > getting multi-connection sessions (such as 959ish FTP) going.
>
> Well, in means of full nat - yes. I have no statistics of how people use
> nf_nat/xt_RAWNAT, but in my tasks I have a lot of packets that do
> not need DPI.
Not only DPI. You're also leaking your network topology though ICMP
error messages, as the internal header is not mangled.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-05-15 15:04 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-05 18:05 [PATCH] xtables-addons: xt_RAWNAT: skb writable part might not include whole l4 header (ipv4 case) Dmitry Popov
2013-05-05 18:24 ` Dmitry Popov
2013-05-08 11:32 ` Jan Engelhardt
2013-05-08 15:12 ` Dmitry Popov
2013-05-08 21:32 ` Jan Engelhardt
2013-05-13 9:50 ` Dmitry Popov
2013-05-15 15:04 ` Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).