|
1 In-house patch to allow the TCP keepalive parameters from cinder.conf |
|
2 to be used on Solaris. Patch has not yet been submitted upstream. |
|
3 |
|
4 --- cinder-2014.2.2/cinder/openstack/common/network_utils.py.orig 2014-12-04 21:00:20.000000000 -0800 |
|
5 +++ cinder-2014.2.2/cinder/openstack/common/network_utils.py 2015-01-23 18:46:17.465276851 -0800 |
|
6 @@ -18,6 +18,7 @@ Network-related utilities and helper fun |
|
7 """ |
|
8 |
|
9 import socket |
|
10 +import sys |
|
11 |
|
12 from six.moves.urllib import parse |
|
13 |
|
14 @@ -135,26 +136,44 @@ def set_tcp_keepalive(sock, tcp_keepaliv |
|
15 if not tcp_keepalive: |
|
16 return |
|
17 |
|
18 - # These options aren't available in the OS X version of eventlet, |
|
19 - # Idle + Count * Interval effectively gives you the total timeout. |
|
20 - if tcp_keepidle is not None: |
|
21 - if hasattr(socket, 'TCP_KEEPIDLE'): |
|
22 - sock.setsockopt(socket.IPPROTO_TCP, |
|
23 - socket.TCP_KEEPIDLE, |
|
24 - tcp_keepidle) |
|
25 + if sys.platform == 'sunos5': |
|
26 + # Should match definitions in <netinet/tcp.h> |
|
27 + TCP_KEEPALIVE_THRESHOLD = 0x16 |
|
28 + TCP_KEEPALIVE_ABORT_THRESHOLD = 0x17 |
|
29 + |
|
30 + if tcp_keepidle is not None: |
|
31 + sock.setsockopt(socket.IPPROTO_TCP, TCP_KEEPALIVE_THRESHOLD, |
|
32 + tcp_keepidle * 1000) |
|
33 + if tcp_keepalive_interval is None and tcp_keepalive_count is None: |
|
34 + return |
|
35 + if tcp_keepalive_interval is None or tcp_keepalive_count is None: |
|
36 + LOG.warning(_LW('tcp_keepintvl and tcp_keepknt must be set ' |
|
37 + 'together')) |
|
38 else: |
|
39 - LOG.warning(_LW('tcp_keepidle not available on your system')) |
|
40 - if tcp_keepalive_interval is not None: |
|
41 - if hasattr(socket, 'TCP_KEEPINTVL'): |
|
42 - sock.setsockopt(socket.IPPROTO_TCP, |
|
43 - socket.TCP_KEEPINTVL, |
|
44 - tcp_keepalive_interval) |
|
45 - else: |
|
46 - LOG.warning(_LW('tcp_keepintvl not available on your system')) |
|
47 - if tcp_keepalive_count is not None: |
|
48 - if hasattr(socket, 'TCP_KEEPCNT'): |
|
49 - sock.setsockopt(socket.IPPROTO_TCP, |
|
50 - socket.TCP_KEEPCNT, |
|
51 - tcp_keepalive_count) |
|
52 - else: |
|
53 - LOG.warning(_LW('tcp_keepknt not available on your system')) |
|
54 + sock.setsockopt( |
|
55 + socket.IPPROTO_TCP, TCP_KEEPALIVE_ABORT_THRESHOLD, |
|
56 + tcp_keepalive_interval * tcp_keepalive_count * 1000) |
|
57 + else: |
|
58 + # These options aren't available in the OS X version of eventlet, |
|
59 + # Idle + Count * Interval effectively gives you the total timeout. |
|
60 + if tcp_keepidle is not None: |
|
61 + if hasattr(socket, 'TCP_KEEPIDLE'): |
|
62 + sock.setsockopt(socket.IPPROTO_TCP, |
|
63 + socket.TCP_KEEPIDLE, |
|
64 + tcp_keepidle) |
|
65 + else: |
|
66 + LOG.warning(_LW('tcp_keepidle not available on your system')) |
|
67 + if tcp_keepalive_interval is not None: |
|
68 + if hasattr(socket, 'TCP_KEEPINTVL'): |
|
69 + sock.setsockopt(socket.IPPROTO_TCP, |
|
70 + socket.TCP_KEEPINTVL, |
|
71 + tcp_keepalive_interval) |
|
72 + else: |
|
73 + LOG.warning(_LW('tcp_keepintvl not available on your system')) |
|
74 + if tcp_keepalive_count is not None: |
|
75 + if hasattr(socket, 'TCP_KEEPCNT'): |
|
76 + sock.setsockopt(socket.IPPROTO_TCP, |
|
77 + socket.TCP_KEEPCNT, |
|
78 + tcp_keepalive_count) |
|
79 + else: |
|
80 + LOG.warning(_LW('tcp_keepknt not available on your system')) |