Skip to content

Add WFP listen hook simulation for sock_addr listen testing#306

Merged
mikeagun merged 3 commits into
microsoft:mainfrom
mikeagun:sockops-listen-hook
Jun 1, 2026
Merged

Add WFP listen hook simulation for sock_addr listen testing#306
mikeagun merged 3 commits into
microsoft:mainfrom
mikeagun:sockops-listen-hook

Conversation

@mikeagun
Copy link
Copy Markdown
Contributor

Add usersim_fwp_cgroup_inet4_listen and usersim_fwp_cgroup_inet6_listen to simulate WFP ALE_AUTH_LISTEN_V4/V6 layer classify calls. These enable unit testing of the
new cgroup/listen4 and cgroup/listen6 sock_addr attach types in ebpf-for-windows.

The functions populate FWPS_FIELD_ALE_AUTH_LISTEN_V4/V6 incoming values (local address, port, compartment ID, interface LUID, app ID) and invoke the registered WFP callout via test_callout.

Michael Agun and others added 3 commits May 13, 2026 12:51
Rename usersim listen hook test functions from sock_ops naming to
cgroup_inet naming to match the sock_addr-based listen hook design:
- usersim_fwp_sock_ops_listen_v4 -> usersim_fwp_cgroup_inet4_listen
- usersim_fwp_sock_ops_listen_v6 -> usersim_fwp_cgroup_inet6_listen
- test_sock_ops_listen_v4 -> test_cgroup_inet4_listen
- test_sock_ops_listen_v6 -> test_cgroup_inet6_listen

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread src/fwp_um.cpp
{
FWPS_INCOMING_VALUE0 incoming_value[FWPS_FIELD_ALE_AUTH_LISTEN_V4_MAX] = {};
incoming_value[FWPS_FIELD_ALE_AUTH_LISTEN_V4_IP_LOCAL_ADDRESS].value.uint32 = parameters->destination_ipv4_address;
incoming_value[FWPS_FIELD_ALE_AUTH_LISTEN_V4_IP_LOCAL_PORT].value.uint16 = parameters->destination_port;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should we rename destination_ipv4_address and destination_port to a more accurate name, like local_ip and remote_ip?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you clarify - are you thinking to alias them inside this function to more intuitive names?

These are the existing classify parameters (for listen the destination address/port are the local ones we are listening on), so renaming the actual fields would break existing callers.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant renaming the fields in fwp_classify_parameters_t struct. This is just a test struct defined in fwp_test.h.

Agree that some code will need to be updated in ebpf repo when the latest commit of usersim is consumed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created a follow-up issue (#308) for this renaming.

@mikeagun mikeagun merged commit a0e1e96 into microsoft:main Jun 1, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants