utils: show error message when priority is missing (#452)

* p4runtime_lib/helper: use more appropriate variable names

Suggested-by: Antonin Bas <abas@vmware.com>
Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>

* utils: show error message when priority is missing

A 'priority' field is required to order entries when the
table's match key includes an optional, ternary or range match.

Suggested-by: Andy Fingerhut <andy_fingerhut@alum.wustl.edu>
Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
This commit is contained in:
Radostin Stoyanov
2022-02-24 15:45:58 +00:00
committed by GitHub
parent ccc5693807
commit 071b89ad30
3 changed files with 36 additions and 11 deletions

View File

@@ -101,17 +101,17 @@ class P4InfoHelper(object):
exact = p4runtime_match.exact
exact.value = encode(value, bitwidth)
elif match_type == p4info_pb2.MatchField.LPM:
lpm = p4runtime_match.lpm
lpm.value = encode(value[0], bitwidth)
lpm.prefix_len = value[1]
lpm_entry = p4runtime_match.lpm
lpm_entry.value = encode(value[0], bitwidth)
lpm_entry.prefix_len = value[1]
elif match_type == p4info_pb2.MatchField.TERNARY:
lpm = p4runtime_match.ternary
lpm.value = encode(value[0], bitwidth)
lpm.mask = encode(value[1], bitwidth)
ternary_entry = p4runtime_match.ternary
ternary_entry.value = encode(value[0], bitwidth)
ternary_entry.mask = encode(value[1], bitwidth)
elif match_type == p4info_pb2.MatchField.RANGE:
lpm = p4runtime_match.range
lpm.low = encode(value[0], bitwidth)
lpm.high = encode(value[1], bitwidth)
range_entry = p4runtime_match.range
range_entry.low = encode(value[0], bitwidth)
range_entry.high = encode(value[1], bitwidth)
else:
raise Exception("Unsupported match type with type %r" % match_type)
return p4runtime_match