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
alignchecker: fully parse structures #24365
alignchecker: fully parse structures #24365
Conversation
5d72feb
to
444831d
Compare
The alignchecker package takes BTF descriptions of structures and creates a map with offsets. For example, struct x { u64 a; u32 b; u8 c; u8 d; }; will be converted to {a: 0, b: 8, c: 12, d: 13} These names are later used in Go struct definitions, so that we can check if they are properly aligned, e.g.: type X struct { A uint64 `align:"a"` B uint32 `align:"b"` C uint8 `align:"c"` D uint8 `align:"d"` } If there are anonymous unions present, then their offsets will be stored as $union0, $union1, etc., e.g., struct x { union { u32 a; u32 b; }; union { u32 c; u32 d; }; u32 f; }; will be converted to {$union0: 0, $union1: 4, f: 8} However, there's no way to refer to inner fields of unions, or to fields of structures. Fix this by parsing BTFs recursively. After this change, e.g., the following structure struct x { u32 a; struct { union { u32 a; u32 b; }; u32 c; }; u32 d; }; will be converted to { a: 0, $struct0: 4, $struct0.$union0: 4, $struct0.$union0.a: 4, $struct0.$union0.b: 4, $struct0.c: 8, d: 12 } Also fix a minor bug: previous code didn't check if an offset exists or not (it was set to 0 by default). Patch two occurrences in code which were referencing non-existing offset (it happened that the corresponding offsets were indeed 0). Signed-off-by: Anton Protopopov <aspsk@isovalent.com>
/test Job 'Cilium-PR-K8s-1.16-kernel-4.19' failed: Click to show.Test Name
Failure Output
If it is a flake and a GitHub issue doesn't already exist to track it, comment Job 'Cilium-PR-K8s-1.26-kernel-net-next' failed: Click to show.Test Name
Failure Output
If it is a flake and a GitHub issue doesn't already exist to track it, comment |
Build finished. |
/test-1.16-4.19 |
/test-1.26-net-next Job 'Cilium-PR-K8s-1.16-kernel-4.19' failed: Click to show.Test Name
Failure Output
If it is a flake and a GitHub issue doesn't already exist to track it, comment |
/test-1.16-4.19 |
The test-1.16-4.19 is unrelated, so marking as ready to merge |
For this sort of situation, please point at the actual CI issue that tracks the unrelated failure. The Jenkins data has already expired ... |
The alignchecker package takes BTF descriptions of structures and creates a map with offsets. For example,
will be converted to
These names are later used in Go struct definitions, so that we can check if they are properly aligned, e.g.:
If there are anonymous unions present, then their offsets will be stored as $union0, $union1, etc., e.g.,
will be converted to
However, there's no way to refer to inner fields of unions, or to fields of structures. Fix this by parsing BTFs recursively. After this change, e.g., the following structure
will be converted to
Also fix a minor bug: previous code didn't check if an offset exists or not (it was set to 0 by default). Patch two occurrences in code which were referencing non-existing offset (it happened that the corresponding offsets were indeed 0).