diff options
author | jmg <jmg@FreeBSD.org> | 2015-06-20 07:49:08 +0000 |
---|---|---|
committer | jmg <jmg@FreeBSD.org> | 2015-06-20 07:49:08 +0000 |
commit | 2f2647539a76cc44cd8721c0b8e54b3d70f15786 (patch) | |
tree | 892ae5638995b8ea6546b36b84013b6cb48a0f68 /usr.sbin | |
parent | d3c1e818051e7ee547068d84491c15e7ba53f4f0 (diff) | |
download | FreeBSD-src-2f2647539a76cc44cd8721c0b8e54b3d70f15786.zip FreeBSD-src-2f2647539a76cc44cd8721c0b8e54b3d70f15786.tar.gz |
add SO_REUSEADDR when starting debug port, lets you still bind when
a TIME_WAIT socket is still around...
Reviewed by: grehan
Review: https://reviews.freebsd.org/D2875
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bhyve/dbgport.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/usr.sbin/bhyve/dbgport.c b/usr.sbin/bhyve/dbgport.c index 534ae65..5be0ceb 100644 --- a/usr.sbin/bhyve/dbgport.c +++ b/usr.sbin/bhyve/dbgport.c @@ -116,6 +116,8 @@ SYSRES_IO(BVM_DBG_PORT, 4); void init_dbgport(int sport) { + int reuse; + conn_fd = -1; if ((listen_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { @@ -128,6 +130,13 @@ init_dbgport(int sport) sin.sin_addr.s_addr = htonl(INADDR_ANY); sin.sin_port = htons(sport); + reuse = 1; + if (setsockopt(listen_fd, SOL_SOCKET, SO_REUSEADDR, &reuse, + sizeof(reuse)) < 0) { + perror("setsockopt"); + exit(1); + } + if (bind(listen_fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) { perror("bind"); exit(1); |