Hi. Does the following patch help? (it is totally untested yet).
---------------------------------------------------------------------------
diff --git a/ryu/controller/ofp_handler.py b/ryu/controller/ofp_handler.py
index 63f888a..92d7e01 100644
--- a/ryu/controller/ofp_handler.py
+++ b/ryu/controller/ofp_handler.py
@@ -52,20 +52,35 @@ class OFPHandler(app_manager.RyuApp):
# TODO: check if received version is supported.
# pre 1.0 is not supported
- if msg.version not in datapath.supported_ofp_version:
- # send the error
- 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 = 'unsupported version 0x%x' % msg.version
- datapath.send_msg(error_msg)
- return
-
- # should we again send HELLO with the version that the switch
- # supports?
- # msg.version != datapath.ofproto.OFP_VERSION:
-
- datapath.set_version(msg.version)
+ if hasattr(msg, 'elements'):
+ # TODO: OFPHET_VERSIONBITMAP
+ pass
+ else:
+ usable_versions = [version for version
+ in datapath.supported_ofp_version
+ if version <= msg.version]
+ if not usable_versions:
+ # send the error
+ 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 = 'unsupported version 0x%x' % msg.version
+ datapath.send_msg(error_msg)
+ return
+ version = max(usable_versions)
+ if version != max(msg.version, ev.datapath.ofproto.OFP_VERSION):
+ # What to do?
+ # should we again send HELLO with this version again?
+ 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 = 'no compatible version found: '
+ 'controller 0x%x switch 0x%x' % (
+ ev.datapath.ofproto.OFP_VERSION, msg.version)
+ datapath.send_msg(error_msg)
+ return
+
+ datapath.set_version(version)
# now send feature
features_reqeust = datapath.ofproto_parser.OFPFeaturesRequest(datapath)
---------------------------------------------------------------------------
On Wed, Dec 12, 2012 at 05:47:10PM -0800, Shivaram Mysore wrote:
> Thanks. But, that did not help. Here is the code
>
> import logging
> import struct
> import array
>
> from ryu.controller import handler
> from ryu.controller import ofp_event
> from ryu.ofproto import ofproto_v1_2
> from ryu.ofproto import ofproto_v1_2_parser
> from ryu.base import app_manager
>
> LOG = logging.getLogger('ryu.app.packettest')
>
> class PacketTest(app_manager.RyuApp):
> OFP_VERSIONS = [ofproto_v1_2.OFP_VERSION]
>
> def __init__(self, *args, **kwargs):
> pass
>
> @handler.set_ev_cls(ofp_event.EventOFPPacketIn, handler.MAIN_DISPATCHER)
> def packet_in_handler(self, ev):
> msg = ev.msg
> dp = msg.datapath
> for f in msg.match.fields:
> if f.header == ofproto_v1_2.OXM_OF_IN_PORT:
> in_port = f.value
>
> actions = [dp.ofproto_parser.OFPActionOutput(dp.ofproto.OFPP_ALL, 0)]
> out = dp.ofproto_parser.OFPPacketOut(
> datapath=dp, buffer_id=msg.buffer_id, in_port=in_port,
> actions=actions)
> LOG.debug("Sending message out %s", out)
> dp.send_msg(out)
>
>
> On the switch side, I see:
> Connection to controller closed because of {"localhost",6633,0,
> {unsupported_version,4}}
>
>
> On Wed, Dec 12, 2012 at 5:40 PM, FUJITA Tomonori
> <[email protected]
> > wrote:
>
> class PacketTest(app_manager.RyuApp):
> OFP_VERSIONS = [ofproto_v1_2.OFP_VERSION]
>
> def __init__(self, *args, **kwargs):
> pass
>
>
>
>
> ------------------------------------------------------------------------------
> LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
> Remotely access PCs and mobile devices and provide instant support
> Improve your efficiency, and focus on delivering more value-add services
> Discover what IT Professionals Know. Rescue delivers
> http://p.sf.net/sfu/logmein_12329d2d
> _______________________________________________
> Ryu-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
--
yamahata
------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel