Ensure that send() and send_msg() in controller return status to calling applications

When a Datapath disconnects, an application may not know about it
until it attempts to send a message to that Datapath.

Ryu's core will detect the failure to send, and will close the
Datapath object - but has no way of letting the application know that
it did so.

With this patch, send_msg() returns True or False, depending on
whether the message that the application was trying to send was able
to be enqueued to send via a given Datapath object.

If the Datapath.send_msg() returns False, the calling application can
thereby determine that the Datapath is no longer valid, and should
clean up any references it has to it.

Existing applications may choose to ignore the return value, and
nothing breaks.

I have patched one utility method that uses send_msg(), since it was
not marked as deprecated.  All utility methods marked as deprecated, I
have not altered.

Signed-off-by: Victor J. Orlikowski <vjo@duke.edu>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
Victor Orlikowski
2016-08-02 11:02:31 +09:00
committed by FUJITA Tomonori
parent 9ee265ab45
commit 12d6584bee

View File

@@ -319,6 +319,7 @@ class Datapath(ofproto_protocol.ProtocolDesc):
if not msg_enqueued:
LOG.debug('Datapath in process of terminating; send() to %s discarded.',
self.address)
return msg_enqueued
def set_xid(self, msg):
self.xid += 1
@@ -332,7 +333,7 @@ class Datapath(ofproto_protocol.ProtocolDesc):
self.set_xid(msg)
msg.serialize()
# LOG.debug('send_msg %s', msg)
self.send(msg.buf)
return self.send(msg.buf)
def _echo_request_loop(self):
if not self.max_unreplied_echo_requests:
@@ -418,7 +419,7 @@ class Datapath(ofproto_protocol.ProtocolDesc):
def send_barrier(self):
barrier_request = self.ofproto_parser.OFPBarrierRequest(self)
self.send_msg(barrier_request)
return self.send_msg(barrier_request)
def send_nxt_set_flow_format(self, flow_format):
assert (flow_format == ofproto_v1_0.NXFF_OPENFLOW10 or