[ovs-git] [openvswitch/ovs] 3f550f: python: socket-util: Split inet_open_active functi...

Timothy Redaelli noreply at github.com
Wed Nov 3 15:03:04 UTC 2021


  Branch: refs/heads/master
  Home:   https://github.com/openvswitch/ovs
  Commit: 3f550fa53824be9ba65e8095d3e97d713be388c9
      https://github.com/openvswitch/ovs/commit/3f550fa53824be9ba65e8095d3e97d713be388c9
  Author: Timothy Redaelli <tredaelli at redhat.com>
  Date:   2021-11-03 (Wed, 03 Nov 2021)

  Changed paths:
    M python/ovs/socket_util.py

  Log Message:
  -----------
  python: socket-util: Split inet_open_active function and use connect_ex.

In an upcoming patch, PyOpenSSL will be replaced with Python ssl module,
but in order to do an async connection with Python ssl module the ssl
socket must be created when the socket is created, but before the
socket is connected.

So, inet_open_active function is splitted in 3 parts:
- inet_create_socket_active: creates the socket and returns the family and
  the socket, or (error, None) if some error needs to be returned.
- inet_connect_active: connect the socket and returns the errno (it
  returns 0 if errno is EINPROGRESS or EWOULDBLOCK).

connect is replaced by connect_ex, since Python suggest to use it for
asynchronous connects and it's also cleaner since inet_connect_active
returns errno that connect_ex already returns, moreover due to a Python
limitation connect cannot not be used with ssl module.

inet_open_active function is changed in order to use the new functions
inet_create_socket_active and inet_connect_active.

Signed-off-by: Timothy Redaelli <tredaelli at redhat.com>
Acked-by: Terry Wilson <twilson at redhat.com>
Tested-by: Terry Wilson <twilson at redhat.com>
Signed-off-by: Ilya Maximets <i.maximets at ovn.org>


  Commit: 68543dd523bd00f53fa7b91777b962ccb22ce679
      https://github.com/openvswitch/ovs/commit/68543dd523bd00f53fa7b91777b962ccb22ce679
  Author: Timothy Redaelli <tredaelli at redhat.com>
  Date:   2021-11-03 (Wed, 03 Nov 2021)

  Changed paths:
    M .ci/linux-prepare.sh
    M .cirrus.yml
    M .travis.yml
    M NEWS
    M python/ovs/poller.py
    M python/ovs/stream.py
    M tests/ovsdb-idl.at

  Log Message:
  -----------
  python: Replace pyOpenSSL with ssl.

Currently, pyOpenSSL is half-deprecated upstream and so it's removed on
some distributions (for example on CentOS Stream 9,
https://issues.redhat.com/browse/CS-336), but since OVS only
supports Python 3 it's possible to replace pyOpenSSL with "import ssl"
included in base Python 3.

Stream recv and send had to be splitted as _recv and _send, since SSLError
is a subclass of socket.error and so it was not possible to except for
SSLWantReadError and SSLWantWriteError in recv and send of SSLStream.

TCPstream._open cannot be used in SSLStream, since Python ssl module
requires the SSL socket to be created before connecting it, so
SSLStream._open needs to create the socket, create SSL socket and then
connect the SSL socket.

Reported-by: Timothy Redaelli <tredaelli at redhat.com>
Reported-at: https://bugzilla.redhat.com/1988429
Signed-off-by: Timothy Redaelli <tredaelli at redhat.com>
Acked-by: Terry Wilson <twilson at redhat.com>
Tested-by: Terry Wilson <twilson at redhat.com>
Signed-off-by: Ilya Maximets <i.maximets at ovn.org>


Compare: https://github.com/openvswitch/ovs/compare/56c3de3c61e6...68543dd523bd


More information about the git mailing list