ryu.app.ofctl: Handle a race with connection close
Report the failure to the client rather than crashing. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
f10f4f7cfd
commit
5d993c46ee
@ -35,3 +35,12 @@ class OFError(_ExceptionBase):
|
||||
"""OFPErrorMsg is received."""
|
||||
|
||||
message = 'OpenFlow errors %(result)s'
|
||||
|
||||
|
||||
class InvalidDatapath(_ExceptionBase):
|
||||
"""Datapath is invalid.
|
||||
|
||||
This can happen when the bridge disconnects.
|
||||
"""
|
||||
|
||||
message = 'Datapath Invalid %(result)s'
|
||||
|
@ -109,18 +109,26 @@ class OfctlService(app_manager.RyuApp):
|
||||
|
||||
@set_ev_cls(event.SendMsgRequest, MAIN_DISPATCHER)
|
||||
def _handle_send_msg(self, req):
|
||||
msg = req.msg
|
||||
datapath = msg.datapath
|
||||
|
||||
try:
|
||||
si = self._switches[datapath.id]
|
||||
except KeyError:
|
||||
self.logger.error('unknown dpid %s' % (datapath.id,))
|
||||
rep = event.Reply(exception=exception.
|
||||
InvalidDatapath(result=datapath.id))
|
||||
self.reply_to_request(req, rep)
|
||||
return
|
||||
|
||||
if req.reply_cls is not None:
|
||||
self._observe_msg(req.reply_cls)
|
||||
|
||||
msg = req.msg
|
||||
datapath = msg.datapath
|
||||
datapath.set_xid(msg)
|
||||
xid = msg.xid
|
||||
barrier = datapath.ofproto_parser.OFPBarrierRequest(datapath)
|
||||
datapath.set_xid(barrier)
|
||||
barrier_xid = barrier.xid
|
||||
|
||||
si = self._switches[datapath.id]
|
||||
assert xid not in si.results
|
||||
assert xid not in si.xids
|
||||
assert barrier_xid not in si.barriers
|
||||
|
Loading…
x
Reference in New Issue
Block a user