diff options
author | Yuichi Ito <ito.yuichi0@gmail.com> | 2014-06-23 14:42:18 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-06-23 17:10:25 +0900 |
commit | 1474ec325556e411313e8b7064232428e92e2f11 (patch) | |
tree | c04dcb95c5eec85b6106b0b47f3872d15256aec8 | |
parent | 740823f7b6d8a3fc796eca189cd4e6ebe5bd6ba5 (diff) |
sw test tool: Modify OFPMatch to normalize
This patch is for avoiding the following issues when using ofproto_v1_4_parser:
- OFPMatch that is created from JSON keeps unicode strings, instead of usual strings.
- In OFPMatch that is created from JSON, IPv6 formats like 'ff::0' or '00ff:0000:0000:0000:0000:0000:0000:0000' are not normalized to 'ff::'.
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/tests/switch/tester.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/ryu/tests/switch/tester.py b/ryu/tests/switch/tester.py index 9cf65e96..73a7bfbd 100644 --- a/ryu/tests/switch/tester.py +++ b/ryu/tests/switch/tester.py @@ -1301,6 +1301,16 @@ class Test(stringify.StringifyMixin): data.serialize() return str(data.data) + def __normalize_match(ofproto, match): + match_json = match.to_jsondict() + oxm_fields = match_json['OFPMatch']['oxm_fields'] + fields = [] + for field in oxm_fields: + field_obj = ofproto.oxm_from_jsondict(field) + field_obj = ofproto.oxm_normalize_user(*field_obj) + fields.append(field_obj) + return match.__class__(_ordered_fields=fields) + # get ofproto modules using user-specified versions (target_ofproto, target_parser) = ofproto_protocol._versions[ OfTester.target_ver] @@ -1332,6 +1342,10 @@ class Test(stringify.StringifyMixin): msg.version = target_ofproto.OFP_VERSION msg.msg_type = msg.cls_msg_type msg.xid = 0 + if isinstance(msg, target_parser.OFPFlowMod): + # normalize OFPMatch + msg.match = __normalize_match(target_ofproto, msg.match) + msg.serialize() prerequisite.append(msg) # parse 'tests' @@ -1380,6 +1394,8 @@ class Test(stringify.StringifyMixin): mod, datapath=tester_dp, cookie=THROUGHPUT_COOKIE, priority=THROUGHPUT_PRIORITY) + msg.match = __normalize_match( + tester_ofproto, msg.match) one[KEY_FLOW] = msg one[KEY_KBPS] = throughput.get(KEY_KBPS) one[KEY_PKTPS] = throughput.get(KEY_PKTPS) |