[ovs-dev] [PATCH] Add Passive TCP connection to IDL

ofer.benyacov at gmail.com ofer.benyacov at gmail.com
Thu Dec 3 07:56:19 UTC 2015


Currently the IDL does not support passive TCP connection,
i.e. when the OVSDB connects to its manager.

This patch enables IDL to use an already-open session
(the one which was previously used for retrieving the db schema).
In addition, it enables IDL to go back to "listen mode" in case the connection
is lost.

LIMITATIONS:
----------------------

This patch enables a **SINGLE** TCP connection from an OVSDB server to an
agent that uses IDL with {IP,PORT} pair. Therefore, the agent will support
only **ONE** OVSDB server using {IP,PORT} pair.

Future development may add multi-session server capability that will allow
an agent to use single {IP,PORT} pair to connect to multiple OVSDB servers.


CAVEAT:
--------------

When a database first connects to the agent, the agent gets the schema and
data and builds its tables. If the session disconnects, the agent goes back
to "listen mode" and accepts **ANY** TCP connection, which means that if
another database will try to connect to the agent using the same {IP,PORT}
pair, it will be connected to the IDL that has the schema and data from
the first database.

A future patch can resolve this problem.


USAGE:
-------------

To use IDL in passive mode, the following example code can be use:

(snippet)

from ovs.jsonrpc import Session
...

from neutron.agent.ovsdb.native import idlutils

...

session = Session.open('ptcp:192.168.10.10:6640')

# first call to session.run creates the PassiveStream object and second one
# accept incoming connection
session.run()
session.run()

# this static method is similar to the original neutron method but the
# rpc.close() command that would result closing the socket.
helper = idlutils.get_schema_helper_from_stream_no_close(session.stream,
	'hardware_vtep')
helper.register_all()
self.idl = idl.Idl(self.connection, helper, session)
idlutils.wait_for_change(self.idl, self.timeout)

self.poller = poller.Poller()
self.thread = threading.Thread(target=self.run)
self.thread.setDaemon(True)
self.thread.start()


TESTING:
---------------

To be able to test passive TCP to the OVSDB, a helper program was used.
The program flow is:
1. Open TCP connection to OVSDB
2. Open TCP connection to the agent application that uses IDL
3. Forward data between connections (Proxy)
4. Simulate a connection problem by stopping and restarting the program

Signed-off-by: Ofer Ben-Yacov <ofer.benyacov at gmail.com>

Tested-by: Ofer Ben-Yacov <ofer.benyacov at gmail.com>

Requested-by: Ben Pfaff <blp at nicira.com>, "D M, Vikas" <vikas.d-m at hpe.com>,
"Kamat, Maruti Haridas" <maruti.kamat at hpe.com>,
Sukhdev Kapur <sukhdev at arista.com>,
"Migliaccio, Armando" <armando.migliaccio at hpe.com>
---



More information about the dev mailing list