mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Terje Eggestad <terje.eggestad@scali.com>
To: "David S. Miller" <davem@redhat.com>
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: Possible bug with UDP and SO_REUSEADDR. Was Re: [PATCH] zerocopy NFS updated
Date: 26 Apr 2002 09:38:52 +0200	[thread overview]
Message-ID: <1019806735.7410.1102.camel@pc-16.office.scali.no> (raw)
In-Reply-To: <20020425.194301.90782367.davem@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1394 bytes --]

'course



On Fri, 2002-04-26 at 04:43, David S. Miller wrote:
>    From: Terje Eggestad <terje.eggestad@scali.com>
>    Date: 25 Apr 2002 14:37:44 +0200
> 
>    However writing a test server that stand in blocking wait on a UDP
>    socket, and start two instances of the server it's ALWAYS the server
>    last started that get the udp message, even if it's not in blocking
>    wait, and the first started server is. 
>    
>    Smells like a bug to me, this behavior don't make much sence. 
>    
>    Using stock 2.4.17.
> 
> Can you post your test server/client application so that I
> don't have to write it myself and guess how you did things?
> 
> Thanks.
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
-- 
_________________________________________________________________________

Terje Eggestad                  mailto:terje.eggestad@scali.no
Scali Scalable Linux Systems    http://www.scali.com

Olaf Helsets Vei 6              tel:    +47 22 62 89 61 (OFFICE)
P.O.Box 150, Oppsal                     +47 975 31 574  (MOBILE)
N-0619 Oslo                     fax:    +47 22 62 89 51
NORWAY            
_________________________________________________________________________

