Re: Failure of SO_REUSEADDR wrt. TIME_WAIT in 2.1.90

David S. Miller (davem@dm.cobaltmicro.com)
Mon, 23 Mar 1998 14:54:23 -0800


Date: Mon, 23 Mar 1998 21:18:19 +0100 (MET)
From: Finn Arne Gangstad <finnag@guardian.no>

In Linux 2.1.90 bind() fails when sockets are in TIME_WAIT even if
SO_REUSEADDR is enabled.

Sorry, stupid bug, here's a fix.

--- include/net/sock.h.~1~ Sun Mar 22 16:33:56 1998
+++ include/net/sock.h Mon Mar 23 14:42:20 1998
@@ -363,6 +363,10 @@
__u16 sport; /* Source port */
__u16 dport; /* Destination port */

+ unsigned short family;
+ unsigned char reuse,
+ nonagle;
+
int sock_readers; /* user count */
int rcvbuf;

@@ -385,13 +389,11 @@
volatile char dead,
done,
urginline,
- reuse,
keepopen,
linger,
destroy,
no_check,
broadcast,
- nonagle,
bsdism;
unsigned char debug;
int proc;
@@ -404,7 +406,6 @@
struct sk_buff_head back_log,
error_queue;

- unsigned short family;
struct proto *prot;

/*
--- include/net/tcp.h.~1~ Sun Mar 22 16:34:22 1998
+++ include/net/tcp.h Mon Mar 23 14:45:00 1998
@@ -161,9 +161,12 @@
int bound_dev_if;
unsigned short num;
unsigned char state,
- family; /* sk->zapped */
+ zapped;
__u16 sport;
__u16 dport;
+ unsigned short family;
+ unsigned char reuse,
+ nonagle;

/* And these are ours. */
__u32 rcv_nxt;
--- net/ipv4/tcp_input.c.~1~ Sun Mar 22 14:07:45 1998
+++ net/ipv4/tcp_input.c Mon Mar 23 14:53:18 1998
@@ -5,7 +5,7 @@
*
* Implementation of the Transmission Control Protocol(TCP).
*
- * Version: $Id: tcp_input.c,v 1.97 1998/03/22 22:10:26 davem Exp $
+ * Version: $Id: tcp_input.c,v 1.98 1998/03/23 22:54:48 davem Exp $
*
* Authors: Ross Biro, <bir7@leland.Stanford.Edu>
* Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
@@ -987,9 +987,10 @@
tw->bound_dev_if= sk->bound_dev_if;
tw->num = sk->num;
tw->state = TCP_TIME_WAIT;
- tw->family = sk->family;
tw->sport = sk->sport;
tw->dport = sk->dport;
+ tw->family = sk->family;
+ tw->reuse = sk->reuse;
tw->rcv_nxt = sk->tp_pinfo.af_tcp.rcv_nxt;
tw->af_specific = sk->tp_pinfo.af_tcp.af_specific;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu