lib: add sockopt helper for setting IPV6_V6ONLY and use it
getaddrinfo returns a list of socket parameters for listening. it
will contain both IPv4 and IPv6 listening sockets. unless we use
IPV6_V6ONLY on the IPv6 ones, only the socket listed first will
work. if the IPv4 one came first, the IPv6 one would get an
"Address in use" error.
this functionality was already present for bgpd and its listening
sockets. as it is needed for vtys as well, make it a common helper.
diff --git a/lib/vty.c b/lib/vty.c
index bd1dbac..e403159 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -1816,6 +1816,7 @@
if (sock < 0)
continue;
+ sockopt_v6only (ainfo->ai_family, sock);
sockopt_reuseaddr (sock);
sockopt_reuseport (sock);