Skip to content

Commit

Permalink
python: Add TCP/SSL probes for OVSDB python lib
Browse files Browse the repository at this point in the history
stream_or_pstream_needs_probes always return 0. This causes TCP/SSL
connection not be probed, and no reconnect when the connection
is aborted

Signed-off-by: Guoshuai Li <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
Guoshuai Li authored and blp committed Jan 4, 2017
1 parent 6abf494 commit e7dce33
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions python/ovs/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,18 @@


def stream_or_pstream_needs_probes(name):
""" 1 if the stream or pstream specified by 'name' needs periodic probes to
verify connectivity. For [p]streams which need probes, it can take a long
time to notice the connection was dropped. Returns 0 if probes aren't
needed, and -1 if 'name' is invalid"""

if PassiveStream.is_valid_name(name) or Stream.is_valid_name(name):
# Only unix and punix are supported currently.
return 0
""" True if the stream or pstream specified by 'name' needs periodic probes
to verify connectivity. For [p]streams which need probes, it can take a
long time to notice the connection was dropped. Returns False if probes
aren't needed, and None if 'name' is invalid"""

cls = Stream._find_method(name)
if cls:
return cls.needs_probes()
elif PassiveStream.is_valid_name(name):
return PassiveStream.needs_probes(name)
else:
return -1
return None


class Stream(object):
Expand Down Expand Up @@ -524,6 +526,10 @@ class PassiveStream(object):
connect = None # overlapped for read operation
connect_pending = False

@staticmethod
def needs_probes(name):
return False if name.startswith("punix:") else True

@staticmethod
def is_valid_name(name):
"""Returns True if 'name' is a passive stream name in the form
Expand Down Expand Up @@ -708,6 +714,10 @@ def usage(name):


class UnixStream(Stream):
@staticmethod
def needs_probes():
return False

@staticmethod
def _open(suffix, dscp):
connect_path = suffix
Expand All @@ -719,6 +729,10 @@ def _open(suffix, dscp):


class TCPStream(Stream):
@staticmethod
def needs_probes():
return True

@staticmethod
def _open(suffix, dscp):
error, sock = ovs.socket_util.inet_open_active(socket.SOCK_STREAM,
Expand All @@ -732,6 +746,9 @@ def _open(suffix, dscp):


class SSLStream(Stream):
@staticmethod
def needs_probes():
return True

@staticmethod
def verify_cb(conn, cert, errnum, depth, ok):
Expand Down

0 comments on commit e7dce33

Please sign in to comment.