livox rust: bind host ports with SO_REUSEADDR, as SDK2 does - #4240
jeff-hykin wants to merge 2 commits into
Conversation
The vendor's livox_ros_driver2 (Livox SDK2) holds the same host ports and binds them with SO_REUSEADDR, so the C++ Point-LIO module (also SDK2) shares them and this driver, binding plainly, was the one process refused with EADDRINUSE. Bind the command and data sockets with reuse set. Also make the impostor-sender test run on macOS, where 127.0.0.2 is not on lo0: fall back to the routed interface address.
|
| ); | ||
| assert!( | ||
| source.is_ok(), | ||
| "must coexist with an SDK2 binder: {:?}", | ||
| source.err() | ||
| ); | ||
| stop.store(true, Ordering::Relaxed); |
There was a problem hiding this comment.
This test only verifies that LiveSource::start returns, then immediately stops the source. It can pass while the SDK2-style sockets receive the handshake ACKs or point and IMU datagrams instead. Keep those sockets bound through a completed fake-device handshake and assert receipt of both packet types. This is non-blocking, but without it the regression test can miss a broken data path.
Artifacts
- Ran the PR's existing coexistence test from the repository root; it passed but only ran the startup-and-stop path, confirming the limited scope.
- Temporary executable command that adds a test retaining the three SDK2-style bindings, ACKing the full handshake, and requiring point and IMU receipt.
- Executed the focused validation from the repository root; it timed out waiting for a packet with competing SDK2-style sockets held, so full traffic coexistence was not demonstrated.
| probe | ||
| .connect(SocketAddrV4::new(Ipv4Addr::new(10, 255, 255, 255), 9)) | ||
| .expect("no 127.0.0.2 alias and no default route: nowhere to forge from"); | ||
| match probe.local_addr().unwrap() { | ||
| std::net::SocketAddr::V4(addr) if !addr.ip().is_loopback() => *addr.ip(), | ||
| addr => panic!("routed address {addr} is not a usable impostor"), | ||
| } |
There was a problem hiding this comment.
Avoid route-dependent fallback
If 127.0.0.2 is unavailable and the runner has no default route, this fallback panics after UDP address selection fails, before the sender-filter assertion runs. The unexpected-sender test therefore fails on isolated or offline runners even though the production behavior is unaffected. Use a deterministic local setup or handle an unavailable route without panicking. This must be fixed before merging because it makes the test suite fail in supported isolated environments.
Artifacts
- Evidence file captured while the check ran.
- The full command output behind this check.
- The full command output behind this check.
- The full command output behind this check.
- The full command output behind this check.
Comments Outside DiffThese findings sit on lines the diff does not cover, so they could not be posted inline. Each one leaves this list once its file changes.
|
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #4240 +/- ##
=======================================
Coverage 79.71% 79.71%
=======================================
Files 1508 1508
Lines 142607 142607
Branches 12209 12209
=======================================
Hits 113681 113681
Misses 25485 25485
Partials 3441 3441
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
| /// over a specific one). A vendor SDK2 process -- `livox_ros_driver2` on the | ||
| /// Galaxea R1 -- holds the same host ports, and the kernel only lets two | ||
| /// sockets share a port when both asked for it. A plain bind is refused with | ||
| /// `EADDRINUSE`; the C++ Point-LIO module, which binds through SDK2, never |
There was a problem hiding this comment.
Can we just remove this commentary about deleted code? Otherwise lgtm!
Don't forcefully reuse the Mid360 port (needed for R1 Pro stuff)