aboutsummaryrefslogtreecommitdiffstats
path: root/main/quagga/quagga-0.99.11-ipv6-only.patch
diff options
context:
space:
mode:
Diffstat (limited to 'main/quagga/quagga-0.99.11-ipv6-only.patch')
-rw-r--r--main/quagga/quagga-0.99.11-ipv6-only.patch29
1 files changed, 29 insertions, 0 deletions
diff --git a/main/quagga/quagga-0.99.11-ipv6-only.patch b/main/quagga/quagga-0.99.11-ipv6-only.patch
new file mode 100644
index 0000000000..53636d6b57
--- /dev/null
+++ b/main/quagga/quagga-0.99.11-ipv6-only.patch
@@ -0,0 +1,29 @@
+On Linux the default behaviour of getaddrinfo is to provide both IPV4 and IPV6
+addresses if available. But the default behaviour of binding to an IPV6 address
+is to handle both the native IPV6 address and IPV4 to IPV6 mapped addresses.
+Without this patch what happens is:
+ 1. First address is IPV6, bind succeeds.
+ 2. Second address is IPV4, bind fails (port already used by IPV6)
+ 3. incoming connections come in on IPV6 listen socket, as IPV4 mapped
+ addresses then BGP gets confused because of client with unexpected address.
+
+The fix is to force IPV6 socket as IPV6 only.
+
+--- a/bgpd/bgp_network.c 2008-08-27 17:59:20.000000000 -0700
++++ b/bgpd/bgp_network.c 2008-08-27 18:02:46.000000000 -0700
+@@ -412,6 +412,15 @@ bgp_socket (struct bgp *bgp, unsigned sh
+ 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");
+