(10) feat(match-action): MatchKey trait + derive + bolero generators#1574
Conversation
There was a problem hiding this comment.
Pull request overview
Adds the match-action core crate and derive macro, providing typed field/rule specs, erased predicates, MatchKey derivation, and bolero-based field generators for future ACL and cascade layers.
Changes:
- Introduces
dataplane-match-actionwithMatchKey, field specs, predicates, rule specs, and generator support. - Adds
dataplane-match-action-deriveproc macro for deriving key layout and companion rule structs. - Adds workspace registration, lockfile entries, and derive/generator roundtrip tests.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
Cargo.toml |
Registers match-action crates and package metadata. |
Cargo.lock |
Adds lock entries for the new crates. |
match-action/Cargo.toml |
Defines crate dependencies and feature flags. |
match-action/src/lib.rs |
Exposes public match-action API types and traits. |
match-action/src/field.rs |
Re-exports FixedSize. |
match-action/src/rule.rs |
Adds rule field specs and universal checks. |
match-action/src/predicate.rs |
Adds erased predicate matching and conversions. |
match-action/src/generator.rs |
Adds bolero hit/miss generators for field predicates. |
match-action/tests/derive_roundtrip.rs |
Tests derive layout, packing, rules, and generics. |
match-action-derive/Cargo.toml |
Defines proc-macro crate dependencies/features. |
match-action-derive/src/lib.rs |
Implements #[derive(MatchKey)]. |
| let lo = be_to_u32(min); | ||
| let hi = be_to_u32(max); | ||
| let v = (lo..=hi).generate(d)?; | ||
| Some(u32_to_be(v, min.len())) |
mvachhar
left a comment
There was a problem hiding this comment.
I love the use of the macro, I hate the definition since it is really hard to understand, but that is the nature of these macros I suppose.
Copilot has some things that should be addressed.
Also, your FiveTuple doc example should be ThreeTuple or expanded to an actual FiveTuple.
I also feel like the macro testing is light, but that might be ok if we are mainly just using a single data type for most of dataplane. We can fix bugs later as we add more data types, assuming bugs crop up.
4bc3201 to
9509b0a
Compare
c071ee9 to
7d5e7ad
Compare
bdba8a6 to
9808e5a
Compare
7d5e7ad
into
pr/daniel-noland/dpdk-test-eal
9808e5a to
7d5e7ad
Compare
Stack (10). Base:
pr/daniel-noland/fixed-size-lookup.The match-action core: the trait + derive macro that everything keys off, plus
its property-test generators.
feat(match-action):MatchKeytrait +#[derive(MatchKey)]proc-macro.feat(match-action): boleroFieldHit/FieldMissgenerators.Review focus: derive semantics and generator coverage, in isolation from ACL.
Review stack (merge bottom -> top):