Граф коммитов

20 Коммитов

Автор SHA1 Сообщение Дата
Alan Jowett 244325d8cd
Add performance test for LRU map (#607)
* Add performance test for LRU map

Signed-off-by: Alan Jowett <alanjo@microsoft.com>

* Add additional test for BPF_MAP_TYPE_LRU_HASH

Signed-off-by: Alan Jowett <alanjo@microsoft.com>

* More bug fixes

Signed-off-by: Alan Jowett <alanjo@microsoft.com>

* Fix build break

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-10-01 18:07:19 -06:00
Alan Jowett 082d938501
Implement BPF_MAP_TYPE_LPM_TRIE over lock-free hashmap. (#572)
* Implement BPF_MAP_TYPE_LPM_TRIE over lock-free hashmap.

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-09-28 13:27:50 -07:00
Dave Thaler c8d3ab9e73
Store ID in maps instead of fds and object pointers (#497)
Fixes #396

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2021-09-09 16:02:42 -07:00
Dave Thaler ea3765fc7c
Add tests for libbpf bpf_map_*_elem APIs (#429)
* Add tests for libbpf bpf_map_*_elem APIs

* Return correct error between EBPF_OBJECT_ALREADY_EXISTS (A program or
map is already pinned with the *same* path) vs
EBPF_ALREADY_PINNED (The program or map already pinned to a *different*
path).

* Update vs lookup elem were inconsistent in whether returning
  EBPF_KEY_NOT_FOUND vs EBPF_INVALID_ARGUMENT when passing an array
  index >= max_entries.  Made them be consistent in using
  EBPF_INVALID_ARGUMENT.

Fixes #376

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2021-08-24 11:33:00 -07:00
Dave Thaler f45e80d385
Add map-in-map support (#408)
* Add map-in-map support

Replace UM ebpf_map_update/delete_element with libbpf-compliant
bpf_map_update/delete_elem

This adds the basic functionality needed for #375

Not in this PR, but in a subsequent PR:
* ensure that all inner maps match the one specified by inner_map_idx,
  much like prog_types have to match in a prog_array.
* ensure that putting a prog_array in an array of maps adheres to the
  prog_array contract that any associated progs have to match the
  type of the calling program.
* read a map id not fd when UM reads the value (will be done together
  with issue #396 since also affects prog_arrays)

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2021-08-23 18:46:24 -07:00
Alan Jowett 764fd17222
Fully support BPF flags for map operations (#425)
* Fully support BPF flags for map operations

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-08-23 15:49:50 -06:00
Alan Jowett 9b184645eb
Stop searching once key is matched (#413)
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-08-21 10:13:15 -06:00
Alan Jowett 16a951c2c3
Switch to hash table from AVL. Lock free in the presence of epoch allocator. (#389)
* Switch to hash table from AVL.
Lock free in the presence of epoch allocator.

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2021-08-20 18:29:11 -06:00
Alan Jowett 184b1945d6
Adds support for querying per-CPU maps from user mode and returning a merged view of the per-CPU data (#384)
* Implement per-cpu maps using trivial option

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-08-17 17:22:32 -06:00
Alan Jowett 7870921e02
Additional analysis fixes (#315)
* Fix C26110,C28023,C28193,C6001,C6031,C6054
* Fix C6101

Signed-off-by: Alan Jowett <alanjo@microsoft.com>

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2021-06-29 15:51:41 -06:00
Alan Jowett 9d798031b4
Fix warnings due to C6011 - NULL pointer deref (#307)
* Switch from _Pre_maybenull_ to _In_opt_

Signed-off-by: Alan Jowett <alanjo@microsoft.com>

* Fix C6011

Signed-off-by: Alan Jowett <alanjo@microsoft.com>

* Fix C6011 in PreprocessCommand

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-06-25 10:24:03 -06:00
Dave Thaler dc157726da
Add some more SAL annotations and clean up some code analysis warnings (#277)
* Make a couple of `_In_` arguments be const
* Add `_opt_` to a number of arguments that can be NULL
* Add SAL annotation to a few more APIs that were missing it
* Remove annotations like
  `_Pre_readable_byte_size_(hash_table->key_size)` since they just give
  code analysis warnings such as:
  ```
  c:\git\dthaler\ebpf-for-windows\libs\platform\ebpf_platform.h(445):
  warning C28230: The type of '_Param_(1)' has no member 'key_size'.
  c:\git\dthaler\ebpf-for-windows\libs\platform\ebpf_platform.h(445):
  warning C28285: For function 'ebpf_hash_table_delete' '_Param_(2)'
  syntax error in
  'SAL_readableTo(byteCount(__formal(0,hash_table)->key_size))' near
  'key_size))'.
  ```

Signed-off-by: Dave Thaler <dthaler@ntdev.microsoft.com>
2021-06-16 13:27:22 -07:00
Alan Jowett 9e8b88a41a
Switch to approved license header format (#268)
* Switch to approved license header format

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-06-10 12:02:00 -07:00
Alan Jowett 877cb22ec0
First pass of adding SAL annotations (#253)
* First pass of adding SAL annotations

Signed-off-by: Alan Jowett <alanjo@microsoft.com>

* Finish annotating platform

Signed-off-by: Alan Jowett <alanjo@microsoft.com>

* Cleanup annotation to get lock tracking work correctly

Signed-off-by: Alan Jowett <alanjo@microsoft.com>

* PR feedback and fix static analysis issues

Signed-off-by: Alan Jowett <alanjo@microsoft.com>

* PR feedback

Signed-off-by: Alan Jowett <alanjo@microsoft.com>

* PR feedback

Signed-off-by: Alan Jowett <alanjo@microsoft.com>

* PR feedback

Signed-off-by: Alan Jowett <alanjo@microsoft.com>

* Fix build break from merge

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-06-10 10:45:23 -06:00
Dave Thaler 6be20d7aad
Simplify names of some ebpf_result codes (#256)
* Simplify names of some ebpf_result codes

* Remove _ERROR_ for consistency
* Combine EBPF_INVALID_HANDLE and EBPF_INVALID_OBJECT
* Rename EBPF_ERROR_NOT_FOUND to EBPF_KEY_NOT_FOUND for consistency with the associated description.
* Change code that returned EBPF_ERROR_NOT_FOUND for a case other than a
key, to use a different appropriate result, so the description stays correct.

Fixes #212

Signed-off-by: Dave Thaler <dthaler@ntdev.microsoft.com>
2021-06-09 19:32:57 -07:00
Shankar Seal 27f8d49888
API to create map and enumerate all pinned maps. (#246)
* API to create map and enumerate all pinned maps.

* Apply suggestions from code review

Co-authored-by: Dave Thaler <dthaler@microsoft.com>

* Address code review comments

* Address code review comments #2

* Address code review comments #3

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
Co-authored-by: Alan Jowett <alanjo@microsoft.com>
2021-06-09 09:44:24 -06:00
Alan Jowett 7e033f0200
Remove allocations from executable memory pool (#251)
* Remove allocations from executable memory pool

Signed-off-by: Alan Jowett <alanjo@microsoft.com>

* Add direction to doxygen

Signed-off-by: Alan Jowett <alanjo@microsoft.com>

* Clarify use of 4096 as page size

Signed-off-by: Alan Jowett <alanjo@microsoft.com>

* PR feedback

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-06-07 14:07:24 -06:00
Dave Thaler 773b27d2c0
Merge error codes from ebpf_windows.h into ebpf_result_t (#210)
Fixes #151

Signed-off-by: Dave Thaler <dthaler@ntdev.microsoft.com>
2021-05-20 12:38:58 -07:00
Alan Jowett 962ef5e03d
Split tests (#158)
* Create unit test for execution context
* Split out platform unit tests
* Call UT as part of CI/CD pipeline

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-05-10 15:14:49 -06:00
Dave Thaler 927b2081e3
Update directory structure (#134)
Fixes #124

Signed-off-by: Dave Thaler <dthaler@ntdev.microsoft.com>
2021-05-05 14:10:28 -06:00