From 04ee0f8f12ff3a1227439c5f67623547d7a5bd11 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Wed, 18 Nov 2009 17:48:30 +1100 Subject: - (djm) [channels.c misc.c misc.h sshd.c] add missing setsockopt() to set IPV6_V6ONLY for local forwarding with GatwayPorts=yes. Unify setting IPV6_V6ONLY behind a new function misc.c:sock_set_v6only() report and fix from jan.kratochvil AT redhat.com --- channels.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'channels.c') diff --git a/channels.c b/channels.c index e8b8aa07..22e7f628 100644 --- a/channels.c +++ b/channels.c @@ -2577,6 +2577,8 @@ channel_setup_fwd_listener(int type, const char *listen_addr, } channel_set_reuseaddr(sock); + if (ai->ai_family == AF_INET6) + sock_set_v6only(sock); debug("Local forwarding listening on %s port %s.", ntop, strport); @@ -3108,13 +3110,8 @@ x11_create_display_inet(int x11_display_offset, int x11_use_localhost, continue; } } -#ifdef IPV6_V6ONLY - if (ai->ai_family == AF_INET6) { - int on = 1; - if (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) < 0) - error("setsockopt IPV6_V6ONLY: %.100s", strerror(errno)); - } -#endif + if (ai->ai_family == AF_INET6) + sock_set_v6only(sock); if (x11_use_localhost) channel_set_reuseaddr(sock); if (bind(sock, ai->ai_addr, ai->ai_addrlen) < 0) { -- cgit v1.2.3