public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: Entirely ignoring TCP and UDP checksum in kernel level
@ 2004-08-22  9:19 Brad Campbell
  0 siblings, 0 replies; 43+ messages in thread
From: Brad Campbell @ 2004-08-22  9:19 UTC (permalink / raw)
  To: Josan Kadett; +Cc: linux-kernel

Josan Kadett wrote:
> It is certainly the solution to the issue. Indeed, everything works fine
> including NAT because the hack is in the kernel level. Your assistance is
> greatly appreciated. The first issue is complete but for now I think I will
> get into a lesser one. (I will write about it when I get have all the
> details)

Wicked! It's often the simple things.

Glad I could help.

Regards,
Brad

^ permalink raw reply	[flat|nested] 43+ messages in thread
* Re: Entirely ignoring TCP and UDP checksum in kernel level
@ 2004-08-22  6:17 Brad Campbell
  2004-08-22  7:18 ` Josan Kadett
  2004-08-22  7:24 ` Josan Kadett
  0 siblings, 2 replies; 43+ messages in thread
From: Brad Campbell @ 2004-08-22  6:17 UTC (permalink / raw)
  To: Josan Kadett; +Cc: linux-kernel

Josan Kadett wrote:
> That is certainly what I require but I need some guidelines; I investigated
> into the issue and fount out that;
> 
> - By only changing the source address coded in the IP header
> - And by just applying checksum to IP header [Not TCP or UDP]
> 
> The problem would be gone since when the source IP in the IP address field
> is validated, the checksum in the underlying protocol is automatically
> validated (because the sender system had already computed this CRC using the
> IP address which we want to write onto the packet)
> 
> I do not have much time to build a code just for this purpose and thus I am
> looking for a simple app. or some other way...

So if we took any packet that came in from 192.168.1.1 and substituted 192.178.77.1 for the Source 
address and then re-calculated the IP checksum you would be up and running?

Regards,
Brad

^ permalink raw reply	[flat|nested] 43+ messages in thread
[parent not found: <04Aug21.205911edt.41960@gpu.utcc.utoronto.ca>]
[parent not found: <1093120934.854.155.camel@krustophenia.net>]
[parent not found: <4126FDD8.1090101@gmc.lt>]
[parent not found: <1093078213.854.76.camel@krustophenia.net>]
* RE: Entirely ignoring TCP and UDP checksum in kernel level
@ 2004-08-21  8:27 Denis Vlasenko
  2004-08-21  8:41 ` Lee Revell
  2004-08-21  9:39 ` Josan Kadett
  0 siblings, 2 replies; 43+ messages in thread
From: Denis Vlasenko @ 2004-08-21  8:27 UTC (permalink / raw)
  To: Josan Kadett; +Cc: linux-kernel

On Saturday 21 August 2004 12:18, Josan Kadett wrote:
> That is not much of an intelligible idea. A way to hack the kernel could be
> found as I still presume. "Turn off checksums" but not by re-writing the
> whole tcp code in the kernel. Isn't that possible ? Linux is an operating
> system of infinite possibilities, right ? But only if you know how to hack
> it...

Of course you can hack the kernel to do it.

However, by replacing that box with Linux device you
get one more Linux box and you will be capable of
doing whole slew of useful things, like traffic filtering, shaping,
accounting, Ethernet bridging, etc etc etc, if/when you will need it.
You can easily debug problems with tools like tcpdump and ethereal.
I simply cannot list everything Linux can do, I don't plan to write
a novel here ;]

I bet current 'crazy box' has nothing even vaguely resembling
these capabilities. Heck, it cannot do standard TCP properly.
So there is little reason to waste your time trying to work around it.
-- 
vda

