Python std library SSLSocket.send does not allow non-zero value for the 
optional flag.

pyOpenSSL was recently switched for the Python standard library ssl module
commit 68543dd523bd00f53fa7b91777b962ccb22ce679 (python: Replace pyOpenSSL with 
ssl).
Python SSLsocket.send() does not allow non-zero optional flag and it will 
explicitly
raise an exception for that. pyOpenSSL did not nothing with this flag but kept
it to be compatible with socket API.
https://github.com/pyca/pyopenssl/blob/main/src/OpenSSL/SSL.py#L1844

Signed-off-by: Miro Tomaska <mtoma...@redhat.com>
Reported-at: https://bugzilla.redhat.com/2115035
---
 python/ovs/socket_util.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/python/ovs/socket_util.py b/python/ovs/socket_util.py
index 651012bf0..d60123ece 100644
--- a/python/ovs/socket_util.py
+++ b/python/ovs/socket_util.py
@@ -23,6 +23,11 @@ import ovs.fatal_signal
 import ovs.poller
 import ovs.vlog
 
+try:
+    import ssl
+except ImportError:
+    ssl = None
+
 if sys.platform == 'win32':
     import ovs.winutils as winutils
     import win32file
@@ -178,7 +183,12 @@ def check_connection_completion(sock):
         if revents & ovs.poller.POLLERR or revents & ovs.poller.POLLHUP:
             try:
                 # The following should raise an exception.
-                sock.send("\0".encode(), socket.MSG_DONTWAIT)
+                if ssl and isinstance(sock, ssl.SSLSocket):
+                    # a SSL wrapped socket does not allow
+                    # non-zero optional flag.
+                    sock.send("\0".encode())
+                else:
+                    sock.send("\0".encode(), socket.MSG_DONTWAIT)
 
                 # (Here's where we end up if it didn't.)
                 # XXX rate-limit
-- 
2.32.0

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to