Repository navigation
fix(net): convert in6_pktinfo's interface index with a range check - #2
Merged
Merged
Conversation
dlep-net does not build for Android: in6_pktinfo.ipi6_ifindex is a u32 in glibc and musl but a c_int in bionic, so the three places that copy it to or from a u32 interface index are type errors there (E0308, mismatched types). A plain cast would build but wrap silently, and on glibc `as u32` is a same-type cast that clippy -D warnings refuses. Both directions now go through i64, which holds either type, with a checked conversion. An index that does not fit the field is not sent (that pktinfo is skipped), and a received index that is negative leaves the interface unset and the scope id untouched. On glibc and musl the behaviour is unchanged.
athola
force-pushed
the
fix/android-in6-pktinfo-ifindex
branch
from
October 6, 2026 01:08
f5afe0d to
0c14670
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
dlep-netdoes not build for Android.in6_pktinfo.ipi6_ifindexis au32in glibc and musl but ac_intin bionic, so the three places indiscovery.rsthat copy it to or from au32interface index fail there:A plain
ascast would build, but it wraps a bad value silently. On glibc,as u32is also a same-type cast, whichclippy -D warningsrefuses.This change converts both directions through
i64, which holds either type, with a checked conversion (two small helpers next to the tests):in6_pktinfois skipped, the same as when no interface is selected.interface_indexunset and the scope id untouched.On glibc and musl the behaviour is unchanged.
Tests, in
crates/dlep-net/src/discovery.rs:an_interface_index_that_does_not_fit_the_field_is_not_senta_received_interface_index_is_checked_not_wrappedBoth are written so they run on Linux with
i32andu32inputs.Checked:
cargo check --target aarch64-linux-android -p dlep-net -p dlep-daemon: 3 errors onmaster, clean with the change. Clippy (-D warnings) is also clean for that target.cargo fmt --all -- --checkandcargo clippy --workspace --all-targets --locked -- -D warningsare clean..github/scripts/test-network.sh cargo test --workspace --locked --offline, in a privileged container: no failures before or after. That is 451 tests before and 453 after, the two new ones, and it includes the IPv6 discovery tests that go through the changed receive path.An Android
cargo checkjob may be helpful for checking Android builds for errors before merge, but it requires an NDK in the runner.