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

44 Коммитов

Автор SHA1 Сообщение Дата
Alan Jowett f084c9d4c3
Remove unneeded nuget package (#2507)
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2023-05-24 14:38:32 +00:00
Gianni Trevisiol 5950a9785b
Load/Attach/Unload programs only once for connect_redirect tests. (#2450)
* draft

* comments, rename

* nit

* test

* nit

* test

* test

* aggregate globals

* Fix C26495 warnings

* debug

* test

* debug

* debug instrument

* instrument

* comment

* debug

* fix hints and address_info leak

* fix leak

* wip

* fix

* fix

* tests

* Finalize and remove instrumentation.

* Merge bpf_object_ptr definitions

* feedback

* nit

* fixed SAL annotation

* feedback

* nit

* revert
2023-05-17 17:32:04 +00:00
Anurag Saxena 93eb42a908
Revert "socket tests and redirection tests does not clean up bpf_object on failure (#2226)" (#2419)
This reverts commit 6c025904b3.
2023-05-02 04:01:52 +00:00
Delaram Amiri 6c025904b3
socket tests and redirection tests does not clean up bpf_object on failure (#2226)
* wrapper for tests using smart pointer

* address PR comments

* address PR comments

* update connect edirect test

* update connect redirect test

* resolve conflict

* resolve conflict

* test with connect redirect

* test with connect redirect

* change connect redirect test

* address PR comment

* rebase the changes from main

* rebase the changes from main

* Update tests/connect_redirect/connect_redirect_tests.cpp

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

* address PR comment

* modify the bpf object pointer

---------

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2023-04-28 18:27:04 +00:00
Alan Jowett 8b1a8e4e0f
Update NuGet packages (#2386)
Co-authored-by: Alan-Jowett <Alan-Jowett@users.noreply.github.com>
2023-04-28 15:57:08 +00:00
Alan Jowett 9a4853adee
Check for crash dumps on workflow faiure (#2327)
* Check for crash dumps on workflow failure.
Fastfail the process on watchdog timeout.

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

* Remove intrin.h to prevent conflict with Windows SDK.

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

* Suppress failfast during unit testing

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

---------

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2023-04-14 17:49:47 +00:00
Dave Thaler 93b7634d23
Fix sanitizer build of fuzzer (#2201)
* Fix sanitizer build of fuzzer

Fixes #1817

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

* Fixes

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

* More fixes

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

* Disable some build steps for FuzzerDebug

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

* Update github workflows

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

* Update verifier to latest

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

* Fix execution_context_fuzzer build

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

* Fix bpf2c and samples

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

* Fix samples compilation

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

* Fix custom program type sample

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

---------

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2023-04-13 15:00:49 +00:00
Alan Jowett e8f437f364
Raise STATUS_ASSERTION_FAILURE on test timeout (#2272)
* Raise STATUS_ASSERTION_FAILURE on test timeout

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

* PR feedback

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

* Manually generated dump on test timeout

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

---------

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2023-04-06 23:03:43 +00:00
Alan Jowett 240fbb16d8
Convert single line if to if with braces (#2224)
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2023-03-27 15:01:21 +00:00
Alan Jowett 4cf0391526
Refactor low memory test into generic fault injection (#2173)
* Refactor low memory test into generic fault injection

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

* Update number of frames to skip

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

* PR feedback

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

---------

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2023-03-11 02:42:28 +00:00
Dave Thaler 3d626ff9c1
Clean up order of includes (#2015)
* Clean up order of includes

Fixes #1963

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

* Update clang-format

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

* Clean up headers

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

* Update sort

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

* FIx various build errors

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

* Fix ordering if including a .c file

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

* Fix cmake build

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

* More header cleanup

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

* Update expected bpf2c output

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

* More header fixes

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

* Update expected bpf2c output for custom bpf.c

The generate script does not handle this file.

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

* Fix tests

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

* Fix more expected bpf2c output

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

---------

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
Co-authored-by: Anurag Saxena <43585259+saxena-anurag@users.noreply.github.com>
Co-authored-by: Alan Jowett <alanjo@microsoft.com>
2023-02-07 18:32:19 +00:00
Alan Jowett 5bd706092b
Add option to generate .spd files for sample driven PGO (#1931)
* Add option to generate .spd files for sample driven PGO

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

* Fix test failure

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

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2023-01-20 23:10:24 +00:00
Anurag Saxena 8cb62b3fd7
Support for multiple implementations of global helper functions (#1761)
* fix

* add native test

* cleanup

* CR comments

* update expected files

* fix

* cr comments
2022-12-31 10:56:28 -07:00
github-actions[bot] 0dff94f740
Update NuGet packages (#1768)
Co-authored-by: Alan-Jowett <Alan-Jowett@users.noreply.github.com>
Co-authored-by: Alan Jowett <alanjo@microsoft.com>
2022-12-19 21:02:25 +00:00
Alan Jowett 0b293ad804
Fix code analysis annotations for In and In_opt parameters by adding const where appropriate or changing to Inout where appropriate. (#1749)
* Fix code analysis annotations for _In_ and _In_opt_ parameters,
add const where appropriate or change to _Inout_ where appropriate.

The following regex expressions were used to find the problems:
Find _In_ or _In_opt_ that are not const and are not followed by _Post_invalid_ or _Frees_ptr_ or _Post_ptr_invalid_:
```_In_[ ]+(?!.*(const|_Post_invalid_|_Frees_ptr_|_Post_ptr_invalid_))```
```_In_opt_[ ]+(?!.*(const|_Post_invalid_|_Frees_ptr_|_Post_ptr_invalid_))```

Some of the _In_ and _In_opt_ parameters are not const due to required compatibility with the Windows API.
Pointers to functions are const by definition, so the const qualifier is not required.

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

* PR feedback

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

* Fix code analysis failure

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>

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2022-12-15 15:58:33 -08:00
github-actions[bot] d28c045228
Update NuGet packages (#1747)
Co-authored-by: Alan-Jowett <Alan-Jowett@users.noreply.github.com>
Co-authored-by: Alan Jowett <alanjo@microsoft.com>
2022-12-13 19:36:39 -07:00
Alan Jowett 3e4d71fd8c
Add missing nuget package declarations (#1745)
Fix paths to packages.
Removed unused nuget packages.

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

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2022-12-13 11:01:11 -08:00
Gianni Trevisiol 99b7ece81f
Visual Studio 2022 porting (#1521)
* Draft

* wip - full build

* wip

* Docs & scripts update

* revert test

* Updates to overall GettingStarted.md guide.

* Updated CI/CD scripts

* Update ebpf-verifier cache key

* Fix #1513. Next action forwarded to #1563.

* Bump up epbfverifier to 05bca47

* Fix CRT path.

* Disable sanitizing

* fix cmake build

* Removed unsupported x86 and ARM configurations.

* Test address sanitizer off

* wip -full build w/asan

* asan enabled on ci/cd

* update wdk version to 22621

* wip - full build

* add mock asan

* Update CL param

* wip - proj sync

* wip - ltcg

* wip - driver settings

* wip-build props

* wip - asan opts

* wip-plat asan

* wip-asan

* wip

* wip

* wip-debug

* Branch resync

* Mitigate compiler OOM.

* remove asan mock

* doc update

* doc update

* Removed commented code.

* Added comments for pragma-s
2022-12-08 20:06:57 -07:00
Alan Jowett c95a90219e
Emulate driver verifier systematic low memory mode (#1512)
* Emulate driver verifier systematic low memory mode

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
2022-11-09 15:28:09 -07:00
Dave Thaler 7e0738ee07
Add support for new libbpf APIs (#1288)
* Update to latest libbpf .h files

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

* Add libbpf_bpf_{prog,attach}_type_str APIs

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

* Add libbpf_attach_type_by_name

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

* Add libbpf_bpf_{link,map}_type_str

And add tests for prog type and attach type names

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

* Add tests

And change type names to match Linux

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

* Fix cmake build

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

* Update tests

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

* Update docs

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

* Add bpf_program__insn_cnt()

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

* Add MSVC deprecated attribute to most deprecated APIs

Still haven't done bpf_object__next() or bpf_prog_load_deprecated()

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

* Mark bpf_object__next was deprecated

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

* Fix some test failures

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

* Suppress instead of disable deprecated warnings

To simplify diffs

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

* Merge with latest main

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

* PR feedback

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2022-07-29 14:57:30 -04:00
Shankar Seal a25ede7aaf
Fix ring buffer test subscriber logic. (#1286)
* Fix ring buffer test subscriber logic.

* PR feedback etc.

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2022-07-14 10:32:38 -07:00
saxena-anurag 1160f7914e
Registry changes for program and section data. (#1192)
* fix

* backup

* fix backup

* msbuild compiling

* fix release build

* fixes

* cmake build fix

* fix cmake build

* fix analyse build

* fix

Signed-off-by: Anurag Saxena <43585259+saxena-anurag@users.noreply.github.com>

* fix expected output

* add pre step for tests

* add pre step for tests

* add -s option, revert this later

* Revert "add -s option, revert this later"

This reverts commit 1f42d100e4.

* code cleanup

Signed-off-by: Anurag Saxena <anusa@microsoft.com>

* rename driver_registry_helper.h

* delete bpf_structs.h

* fix

* hardcode HKLM

* code cleanup

* fix

* backup

* fix backup

* msbuild compiling

* fix release build

* fixes

* cmake build fix

* fix cmake build

* fix analyse build

* fix

Signed-off-by: Anurag Saxena <43585259+saxena-anurag@users.noreply.github.com>

* add pre step for tests

* add pre step for tests

* add -s option, revert this later

* Revert "add -s option, revert this later"

This reverts commit 1f42d100e4.

* code cleanup

Signed-off-by: Anurag Saxena <anusa@microsoft.com>

* rename driver_registry_helper.h

* delete bpf_structs.h

* fix

* hardcode HKLM

* code cleanup

* fix build break

* fix build break, enable warning

* fix bad merge

* cleanup

* fix

* fix tests

* add tests, make ebpf_store_helper platform agnostic

* fixes, cleanup, common code for store APIs

* fix cmake build, driver tests

* cleanup

* code cleanup

* cr comments

* code cleanup

* cleanup

* bugfix

* Apply suggestions from code review

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

* cr comments

* fix build break

* move UM read store APIs to a different file

* cr comments

* cr comments

* cr comments

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2022-06-30 16:53:03 -07:00
Alessandro Gario 6a54714ec2
cmake: Add base targets (#882)
Signed-off-by: Alessandro Gario <alessandro.gario@gmail.com>
2022-04-26 05:39:37 -07:00
Dave Thaler 086b80149d
Nuget package (#999)
* WIP: Developer nuget package

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

* Add bpf2c utility

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

* Build nupkg from within VisualStudio

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

* Don't use relative path to externals

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

* Update props file in nuget package

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

* Fix include and library paths

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

* Fix debug build

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

Co-authored-by: saxena-anurag <43585259+saxena-anurag@users.noreply.github.com>
2022-04-25 10:26:56 -07:00
Shankar Seal ec26f5d273
WFP ALE Flow established callout, tests etc. (#978)
* WFP ALE Flow established callout, tests etc.

* PR Feedback.

* bug fixes.

* PR feedback 2.
2022-04-20 16:48:20 -07:00
Alan Jowett fd94c807a5
Centralize compiler options (#823)
* Centralize all compiler options

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2022-03-29 10:41:09 -06:00
Alan Jowett 5e468b8857
Switch to current catch2 release (#809)
* Switch to current catch2 release

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2022-03-18 17:39:21 -06:00
Shankar Seal 48f0ff60e2
fix CICD script to throw on test failure. (#741)
* fix script.

* temporary workaround.

* fix test.
2022-01-31 21:23:23 -08:00
Shankar Seal 91e74be955
ring buffer map. (#659)
* ring buffer map.

* PR Feedback iteration 0.

* PR Feedback iteration 1

* Fix race.

* PR Feedback iteration 2

* bugfix.

* Bug fix.

* Fix test issue

* PR Feedback.

* Update libs/api_common/device_helper.cpp

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2021-12-03 13:19:21 -08:00
Dave Thaler 20d7a6565e
Add more libbpf APIs needed by bpftool (#576)
* Add more libbpf APIs needed by bpftool

* Add missing export for existing bpf_map__name API
* Add bpf_object__load
* Add bpf_object__load_xattr
* Add bpf_object__open_file
* Add bpf_object__unload() API
* Add bpf_program__get_type
* Add bpf_program__set_type
* Add bpf_program__unload() API
* Add libbpf_get_error
* Add libbpf_num_possible_cpus
* Rename BPF_MAP_TYPE_UNSPECIFIED to BPF_MAP_TYPE_UNSPEC for libbpf
  compat
* Rename BPF_PROG_TYPE_UNKNOWN to BPF_PROG_TYPE_UNSPEC for libbpf compat
* Add attach_type to bpf_link_info
* Add map_flags to bpf_map_info (but currently always 0)

Fixes #575

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2021-09-23 19:32:09 -07:00
Alan Jowett 967990f700
Disable /ZI and incremental linking (#546)
* Disable /ZI and incremental linking

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-09-16 16:49:02 -06:00
Dave Thaler 12bb2e7195
Update netsh commands to use more standard libbpf apis (#527)
* Update netsh commands to use more standard libbpf apis

* Add support for libbpf bpf_obj_pin() API
* Add support for libbpf bpf_object__next() API
* Rename BPF_{PROG,ATTACH}_TYPE_UNKNOWN to ...UNSPEC for libbpf compat
* Remove now-unused handle APIs ebpf_api_load_program and
  ebpf_api_pin_object, which is part of issue #383
  * netsh set/delete program now uses the ID to identify the program,
    like bpftool does, so that it can work even if the program wasn't
    loaded from an ELF file

Fixes #191

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2021-09-14 10:59:57 -07:00
Alan Jowett e553150b1b
Switch from MultiThreadedDebug to MultiThreadedDebugDll (#528)
* Switch from MultiThreadedDebug to MultiThreadedDebugDll
* Pull in latest ebpf-verifier

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-09-14 08:46:01 -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
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 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
saxena-anurag 014ee34392
Add eBPF UM APIs (#368)
* parse map names from elf file
* add apis, change test code

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2021-08-10 17:04:07 -07:00
Dave Thaler 2617349903
Remove duplicate public APIs where standard libbpf APIs exist (#356)
* Remove duplicate public APIs where standard libbpf APIs exist

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2021-08-03 17:25:50 -07:00
Dave Thaler 4d0ac1bd4d
Replace "information" with "info" for consistency (#331)
Previously some places had "info" and some had "information".
Both appear in dictionaries, so guidance to avoid abbreviations does not apply.

Fixes #314

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2021-07-07 11:16:35 -07:00
Shankar Seal f96522ecd4
fix sal on safeint functions (#321)
* fix sal on safeint functions

Co-authored-by: Alan Jowett <alanjo@microsoft.com>
2021-06-29 21:42:40 -07:00
Alan Jowett a0801d410c
Suppress C26451 (#312)
* Suppress C26451 and related errors

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-06-28 16:13:29 -07: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 a46b00c2e3
Add VM setup scripts and docs (#281)
* Create an install script rather than having to manually do lots
  of steps
* Make Debug build use vcruntime as static libs to avoid adding
  another prerequisite on a machine before installing eBPF.  This
  isn't required for Release builds as vcruntime release DLLs
  are part of Windows, unlike vcruntime debug DLLs

Fixes #248

Signed-off-by: Dave Thaler <dthaler@ntdev.microsoft.com>
2021-06-15 08:44:43 -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