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

14 Коммитов

Автор SHA1 Сообщение Дата
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
Dave Thaler 063ed2a4f8
Update to latest libbpf and bpftool (#1155)
* Update to latest libbpf and bpftool

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

* Fix test

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

* Update to latest verifier commit

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2022-05-31 17:43:39 -07:00
Dave Thaler bec56bc8c3
Add (non-deprecated) bpf_prog_load API support (#1130)
* Add bpf_prog_load()
* Move prototype for bpf_prog_load_deprecated() from libbpf.h to bpf.h
  to match libbpf
* Mark as deprecated bpf_object__load_xattr(), bpf_load_program(), and
  bpf_load_program_xattr() to match libbpf
* Make bpf_load_program_xattr() support the program name field, where
  previously it was ignored and a random name was used.

Fixes #1073

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2022-05-24 16:12:00 -07:00
Dave Thaler 4718bf7a73
Support bpf_object__load() with native programs (#1133)
* Make bpf_object__open_file work with native files

* Update bpf_object__open_file()
* Add bpf_object__open()
* Rename ebpf_enumerate_sections() to ebpf_enumerate_program_sections()

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

* Remove ebpf_program_load

And add a couple of windows-specific libbpf related APIs

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

* Fix bug in enumerate sections hit by tail_call_multiple_um.dll

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

* Fix program_name field in object_open

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

* Cleanup

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

* Fix order of PE sections returned

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

* Bug fix

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

* Bug fix

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

* Bug fix and revert enumerate_sections rename

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

* Updated expected bpf2c output

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

* Fix analysis warning

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

* Updated issue number in TODO comments

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

* Address Anurag's feedback

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2022-05-24 14:53:04 -07:00
Dave Thaler b7df2bec27
Document whether to close fds returned from various APIs (#1095)
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2022-05-12 16:21:16 -07:00
Dave Thaler 1e1b18e374
Add support for bpf_program__type (#1074)
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2022-05-09 10:11:48 -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 a9ab3370d5
`bpf_prog_attach` API and other changes. (#891)
* remove dependabot from the fork.

* Revert "remove dependabot from the fork."

This reverts commit c542c6cd44.

* Program info and hook NPI providers for sock_addr.

* Program info and hook NPI providers for sock_addr.

* PR Feedback.

* PR Feedback 2.

* wfp callout for sock_addr hook.

* PR Feedback.

* fix build break.
2022-04-07 18:18:53 -07:00
Dave Thaler 59c0b4e185
Allow attaching an XDP program to a specific ifindex (#755)
* Allow attaching an XDP program to a specific ifindex
* Update tests since droppacket.o changed
* Add ifindex use back to droppacket.c for testing purposes
* Verify xdp program to unlink is actually an XDP program
* Add comment re moving xdp fd replace logic to execution context
* Add libbpf test and add support for bpf_xdp_query_id

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2022-02-14 16:40:56 -08: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 41f5fd1b29
Add bpf_load_program, bpf_load_program_xattr APIs (#710)
* Add bpf_load_program, bpf_load_program_xattr APIs

Fixes #186

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

* Address review feedback

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

* Address code review feedback

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2022-01-07 10:31:31 -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 599230fd3f
Libbpf doxygen fixes (#608)
* Libbpf doxygen fixes

* Add missing bpf_map__name
* Move bpf_object__unload to be in alphabetical order

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2021-09-28 17:22:31 -07: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