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

470 Коммитов

Автор SHA1 Сообщение Дата
Dave Thaler b6a0fb84b9
Add support for libbpf bpf_obj_get_info_by_fd API (#510)
* Add support for libbpf bpf_obj_get_info_by_fd API

This is the last libbpf api needed to enable the bpftool
flow to detach an already loaded program.

The count of maps is changed from size_t to uint32_t for
consistency with libbpf and because it's not actually a size
in the sizeof() sense, it's a count in the countof() sense.

Also fix bug where map_name was never being set in the kernel

Fixes #372

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2021-09-10 21:54:07 -07:00
Alan Jowett 25f9887e69
Remove dependency on run-tests.bat (#517)
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-09-10 17:59:53 -06:00
Alan Jowett f0a07e7dd0
Switch to ExAllocatePoolZero (#509)
Resolves: #506

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-09-10 17:35:03 -06:00
Alan Jowett 7e12a6f920
Add support for bpf_ktime_get_ns (#511)
* Add support for bpf_ktime_get_ns

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-09-10 12:45:52 -06:00
Alan Jowett 84fef4e73c
Run utility helper tests in both interpret and jit modes (#512)
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-09-10 10:39:30 -07:00
Shankar Seal acb6859758
Support for xdp_tx. (#498)
* xdp_tx

* Fix analysis error.

* update documentation.

* IPv6 tests.

* Apply suggestions from code review
2021-09-09 22:34:03 -07:00
Dave Thaler 38952de71a
Require all inner map attributes to match (#508)
Updated the map_in_map.c test to use HASH instead of ARRAY as the inner
map type, to make it possible to test key_size mismatch (since key_size
must be 4 for all ARRAY maps, it can't be tested with ARRAY).

Fixes #507

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2021-09-09 21:11:19 -07:00
Alan Jowett 4083f4eeb2
Add driver.yml - the workflow to install eBPF core on a self-host machine. (#504)
* Add driver.yml - the workflow to install eBPF core on a self-host machine and run tests.

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-09-09 18:01:52 -06: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
Alan Jowett 24f5282063
Adding dependent workflow to run after build (#500) 2021-09-08 12:00:16 -06:00
Shankar Seal 8ee6344a1c
XDP ethernet packet (#493)
* cleanup test code.

* xdp eth packet.

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
Co-authored-by: Alan Jowett <alanjo@microsoft.com>
2021-09-07 14:07:17 -06:00
Alan Jowett 866f8a6917
Fix non-determinism in build due to multiple projects generating header (#496)
* Fix non-determinism in build due to multiple projects generating header
* Only regenerate git_commit_id.h on change

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-09-07 13:22:49 -06:00
Dave Thaler 7a921c0ef2
Add doxygen documentation for libbpf apis (#491)
* Add doxygen documentation for libbpf apis

Eventually this should be upstreamed, but as a workaround the docs
are put into our repo in the meantime.

As discussed at
https://stackoverflow.com/questions/23798053/how-to-document-errno-value-with-doxygen
doxygen does not have a built-in way to document errno values set.  It is
possible by creating doxygen custom commands, but for now we use
the "exception" section as recommended at the bottom of that page.

Fixes #490

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2021-09-07 10:51:18 -07:00
Dave Thaler 2349de2a46
Add object IDs (#487)
* Add object IDs

Add support for the following libbpf APIs:
* bpf_{link,map,prog}_get_fd_by_id
* bpf_{link,map,prog}_get_next_id

Addresses the main part of #396.
A subsequent PR will handle the rest of 396 which includes:
* remove "extra_value" complexity from maps

The changes in api_common.hpp and libbpf_internal.h are from PR 482 and so will go
away in a rebase once that PR is merged.

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Address PR feedback

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Address PR feedback

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Address PR feedback

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2021-09-07 09:54:08 -07:00
Shankar Seal dae2a4def5
clean up test code (#492)
* cleanup test code.

* PR feedback.
2021-09-07 08:46:07 -07:00
dbarac 3e3e317ad4
add sample_ebpf_ext.sys to built_files array in scripts/deploy-ebpf.ps1 (#494) 2021-09-06 22:41:39 -07:00
Dave Thaler 5f5e2c0d1f
Add bpf_link_detach and bpf_link__fd APIs (#482)
* Add bpf_link_detach and bpf_link__fd APIs

Fixes #372

Addresses leftover TODO comments referencing issue 81.

Fixes bug where errno was not being set to correct errno values

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2021-09-03 14:51:50 -07:00
saxena-anurag cec8bd0014
Fix bpf_link__destroy(), add bpf_link__disconnect() (#485)
* api changes

* fix

* Apply suggestions from code review

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

* changes

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2021-09-03 12:21:04 -07:00
Alan Jowett f6d46d1b38
BPF_MAP_TYPE_PERCPU* should pad values to EBPF_CACHE_LINE_SIZE (#486)
* Cache align map structures

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-09-02 20:06:32 -07:00
Shankar Seal ec68058a36
Test utility helper functions. (#480)
* Test utility helper functions.

* fix build break.

* PR feedback.

* PR feedback.
2021-09-02 17:23:16 -07:00
Alan Jowett 74daa0fcec
Set ps unrestricted (#483)
* Set ExecutionPolicy Unrestricted for PS script in build

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-09-02 14:54:03 -06:00
Alan Jowett ffdc71166e
ebpf_epoch: _ebpf_flush_timer_set should be per-CPU (#481)
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-09-02 13:55:45 -06:00
Alan Jowett ac9b6282b8
Add version info to ebpfcore.sys, ebpfapi.dll, netebpfext.sys, and ebpfsvc.exe (#478)
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2021-09-01 17:57:35 -06:00
Dave Thaler dd3f1b427c
Rename ebpf_helpers.h to bpf_helpers.h for cross-plat compat (#472)
Libbpf has bpf_helpers.h which is mostly platform-agnostic, and
bpf_helper_defs.h which is platform-specific but is included
by bpf_helpers.h.   Until libbpf is made more platform-agnostic
(issue #351), the workaround is to have a separate pair of files.
Our bpf_helpers.h and our own bpf_helper_defs.h, both of which
would ideally be merged into libbpf's in the future.

Platform-specific defines are in ebpf_struct.h, though that
name may need to change later on.  Linux uses "linux/bpf.h"
(e.g., as used in the https://docs.cilium.io/en/v1.8/bpf/ and
https://developers.redhat.com/blog/2021/04/01/get-started-with-xdp
articles) or "vmlinux.h" (e.g., as used in the
https://ruderich.org/simon/notes/xdp-minimal-example article),
and these filenames are hard coded in eBPF programs.  In the future,
we should probably settle on a cross-platform name and use include
paths to distinguish them, as opposed to requiring ifdefs in eBPF
programs.  However, all of that is part of issue 351 and not this
issue.

Also removed obsolete/unused "repro.c" from tests/samples

Fixes #426

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

Co-authored-by: Alan Jowett <alanjo@microsoft.com>
2021-09-01 16:30:33 -07:00
Alan Jowett cab6f57fb6
Add performance benchmarks for helper functions. (#474)
* Add performance benchmarks for helper functions

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-09-01 13:43:59 -06:00
Dave Thaler e33680b562
Update verifier to latest (#473)
Fixes a display bug in "netsh ebpf show disassembly ..."
and "netsh show verification ... level=verbose"

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

Co-authored-by: Alan Jowett <alanjo@microsoft.com>
Co-authored-by: saxena-anurag <43585259+saxena-anurag@users.noreply.github.com>
2021-09-01 09:53:36 -06:00
Dave Thaler d5c275acb3
Add netsh command to show maps (#476)
Signed-off-by: Dave Thaler <dthaler@microsoft.com>

Co-authored-by: saxena-anurag <43585259+saxena-anurag@users.noreply.github.com>
2021-09-01 08:10:39 -07:00
Alan Jowett 2aaa711f7d
Revert untested changes to epbf_epoch.c (#475)
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-08-31 21:19:31 -07:00
Alan Jowett 27c4c8f681
All per-CPU structures should be allocated on EBPF_CACHE_LINE_SIZE boundaries (#471)
* All per-CPU structures should be allocated on EBPF_CACHE_LINE_SIZE boundaries

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-08-31 18:21:00 -06:00
Alan Jowett ff47814b90
Workaround for issue where ProcDump64 swallows return codes. (#469)
* Set ProcDump64 as Just-In-Time debugger and set to capture dumps.
Fail test if dumps are generated.

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-08-31 14:21:22 -07:00
Alan Jowett 2e62286c9c
Simplified epoch tracking code to fix bugs hit in non-preemptive path. (#446)
* Fix epoch bugs and add performance tests
* Align ebpf_epoch_cpu_entry_t to CPU cache size to avoid false sharing

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2021-08-31 09:00:21 -06:00
Shankar Seal 16856deb0a
Pass program handle in GET_PROGRAM_INFO message. (#463)
* fix

* PR feedback.

* Apply suggestions from code review

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

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2021-08-30 20:15:09 -07:00
Dave Thaler 0a1555956e
Add map-in-map type checking (#451)
* Add map-in-map type checking

This PR enforces that all inner maps must be of the same type
as the inner map template used for verification.  Other fields
might need to match too, and if so those will be updated in
a subsequent PR once it is confirmed which fields must match.

A few pieces of this PR related to map_id are prerequisites
for issue #396 which will add IDs for programs, maps, and links.

Finally, there are multiple definitions of bpf_map, since the
version used to write eBPF programs is different from what is
stored in memory (which uses map IDs) so to avoid confusion in
code and allow the compiler to do type checking to catch some
bugs, this splits ebpf_map_definition_t into two, one for
in_memory and one for in_file (meaning in an eBPF program).
This will also allow the future PR for issue 396 to be more
understandable, but also aids clarity in some parts of this PR.

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2021-08-30 19:14:08 -07:00
Shankar Seal c764977442
utility general helper functions. (#450) 2021-08-28 11:05:57 -07:00
Alan Jowett 5983cbf07d
Micro-benchmarks for epoch and hash-table (#443)
* First version of performance tests

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-08-27 14:01:44 -06:00
Shankar Seal 7be9ef61dc
Fix bugs in kernel platform library. (#447)
Co-authored-by: Alan Jowett <alanjo@microsoft.com>
2021-08-27 11:59:58 -06:00
Alan Jowett f5e18cd4d8
Partition epoch thread list (#436)
* Partition epoch thread list
Perform memory free on epoch_exit

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-08-26 19:00:15 -06:00
Shankar Seal 86d01a743b
fix typo (#435)
* fix typo
2021-08-25 14:09:08 -07:00
Shankar Seal adfac5ee7d
eBPF extension readme (#430)
* eBPF extension readme

* Apply suggestions from code review

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

* PR feedback.

* PR Feedback.

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
Co-authored-by: Alan Jowett <alanjo@microsoft.com>
2021-08-25 12:50:05 -06:00
Alan Jowett 4be43a7ea1
Include required Clang version (#431)
* Update Getting Started to recommend current release version of Clang/LLVM

Clang-format behaves differently depending on the version of Clang installed.
Update getting started guide to recommend Clang / LLVM 10.0.0.
Update the development guide to indicate that Clang 10 or higher is required for consistent formatting.
Reformat all code using Clang 10.0.0

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-08-25 09:01:16 -06:00
Alan Jowett c9d40f09c4
Fix bug in epoch rundown and flush timer (#432)
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-08-24 16:17:24 -06: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
Dave Thaler c029cf21e7
Add note about github discussions (#428)
Also move the Zoom meeting info to an announcement in the discussions area

Fixes #162

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2021-08-23 17:51:01 -07:00
Alan Jowett 2035ef7366
Add support for stack unwind on success. (#367)
Signed-off-by: Alan Jowett alanjo@microsoft.com
2021-08-23 17:24:22 -06: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 024abd4534
PR feedback from #418 (#424)
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-08-23 14:49:26 -06:00
Shankar Seal 5519c26f5b
Register program type specific helper functions to uBPF in interpreted mode (#402)
* Register program type specific helper functions to uBPF in interpreted mode.

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2021-08-23 12:24:45 -07:00
Alan Jowett b917cc5ba8
Partition epoch free list by CPU (#418)
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-08-23 08:58:59 -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