summaryrefslogtreecommitdiff
path: root/usr.sbin/ldpd
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2010-02-18 10:50:15 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2010-02-18 10:50:15 +0000
commitcabeabb1f3400695ed05818d0aa800d33fff0330 (patch)
treeef07185b3c4a3656f2ae23e5c7857b49bbcf1f28 /usr.sbin/ldpd
parente46ca6c0b0cdf573e217b1d60d75f3363228a7c1 (diff)
We need to set SO_REUSEADDR before doing the bind() of the tcp socket.
It does not help to set SO_REUSEPORT after doing the bind. Fixes failures to start ldpd because of TIME_WAIT sessions. OK michele
Diffstat (limited to 'usr.sbin/ldpd')
-rw-r--r--usr.sbin/ldpd/interface.c6
-rw-r--r--usr.sbin/ldpd/ldpe.c7
2 files changed, 7 insertions, 6 deletions
diff --git a/usr.sbin/ldpd/interface.c b/usr.sbin/ldpd/interface.c
index b921a5d675a..a7dc36147f5 100644
--- a/usr.sbin/ldpd/interface.c
+++ b/usr.sbin/ldpd/interface.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: interface.c,v 1.1 2009/06/01 20:59:45 michele Exp $ */
+/* $OpenBSD: interface.c,v 1.2 2010/02/18 10:50:14 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -431,9 +431,9 @@ if_set_recvbuf(int fd)
int
if_set_reuse(int fd, int enable)
{
- if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &enable,
+ if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &enable,
sizeof(int)) < 0) {
- log_warn("if_set_reuse: error setting SO_REUSEPORT");
+ log_warn("if_set_reuse: error setting SO_REUSEADDR");
return (-1);
}
diff --git a/usr.sbin/ldpd/ldpe.c b/usr.sbin/ldpd/ldpe.c
index 400a6d75a68..e13cb6c795a 100644
--- a/usr.sbin/ldpd/ldpe.c
+++ b/usr.sbin/ldpd/ldpe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldpe.c,v 1.3 2009/06/06 08:09:43 pyr Exp $ */
+/* $OpenBSD: ldpe.c,v 1.4 2010/02/18 10:50:14 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -126,6 +126,9 @@ ldpe(struct ldpd_conf *xconf, int pipe_parent2ldpe[2], int pipe_ldpe2lde[2],
IPPROTO_TCP)) == -1)
fatal("error creating session socket");
+ if (if_set_reuse(xconf->ldp_session_socket, 1) == -1)
+ fatal("if_set_reuse");
+
if (bind(xconf->ldp_session_socket, (struct sockaddr *)&sess_addr,
sizeof(sess_addr)) == -1)
fatal("error binding session socket");
@@ -137,8 +140,6 @@ ldpe(struct ldpd_conf *xconf, int pipe_parent2ldpe[2], int pipe_ldpe2lde[2],
if (if_set_tos(xconf->ldp_session_socket,
IPTOS_PREC_INTERNETCONTROL) == -1)
fatal("if_set_tos");
- if (if_set_reuse(xconf->ldp_session_socket, 1) == -1)
- fatal("if_set_reuse");
if (if_set_nonblock(xconf->ldp_session_socket) == -1)
fatal("if_set_nonblock");