diff --git a/ryu/lib/ofctl_nicira_ext.py b/ryu/lib/ofctl_nicira_ext.py index 98f5167a..aad8dcaa 100644 --- a/ryu/lib/ofctl_nicira_ext.py +++ b/ryu/lib/ofctl_nicira_ext.py @@ -39,9 +39,7 @@ def action_to_str(act, ofctl_action_to_str): src_start, src_end) elif sub_type == nicira_ext.NXAST_REG_LOAD: - start = act.ofs - end = start + act.nbits - return 'NX_LOAD: {%s[%s..%s]: %x}' % (act.dst, start, end, act.value) + return 'NX_LOAD: {%s%s: %x}' % (act.dst, nicira_ext.ofs_nbits_str(act.ofs_nbits), act.value) elif sub_type == nicira_ext.NXAST_LEARN: specs = [] diff --git a/ryu/ofproto/nicira_ext.py b/ryu/ofproto/nicira_ext.py index 19c8394c..9c2d2aaf 100644 --- a/ryu/ofproto/nicira_ext.py +++ b/ryu/ofproto/nicira_ext.py @@ -332,6 +332,17 @@ def ofs_nbits(start, end): return (start << 6) + (end - start) +def ofs_nbits_str(n): + start = 0 + while True: + start += 1 + if (start << 6) > n: + break + start -= 1 + end = n + start - (start << 6) + return "[%d..%d]" % (start, end) + + def nxm_header__(vendor, field, hasmask, length): return (vendor << 16) | (field << 9) | (hasmask << 8) | length