test: filter flow r/n first-hop rules match 3-byte path hashes on their first 2 bytes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ae8d5057da
commit
b83269c807
1 file changed
+17
@@ -231,6 +231,23 @@ TEST(FlowMatch, RelayInPath) {
|
||||
EXPECT_TRUE(t.verdict(pkt(FLOW_PKT_OTHER, pl, 1, path3, 3, 1), 0, false));
|
||||
}
|
||||
|
||||
// 3-byte path hashes (path hash mode 2): r/n rules with a first hop compare the
|
||||
// first 2 bytes of the 3-byte hop, exactly as for 2-byte hops.
|
||||
TEST(FlowMatch, FirstHopOfThreeBytePaths) {
|
||||
uint8_t hop3[] = {0xf8, 0xbf, 0x42, 0x11, 0x22, 0x33};
|
||||
uint8_t other3[] = {0xf8, 0xbe, 0x42};
|
||||
uint8_t req[] = {0x8b, 0x2c, 0, 0};
|
||||
uint8_t anon[] = {0x8b, 0, 0};
|
||||
FlowTable r4; r4.add(R('r', "8b2cf8bf"), 0);
|
||||
EXPECT_TRUE(r4.verdict(pkt(FLOW_PKT_ADDR, req, 4, hop3, 3, 2), 0, false));
|
||||
EXPECT_FALSE(r4.verdict(pkt(FLOW_PKT_ADDR, req, 4, other3, 3, 1), 0, false));
|
||||
FlowTable r3; r3.add(R('r', "2cf8bf"), 0);
|
||||
EXPECT_TRUE(r3.verdict(pkt(FLOW_PKT_ADDR, req, 4, hop3, 3, 2), 0, false));
|
||||
FlowTable n3; n3.add(R('n', "8bf8bf"), 0);
|
||||
EXPECT_TRUE(n3.verdict(pkt(FLOW_PKT_ANON, anon, 3, hop3, 3, 2), 0, false));
|
||||
EXPECT_FALSE(n3.verdict(pkt(FLOW_PKT_ANON, anon, 3, other3, 3, 1), 0, false));
|
||||
}
|
||||
|
||||
// ── modes, throttle, dry ─────────────────────────────────────────────────────
|
||||
|
||||
TEST(FlowVerdict, ThrottleOnePerWindowAndCounters) {
|
||||
|
||||
Reference in new issue
Block a user