All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Troin <phil@fifi.org>
To: linux-kernel@vger.kernel.org
Cc: Andi Kleen <ak@suse.de>
Subject: Wierd listen/connect: accept queue never fills up
Date: 27 Nov 2002 18:58:33 -0800	[thread overview]
Message-ID: <87y97ee6xy.fsf@ceramic.fifi.org> (raw)

[Andi, I've CC'ed you since you're listed as the author of the `new
listen' code in net/ipv4/tcp_ipv4.c]

Seen on linux 2.4.20rc2.

This program is always able to establish new connections to itself:
the accept queue never fills up and connections always succeed
(although they take quite some time after the first four):

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

  int main(void)
  {
    int fd;
    struct sockaddr_in sin;
    socklen_t sinlen;

    if ((fd = socket(PF_INET, SOCK_STREAM, 0)) == -1)
      perror("socket"), exit(1);

    sin.sin_family      = AF_INET;
    sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
    sin.sin_port	      = htons(0);
    if (bind(fd, (struct sockaddr*)&sin, sizeof(sin)) == -1)
      perror("bind"), exit(1);
    if (listen(fd, 1) == -1)
      perror("listen"), exit(1);

    sinlen = sizeof(sin);
    getsockname(fd, (struct sockaddr*)&sin, &sinlen);

    while (1)
      {
        int fdc;

        if ((fdc = socket(PF_INET, SOCK_STREAM, 0)) == -1)
  	perror("socket"), exit(1);
        printf("%c", connect(fdc, (struct sockaddr*)&sin, sinlen) == -1
  	     ? 'F' : '.');
        fflush(stdout);
      }

    exit(0);
  }

I've tried enabling and disabling tcp_syncookies, without any effect.

The same program starts returning errors after two successful connects
on Solaris and one on HP-UX. Linux keeps returning new connections...

Phil.

             reply	other threads:[~2002-11-28  2:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-28  2:58 Philippe Troin [this message]
2002-11-28  3:17 ` Wierd listen/connect: accept queue never fills up Ivan Pulleyn
2002-12-03  1:44   ` Philippe Troin
  -- strict thread matches above, loose matches on Subject: below --
2002-12-03  8:25 Margit Schubert-While

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=87y97ee6xy.fsf@ceramic.fifi.org \
    --to=phil@fifi.org \
    --cc=ak@suse.de \
    --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 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.