From ca0512692156d5bbb902523d2f123fc89dbec1ab Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Sun, 4 Oct 2009 16:21:49 +0200 Subject: 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. Conflicts: lib/sockunion.c --- bgpd/bgp_network.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'bgpd/bgp_network.c') diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c index 274a989d..a7dca531 100644 --- a/bgpd/bgp_network.c +++ b/bgpd/bgp_network.c @@ -395,14 +395,7 @@ bgp_listener (int sock, struct sockaddr *sa, socklen_t salen) # endif #endif -#ifdef IPV6_V6ONLY - /* Want only IPV6 on ipv6 socket (not mapped addresses) */ - if (sa->sa_family == AF_INET6) { - int on = 1; - setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY, - (void *) &on, sizeof (on)); - } -#endif + sockopt_v6only (sa->sa_family, sock); ret = bind (sock, sa, salen); en = errno; -- cgit v1.2.1