Skip to content

Commit

Permalink
extract-ofp-fields: Detect duplicate fields.
Browse files Browse the repository at this point in the history
Figure out if a developer accidentally defines new NXM fields using an
existing number, and warn them. Useful particularly if new fields are
introduced upstream while rebasing an in-progress patchset.

Signed-off-by: Joe Stringer <[email protected]>
Acked-by: Ben Pfaff <[email protected]>
  • Loading branch information
joestringer committed May 27, 2015
1 parent d2843eb commit 8c10186
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions build-aux/extract-ofp-fields
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,12 @@ def parse_oxms(s, prefix, n_bytes):
return tuple(parse_oxm(s2.strip(), prefix, n_bytes) for s2 in s.split(','))


match_types = dict()


def parse_oxm(s, prefix, n_bytes):
global match_types

m = re.match('([A-Z0-9_]+)\(([0-9]+)\) since(?: OF(1\.[0-9]+) and)? v([12]\.[0-9]+)$', s)
if not m:
fatal("%s: syntax error parsing %s" % (s, prefix))
Expand All @@ -153,6 +158,14 @@ def parse_oxm(s, prefix, n_bytes):
fatal("unknown OXM class for %s" % name)
oxm_vendor, oxm_class = class_

if class_ in match_types:
if oxm_type in match_types[class_]:
fatal("duplicate match type for %s (conflicts with %s)" %
(name, match_types[class_][oxm_type]))
else:
match_types[class_] = dict()
match_types[class_][oxm_type] = name

# Normally the oxm_length is the size of the field, but for experimenter
# OXMs oxm_length also includes the 4-byte experimenter ID.
oxm_length = n_bytes
Expand Down

0 comments on commit 8c10186

Please sign in to comment.