p4c icon indicating copy to clipboard operation
p4c copied to clipboard

PSA-eBPF parser metadata issue

Open gycsaba96 opened this issue 2 years ago • 2 comments

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,
};

gycsaba96 avatar Nov 16 '22 15:11 gycsaba96

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).

tatry avatar Nov 17 '22 13:11 tatry

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 word parser in both type names).

My mistake :)

gycsaba96 avatar Nov 18 '22 11:11 gycsaba96

@gycsaba96

Sorry that you have to wait a long time. I have created a fix #3778 for this issue.

tatry avatar Dec 14 '22 14:12 tatry

@tatry Thank you for your efforts!

gycsaba96 avatar Jan 09 '23 10:01 gycsaba96