summaryrefslogtreecommitdiff
path: root/bgpd
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2008-08-24 20:36:51 -0400
committerPaul Jakma <paul@quagga.net>2009-05-08 22:59:42 +0100
commite9a3670706edf37c5a863c93e5ef0c269e484eb9 (patch)
tree312ef6b631d3408837f21d9b37d7c47c4693ac2d /bgpd
parent21b86436a8c826da84b47cd773fdffbf3d05141e (diff)
Fix bgp ipv4/ipv6 accept handling
When bgp calls getaddrinfo, it gets both ipv6 and ipv4 addresses. Unless IPV6_ONLY is set on Linux, only the ipv6 bind will succeed, and the IPV4 connections will come in as mapped connections on the IPV6 socket.
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_network.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c
index 5dbd4872..6d16c6ec 100644
--- a/bgpd/bgp_network.c
+++ b/bgpd/bgp_network.c
@@ -412,6 +412,15 @@ bgp_socket (struct bgp *bgp, unsigned short port, char *address)
setsockopt_ipv4_tos (sock, IPTOS_PREC_INTERNETCONTROL);
#endif
+#ifdef IPV6_V6ONLY
+ /* Want only IPV6 on ipv6 socket (not mapped addresses) */
+ if (ainfo->ai_family == AF_INET6) {
+ int on = 1;
+ setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY,
+ (void *) &on, sizeof (on));
+ }
+#endif
+
if (bgpd_privs.change (ZPRIVS_RAISE) )
zlog_err ("bgp_socket: could not raise privs");