* Add initial bpftool tests and another libbpf test
And fix various bugs hit by the tests.
This PR only adds a couple of initial tests.
A future PR will add many more tests.
bpftool_tests.exe is meant to be run on a machine with the drivers
installed. A future PR will add it to the KM test runner in CI/CD.
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
* Fix release build
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
* Fix test
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
* Fix test
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
* Send stderr to bpf2c_tests log
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
* Update expected bpf2c output for map.o
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
* Fix bpf2c map output
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>
* Encode all program info types
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Expand hard coded program types and helper functions
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Fix tail_call_map verification failure
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Fix tail_call_map verification failure
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Call ebpf_verifier prior to code gen
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Resovle failures after merge
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* PR feedback
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Revert rollback of catch2
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
* Fix reply id/length on failure in KM
And make UM and KM more closely follow the same logic to catch this sort
of bug in the future. Before this, UM would succeed and KM would fail,
and there were only UM tests for this case.
Fixes#946
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
* Fix device_helper.hpp
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
* Fix reply length
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
* Cleanup
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
* PR feedback
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
Co-authored-by: Alan Jowett <alanjo@microsoft.com>
* remove dependabot from the fork.
* Revert "remove dependabot from the fork."
This reverts commit c542c6cd44.
* add sock_ops program and attach types.
* PR Feedback.
ebpf_get_next_map was obsoleted by standard libbpf apis
(specifically bpf_map_get_next_id and bpf_map_get_fd_by_id)
and isn't called by anything including test code.
This increases our code coverage percentage.
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
Co-authored-by: Alan Jowett <alanjo@microsoft.com>
* 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.
* add mock layer to test native module load
* Apply suggestions from code review
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
* make unit_test dependent on dll projects
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
Co-authored-by: Alan Jowett <alanjo@microsoft.com>
* initial_commit
* fix build
* fix build
* fix build break due to merge
* debug build
* api changes, other changes
* bpf2c change to enmit program type, other fixes
* hydrate UM ebpf_object, other fixes
* remove logic to disable programs
* fixes
* fix sal
* build break
* build break
* fix sal errors
* fixes
* fix bpf2c_tests failure
* unload driver when program ref count becomes 0, other minor fixes
* fixes
* tail_call fixes, add test cases, other fixes
* build break
* build break
* code cleanup
* fix bad merge
* code cleanup
* code cleanup
* cleanup
* Apply suggestions from code review
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
* cr comments
* Apply suggestions from code review
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
* cr comments
* Apply suggestions from code review
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
* cr comments
* cr comments
* Apply suggestions from code review
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
* address cr comments
* Apply suggestions from code review
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
* add tracing in ebpfcore, other fixes
* tracing
* add section for each map in sample
* do not delete the native service
* fix bad merge
* remove code to delete service, other fixes
* cr comments
* bpf2c should read and populate all the maps in ELF file
* add test case for creating map-in-map from native driver
* Apply suggestions from code review
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
* cr comments
* add tracing for api code changes
* rename epbf_native_t to ebpf_native_module_t
* fix bad merge
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
* Add BPF_PROG_TYPE_CGROUP_SOCK_ADDR program type and CGROUP_INET4/6_CONNECT/RECV_ACCEPT attach types.
* PR Feedback #1.
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
* Enable building with Address Sanitizer
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Grab clang binaries
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Fix read overrun in map_crud_operations_lpm_trie_32
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Fix potential read of uninitialized memory
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Really fix read overrun
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Fix second overrun
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Remove RPC client test for now
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* PR feedback
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Apply suggestions from code review
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
Add an additional flag per CPU EBPF_EPOCH_PER_CPU_STALE.
This flag is accessed by ebpf_epoch_exit and by the flush timer.
This flag is set to on by the flush timer if the free_list is not empty.
This flag is set to off by ebpf_epoch_exit (if set).
If the flush timer sees this flag on and the free_list is not empty, then it will schedule an _ebpf_epoch_stale_worker DPC on the CPU (this DPC calls ebpf_epoch_enter/ebpf_epoch_exit).
Resolves: #813
Signed-off-by: Alan Jowett alanjo@microsoft.com
* Add mutual auth for RPC client / server.
RPC client and server should authenticate each other, to ensure:
Only admin client makes a call to ebpfsvc.
Client is talking only to ebpfsvc.
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Initial printk numeric args support
Also add a verification failure test case if trying to print a pointer
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
* Add varargs support to printk
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
* Validate printk format specifiers
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
* Verify that printk specifier count and arg count match
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
* Update doxygen docs
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
Co-authored-by: saxena-anurag <43585259+saxena-anurag@users.noreply.github.com>
* Initial version of bpf_printk support
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
* Convert printk.c sample to use bind hook instead of xdp hook
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
* Add wprp file to deployment script
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
* Unify UM and KM platforms as much as possible for printk support
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
* Fix annotation
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
* Work around compiler warning
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
* Fix comment
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
* Fix keyword
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
* Fix test when -s is used
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
* Add test to trigger division by zero handler
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Fix bugcheck in interpreter on division by zero
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* PR feedback
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Pickup latest ebpf-verifier to resolve this issue
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Strip paths from netsh output
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Pickup latest ebpf-verifier changes
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Switch to run CI/CD on Server 2019 + VS2019
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Pickup fix for https://github.com/vbpf/ebpf-verifier/issues/306
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Pickup fix for https://github.com/vbpf/ebpf-verifier/issues/306
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* PR feedback
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
* 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>
* Add option EBPF_JIT_ALWAYS_ON to permit building EC with no interpreter
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Add documentation on using compile time options
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Set EBPF_JIT_ALWAYS_ON for release builds
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Tests should expect interpret to fail if EBPF_JIT_ALWAYS_ON is defined
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Rename EBPF_JIT_ALWAYS_ON to CONFIG_BPF_JIT_ALWAYS_ON
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Tests should expect interpret to fail if EBPF_JIT_ALWAYS_ON is defined
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Update docs/GettingStarted.md
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
* Load returns EBPF_PROGRAM_LOAD_FAILED
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Split up load into individual test cases
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Program load fails with EBPF_PROGRAM_LOAD_FAILED
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* Skip tests that depend on interpret mode when it's disabled
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
* PR feedback
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
* Support map fds with bpf_load_program
Fixes#714
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
* Address code review feedback
Also do some code cleanup
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
* Address feedback
Signed-off-by: Dave Thaler <dthaler@microsoft.com>