-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Add macro for BPF_HASH #135
Comments
Or even supporting both explicit or implicit value types (3rd argument optional):
|
* Usage: BPF_HASH(tablename, key_type=u64, leaf_type=u64) 2nd and 3rd arguments are optional in the C++ default argument style Fixes: #135 Signed-off-by: Brenden Blanco <bblanco@plumgrid.com>
This has been working, so the ticket can be closed. It works for hashes that exist only for the C program; eg, temporarily storing timestamps. I hit issues accessing a BPF_HASH() key (when a key_t is not in use, like in the example above) from Python, complaining about it not being c_int, but that can be a separate issue. |
For the python case you mentioned, what I tend to do is wrap things that should be a ctype with a Table.Key() or Table.Leaf() type. For instance, if Key is a complex type like b["stats"][b["stats"].Key(0, 1)] = b["stats"].Leaf(42) |
It's nice to have a lot of control over BPF maps, but I wonder if we
could have some simplified macros for the really common cases, like: hash
of one key -> u64.
Before:
After:
Where the name is "start", the single key is "struct request *", and it
assumes the value is u64 (common case), and there is a global default for
number of entries (10240). If people want to customize, then do BPF_TABLE.
The text was updated successfully, but these errors were encountered: