From: Patrick McHardy <kaber@trash.net>
To: Maciej Soltysiak <solt@dns.toxicfilms.tv>
Cc: Rusty Russell <rusty@rustcorp.com.au>,
netfilter-devel@lists.netfilter.org
Subject: Re: [PATCH] netfilter: ECN target corrupts packets (2.6 only)
Date: Sun, 02 Jan 2005 22:04:48 +0100 [thread overview]
Message-ID: <41D861F0.8000303@trash.net> (raw)
In-Reply-To: <1625859504.20050102160729@dns.toxicfilms.tv>
[-- Attachment #1: Type: text/plain, Size: 662 bytes --]
Maciej Soltysiak wrote:
>>Nasty bug, caught while writing the ECN target test. Corrupts
>>checksums of packets when target is used on them.
>>
>>
>>Let this be a warning on the evils of casts.
>>
>>
>Heh, so that's why ECN stopped working for me :-)
>I will check that out.
>
>I did tcpdumps but for some strange reason I could not see
>the problem there. Maybe tcpdump got premangled packets..
>
>
There's more brokeness, it mangles the tcp header before making
it writable and doesn't reload pointers after doing so. This patch
should fix all of it and as a side-effect avoids some useless
copying. Any voluteers for testing ? :)
Regards
Patrick
[-- Attachment #2: x --]
[-- Type: text/plain, Size: 1774 bytes --]
===== net/ipv4/netfilter/ipt_ECN.c 1.11 vs edited =====
--- 1.11/net/ipv4/netfilter/ipt_ECN.c 2004-10-26 01:10:25 +02:00
+++ edited/net/ipv4/netfilter/ipt_ECN.c 2005-01-02 22:00:14 +01:00
@@ -61,31 +61,28 @@
if (th == NULL)
return 0;
- diffs[0] = ((u_int16_t *)th)[6];
- if (einfo->operation & IPT_ECN_OP_SET_ECE)
- th->ece = einfo->proto.tcp.ece;
-
- if (einfo->operation & IPT_ECN_OP_SET_CWR)
- th->cwr = einfo->proto.tcp.cwr;
- diffs[1] = ((u_int16_t *)&th)[6];
-
- /* Only mangle if it's changed. */
- if (diffs[0] != diffs[1]) {
- diffs[0] = diffs[0] ^ 0xFFFF;
+ if ((einfo->operation & IPT_ECN_OP_SET_ECE &&
+ th->ece != einfo->proto.tcp.ece) ||
+ (einfo->operation & IPT_ECN_OP_SET_CWR &&
+ th->cwr != einfo->proto.tcp.cwr)) {
if (!skb_ip_make_writable(pskb,
(*pskb)->nh.iph->ihl*4+sizeof(_tcph)))
return 0;
+ th = (void *)(*pskb)->nh.iph + (*pskb)->nh.iph->ihl*4;
- if (th != &_tcph)
- memcpy(&_tcph, th, sizeof(_tcph));
+ diffs[0] = ((u_int16_t *)th)[6];
+ if (einfo->operation & IPT_ECN_OP_SET_ECE)
+ th->ece = einfo->proto.tcp.ece;
+ if (einfo->operation & IPT_ECN_OP_SET_CWR)
+ th->cwr = einfo->proto.tcp.cwr;
+ diffs[1] = ((u_int16_t *)th)[6];
+ diffs[0] = diffs[0] ^ 0xFFFF;
if ((*pskb)->ip_summed != CHECKSUM_HW)
- _tcph.check = csum_fold(csum_partial((char *)diffs,
- sizeof(diffs),
- _tcph.check^0xFFFF));
- memcpy((*pskb)->data + (*pskb)->nh.iph->ihl*4,
- &_tcph, sizeof(_tcph));
- if ((*pskb)->ip_summed == CHECKSUM_HW)
+ th->check = csum_fold(csum_partial((char *)diffs,
+ sizeof(diffs),
+ th->check^0xFFFF));
+ else
if (skb_checksum_help(*pskb, inward))
return 0;
(*pskb)->nfcache |= NFC_ALTERED;
next prev parent reply other threads:[~2005-01-02 21:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-02 11:17 [PATCH] netfilter: ECN target corrupts packets (2.6 only) Rusty Russell
2005-01-02 15:07 ` Maciej Soltysiak
2005-01-02 21:04 ` Patrick McHardy [this message]
2005-01-03 10:15 ` Rusty Russell
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=41D861F0.8000303@trash.net \
--to=kaber@trash.net \
--cc=netfilter-devel@lists.netfilter.org \
--cc=rusty@rustcorp.com.au \
--cc=solt@dns.toxicfilms.tv \
/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.