Conversation
d6fc75b to
1fc7a4f
Compare
|
The breaking change is due to replacing ebpf.MapID and ProgramID with a type alias. |
1fc7a4f to
ae08243
Compare
c11a8e0 to
427cfcd
Compare
dylandreimerink
left a comment
There was a problem hiding this comment.
I like this! More type safety more better
ti-mo
left a comment
There was a problem hiding this comment.
Wouldn't this allow us to unexport sys.Pointer? Ie. if it needs to be used outside of the package, it needs to be wrapped in an (Unsafe/Typed/String/XYZ)Pointer. Then we make sure UAPI no longer takes any sys.Pointers.
I still see a bunch of sys.Pointer uses in the map API; I'd argue those should all be sys.UnsafePointers instead, to be converted to typed pointers before returning.
Add TypedPointer which is a type safe wrapper around Pointer. This relieves users of the generated bindings from knowing which types are expected. This should make it less likely that we cause a hard to debug panic or crash due to the kernel overwriting runtime memory. sys.Pointer still exists because there are some cases where we legitimately don't know what type to point at, for example the link info APIs. Map APIs are also unchanged for now because they don't benefit much from converting to TypedPointer[byte]. The trick to include "_ [0]*T" in TypedPointer is taken from atomic.Pointer in the Go stdlib. Signed-off-by: Lorenz Bauer <[email protected]>
427cfcd to
fde0d85
Compare
Discussed face to face: UnsafePointer is a constructor, not a type. We still need |
Add TypedPointer which is a type safe wrapper around Pointer. This relieves users of the generated bindings from knowing which types are expected. This should make it less likely that we cause a hard to debug panic or crash due to the kernel overwriting runtime memory.
sys.Pointer still exists because there are some cases where we legitimately don't know what type to point at, for example the link info APIs. Map APIs are also unchanged for now because they don't benefit much from converting to TypedPointer[byte].