In-house patch to allow the TCP keepalive parameters to be used on Solaris.
Patch has not yet been submitted upstream.
--- oslo.utils-1.4.0/oslo_utils/netutils.py.orig 2015-10-21 10:11:23.275736933 -0600
+++ oslo.utils-1.4.0/oslo_utils/netutils.py 2015-10-21 10:11:26.709349827 -0600
@@ -20,6 +20,7 @@ Network-related utilities and helper fun
import logging
import os
import socket
+import sys
import netaddr
import netifaces
@@ -317,26 +317,44 @@ def set_tcp_keepalive(sock, tcp_keepaliv
if not tcp_keepalive:
return
- # These options aren't available in the OS X version of eventlet,
- # Idle + Count * Interval effectively gives you the total timeout.
- if tcp_keepidle is not None:
- if hasattr(socket, 'TCP_KEEPIDLE'):
- tcp_keepidle)
- else:
- LOG.warning(_LW('tcp_keepidle not available on your system'))
- if tcp_keepalive_interval is not None:
- if hasattr(socket, 'TCP_KEEPINTVL'):
- tcp_keepalive_interval)
- else:
- LOG.warning(_LW('tcp_keepintvl not available on your system'))
- if tcp_keepalive_count is not None:
- if hasattr(socket, 'TCP_KEEPCNT'):
- tcp_keepalive_count)
+ if sys.platform == 'sunos5':
+ # Should match definitions in <netinet/tcp.h>
+ TCP_KEEPALIVE_THRESHOLD = 0x16
+ TCP_KEEPALIVE_ABORT_THRESHOLD = 0x17
+
+ if tcp_keepidle is not None:
+ sock.setsockopt(socket.IPPROTO_TCP, TCP_KEEPALIVE_THRESHOLD,
+ tcp_keepidle * 1000)
+ if tcp_keepalive_interval is None and tcp_keepalive_count is None:
+ return
+ if tcp_keepalive_interval is None or tcp_keepalive_count is None:
+ LOG.warning(_LW('tcp_keepintvl and tcp_keepknt must be set '
+ 'together'))
else:
- LOG.warning(_LW('tcp_keepcnt not available on your system'))
+ socket.IPPROTO_TCP, TCP_KEEPALIVE_ABORT_THRESHOLD,
+ tcp_keepalive_interval * tcp_keepalive_count * 1000)
+ else:
+ # These options aren't available in the OS X version of eventlet,
+ # Idle + Count * Interval effectively gives you the total timeout.
+ if tcp_keepidle is not None:
+ if hasattr(socket, 'TCP_KEEPIDLE'):
+ tcp_keepidle)
+ else:
+ LOG.warning(_LW('tcp_keepidle not available on your system'))
+ if tcp_keepalive_interval is not None:
+ if hasattr(socket, 'TCP_KEEPINTVL'):
+ tcp_keepalive_interval)
+ else:
+ LOG.warning(_LW('tcp_keepintvl not available on your system'))
+ if tcp_keepalive_count is not None:
+ if hasattr(socket, 'TCP_KEEPCNT'):
+ tcp_keepalive_count)
+ else:
+ LOG.warning(_LW('tcp_keepcnt not available on your system'))