Re: 2.2 generating odd TCP resets?
Well, this seems to be half the story. If I remove the close() and let server bleed file descriptors, the RST goes away. If I add a read() on the socket after sending all the data, the RST goes away. However, there's NO DATA on the socket. read() returns zero until the client closes the socket. In the code below, I removed the shutdown() and added the block after do_scan() to eliminate the RST. The read() never finds any data. If there's no data pending, why does read() have any affect? b.c. fcntl (data_fd, F_SETFL, 1);/* set non-blocking */ /*shutdown (data_fd, 0); */ do_scan (w, h, data_fd); { char buff[10]; int i, c; printf("looking for extra data\n"); while ((c = read(data_fd, buff, 10)) >= 0) { if (c > 0) { for (i=0; i > Most likely reason is that the server calls close() while there is > still data pending to be read. As TCP is a reliable transport, this > loss of data causes a RST. > > An application bug. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] Please read the FAQ at http://www.tux.org/lkml/
Re: 2.2 generating odd TCP resets?
> Looks like the application on the Linux system is issuing a close() on > the socket before reading all of the available data. That always > causes a RST to be sent. Here's some stripped down code to generate bogus (I think) TCP resets on 2.2.14-17. The RST is generated when the server closes the socket, but there is NO data pending on the socket. On linux run ./st on windows run ./st 10.0.70.5 (or whatever). The windows box should return an error on read after linux generates the RST. The code can be compiled with cygwin. Is there any reason this should fail? It does not fail when talking to a linux host. The only obvious difference is windows generates two ACK's of the server's FIN. #include #include #include #include #include #define LEN 100 int main(int argc, char *argv[]) { struct sockaddr_in sin; int len, fd; char buff[LEN]; len = sizeof (sin); sin.sin_family = AF_INET; sin.sin_port = htons (5000); if (argc > 1) { /* client side */ int n, count = 0; printf("client\n"); sin.sin_addr.s_addr = inet_addr(argv[1]); fd = socket (AF_INET, SOCK_STREAM, 0); if (fd < 1) { perror("socket"); exit(0); } while (connect (fd, (struct sockaddr *) &sin, len)) { usleep(1); perror("connect"); } printf("connected to server\n"); shutdown(fd, 1); usleep(200); while (count < LEN) { n = read(fd, buff, 100); if (n < 0) { printf("error on read\n"); break; } count += n; } if (count == LEN) printf("read ok\n"); /*printf("read %s\n", buff); */ close(fd); } else { /* server side */ int i, new_fd; int on = 1; printf("server\n"); sin.sin_addr.s_addr = INADDR_ANY; fd = socket (AF_INET, SOCK_STREAM, 0); setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)); if (fd < 1) { perror("serv socket"); exit(0); } if (bind (fd, (struct sockaddr *)&sin, len) < 0 ||listen (fd, 1) < 0) { perror("bind/listen"); close(fd); exit(0); } new_fd = accept (fd, 0, 0); if (new_fd < 0) { perror("accept"); exit(0); } close(fd); usleep(100); shutdown (new_fd, 0); fcntl (new_fd, F_SETFL, 1); for (i = 0; i < LEN; ++i) buff[i] = i%256; write(new_fd, buff, LEN); close(new_fd); printf("socket closed\n"); usleep(1000); printf("server exiting\n"); } return 0; } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] Please read the FAQ at http://www.tux.org/lkml/
2.2 generating odd TCP resets?
I've been trying to get xsane-win32 working with a linux server. It keeps failing because read() on the win95 box returns an error just before the data transfer is complete. Dumping the conversation, I see linux sending a TCP RST: 00:26:29.260171 > porky.cisco.com.1034 > scan.1029: P 2185689:2187149(1460) ack 2 win 32120 (DF) 00:26:29.260988 < scan.1029 > porky.cisco.com.1034: . 2:2(0) ack 2187149 win 0 (DF) 00:26:29.288496 < scan.1029 > porky.cisco.com.1034: . 2:2(0) ack 2187149 win 1460 (DF) 00:26:29.288551 > porky.cisco.com.1034 > scan.1029: FP 2187149:2187555(406) ack 2 win 32120 (DF) 00:26:29.288861 < scan.1029 > porky.cisco.com.1034: . 2:2(0) ack 2187556 win 1054 (DF) 00:26:29.320316 < scan.1029 > porky.cisco.com.1034: . 2:2(0) ack 2187556 win 8354 (DF) 00:26:29.320404 > porky.cisco.com.1034 > scan.1029: R 3147707184:3147707184(0) win 0 Why is it sending a reset? Because the FIN was ACK'ed twice? Is this correct behavior? I've tried 2.2.14 and 2.2.17, with the same result. b.c. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] Please read the FAQ at http://www.tux.org/lkml/