[ovs-dev] [PATCHv2] extract-ofp-fields: Detect duplicate fields.

Joe Stringer joestringer at nicira.com
Wed May 20 21:53:22 UTC 2015


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 <joestringer at nicira.com>
---
v2: Don't modify oxm_name_to_class().
---
 build-aux/extract-ofp-fields | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/build-aux/extract-ofp-fields b/build-aux/extract-ofp-fields
index f05487e..315552d 100755
--- a/build-aux/extract-ofp-fields
+++ b/build-aux/extract-ofp-fields
@@ -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))
@@ -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
-- 
2.1.4




More information about the dev mailing list