p4c: Calling exit in actions after an assignment
I have a question on the behaviour of exit in the control pipeline. I have the following transformation in an action
control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) {
@name("ingress.do_action") action do_action(inout bit<16> val_0) {
val_0 = 16w3;
exit;
}
apply {
do_action(h.eth_hdr.eth_type);
}
}
to
control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) {
bit<16> val_0;
@name("ingress.do_action") action do_action() {
val_0 = h.eth_hdr.eth_type;
val_0 = 16w3;
exit;
h.eth_hdr.eth_type = val_0;
}
apply {
do_action();
}
}
So eth_type is assigned after the exit call, instead of before. What is supposed to happen when I call exit? Is the program still emitting the packet? Or is the header reset?
This happens after SimpleSwitchMidEnd_4_RemoveActionParameters.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16 (9 by maintainers)
The P4 language specification issue https://github.com/p4lang/p4-spec/issues/822 mentioned earlier was resolved today. You can read the details of the changes in the newest language spec, but basically the idea is that after a return or exit is executed, all relevant copy-out behavior for all
outandinoutdirection parameters should happen after that.I would recommend leaving this issue open until that language spec issue is resolved. Some of the comments I have added there since creating it lead me to believe that perhaps it should be the case that copy-out occurs, even if a
returnorexitstatement are executed inside of a control/action.