The representation of oxm_type/oxs_type is an int type value if OXM/OXS in OpenFlowBasic class, but a tuple type value if in Experimenter class. So, Python3 may fail to sort a list of OXM/OXS fields by using oxm_type/oxs_type. This patch adds 'key' parameter into sort() method and enables to sort a list which contains both OpenFlowBasic and Experimenter.
Signed-off-by: IWASE Yusuke <[email protected]> --- ryu/ofproto/ofproto_v1_2_parser.py | 3 ++- ryu/ofproto/ofproto_v1_3_parser.py | 3 ++- ryu/ofproto/ofproto_v1_4_parser.py | 3 ++- ryu/ofproto/ofproto_v1_5_parser.py | 9 ++++++--- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ryu/ofproto/ofproto_v1_2_parser.py b/ryu/ofproto/ofproto_v1_2_parser.py index 28debf8..696154f 100644 --- a/ryu/ofproto/ofproto_v1_2_parser.py +++ b/ryu/ofproto/ofproto_v1_2_parser.py @@ -3398,7 +3398,8 @@ class OFPMatch(StringifyMixin): in kwargs.items()] # assumption: sorting by OXM type values makes fields # meet ordering requirements (eg. eth_type before ipv4_src) - fields.sort() + fields.sort( + key=lambda x: x[0][0] if isinstance(x[0], tuple) else x[0]) self._fields2 = [ofproto.oxm_to_user(n, v, m) for (n, v, m) in fields] diff --git a/ryu/ofproto/ofproto_v1_3_parser.py b/ryu/ofproto/ofproto_v1_3_parser.py index 950f039..44c939c 100644 --- a/ryu/ofproto/ofproto_v1_3_parser.py +++ b/ryu/ofproto/ofproto_v1_3_parser.py @@ -832,7 +832,8 @@ class OFPMatch(StringifyMixin): in kwargs.items()] # assumption: sorting by OXM type values makes fields # meet ordering requirements (eg. eth_type before ipv4_src) - fields.sort() + fields.sort( + key=lambda x: x[0][0] if isinstance(x[0], tuple) else x[0]) self._fields2 = [ofproto.oxm_to_user(n, v, m) for (n, v, m) in fields] diff --git a/ryu/ofproto/ofproto_v1_4_parser.py b/ryu/ofproto/ofproto_v1_4_parser.py index d3fc87c..6b353ca 100644 --- a/ryu/ofproto/ofproto_v1_4_parser.py +++ b/ryu/ofproto/ofproto_v1_4_parser.py @@ -716,7 +716,8 @@ class OFPMatch(StringifyMixin): in kwargs.items()] # assumption: sorting by OXM type values makes fields # meet ordering requirements (eg. eth_type before ipv4_src) - fields.sort() + fields.sort( + key=lambda x: x[0][0] if isinstance(x[0], tuple) else x[0]) self._fields2 = [ofproto.oxm_to_user(n, v, m) for (n, v, m) in fields] diff --git a/ryu/ofproto/ofproto_v1_5_parser.py b/ryu/ofproto/ofproto_v1_5_parser.py index aa03e5a..afce9d7 100644 --- a/ryu/ofproto/ofproto_v1_5_parser.py +++ b/ryu/ofproto/ofproto_v1_5_parser.py @@ -717,7 +717,8 @@ class OFPMatch(StringifyMixin): in kwargs.items()] # assumption: sorting by OXM type values makes fields # meet ordering requirements (eg. eth_type before ipv4_src) - fields.sort() + fields.sort( + key=lambda x: x[0][0] if isinstance(x[0], tuple) else x[0]) self._fields2 = [ofproto.oxm_to_user(n, v, m) for (n, v, m) in fields] @@ -859,7 +860,8 @@ class OFPStats(StringifyMixin): fields = [ofproto.oxs_from_user(k, v) for (k, v) in kwargs.items()] # sort by OXS type values - fields.sort() + fields.sort( + key=lambda x: x[0][0] if isinstance(x[0], tuple) else x[0]) # No mask self.fields = [ofproto.oxs_to_user(n, v, None) for (n, v, _) in fields] @@ -2203,7 +2205,8 @@ class OFPTableFeaturePropOxmValues(OFPTableFeatureProp): in kwargs.items()] # assumption: sorting by OXM type values makes fields # meet ordering requirements (eg. eth_type before ipv4_src) - values.sort() + values.sort( + key=lambda x: x[0][0] if isinstance(x[0], tuple) else x[0]) self.oxm_values = [ofproto.oxm_to_user(n, v, m) for (n, v, m) in values] -- 1.9.1 ------------------------------------------------------------------------------ Monitor Your Dynamic Infrastructure at Any Scale With Datadog! Get real-time metrics from all of your servers, apps and tools in one place. SourceForge users - Click here to start your Free Trial of Datadog now! http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140 _______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
