netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* TCP checksum error on local device
@ 2008-07-09 14:34 Kevin Spiteri
  2008-07-09 15:10 ` Kristof Provost
  0 siblings, 1 reply; 4+ messages in thread
From: Kevin Spiteri @ 2008-07-09 14:34 UTC (permalink / raw)
  To: netdev

When I send TCP data from localhost to localhost (either on 127.0.0.1
or on the public IP of the machine), the TCP checksum is wrong.

I am using the kernel that came with Xubuntu 8.04, /proc/version:
Linux version 2.6.24-19-generic (buildd@palmer) (gcc version 4.2.3
(Ubuntu 4.2.3-2ubuntu7)) #1 SMP Wed Jun 18 14:43:41 UTC 2008

When I run the sample program below and capture traffic on the lo
device using Wireshark, the TCP segment that contains data has an
incorrect checksum. All other segments have a correct checksum.

#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>

int main(int argc, char **argv)
{
    int fd_srv, fd_s0, fd_s1;
    struct sockaddr_in address;
    socklen_t len = sizeof(address);
    char buffer[1] = {0};

    fd_srv = socket(AF_INET, SOCK_STREAM, 6);
    memset(&address, 0, len);
    address.sin_family = AF_INET;
    address.sin_addr.s_addr = htonl(0x7f000001);
    address.sin_port = htons(12345);
    bind(fd_srv, (struct sockaddr *)(&address), len);
    listen(fd_srv, 0);

    fd_s0 = socket(AF_INET, SOCK_STREAM, 6);
    connect(fd_s0, (struct sockaddr *)(&address), len);

    fd_s1 = accept(fd_srv, (struct sockaddr *)(&address), &len);
    close(fd_srv);

    write(fd_s0, buffer, 1);
    read(fd_s1, buffer, 1);
    close(fd_s0);
    close(fd_s1);

    return 0;
}

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

end of thread, other threads:[~2008-07-09 15:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-09 14:34 TCP checksum error on local device Kevin Spiteri
2008-07-09 15:10 ` Kristof Provost
2008-07-09 15:28   ` Kevin Spiteri
2008-07-09 15:38     ` Ben Hutchings

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).