Currently, ofctl_v1_[23].py adds non-existing match fields when getting unknown match fields, then parser returns KeyError. This patch fixes ofctl_v1_[23].py to ignore unkown match fields and output error messages.
Signed-off-by: IWASE Yusuke <[email protected]> --- ryu/lib/ofctl_v1_2.py | 28 +++++++++++++++------------- ryu/lib/ofctl_v1_3.py | 28 +++++++++++++++------------- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/ryu/lib/ofctl_v1_2.py b/ryu/lib/ofctl_v1_2.py index 1c1ff5d..37f8792 100644 --- a/ryu/lib/ofctl_v1_2.py +++ b/ryu/lib/ofctl_v1_2.py @@ -251,23 +251,25 @@ def to_match(dp, attrs): kwargs = {} for key, value in attrs.items(): - if key in convert: - value = convert[key](value) if key in keys: # For old field name key = keys[key] - if key == 'tp_src' or key == 'tp_dst': - # TCP/UDP port - conv = {inet.IPPROTO_TCP: {'tp_src': 'tcp_src', - 'tp_dst': 'tcp_dst'}, - inet.IPPROTO_UDP: {'tp_src': 'udp_src', - 'tp_dst': 'udp_dst'}} - ip_proto = attrs.get('nw_proto', attrs.get('ip_proto', 0)) - key = conv[ip_proto][key] - kwargs[key] = value + if key in convert: + value = convert[key](value) + if key == 'tp_src' or key == 'tp_dst': + # TCP/UDP port + conv = {inet.IPPROTO_TCP: {'tp_src': 'tcp_src', + 'tp_dst': 'tcp_dst'}, + inet.IPPROTO_UDP: {'tp_src': 'udp_src', + 'tp_dst': 'udp_dst'}} + ip_proto = attrs.get('nw_proto', attrs.get('ip_proto', 0)) + key = conv[ip_proto][key] + kwargs[key] = value + else: + # others + kwargs[key] = value else: - # others - kwargs[key] = value + LOG.error('Unknown match field: %s', key) return dp.ofproto_parser.OFPMatch(**kwargs) diff --git a/ryu/lib/ofctl_v1_3.py b/ryu/lib/ofctl_v1_3.py index 04bf76d..8490206 100644 --- a/ryu/lib/ofctl_v1_3.py +++ b/ryu/lib/ofctl_v1_3.py @@ -272,23 +272,25 @@ def to_match(dp, attrs): kwargs = {} for key, value in attrs.items(): - if key in convert: - value = convert[key](value) if key in keys: # For old field name key = keys[key] - if key == 'tp_src' or key == 'tp_dst': - # TCP/UDP port - conv = {inet.IPPROTO_TCP: {'tp_src': 'tcp_src', - 'tp_dst': 'tcp_dst'}, - inet.IPPROTO_UDP: {'tp_src': 'udp_src', - 'tp_dst': 'udp_dst'}} - ip_proto = attrs.get('nw_proto', attrs.get('ip_proto', 0)) - key = conv[ip_proto][key] - kwargs[key] = value + if key in convert: + value = convert[key](value) + if key == 'tp_src' or key == 'tp_dst': + # TCP/UDP port + conv = {inet.IPPROTO_TCP: {'tp_src': 'tcp_src', + 'tp_dst': 'tcp_dst'}, + inet.IPPROTO_UDP: {'tp_src': 'udp_src', + 'tp_dst': 'udp_dst'}} + ip_proto = attrs.get('nw_proto', attrs.get('ip_proto', 0)) + key = conv[ip_proto][key] + kwargs[key] = value + else: + # others + kwargs[key] = value else: - # others - kwargs[key] = value + LOG.error('Unknown match field: %s', key) return dp.ofproto_parser.OFPMatch(**kwargs) -- 1.9.1 ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
