Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

L3af on windows #68

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ enabled: false
# san-match-rules: .+l3afd.l3af.io,.*l3af.l3af.io,^l3afd.l3af.io$

[l3af-config-store]
filename: /var/l3afd/l3af-config.json
filename: /var/l3afd/l3af-config.json
Copy link
Collaborator

Choose a reason for hiding this comment

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

Revert?

56 changes: 56 additions & 0 deletions dev_environment/cfg/l3afd_win.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[DEFAULT]

[l3afd]
pid-file: /var/l3afd/l3afd.pid
datacenter: dc
bpf-dir: /var/l3afd/repo
bpf-log-dir: /var/l3afd/repo
shutdown-timeout: 1s
http-client-timeout: 10s
max-ebpf-restart-count: 3
bpf-chaining-enabled: false
swagger-api-enabled: true
environment: DEV
BpfMapDefaultPath: /sys/fs/bpf

[ebpf-repo]
url: C:/var/l3afd/repo

[web]
metrics-addr: 0.0.0.0:8898
ebpf-poll-interval: 30s
n-metric-samples: 20

[xdp-root]
package-name: xdp-root
artifact: l3af_xdp_root.tar.gz
ingress-map-name: xdp_root_array
command: xdp_root
version: latest
object-file: xdp_root_kern.o
entry-function-name: xdp_root

[tc-root]
package-name: tc-root
artifact: l3af_tc_root.tar.gz
ingress-map-name: tc/globals/tc_ingress_root_array
egress-map-name: tc/globals/tc_egress_root_array
command: tc_root
version: latest
ingress-object-file: tc_root_ingress_kern.o
egress-object-file: tc_root_egress_kern.o
ingress-entry-function-name: tc_ingress_root
egress-entry-function-name: tc_egress_root

[ebpf-chain-debug]
addr: localhost:8899
enabled: false

[l3af-configs]
restapi-addr: localhost:53000

[l3af-config-store]
filename: /var/l3afd/l3af-config.json

[mtls]
enabled: false
25 changes: 25 additions & 0 deletions dev_environment/cfg/port_quota_add_payload.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[
{
"host_name": "l3af",
"iface": "Ethernet 4",
"bpf_programs": {
"xdp_ingress": [
{
"name": "port_quota",
"seq_id": 1,
"artifact": "port_quota.exe",
evershalik marked this conversation as resolved.
Show resolved Hide resolved
"cmd_start": "port_quota.exe",
"version": "debug",
"user_program_daemon": true,
"admin_status": "enabled",
"prog_type": "xdp",
"cfg_version": 1,
"start_args": {
"load": "load"
}
}
]
}
}
]

11 changes: 11 additions & 0 deletions dev_environment/cfg/port_quota_delete_payload.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"bpf_programs": {
"xdp_ingress": [
"port_quota"
]
},
"host_name": "leaf1",
"iface": "Ethernet"
}
]
85 changes: 85 additions & 0 deletions dev_environment/l3af_on_windows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
### Prerequisites:

- [Git](https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/Git-2.41.0.3-64-bit.exe)
- Cmake
- Clang
- Nmake
- [Golang](https://go.dev/doc/install)
- C++ using: [MSYS2](https://www.msys2.org/)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be good to know why MSYS2 is needed, so we can work to remove that dependency

- [Visual Studio Build Tools 2022](https://aka.ms/vs/17/release/vs_buildtools.exe)
evershalik marked this conversation as resolved.
Show resolved Hide resolved

### Steps to Build l3afd on Windows:

1. Clone l3afd repo:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
1. Clone l3afd repo:
1. Clone the l3afd repository:

```bash
git clone https://github.com/l3af-project/l3afd.git
```

2. Build l3afd using:
```bash
cmake -B build
cmake --build build
```

>l3afd.exe file will be created after this.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
>l3afd.exe file will be created after this.
>l3afd.exe will be created after this.


### Steps to run l3afd on Windows:

3. Update [l3afd_win.cfg](./cfg/l3afd_win.cfg) file:

- Replace the `l3afd.cfg` file in `l3afd` repo with the above `l3afd_win.cfg` file
- Manually create a directory and set the custom path for pid-file: `mkdir C:\var\l3afd`
- Set `swagger-api-enabled` to **true**

4. Run l3afd.exe
```bash
l3afd.exe
```

![l3afd.exe](../images/l3af-on-windows/l3afd.exe_output.png)

### Access Swagger API on the dashboard:
Go to this webpage: http://localhost:53000/swagger/index.html

![SwaggerAPI](../images/l3af-on-windows/SwaggerAPI.png)

### Attaching eBPF program with L3AF:

> **NOTE:** Before moving further, set up [eBPF for Windows](https://github.com/microsoft/ebpf-for-windows/blob/main/docs/GettingStarted.md) on the system.

#### Changes need to be done before proceeding:

Manually set the following paths in [l3afd_win.cfg](../config/l3afd_win.cfg):
- bpf-dir:
- bpf-log-dir:
- BpfMapDefaultPath:
- [ebpf-repo] url:
- set bpf-chaining-enabled to false

#### Using [payload.json](./cfg/port_quota_add_payload.json) to load programs:

- Use this curl command to add an eBPF program using the `payload.json` file:
```bash
curl -X POST http://localhost:53000/l3af/configs/v1/add -d "@cfg/payload.json"
```

- See the `logs` in the window where `l3afd.exe` is running:

![ebppAddProgramLog](../images/l3af-on-windows/ebppAddProgramLog.png)

### Confirm eBPF program loading on Windows:

- Use this command to list all the eBPF programs running on the system:
```bash
netsh ebpf show programs
```
or
```bash
bpftool prog show
```






Binary file added images/l3af-on-windows/SwaggerAPI.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/l3af-on-windows/ebppAddProgramLog.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/l3af-on-windows/l3afd.exe_output.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.