Handle const default actions correctly in P4-14 and P4Runtime serialization #326
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In #309, we noticed two issues:
NoAction
entries.const_default_action_id
in P4Runtime, even if the default action isn't const.These two things turn out to be related.
Explicit P4-14 default actions are all "const" from a P4-16 perspective. They're fixed at compile time, and the control plane can't change them. (The control plane may be able to change the associated action data, though, but that's a separate issue.)
The P4-16 non-const default action is more or less equivalent to not specifying a default action at all in P4-14. The only difference is that P4-16 allows you to set the initial state of the default action, while in P4-14, the initial state is always "take no action at all".
When we process a P4-14 program in the p4c frontend, tables without explicit default actions are assigned a default action of
NoAction
by the compiler. The problem is that the constness rules above aren't followed. We treat P4-14 default actions as if they were never const, when in fact they should always be const if they're explicitly specified.In 39354ec, I've resolved that issue; with that patch applied, only
NoAction
default actions inserted by the compiler are non-const.This dovetails nicely with 4a2c57e, which fixes p4runtimeSerializer so that it only produces a
const_default_action_id
for a table if the default action is actually const. That fixes a bug on its own, but with these two patches combined, we get rid of the flood ofNoAction
default actions in the P4Runtime output.These two patches, taken together, address the most important remaining problem that I'm aware of related to issue #309.