Conversation
lmb
commented
Sep 6, 2019
| @@ -0,0 +1,7 @@ | |||
| Copyright (c) 2017 Nathan Sweet | |||
Contributor
Author
There was a problem hiding this comment.
We'll have to merge this with LICENSE in a follow up commit.
There is no need to have helper flags in the main package. Arguably they should live in asm if they are really needed.
Also rename Unrecognized to UnspecifiedProgram to match UnspecifiedMap.
Follow the kernel naming of map_lookup_elem more closely. Also return an error when a key is not found, instead of the awkward boolean.
Use the IsNotExist infrastructure for Delete calls and remove DeleteStrict.
Let the user specify flags instead of adding a new function for every flag of map_update_elem. This reduces the API surface, and makes the library more versatile. It also provides a clear way to support BPF_F_LOCK which wasn't possible previously.
This gives us flexibility to add more detailed errors later.
Clarify the use case of MapABI and ProgramABI, and document the behaviour of Check on the function instead of on the struct.
Marshaler isn't really part of the API, it's just there for documentation purposes. Let's improve the documentation instead of cluttering the API.
The current receive is called bpf, which doesn't make much sense in the context of the package.
Lookup, Update, Delete and NextKey are probably the most performance
critical functions. Add a small benchmark for them. On my machine
I get the following:
name time/op
Map/Lookup-8 622ns ± 1%
Map/Update-8 650ns ± 1%
Map/NextKey-8 540ns ± 0%
Map/Delete-8 640ns ± 3%
name alloc/op
Map/Lookup-8 0.00B
Map/Update-8 0.00B
Map/NextKey-8 0.00B
Map/Delete-8 40.0B ± 0%
name allocs/op
Map/Lookup-8 0.00
Map/Update-8 0.00
Map/NextKey-8 0.00
Map/Delete-8 2.00 ± 0%
Delete allocates because it returns a not found error when deleting
a non-existing key.
eBPF helpers are added frequently, so we should make updating the list simple. Remove the (duplicate, probably incorrect) documentation and re-generate the new list of functions.
XAdd is just another mode of the Store class, so keep the naming consistent.
The test was used to show the difference between old and new syntax. Remove it since it's not needed anymore.
Contributor
Author
|
@joestringer I've made the fixups, this is good to go from my side. |
brb
reviewed
Sep 16, 2019
Contributor
Author
|
@brb @joestringer can either of you approve the PR? |
brb
approved these changes
Sep 23, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull in
newtools/ebpfMap and Program, and preserve history by creating a merge commit.This includes the
asmsubpackage to be able to testProgramandMapwithout requiring an ELF loader.I made the following changes from
newtools/ebpfmaster, based on our previous discussion:Fixes #1