[-- Attachment #2: client.c --]
[-- Type: text/x-c, Size: 1336 bytes --]

#include <stdio.h>
#include <errno.h>
#include <stdlib.h>

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

#include <unistd.h>
#include <fcntl.h>

#define BS 4096*3
main(int argc, char ** argv)
{
  int s, n, ns, cond, len, rc, val;
  short port = 6767;
  struct sockaddr_in mysock;
  char buffer[BS];
  char addr[16], * host;
  time_t t; 
  struct hostent * he;
  s = socket(PF_INET, SOCK_DGRAM, 0);

  if (argc >= 2) {
    host = argv[1];
  } else {
    printf ("error\n");
  };

  if (argc >= 3) {
    port = atoi(argv[2]);
  };

  mysock.sin_family = AF_INET;
  mysock.sin_port = htons(port);
  he = gethostbyname(host);
  if (he == NULL) exit(9);

  printf ("host  %s : %s, %d %#x \n", host, he->h_name, he->h_addrtype, he->h_addr_list[0]);
  memcpy(&mysock.sin_addr.s_addr, he->h_addr_list[0], he->h_length);
  
  printf("\n");
  time(&t);
  rc = sprintf(buffer, "%d : %s : hei hei", getpid(), ctime(&t));
  len = sizeof(struct sockaddr_in);
  inet_ntop(AF_INET, &mysock.sin_addr.s_addr, addr, 16);
  printf("sento: %s:%d =\"%s\"\n", addr, ntohs(mysock.sin_port), buffer);
  rc = sendto(s, buffer, rc, 0, (struct sockaddr*) &mysock, len); 

};

/* 
 * Local variables:
 *  compile-command: "gcc -g  -o client client.c"
 * End:
 */

[-- Attachment #3: server.c --]
[-- Type: text/x-c, Size: 1351 bytes --]

#include <stdio.h>
#include <errno.h>
#include <stdlib.h>

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

#include <unistd.h>
#include <fcntl.h>

#define BS 4096*3
main(int argc, char ** argv)
{
  int s, n, ns, cond, len, rc, val;
  short port = 6767;
  struct sockaddr_in mysock, peeraddr;
  char buffer[BS];
  char addr[16];
 
  s = socket(PF_INET, SOCK_DGRAM, 0);

  if (argc >= 2) {
    port = atoi(argv[1]);
  };

  mysock.sin_family = AF_INET;
  mysock.sin_port = htons(port);
  mysock.sin_addr.s_addr = INADDR_ANY;
  
  val = 1;
  rc = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(int));
  printf ("setsockopt => %d (%d)\n", rc, errno);
  
  rc = bind(s, (struct sockaddr*) &mysock, sizeof(struct sockaddr_in));
  printf ("bind => %d (%d)\n", rc, errno);
  

  while(1) {

    printf("\n");
    len = sizeof(struct sockaddr_in);
    rc = recvfrom(s, buffer, BS, 0, (struct sockaddr*) &peeraddr, &len); 

    if (rc == -1) printf("recvfrom returned %d (%d)\n", rc, errno);
    else {
      inet_ntop(AF_INET, &peeraddr.sin_addr.s_addr, addr, 16);
      printf("recvfrom got from %s:%d =\"%s\"\n", addr, ntohs(peeraddr.sin_port), buffer);
    };
    sleep(1);
  };
};

/* 
 * Local variables:
 *  compile-command: "gcc -g  -o server server.c"
 * End:
 */

  reply	other threads:[~2002-04-26  7:39 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20020410.190550.83626375.taka@valinux.co.jp.suse.lists.linux.kernel>
2002-04-10 19:32 ` Andi Kleen
2002-04-11  2:30   ` David S. Miller
2002-04-11  6:46     ` Hirokazu Takahashi
2002-04-11  6:48       ` David S. Miller
2002-04-11  7:41         ` Hirokazu Takahashi
2002-04-11  7:52           ` David S. Miller
2002-04-11 11:38             ` Hirokazu Takahashi
2002-04-11 11:36               ` David S. Miller
2002-04-11 18:00                 ` Denis Vlasenko
2002-04-11 13:16                   ` Andi Kleen
2002-04-11 17:36                     ` Benjamin LaHaise
2002-04-16  0:17                     ` Mike Fedyk
2002-04-16 15:37                       ` Oliver Xymoron
2002-04-11 17:33             ` Benjamin LaHaise
2002-04-12  8:10               ` Hirokazu Takahashi
2002-04-12 12:30         ` Hirokazu Takahashi
2002-04-12 12:35           ` Andi Kleen
2002-04-12 21:22             ` Jamie Lokier
2002-04-12 21:31               ` David S. Miller
2002-04-13  0:21                 ` Jamie Lokier
2002-04-13  6:39                   ` Andi Kleen
2002-04-13  8:01                     ` Hirokazu Takahashi
2002-04-13 19:19                     ` Eric W. Biederman
2002-04-13 19:37                       ` Andi Kleen
2002-04-13 20:34                         ` Eric W. Biederman
2002-04-24 23:11                           ` Mike Fedyk
2002-04-25 17:11                             ` Andreas Dilger
2002-04-13 18:52                 ` Chris Wedgwood
2002-04-14  0:07                   ` Keith Owens
2002-04-14  8:19                     ` Chris Wedgwood
2002-04-14  8:40                       ` Keith Owens
2002-04-12 21:39             ` David S. Miller
2002-04-15  1:30               ` Hirokazu Takahashi
2002-04-15  4:23                 ` David S. Miller
2002-04-16  1:03                   ` Hirokazu Takahashi
2002-04-16  1:41                     ` Jakob Østergaard
2002-04-16  2:20                       ` Hirokazu Takahashi
2002-04-18  5:01                       ` Hirokazu Takahashi
2002-04-18  7:58                         ` Jakob Østergaard
2002-04-18  8:53                         ` Trond Myklebust
2002-04-19  3:21                           ` Hirokazu Takahashi
2002-04-19  9:18                             ` Trond Myklebust
2002-04-20  7:47                               ` Hirokazu Takahashi
2002-04-25 12:37                                 ` Possible bug with UDP and SO_REUSEADDR. Was " Terje Eggestad
2002-04-26  2:43                                   ` David S. Miller
2002-04-26  7:38                                     ` Terje Eggestad [this message]
2002-04-29  0:41                                     ` Possible bug with UDP and SO_REUSEADDR David Schwartz
2002-04-29  8:06                                       ` Terje Eggestad
2002-04-29  8:44                                         ` David Schwartz
2002-04-29 10:03                                           ` Terje Eggestad
2002-04-29 10:38                                             ` David Schwartz
2002-04-29 14:20                                               ` Terje Eggestad
     [not found]                               ` <200204192128.QAA24592@popmail.austin.ibm.com>
2002-04-20 10:14                                 ` [PATCH] zerocopy NFS updated Hirokazu Takahashi
2002-04-20 15:49                                   ` Andrew Theurer

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=1019806735.7410.1102.camel@pc-16.office.scali.no \
    --to=terje.eggestad@scali.com \
    --cc=davem@redhat.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

all inboxes | Powered by JetHome®