Skip to content

Support BPF dynamic pointers #3515

Open
@dthaler

Description

@dthaler

Describe the feature you'd like supported

Linux supports memory allocation, access, and release via helper functions.

 struct bpf_dynptr_kern {
 void *data;
 u32 size;
 u32 offset;
 } __aligned(8);

 /* Dynamically allocate memory */
 bpf_dynptr_alloc(size, 0, &ptr);

 /* Get a dynptr to __sk_buff data */
 bpf_dynptr_from_skb(skb, &skb_ptr);

 /* Get a dynptr to xdp_md data */
 bpf_dynptr_from_xdp(ctx, &xdp_ptr);

 /* Advance the ptr into skb->data */
 bpf_dynptr_advance(&skb_ptr, sizeof(struct ethhdr));

 /* Write into the memory */
 bpf_dynptr_write(&ptr, 0, buf, sizeof(buf));

 /* Release the memory allocation */
 bpf_dynptr_put(&ptr);

References:

Support is blocked on vbpf/prevail#273

Proposed solution

Support the same helper functions that Linux supports

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    blockedBlocked on another issue that must be done firstenhancementNew feature or requesthelp wantedExtra attention is neededtriagedDiscussed in a triage meeting

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions