mildsunrise / node_netlink

⚒ Use Netlink from Node.js
MIT License
22 stars 2 forks source link

Improve LinkStats[64] ABI compatibility #19

Closed christoph-heiss closed 1 year ago

christoph-heiss commented 1 year ago

Hi!

This improves compatibility with the ABIs of kernels < v4.6 and > v5.18.

I noticed that this broke https://github.com/christoph-heiss/wgdash with kernels > v5.18, failing with Unexpected length for LinkStats64. This PR fixes that and should also future-proof it a bit more.

Thanks!

mildsunrise commented 1 year ago

agh, this is a PITA. we can't change that code, it's autogenerated from the type definitions. right now I was working under the assumption that changing struct size was an ABI-breaking change and thus would not happen. I see this is clearly not the case. I'll try to see what I can do...

christoph-heiss commented 1 year ago

Well, that makes things a bit more complicated.

If it's okay for you, I can come up with an approach on how to encode this into the type definitions. Otherwise I'd also gladly help implementing your approach, just let me know.

Since this makes this PR effectively moot, feel free to close it.

mildsunrise commented 1 year ago

Yeah, that sounds about right. Ideally structs should have an __unparsed field (same name as for attribute objects, but this time it would be a Buffer) if there are any unexpected trailing fields. Any fields that are not present could be left unset in the parsed object. Question is what to do for input if user doesn't specify those fields, I guess we just produce a shorter struct... we could also set them to zero, but I don't know if that could cause unintended behavior.