diff options
-rw-r--r-- | ryu/controller/ofp_handler.py | 11 | ||||
-rw-r--r-- | ryu/ofproto/ofproto_v1_0_parser.py | 2 | ||||
-rw-r--r-- | ryu/ofproto/ofproto_v1_2_parser.py | 2 | ||||
-rw-r--r-- | ryu/ofproto/ofproto_v1_3_parser.py | 2 | ||||
-rw-r--r-- | ryu/ofproto/ofproto_v1_4_parser.py | 2 | ||||
-rw-r--r-- | ryu/ofproto/ofproto_v1_5_parser.py | 2 |
6 files changed, 16 insertions, 5 deletions
diff --git a/ryu/controller/ofp_handler.py b/ryu/controller/ofp_handler.py index 6ab02fe8..5c4d46de 100644 --- a/ryu/controller/ofp_handler.py +++ b/ryu/controller/ofp_handler.py @@ -60,11 +60,12 @@ class OFPHandler(ryu.base.app_manager.RyuApp): return hub.spawn(self.controller) def _hello_failed(self, datapath, error_desc): - self.logger.error(error_desc) - error_msg = datapath.ofproto_parser.OFPErrorMsg(datapath) - error_msg.type = datapath.ofproto.OFPET_HELLO_FAILED - error_msg.code = datapath.ofproto.OFPHFC_INCOMPATIBLE - error_msg.data = error_desc + self.logger.error('%s on datapath %s', error_desc, datapath.address) + error_msg = datapath.ofproto_parser.OFPErrorMsg( + datapath=datapath, + type_=datapath.ofproto.OFPET_HELLO_FAILED, + code=datapath.ofproto.OFPHFC_INCOMPATIBLE, + data=error_desc) datapath.send_msg(error_msg, close_socket=True) @set_ev_handler(ofp_event.EventOFPHello, HANDSHAKE_DISPATCHER) diff --git a/ryu/ofproto/ofproto_v1_0_parser.py b/ryu/ofproto/ofproto_v1_0_parser.py index bfc55512..a288964a 100644 --- a/ryu/ofproto/ofproto_v1_0_parser.py +++ b/ryu/ofproto/ofproto_v1_0_parser.py @@ -1258,6 +1258,8 @@ class OFPErrorMsg(MsgBase): super(OFPErrorMsg, self).__init__(datapath) self.type = type_ self.code = code + if isinstance(data, six.string_types): + data = data.encode('ascii') self.data = data @classmethod diff --git a/ryu/ofproto/ofproto_v1_2_parser.py b/ryu/ofproto/ofproto_v1_2_parser.py index 9b4dda4b..244126c3 100644 --- a/ryu/ofproto/ofproto_v1_2_parser.py +++ b/ryu/ofproto/ofproto_v1_2_parser.py @@ -141,6 +141,8 @@ class OFPErrorMsg(MsgBase): super(OFPErrorMsg, self).__init__(datapath) self.type = type_ self.code = code + if isinstance(data, six.string_types): + data = data.encode('ascii') self.data = data if self.type == ofproto.OFPET_EXPERIMENTER: self.exp_type = kwargs.get('exp_type', None) diff --git a/ryu/ofproto/ofproto_v1_3_parser.py b/ryu/ofproto/ofproto_v1_3_parser.py index 7730aa12..0324c82b 100644 --- a/ryu/ofproto/ofproto_v1_3_parser.py +++ b/ryu/ofproto/ofproto_v1_3_parser.py @@ -251,6 +251,8 @@ class OFPErrorMsg(MsgBase): super(OFPErrorMsg, self).__init__(datapath) self.type = type_ self.code = code + if isinstance(data, six.string_types): + data = data.encode('ascii') self.data = data if self.type == ofproto.OFPET_EXPERIMENTER: self.exp_type = kwargs.get('exp_type', None) diff --git a/ryu/ofproto/ofproto_v1_4_parser.py b/ryu/ofproto/ofproto_v1_4_parser.py index fca35f57..470e2013 100644 --- a/ryu/ofproto/ofproto_v1_4_parser.py +++ b/ryu/ofproto/ofproto_v1_4_parser.py @@ -262,6 +262,8 @@ class OFPErrorMsg(MsgBase): super(OFPErrorMsg, self).__init__(datapath) self.type = type_ self.code = code + if isinstance(data, six.string_types): + data = data.encode('ascii') self.data = data if self.type == ofproto.OFPET_EXPERIMENTER: self.exp_type = kwargs.get('exp_type', None) diff --git a/ryu/ofproto/ofproto_v1_5_parser.py b/ryu/ofproto/ofproto_v1_5_parser.py index 03946622..c19a7e8d 100644 --- a/ryu/ofproto/ofproto_v1_5_parser.py +++ b/ryu/ofproto/ofproto_v1_5_parser.py @@ -262,6 +262,8 @@ class OFPErrorMsg(MsgBase): super(OFPErrorMsg, self).__init__(datapath) self.type = type_ self.code = code + if isinstance(data, six.string_types): + data = data.encode('ascii') self.data = data if self.type == ofproto.OFPET_EXPERIMENTER: self.exp_type = kwargs.get('exp_type', None) |