From fa3e0a31c7d1566569bc75b199858cfa0f45ab45 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Sun, 24 Feb 2019 12:04:33 -0800 Subject: [PATCH] scoutfs: use SO_REUSEADDR for server socket The server's listening address is fixed by the raft config in the super block. If it shuts down and rapidly starts back up it needs to bind to the currently lingering address. Signed-off-by: Zach Brown --- kmod/src/net.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kmod/src/net.c b/kmod/src/net.c index 98aae7b4..fae167f8 100644 --- a/kmod/src/net.c +++ b/kmod/src/net.c @@ -1360,6 +1360,7 @@ int scoutfs_net_bind(struct super_block *sb, { struct socket *sock = NULL; int addrlen; + int optval; int ret; /* caller state machine shouldn't let this happen */ @@ -1370,6 +1371,12 @@ int scoutfs_net_bind(struct super_block *sb, if (ret) goto out; + optval = 1; + ret = kernel_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, + (char *)&optval, sizeof(optval)); + if (ret) + goto out; + addrlen = sizeof(struct sockaddr_in); ret = kernel_bind(sock, (struct sockaddr *)sin, addrlen); if (ret)