-
Notifications
You must be signed in to change notification settings - Fork 652
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
Improve kernel 4.4.x compatibility #436
Conversation
b82d40e
to
592dbd0
Compare
Hi Nicholas, sorry that the first review took so long. Last week was busy with Linux Plumbers conference. We don't support kernels < 4.9 at the moment, so this code will never be exercised on CI. So to be able to merge this we'd have to change this policy. We don't have to support kernels that old, so I don't want to shoulder that burden, tbh. Is that something DataDog is willing to invest time in? If yes, you would need to start by adding 4.4 kernels to CI and making sure tests are all working. Then we could tackle this PR. |
a008320
to
458e9c0
Compare
No problem for the delay Linux Plumbers was nice. |
5221c83
to
6854a06
Compare
59f79da
to
022202e
Compare
ef453cf
to
0ec2a91
Compare
Map.Iterate()
on kernels < 4.4.132
Map.Iterate()
on kernels < 4.4.13216e5cbf
to
d86194a
Compare
2087703
to
89d1def
Compare
83b41ad
to
2a1a987
Compare
65f574b
to
8c499e4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you adjust the commit message of the final commit to reflect the changes you have made? Otherwise lgtm, thanks for working this out!
8c499e4
to
8465327
Compare
Thanks, I updated the commit and PR comment |
8465327
to
a9a17d9
Compare
@lmb could you merge this PR as write access is need |
Make map.Iterate() safe to use on older kernels by guessing a non-existent key that will return a pointer to the first element of the map. By specifying an invalid value pointer, we can test if a key exists without having the kernel copy memory. This approach takes inspiration from BCC: https://github.com/iovisor/bcc/blob/c73d7d8901fdac99510a94a3b9ff5ebf2d8f5956/src/cc/libbpf.c#L402
a9a17d9
to
518c5fe
Compare
This PR contain
Here some implementation detail/comment about map.Iterate()
Safe map.Iterate() to use with old kernel by guessing an non existing key that will point the first element of the map/array.
Thanks to a trick (map.lookup(key, invalidPointer)) of iovisor/bcc we can quickly test if a key exist or not in the map.
If the key is unknown map.GetNextKey() will return the first key that we can iterate to.
The non existing guessing will test these keys in order [0x00..., 0xff..., 0x55..., random] to find an unknown key.
If after all these try we can't found a non existing key, error errFirstKeyNotFound will be returned.
iovisor/bcc trick : https://github.com/iovisor/bcc/blob/c73d7d8901fdac99510a94a3b9ff5ebf2d8f5956/src/cc/libbpf.c#L402