author | Devjani Ray <devjani.ray@oracle.com> |
Fri, 20 May 2016 17:42:29 -0400 | |
branch | s11u3-sru |
changeset 6035 | c9748fcc32de |
permissions | -rw-r--r-- |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
1 |
In-house patch to allow the TCP keepalive parameters to be used on Solaris. |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
2 |
Patch has not yet been submitted upstream. |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
3 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
4 |
--- oslo.utils-1.4.0/oslo_utils/netutils.py.orig 2015-10-21 10:11:23.275736933 -0600 |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
5 |
+++ oslo.utils-1.4.0/oslo_utils/netutils.py 2015-10-21 10:11:26.709349827 -0600 |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
6 |
@@ -20,6 +20,7 @@ Network-related utilities and helper fun |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
7 |
import logging |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
8 |
import os |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
9 |
import socket |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
10 |
+import sys |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
11 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
12 |
import netaddr |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
13 |
import netifaces |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
14 |
@@ -317,26 +317,44 @@ def set_tcp_keepalive(sock, tcp_keepaliv |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
15 |
if not tcp_keepalive: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
16 |
return |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
17 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
18 |
- # These options aren't available in the OS X version of eventlet, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
19 |
- # Idle + Count * Interval effectively gives you the total timeout. |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
20 |
- if tcp_keepidle is not None: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
21 |
- if hasattr(socket, 'TCP_KEEPIDLE'): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
22 |
- sock.setsockopt(socket.IPPROTO_TCP, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
23 |
- socket.TCP_KEEPIDLE, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
24 |
- tcp_keepidle) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
25 |
- else: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
26 |
- LOG.warning(_LW('tcp_keepidle not available on your system')) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
27 |
- if tcp_keepalive_interval is not None: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
28 |
- if hasattr(socket, 'TCP_KEEPINTVL'): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
29 |
- sock.setsockopt(socket.IPPROTO_TCP, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
30 |
- socket.TCP_KEEPINTVL, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
31 |
- tcp_keepalive_interval) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
32 |
- else: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
33 |
- LOG.warning(_LW('tcp_keepintvl not available on your system')) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
34 |
- if tcp_keepalive_count is not None: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
35 |
- if hasattr(socket, 'TCP_KEEPCNT'): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
36 |
- sock.setsockopt(socket.IPPROTO_TCP, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
37 |
- socket.TCP_KEEPCNT, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
38 |
- tcp_keepalive_count) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
39 |
+ if sys.platform == 'sunos5': |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
40 |
+ # Should match definitions in <netinet/tcp.h> |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
41 |
+ TCP_KEEPALIVE_THRESHOLD = 0x16 |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
42 |
+ TCP_KEEPALIVE_ABORT_THRESHOLD = 0x17 |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
43 |
+ |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
44 |
+ if tcp_keepidle is not None: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
45 |
+ sock.setsockopt(socket.IPPROTO_TCP, TCP_KEEPALIVE_THRESHOLD, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
46 |
+ tcp_keepidle * 1000) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
47 |
+ if tcp_keepalive_interval is None and tcp_keepalive_count is None: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
48 |
+ return |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
49 |
+ if tcp_keepalive_interval is None or tcp_keepalive_count is None: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
50 |
+ LOG.warning(_LW('tcp_keepintvl and tcp_keepknt must be set ' |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
51 |
+ 'together')) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
52 |
else: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
53 |
- LOG.warning(_LW('tcp_keepcnt not available on your system')) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
54 |
+ sock.setsockopt( |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
55 |
+ socket.IPPROTO_TCP, TCP_KEEPALIVE_ABORT_THRESHOLD, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
56 |
+ tcp_keepalive_interval * tcp_keepalive_count * 1000) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
57 |
+ else: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
58 |
+ # These options aren't available in the OS X version of eventlet, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
59 |
+ # Idle + Count * Interval effectively gives you the total timeout. |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
60 |
+ if tcp_keepidle is not None: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
61 |
+ if hasattr(socket, 'TCP_KEEPIDLE'): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
62 |
+ sock.setsockopt(socket.IPPROTO_TCP, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
63 |
+ socket.TCP_KEEPIDLE, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
64 |
+ tcp_keepidle) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
65 |
+ else: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
66 |
+ LOG.warning(_LW('tcp_keepidle not available on your system')) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
67 |
+ if tcp_keepalive_interval is not None: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
68 |
+ if hasattr(socket, 'TCP_KEEPINTVL'): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
69 |
+ sock.setsockopt(socket.IPPROTO_TCP, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
70 |
+ socket.TCP_KEEPINTVL, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
71 |
+ tcp_keepalive_interval) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
72 |
+ else: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
73 |
+ LOG.warning(_LW('tcp_keepintvl not available on your system')) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
74 |
+ if tcp_keepalive_count is not None: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
75 |
+ if hasattr(socket, 'TCP_KEEPCNT'): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
76 |
+ sock.setsockopt(socket.IPPROTO_TCP, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
77 |
+ socket.TCP_KEEPCNT, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
78 |
+ tcp_keepalive_count) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
79 |
+ else: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff
changeset
|
80 |
+ LOG.warning(_LW('tcp_keepcnt not available on your system')) |