diff options
author | Angelos D. Keromytis <angelos@cvs.openbsd.org> | 2001-08-23 23:32:36 +0000 |
---|---|---|
committer | Angelos D. Keromytis <angelos@cvs.openbsd.org> | 2001-08-23 23:32:36 +0000 |
commit | 0bff693df4f4b002fb94517b0c072198e72bec99 (patch) | |
tree | 61218a9179ed39a67fc849b5adad082feab4ef02 /sbin/isakmpd/udp.c | |
parent | 609abece174c8f84050581cc4d1e6f64a6fd3542 (diff) |
Make the wildcard address use SO_REUSEPORT, so multiple instances of
isakmpd can run on the same machine and reuse the wildcard
address. This is intended mostly for debugging and testing purposes,
so multiple listener issues are not relevant.
Diffstat (limited to 'sbin/isakmpd/udp.c')
-rw-r--r-- | sbin/isakmpd/udp.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/sbin/isakmpd/udp.c b/sbin/isakmpd/udp.c index 7f45859f8f7..3ed3056d716 100644 --- a/sbin/isakmpd/udp.c +++ b/sbin/isakmpd/udp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp.c,v 1.49 2001/08/23 23:11:02 angelos Exp $ */ +/* $OpenBSD: udp.c,v 1.50 2001/08/23 23:32:35 angelos Exp $ */ /* $EOM: udp.c,v 1.57 2001/01/26 10:09:57 niklas Exp $ */ /* @@ -136,7 +136,7 @@ static struct transport * udp_make (struct sockaddr *laddr) { struct udp_transport *t = 0; - int s, on; + int s, on, wildcardaddress = 0; t = calloc (1, sizeof *t); if (!t) @@ -157,6 +157,19 @@ udp_make (struct sockaddr *laddr) if (sysdep_cleartext (s, laddr->sa_family) == -1) goto err; + /* Wildcard address ? */ + switch (laddr->sa_family) + { + case AF_INET: + if (((struct sockaddr_in *)laddr)->sin_addr.s_addr == INADDR_ANY) + wildcardaddress = 1; + break; + case AF_INET6: + if (IN6_IS_ADDR_UNSPECIFIED(&((struct sockaddr_in6 *)laddr)->sin6_addr)) + wildcardaddress = 1; + break; + } + /* * In order to have several bound specific address-port combinations * with the same port SO_REUSEADDR is needed. @@ -165,23 +178,11 @@ udp_make (struct sockaddr *laddr) */ on = 1; if (setsockopt (s, SOL_SOCKET, -#if 0 - (laddr->sin_addr.s_addr == INADDR_ANY - && conf_get_str ("General", "Listen-on")) - ? SO_REUSEPORT : SO_REUSEADDR, -#else - SO_REUSEADDR, -#endif + wildcardaddress ? SO_REUSEPORT : SO_REUSEADDR, (void *)&on, sizeof on) == -1) { log_error ("udp_make: setsockopt (%d, %d, %d, %p, %d)", s, SOL_SOCKET, -#if 0 - (laddr->sin_addr.s_addr == INADDR_ANY - && conf_get_str ("General", "Listen-on")) - ? SO_REUSEPORT : SO_REUSEADDR, -#else - SO_REUSEADDR, -#endif + wildcardaddress ? SO_REUSEPORT : SO_REUSEADDR, &on, sizeof on); goto err; } @@ -658,7 +659,6 @@ udp_init (void) log_error ("udp_init: could not allocate default IPv4 ISAKMP UDP port"); return; } - LIST_INSERT_HEAD (&udp_listen_list, (struct udp_transport *)default_transport, link); |