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

Add total_size field in ebpf_extension_header_t #3526

Closed
saxena-anurag opened this issue May 5, 2024 · 2 comments · Fixed by #3573
Closed

Add total_size field in ebpf_extension_header_t #3526

saxena-anurag opened this issue May 5, 2024 · 2 comments · Fixed by #3573
Assignees
Labels
P2 triaged Discussed in a triage meeting
Milestone

Comments

@saxena-anurag
Copy link
Contributor

Currently ebpf_extension_header_t struct is defined as below:

typedef struct _ebpf_extension_header
{
    uint16_t version; ///< Version of the extension data structure.
    size_t size;      ///< Size of the extension data structure.
} ebpf_extension_header_t;

This works fine, as long as the runtime gets a pointer to single object, and the version and size fields are sufficient to safely read and copy the fields from the original struct. But if the extension (or any other versioned interface which is also using this header for versioning) passes an array of structs, then the runtime also needs to figure out the total size of a struct. Due to padding, the struct will not be same as size above. So for each case, the runtime has to calculate the total size of the struct, and padding added for each struct will be different.

One way to simplify this is to add another field total_size in the above struct, which will be simply sizeof(<struct>).

@dthaler
Copy link
Collaborator

dthaler commented May 6, 2024

When would an extension pass an array of ebpf_extension_header_t structs?

@saxena-anurag
Copy link
Contributor Author

When would an extension pass an array of ebpf_extension_header_t structs?

It will not pass an array of ebpf_extension_header_t struct, but it can (does) pass an array of struct that has ebpf_extension_header_t in it.

Example: ebpf_helper_function_prototype_t. Similarly there are instances in the native module NMR interface also.

@dahavey dahavey added the triaged Discussed in a triage meeting label May 6, 2024
@dahavey dahavey added this to the 2405 milestone May 6, 2024
@dahavey dahavey added the P2 label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 triaged Discussed in a triage meeting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants