Open jafingerhut opened 4 years ago
Another alternative:
push(my_header_stack, n)
operation, immediately follow it with add_header(my_header_stack[0]); add_header(my_header_stack[1]); ... add_header(my_header_stack[n-1]);
, which is effectively what p4c is doing for you under the covers after every P4_14 push operation.
Before this commit to the behavioral-model repository in March 2018, p4c-bmv2 and behavioral-model had the same assumptions about how push operations in the JSON file worked: https://github.com/p4lang/behavioral-model/commit/9131ed9bc4f634e415d459e7d26e154396be1042
After that commit, the default builds of behavioral-model changed, but p4c-bmv2 did not change to update with it.
If you encounter this, options you have:
Use latest p4c and behavioral-model together, which have common assumptions on how the BMv2 JSON push operation works (which is: the new pushed headers are invalid, and when compiling P4_14 programs, the p4_14 compiler when creating the BMv2 JSON file should insert add_header primitive operations after push operations, to make the newly inserted headers valid)
Use p4c-bmv2, and also use the option mentioned in the commit message linked above when building behavioral-model, i.e. "The legacy implementation can be toggled by passing the
--disable-WP4-16-stacks
flag to configure."Convince someone, or yourself, to update p4c-bmv2 to follow the new behavior implemented by behavioral-model.