public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Meybohm <dmeybohm@bellsouth.net>
To: Josan Kadett <corporate@superonline.com>
Cc: "'Brad Campbell'" <brad@wasp.net.au>, linux-kernel@vger.kernel.org
Subject: Re: Entirely ignoring TCP and UDP checksum in kernel level
Date: Sun, 22 Aug 2004 23:38:05 -0400	[thread overview]
Message-ID: <20040823033805.GA4103@localhost> (raw)
In-Reply-To: <S268076AbUHVT2N/20040822192813Z+185@vger.kernel.org>

On Sun, Aug 22, 2004 at 10:28:10PM +0200, Josan Kadett wrote:
> I have found the exact reason why NAT does not work;
> 
> - The patched linux box ignores IP checksum errors
> - Since now the source address is mofidified without checksumming, NAT also
> carries that wrong checksum
> - Other boxes does not ignore the checksum and drop packets
> 
> I think the solution is here, I have done many different modifications to
> get the system redirect packets with wrong checksum. Now all to be done, is
> to correct this checksum by changing some code in ip_input.c so that it
> recalculates the checksum when the packets seem to arrive from 192.168.1.1. 
> 
> Where in the code then?

The attached patch might work. It changes the IP source address from
192.168.1.1 to 192.168.77.1 and then recalculates the IP header
checksum. (I haven't tested it, though).

Do I understand you correctly that the IP checksum is calculated
correctly, but for the address 192.168.1.1, and the UDP and TCP
checksums are computed as if the address was 192.168.77.1?  If so, I
think this should work...

Now, can you please oblige us with the name of the manufacturers of the
broken router (as someone else also previously requested), so they can
be properly publicly ridiculed?  :-)


Hope it helps,

Dave


---


diff -puN net/ipv4/ip_input.c~ip-ignore-csum net/ipv4/ip_input.c
--- v2.6.8/net/ipv4/ip_input.c~ip-ignore-csum	2004-08-22 22:56:34.000000000 -0400
+++ v2.6.8-dym/net/ipv4/ip_input.c	2004-08-22 23:07:26.000000000 -0400
@@ -355,6 +355,27 @@ drop:
         return NET_RX_DROP;
 }
 
+static inline void mangle_addr_and_csum(struct iphdr *iph)
+{
+#define MANGLE_SADDR_IN   htonl(0xc0a80101)
+#define MANGLE_SADDR_OUT  htonl(0xc0a84d01)
+
+	if (iph->saddr != MANGLE_SADDR_IN)
+		return;
+
+	/* Change the source address from 192.168.1.1 to 192.168.77.1 and
+	 * correct the checksum. */
+	iph->saddr = MANGLE_SADDR_OUT;
+	iph->check = 0;
+	iph->check = ip_fast_csum((u8 *)iph, iph->ihl);
+
+	/* Make sure the checksum is correct now. */
+	if (ip_fast_csum((u8 *)iph, iph->ihl) != 0) {
+		printk(KERN_ERR "checksum %08x -> %08x failed! (%04x)\n",
+		       MANGLE_SADDR_IN, iph->saddr, iph->check);
+	}
+}
+
 /*
  * 	Main IP Receive routine.
  */ 
@@ -399,6 +420,9 @@ int ip_rcv(struct sk_buff *skb, struct n
 
 	iph = skb->nh.iph;
 
+	/* Take care of broken router. */
+	mangle_addr_and_csum(iph);
+
 	if (ip_fast_csum((u8 *)iph, iph->ihl) != 0)
 		goto inhdr_error; 
 

_

  reply	other threads:[~2004-08-23  3:42 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <41285DB3.6070605@wasp.net.au>
2004-08-22 10:14 ` Entirely ignoring TCP and UDP checksum in kernel level Josan Kadett
2004-08-22 11:48   ` James Courtier-Dutton
2004-08-22 10:25 ` Josan Kadett
2004-08-22  9:36   ` Brad Campbell
2004-08-22 10:48     ` Josan Kadett
2004-08-22 13:10       ` Brad Campbell
2004-08-22 13:13       ` Brad Campbell
2004-08-22 19:27         ` Josan Kadett
2004-08-22 20:28         ` Josan Kadett
2004-08-23  3:38           ` David Meybohm [this message]
2004-08-23  5:26             ` Josan Kadett
2004-08-23  8:40             ` Josan Kadett
2004-08-22  9:19 Brad Campbell
  -- strict thread matches above, loose matches on Subject: below --
2004-08-22  6:17 Brad Campbell
2004-08-22  7:18 ` Josan Kadett
2004-08-22  7:24 ` Josan Kadett
2004-08-22  7:04   ` Brad Campbell
2004-08-22  8:12     ` Josan Kadett
2004-08-22  8:29       ` Brad Campbell
     [not found] <04Aug21.205911edt.41960@gpu.utcc.utoronto.ca>
2004-08-22  2:08 ` Josan Kadett
2004-08-22  6:01   ` Brad Campbell
2004-08-22  7:06     ` Josan Kadett
     [not found] <1093120934.854.155.camel@krustophenia.net>
2004-08-21 20:46 ` Lee Revell
2004-08-21 21:53   ` Josan Kadett
     [not found] <4126FDD8.1090101@gmc.lt>
2004-08-21  9:00 ` Josan Kadett
2004-08-21  8:11   ` Denis Vlasenko
2004-08-21  9:18     ` Josan Kadett
2004-08-21  8:26       ` Lee Revell
2004-08-21  9:35         ` Josan Kadett
2004-08-21  9:14   ` Vojtech Pavlik
     [not found] <1093078213.854.76.camel@krustophenia.net>
2004-08-21  8:58 ` Lee Revell
2004-08-21 21:41   ` Josan Kadett
2004-08-21  8:27 Denis Vlasenko
2004-08-21  8:41 ` Lee Revell
2004-08-21  9:50   ` Josan Kadett
2004-08-21  9:06     ` Kalin KOZHUHAROV
2004-08-21 21:46       ` Josan Kadett
2004-08-21  9:39 ` Josan Kadett
     [not found] <4126F16D.1000507@gmc.lt>
2004-08-21  8:02 ` Josan Kadett
2004-08-21  7:36   ` Kalin KOZHUHAROV
2004-08-21  8:54     ` Josan Kadett
2004-08-21  6:15 Josan Kadett
2004-08-21  7:10 ` Willy Tarreau

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=20040823033805.GA4103@localhost \
    --to=dmeybohm@bellsouth.net \
    --cc=brad@wasp.net.au \
    --cc=corporate@superonline.com \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox