Skip to content

VERY DRAFT: wasm32 validator support#1380

Draft
daniel-noland wants to merge 13 commits intomainfrom
pr/daniel-noland/wasm32-validator-support
Draft

VERY DRAFT: wasm32 validator support#1380
daniel-noland wants to merge 13 commits intomainfrom
pr/daniel-noland/wasm32-validator-support

Conversation

@daniel-noland
Copy link
Collaborator

I'm still cleaning this up and so it isn't really worth review yet. Mostly I need to see interaction with the CI at the moment

daniel-noland and others added 13 commits March 23, 2026 13:33
Remove `#![allow(clippy::redundant_closure_for_method_calls)]` and replace
all redundant closures with method references throughout the config crate.

I actually don't love this particular change because I thought it was fine
before.  That said, I hate having arguments with the linter a lot more.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Daniel Noland <daniel@githedgehog.com>
Remove `#![allow(clippy::doc_markdown)]` and add backticks around type
names in doc comments throughout the config crate.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Daniel Noland <daniel@githedgehog.com>
Remove `#![allow(clippy::missing_errors_doc)]` and add errors doc
sections to all public functions returning Result throughout the config
crate.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Daniel Noland <daniel@githedgehog.com>
Remove `#![allow(clippy::struct_excessive_bools)]` and add per-struct
`#[allow(clippy::struct_excessive_bools)]` annotations on BGP and BMP
config structs where booleans directly model protocol flags.

The lint removal was actually perfectly fine, but should be done on a
per struct level rather than package wide.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Daniel Noland <daniel@githedgehog.com>
First up, we aren't using kani at the moment so it is just causing clutter.
Next, we had some over-broad `allows` running around which Claude and I
cleaned up.
Finally, we re-organized a few cargo build features to prep for the wasm
build.

These are pure code quality improvements with no functional change.
We had some over-broad style violations in the form of package wide `allow`s.

- Remove unused import of peering in vpc.rs
- Add missing doc comment sections (`# Errors`) for VpcPeering::validate
- Fix doc_markdown lint: wrap VpcPeering in backticks

These are pure code quality improvements with no functional change.
Add WASM/WASI targets to the Rust toolchain configuration in the Nix
overlay. This enables cross-compilation to wasm32-wasip1 and
wasm32-wasip2 from the development environment.
- Move atomic-instant-full to `cfg(x86_64, aarch64)` target deps
  (requires native atomic instructions not available on wasm32)
- Move linux-raw-sys to `cfg(unix)` target deps
- Gate flows and packet modules with `#![cfg(unix)]` (depend on
  linux-specific types and atomic-instant-full)
- Gate flows re-export in lib.rs with `#[cfg(unix)]`
- Replace linux_raw_sys::if_ether::ETH_MAX_MTU constant with
  hardcoded 65535 in Mtu, gating the linux_raw_sys import

These changes allow the net crate to compile on wasm32-wasip1 while
preserving all existing functionality on unix targets.
The sysfs crate provides Linux sysfs/procfs access which is not
available on wasm32 targets. Make it optional behind a 'sysfs' feature
(enabled by default) and gate the nic module that depends on it.

This allows the hardware crate's core types (PCI addresses, bridge
attributes, etc.) to be used on non-Linux targets without pulling in
Linux-specific filesystem dependencies.
Introduce a 'client' feature (enabled by default) that gates the
heavy, WASM-incompatible dependencies behind an opt-in feature

The generated CRD types and their derive dependencies (kube with just
`derive`, `kube-core`, `k8s-openapi`, `schemars`, `serde`, `serde_json`,
`serde_yaml_ng`) remain always available.

Gate the client.rs and utils.rs modules (and the
`watch_gateway_agent_crd` re-export) with `#[cfg(feature = "client")]`.

This allows crates that only need CRD type definitions (like the
validator) to depend on `k8s-intf` with `default-features = false`,
avoiding the entire async/crypto/linker dependency tree that prevents
wasm32-wasip1 compilation.
Move tracectl and linkme to `[target.'cfg(unix)'.dependencies]` in
config/Cargo.toml since both depend on unix-specific functionality:
- `tracectl`: uses unix-only tracing infrastructure
- `linkme`: uses linker section injection (not available on wasm32)

Provide platform-conditional alternatives for non-unix targets:
- Use `tracing::metadata::LevelFilter` as a drop-in for
  `tracectl::LevelFilter` in tracecfg converters
- Define `DEFAULT_DEFAULT_LOGLEVEL` constant for non-unix
- Provide no-op `TracingConfig::validate()` on non-unix
- Add `cfg(unix)` gate on `trace_target!` macro invocation in lib.rs
- Add non-unix ConfigError::Tracing variant using String

Also use `default-features = false` for hardware and k8s-intf deps,
and explicitly add sysfs feature where needed in dev-dependencies.
Workspace Cargo.toml:
- Set `default-features = false` for hardware and `k8s-intf` workspace deps
  so that downstream crates opt-in to platform-specific features
- Remove `rt-multi-thread` from tokio workspace default features
  (now requested explicitly by crates that need it)
- Remove codec from tokio-util workspace default features
  (now requested explicitly by crates that need it)

Downstream crate adjustments:
- validator: use `k8s-intf`; with `default-features = false` (only needs CRD
  types, not the full K8s client)
- k8s-less: explicitly request `k8s-intf` 'client' feature
- mgmt: explicitly request `k8s-intf` 'client' feature
- args: explicitly request hardware 'sysfs' feature
- init: explicitly request hardware 'sysfs' feature
- routing: explicitly request tokio 'rt-multi-thread' feature and
  tokio-util 'codec' feature

With these changes, the validator can be checked against wasm32-wasip1:
cargo check --target wasm32-wasip1 -p dataplane-validator
@daniel-noland daniel-noland force-pushed the pr/daniel-noland/wasm32-validator-support branch from ef670aa to b9326ca Compare March 23, 2026 22:21
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.

1 participant