Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PSA eBPF] Invalid access to struct field using pointer #5031

Open
marsontti opened this issue Nov 24, 2024 · 0 comments
Open

[PSA eBPF] Invalid access to struct field using pointer #5031

marsontti opened this issue Nov 24, 2024 · 0 comments
Labels
bug This behavior is unintended and should be fixed. ebpf-psa Topics related to the eBPF PSA back end

Comments

@marsontti
Copy link

marsontti commented Nov 24, 2024

Hi everyone. I'm trying to implement incremental checksum in P4 PSA eBPF. I'm using P4-eBPF backend to compile my code and error occurs during compilation:

make -f /home/marsontic/p4c-1.2.4.16/backends/ebpf/runtime/kernel.mk BPFOBJ=my_switch.o P4FILE=my_switch.p4 ARGS="-DPSA_PORT_RECIRCULATE=2" P4ARGS="--Wdisable=unused" psa


my_switch.c:1297:35: error: member reference type 'struct metadata *' is a pointer; did you mean to use '->'?
            ck_1_state = user_meta.fwd_metadata.checksum_state;

The P4 code which is related to this:

control EgressDeparserImpl(packet_out packet,
                           out empty_metadata_t clone_e2e_meta,
                           out empty_metadata_t recirculate_meta,
                           inout headers hdr,
                           in metadata user_meta,
                           in psa_egress_output_metadata_t istd,
                           in psa_egress_deparser_input_metadata_t edstd){
    InternetChecksum() ck;
    apply {
         if (hdr.ipv4.isValid()) {
            ck.clear();
            ck.add({
                    hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv,
                    hdr.ipv4.totalLen,
                    hdr.ipv4.identification,
                    hdr.ipv4.flags, hdr.ipv4.fragOffset,
                    hdr.ipv4.ttl, hdr.ipv4.protocol,
                    hdr.ipv4.srcAddr,
                    hdr.ipv4.dstAddr
                });
            hdr.ipv4.hdrChecksum = ck.get();
        }

        ck.set_state(user_meta.fwd_metadata.checksum_state);

I'm able to workaround this by just changing the line in generated C code and compile again, but I'm not sure if it's a good idea:

ck_1_state = user_meta->fwd_metadata.checksum_state;

@fruffy fruffy added bug This behavior is unintended and should be fixed. ebpf-psa Topics related to the eBPF PSA back end labels Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This behavior is unintended and should be fixed. ebpf-psa Topics related to the eBPF PSA back end
Projects
None yet
Development

No branches or pull requests

2 participants