p4c
p4c copied to clipboard
PSA-eBPF parser metadata issue
The new PSA-eBPF backend doesn't support parser metadata correctly.
When I try to use the metadata with the type of psa_ingress_parser_input_metadata_t
, I get an error message from the clang compiler.
Input:
parser packet_parser(...,
in psa_ingress_parser_input_metadata_t pipi_md,
...) {
...
state parse_ethernet{
pkt.extract(hdr.ethernet);
transition select(pipi_md.packet_path){
PSA_PacketPath_t.RESUBMIT: reject;
default: accept;
}
}
}
Error message:
out.c:341:20: error: use of undeclared identifier 'pipi_md'
select_0 = pipi_md.packet_path;
^
For reproducibility purposes, I created this repository with a minimal example. One can reproduce the issue using the following commands:
make p4c-docker-setup
make build
Looking at the generated C code, the metadata is defined after the accept
label with the wrong name:
accept: {
struct psa_ingress_input_metadata_t standard_metadata = {
.ingress_port = skb->ifindex,
.packet_path = compiler_meta__->packet_path,
.parser_error = ebpf_errorCode,
};
I can confirm that psa_ingress_parser_input_metadata_t
for parser is not generated, so it is a bug. Probably I or @osinstom will fix this.
@gycsaba96
Looking at the generated C code, the metadata is defined after the accept label with the wrong name:
This is a psa_ingress_input_metadata_t
for ingress control block, not for ingress parser block (note the difference in word parser
in both type names).
Thank you in advance!
This is a
psa_ingress_input_metadata_t
for ingress control block, not for ingress parser block (note the difference in wordparser
in both type names).
My mistake :)
@gycsaba96
Sorry that you have to wait a long time. I have created a fix #3778 for this issue.
@tatry Thank you for your efforts!