From: yasuoka Date: Mon, 1 Jul 2024 05:18:16 +0000 (+0000) Subject: Set SO_REUSEADDR for the listening socket. This makes radiusd(8) X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=55b9f5bef6a12de5e77ff1b41da0ed009b86eaa1;p=openbsd Set SO_REUSEADDR for the listening socket. This makes radiusd(8) can bind both on an interface address and a wildcard address. --- diff --git a/usr.sbin/radiusd/radiusd.c b/usr.sbin/radiusd/radiusd.c index 91f4a112c96..c40b0754481 100644 --- a/usr.sbin/radiusd/radiusd.c +++ b/usr.sbin/radiusd/radiusd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: radiusd.c,v 1.40 2024/07/01 03:48:57 yasuoka Exp $ */ +/* $OpenBSD: radiusd.c,v 1.41 2024/07/01 05:18:16 yasuoka Exp $ */ /* * Copyright (c) 2013, 2023 Internet Initiative Japan Inc. @@ -204,7 +204,7 @@ radiusd_start(struct radiusd *radiusd) { struct radiusd_listen *l; struct radiusd_module *module; - int s; + int s, on; char hbuf[NI_MAXHOST]; TAILQ_FOREACH(l, &radiusd->listen, next) { @@ -220,6 +220,12 @@ radiusd_start(struct radiusd *radiusd) hbuf, (int)htons(l->addr.ipv4.sin_port)); goto on_error; } + + on = 1; + if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) + == -1) + log_warn("%s: setsockopt(,,SO_REUSEADDR) failed: %m", + __func__); if (bind(s, (struct sockaddr *)&l->addr, l->addr.ipv4.sin_len) != 0) { log_warn("Listen %s port %d is failed: bind()",