Skip to content

Addition with a variable==0 behaves differently than addition with a constant 0 #35

@Nieuwejaar

Description

@Nieuwejaar

This is a vague description of a specific problem. The version of sidecar-lite with multipath almost enabled (oxidecomputer/sidecar-lite@587ba36) will pass cargo test.

If I make a no-op change to control router_v4_idx, the test fails.

nils@atrium:~/dev/softnpu/sidecar-lite$ git diff
diff --git a/p4/sidecar-lite.p4 b/p4/sidecar-lite.p4
index bb2bfa7..ed4da0d 100644
--- a/p4/sidecar-lite.p4
+++ b/p4/sidecar-lite.p4
@@ -553,7 +553,7 @@ control router_v4_idx(
        // bit<16> hash = csum.run({dst_addr, src_addr});
        bit<16> hash = 0;
         bit<16> offset = 0;
-        ingress.path_idx = idx;
+        ingress.path_idx = idx + offset;
     }
nils@atrium:~/dev/softnpu/sidecar-lite$ cargo test
   Compiling sidecar-lite v0.1.0 (/home/nils/dev/softnpu/sidecar-lite/softnpu)
    Finished test [unoptimized + debuginfo] target(s) in 4.52s
     Running unittests src/main.rs (target/debug/deps/scadm-57e417cb3be430c3)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/lib.rs (target/debug/deps/sidecar_lite-2332ee4720c17ce6)

running 2 tests
test test::vlan_routing_ingress ... FAILED

In this case, we have set offset to 0, so the function's behavior should be unchanged.

If I hardcode this as ingress.path_idx = idx + 16w0, then the test succeeds again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions