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

31 Коммитов

Автор SHA1 Сообщение Дата
Dave Thaler 3a9958f501
Support "netsh ebpf show sections" with native drivers (#1070)
* WIP: enumerate sections in native code

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

* Make bpf2c emit section names

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

* More of PE section enumeration

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

* Fix program type and map count display for native programs

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

* Update cmake files

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

* Temporarily disable some compiler warnings for the pe-parse project

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

* Native programs have different sizes for skeleton in debug vs release

Also add text case for section is just ".text"

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

* Address PR feedback

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

* Force inlining utility functions inside ebpf programs

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

* Update expected output

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

* More expected output changes

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

* Fix ebpfapi to allow a single section of name .text

To match libbpf behavior

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

* Fix test

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

* Resolve analysis warnings

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

* Fix analysis warnings

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

* Address PR comments from Anurag

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

* Fix test

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2022-05-11 14:06:49 -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
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
Shankar Seal d5cf5e8622
support interface parameter for loading XDP program in netsh ebpf con… (#790)
* support interface parameter for loading XDP program in netsh ebpf context.

* PR Feedback.

* PR Feedback.
2022-03-09 16:15:58 -08:00
Dave Thaler 980646a793
Improve netsh helper initialization error message output (#788)
* Improve netsh helper initialization error message output

Fixes #787

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

* Updated code comment

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2022-03-01 12:51:41 -08:00
Shankar Seal 40915b0d15
Netebpfext refactor (#776)
* fix crash.

* use NMR APIs.

* program info provider; bind program info

rename attach provider as hook provider

function renaming

* refactor hook providers.

* async client detach.

* cicd automation and documentation.

* PR Feedback.

* switch to server 2019.

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
Co-authored-by: Alan Jowett <alanjo@microsoft.com>
2022-02-25 17:53:12 -08:00
saxena-anurag 6b4dda75a1
remove ebpf_api_initiate, ebpf_api_terminate from sources (#738)
* remove ebpf_api_initiate, ebpf_api_terminate from sources

* cleaup traces

* cleanup traces
2022-01-31 08:32:28 -08:00
Dave Thaler 6d3be2a0c2
Fix netsh "show maps" output (#581)
* Fix netsh "show maps" output

* Display correct inner map ID
* Display Map ID
* Display count of # paths pinned
* Correct "set program" help text

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

* Fix rebase

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

Co-authored-by: Alan Jowett <alanjo@microsoft.com>
2021-09-21 10:34:13 -06:00
Dave Thaler 52e4acdcdf
Add option to pin all programs added, and show links and maps (#553)
* Add option to pin all programs added and show links and maps

* "add programs" now supports the equivalent of bpftool's "prog loadall"
  in addition to just "prog load"
* add "show links" netsh command
* expose "show maps" netsh command.  It was partially implemented but
  never exposed before.
* remove ebpf_map_query_definition() and test as being redundant with
  bpf_obj_get_info_by_fd() (and in the future, a strongly typed one that
  is map specific but different from the query map definition prototype)
* Fix bug where getting the next ID failed to check for index beyond
  array size.  And add test cases for it.
* Fix bug in ebpf_state.c where after enough tests ran it would start
  returning EBPF_NO_MEMORY because _ebpf_state_next_index was never
  reset.

Addresses #549

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2021-09-17 18:52:47 -07:00
Alan Jowett cdcf793a54
Move generated include to include (#564)
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-09-17 17:13:14 -06: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 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
Alan Jowett f5ba5c5d7c
Use CRT library to map handles to fds (#513)
* Use CRT library to map handles to fds

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-09-14 09:25:56 -06: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 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
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 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 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
Shankar Seal a93f4ba714
program information serialization (#302)
* program information serialization.

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2021-06-28 16:47:34 -07:00
Dave Thaler 360aa224ea
Add some netsh tests (#295)
Adds tests for "show sections" and "show disassembly"

Addresses part of issue #240

Signed-off-by: Dave Thaler <dthaler@ntdev.microsoft.com>
2021-06-23 09:54:36 -07:00
saxena-anurag c31547cff5
Add ebpf public APIs - #1 (#290)
* add ebpf_program_load(), few other APIs
2021-06-22 20:42:18 -07: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
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
Dave Thaler bf7eef76c5
Make netsh "show verification" command display max instruction count (#242)
Fixes #193

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2021-06-02 12:22:06 -06:00
Dave Thaler 50a773d8dc
Fix bugs in netsh helper (#238)
* Pinning a program requires a name to pin to
* The load program API doesn't correctly deal with an empty section name
  (it does use the first section but then tells the execution context
  that the section name is empty instead of the chosen one), so for now
  require the section name in any "add program" command
* Allow netsh to hold references on multiple programs
* Fix handle leak in "show programs"
* Implement ability to pin a program, but unpinning requires
  a way to look up what a program was pinned to, and no such
  API exists currently.
* Implement filtering "show programs" output by filename and section

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

Co-authored-by: Alan Jowett <alanjo@microsoft.com>
2021-06-01 09:47:26 -06:00
Dave Thaler d37e65801a
Fix netsh display of program type (#226)
Since the program type changed from int to GUID the display has been
broken (it displays a useless pointer value).  This fix makes it display
the string name of the type.

Signed-off-by: Dave Thaler <dthaler@ntdev.microsoft.com>
2021-05-25 22:05:03 -07:00
Dave Thaler faebbdd32a
Clean up compiler warnings (#225)
The IDL was generating MIDL2279 because it used const on an [out] param,
which is warned against since RPC marshaling copies the result into new
memory.  See https://marc.info/?l=ms-dcom&m=103440617317922 for some
discussion.

Other changes should hopefully be obvious.

Signed-off-by: Dave Thaler <dthaler@ntdev.microsoft.com>
2021-05-25 15:36:19 -07:00
Alan Jowett c47617951a
Split public and internal headers (#154)
* Split public and internal headers

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-05-10 09:47:54 -06:00
Dave Thaler 7a34bb0c86
Make verifier and netsh use GUIDs instead of int program types (#150)
Signed-off-by: Dave Thaler <dthaler@ntdev.microsoft.com>
2021-05-08 10:45:50 -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