Prior to this patch the code serialises an OFPMatch as:
"OFPMatch": {
"oxm_fields": {
"arp_op": 1,
...
}
}
But the parser fails, complaining that "oxm_fields" is an unknown field name.
Resolve this by using the same JSON format as OF1.3:
"OFPMatch": {
"length": 329,
"oxm_fields": [
{
"OXMTlv": {
"field": "in_port",
"mask": null,
"value": 84281096
}
},
...
}
}
Signed-off-by: Simon Horman <[email protected]>
---
ryu/ofproto/ofproto_v1_4_parser.py | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/ryu/ofproto/ofproto_v1_4_parser.py
b/ryu/ofproto/ofproto_v1_4_parser.py
index 616e0f5..980f201 100644
--- a/ryu/ofproto/ofproto_v1_4_parser.py
+++ b/ryu/ofproto/ofproto_v1_4_parser.py
@@ -478,6 +478,33 @@ class OFPMatch(StringifyMixin):
def stringify_attrs(self):
yield "oxm_fields", dict(self._fields2)
+ def to_jsondict(self):
+ """
+ Returns a dict expressing the flow match.
+ """
+ body = {"oxm_fields": [ofproto.oxm_to_jsondict(k, uv) for k, uv
+ in self._fields2],
+ "length": self.length,
+ "type": self.type}
+ return {self.__class__.__name__: body}
+
+ @classmethod
+ def from_jsondict(cls, dict_):
+ """
+ Returns an object which is generated from a dict.
+
+ Exception raises:
+ KeyError -- Unknown match field is defined in dict
+ """
+ fields = [ofproto.oxm_from_jsondict(f) for f
+ in dict_['oxm_fields']]
+ o = OFPMatch()
+ # XXX old api compat
+ # serialize and parse to fill OFPMatch.fields
+ buf = bytearray()
+ o.serialize(buf, 0)
+ return OFPMatch.parser(str(buf), 0)
+
class OFPPortDescPropUnknown(StringifyMixin):
def __init__(self, type_=None, length=None, buf=None):
--
1.8.5.2
------------------------------------------------------------------------------
WatchGuard Dimension instantly turns raw network data into actionable
security intelligence. It gives you real-time visual feedback on key
security issues and trends. Skip the complicated setup - simply import
a virtual appliance and go from zero to informed in seconds.
http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel