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

17 Коммитов

Автор SHA1 Сообщение Дата
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
Delaram Amiri 215323919a
Implementation of syscalls in bpf_syscall.cpp (#1866)
* update fuzzing doc

* Update docs/Fuzzing.md

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

* update based on PR comment

* implementation of bpf syscall

* modify attach/detach APIs

* modify unit tests

* modify unit test

* Update tests/unit/libbpf_test.cpp

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

* Update tests/unit/libbpf_test.cpp

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

* Update tests/unit/libbpf_test.cpp

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

* Update tests/unit/libbpf_test.cpp

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

* Update tests/unit/libbpf_test.cpp

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

* Update tests/unit/libbpf_test.cpp

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

* Update tests/unit/libbpf_test.cpp

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

* change attach struct to unnamed

* Update tests/unit/libbpf_test.cpp

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

* added failure test for look up and deletion

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2023-01-17 17:56:03 +00:00
Alan Jowett a902b82788
PR feedback from https://github.com/microsoft/ebpf-for-windows/pull/1825 (#1838)
* PR feedback from https://github.com/microsoft/ebpf-for-windows/pull/1825

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

* Update libs/execution_context/ebpf_program.c

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

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2023-01-08 19:53:53 -07:00
Alan Jowett de5ab7aaec
Add bpf_prog_test_run_opts support (#1825)
* Add bpf_prog_test_run_opts support

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

* Update BPF syscall interface

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

* Fix code analysis failure

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

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2023-01-09 00:24:24 +00: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
Dave Thaler 4cd7d96b99
Fix doxygen output (#940)
Several fields were missing descriptions in the generated docs.
This PR fixes the docs to actually show the relevant descriptions.

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

Co-authored-by: Alan Jowett <alanjo@microsoft.com>
2022-04-13 12:29:41 -06:00
Dave Thaler 2f5ac3fbe9
Add some header file names included by typical eBPF programs (#916)
* Add some header file names included by typical eBPF programs

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

* PR feedback

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

* Fix test

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

* Remove unneeded include

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

* Add _MSC_VER checks around pragma warnings in ebpf program headers

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

* Use full path to avoid requiring an include path

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

Co-authored-by: Alan Jowett <alanjo@microsoft.com>
2022-04-11 13:26:49 -07:00
Dave Thaler d00377f074
Make map definition more cross-platform compatible (#904)
Fixes #903

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2022-04-07 18:53:21 -07:00
Dave Thaler 34598edf84
Update bpftool and libbpf dependencies (#744)
* Update bpftool

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

* Update paths to libbpf and bpftool

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

* Add more libbpf APIs

* Added bpf_map_create, bpf_object__next_map, bpf_object__next_program, bpf_object__prev_map, bpf_object__prev_program
* Removed obsolete exports ebpf_create_map and ebpf_create_map_name
* Updated prototype of bpf_program__attach and bpf_progam__attach_xdp to
  match latest libbpf header

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

* Address code review feedback

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2022-02-08 13:21:19 -08:00
Dave Thaler b9dc141163
Add bpf() API (#711)
* Add bpf() API

Addresses issue #559

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

* Address code review suggestion

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2022-01-11 20:47:06 -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
Dave Thaler aa09128ae0
Add libpf's libbpf_prog_type_by_name() API (#534)
* Add libpf's libbpf_prog_type_by_name() API

And add an ebpf_get_program_type_by_name() that returns the GUIDs
instead of ints.

This also removes the hard-coding of GUIDs or ints from the netsh
helper.

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2021-09-15 12:08:18 -07: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
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
Dave Thaler 7c12adb067
Prevent mismatched program types in PROG_ARRAY maps (#374)
* Prevent mismatched program types in PROG_ARRAY maps

* Each prog array map has a natural progtype, determined when
  asociating it from a program, or when adding the first program
  to it, if not associated with any program.
* Trying to add a program with mismatching type will fail
* Added libbpf bpf_create_map() API
* Fixed error returns from several libbpf APIs to be negative
* For efficiency, ebpf_program_get_properties now returns a
  pointer rather than copying the data inside the execution
  context, and is renamed to ebpf_program_get_parameters()
  to match what its return type always was.
* Fixed a bug in map size calculation that resulted in a huge
  amount of memory being allocated
* Updated return type of bpf_tail_call to the value meant
  to signal stack unwind needed

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2021-08-11 12:17:10 -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 8006f181e0
Libbpf API compatibility (#350)
* Libbpf API compatibility

Libbpf is incorporated as a submodule just for the header file.
As discussed in issue #84, we cannot currently use the implementation
since it is very Linux and GCC specific.

This PR also fixes a bug where the user-mode API was calling
CloseHandle directly instead of Platform::CloseHandle which is needed
to make tests work with the mock platform.

Addresses #84

Some code will be cleaner once issue #81 is done

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2021-07-30 15:34:21 -07:00