^ permalink raw reply	[flat|nested] 43+ messages in thread
[parent not found: <4126F16D.1000507@gmc.lt>]
* Entirely ignoring TCP and UDP checksum in kernel level
@ 2004-08-21  6:15 Josan Kadett
  2004-08-21  7:10 ` Willy Tarreau
  0 siblings, 1 reply; 43+ messages in thread
From: Josan Kadett @ 2004-08-21  6:15 UTC (permalink / raw)
  To: linux-net, linux-kernel

I will explain the problem briefly;

- We have an old network concentrator device in our WAN, this device uses IP
number 192.168.77.1 as its primary address
- The device has another IP number (a local address) that is 192.168.1.1

When we ping the device from the internal network, we have to use the
device's primary IP number which is 192.168.77.1:

ping -> 192.168.77.1
reply from 192.168.1.1

Normally the reply should come from 192.168.77.1, but the device has some
kind of programming failure and thus responds us using its internal IP
number regardless of how we configure it.

This does not affect the ping from returning back even it is sourced by a
different address than it is originally destined to, however; if we telnet
to the device we get the following failure:

telnet -> TCP SYN sent to 192.168.77.1
TCP SYN ACK reply from 192.168.1.1
TCP SYN sent to 192.168.77.1
TCP SYN sent to 192.168.77.1
TCP SYN sent to 192.168.77.1
.... [The connection times since our linux host does not "see" the TCP SYN
ACK reply for an obvious reason)

The client from which we send telnet requests to the device gets a packet
from 192.168.1.1 instead of getting a packet from 192.168.77.1. However; at
this case, the returning TCP SYN ACK packet has the wrong CRC checksum
because;

The network concentrator computes the TCP checksum with the source address
header of its IP number 192.167.77.1, however; our client that gets the
packet from the address 192.168.1.1 uses this address instead of the correct
one in order to compute the checksum and thus they mismatch;

Eg.
0D 74 (Checksum computed by concentrator device)
13 D6 (Checksum computed by our client)

So the incoming packets are dropped due to the fact that they have "wrong"
checksum... Now either we should find a way to correct the source address
and the IP checksum in each incoming packet received by our client, or we
should "program" a utility for it. Here is what we plan to do;

- Intercept each packet coming from interface eth0
- Put the IP data in buffer
- Find and change the bits in which the source IP address is encoded (from
192.168.1.1 back to 192.168.77.1)
- Since the TCP packet has already been checksummed for the correct IP,
after we change the source, the TCP checksum would be "automatically"
corrected
- But since we modified the source IP, now the IP header checksum is broken;
so recalculate it and put it in correct place
- "Re-inject" the packet to the interface eth0, but to the "incoming" data
path that would be received by kernel (just as generating a packet that goes
to system itself, instead of an external link)

I found that in /usr/src/linux/net/ipv4/tcp_input.c and udp.c are the two
sources that control how the communication occurs. I experimented with the
code and re-compiled the kernel times over times, though either the "CRC"
checksum checking was still there or the communication was totally cut out.

I also investigated terms such as CRC checksum offloading and such, and as I
could see that there was no easy way (a switch or a definition) to disable
CRC checksumming of received packets, either it be TCP or UDP. I am still
sure that if the kernel is "told" to allow all packets regardless of their
CRC field, I would resolve the problem with our network, but the question is
"how ??"

Below is a detailed view of the malformed packet;

Ethernet II Header
     |
     - IP Header 
       (flags) Source IP: 192.168.1.1 (This is where the problem begins, it
should have been 192.168.77.1)
                 Dest.    IP: 192.168.1.5 (Our client's IP number)
          Checksum [0x7d43] --> Correct CRC for IP header
     |
     - UDP Header (The same case for TCP)
       (flags) Source Port: 161
                 Dest.    Port: 32816
          Length: 0x0048
          Checksum [0x341a] --> Wrong CRC that causes all problems.**

Our system thinks that the checksum would be what it wants to be, so the
conflict between these two devices makes communication impossible. I know,
if a patch is applied to the source code of the kernel, both TCP and UDP
would ingore the CRC and allow communication. Since our network is
absolutely reliable, there will not be a single side effect of disabling
TCP/UDP checksums.

Now if all else fails, at least I have one option though I really do not
wish to program a packet interceptor for no reason but the dumbness of a
router and the "abhorrent rigidity" of linux TCP/IP stack. But if I must
then I will... (We will not replace a multi-K$ UAC device just for this
reason)

Perhaps there is a small utility that corrects checksums of the incoming
data (in real-time) ? Indeed many sniffers have this option to correct the
CRC (or show the correct value), but none of them are programmed to create a
stream in which the modifications are done and the packets get re-injected.



^ permalink raw reply	[flat|nested] 43+ messages in thread

end of thread, other threads:[~2004-08-23  7:40 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox