Skip to content

Commit

Permalink
Merge pull request #151 from crezov/master
Browse files Browse the repository at this point in the history
fix NXActionRegLoad action_to_str
  • Loading branch information
anarkiwi committed Sep 9, 2021
2 parents ef58b40 + e67d259 commit 537f35f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 1 addition & 3 deletions ryu/lib/ofctl_nicira_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
11 changes: 11 additions & 0 deletions ryu/ofproto/nicira_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 537f35f

Please sign in to comment.