Skip to content

Fix/ttl dscp portable sockopt constants - #16

Open
kristapssk wants to merge 2 commits into
hdds-team:masterfrom
kristapssk:fix/ttl-dscp-portable-sockopt-constants
Open

Fix/ttl dscp portable sockopt constants#16
kristapssk wants to merge 2 commits into
hdds-team:masterfrom
kristapssk:fix/ttl-dscp-portable-sockopt-constants

Conversation

@kristapssk

Copy link
Copy Markdown

Description

Two IP-level socket options in crates/hdds/src/transport/ used hardcoded
Linux numeric constants that are different on macOS/BSD, causing runtime
failure with IoError(Os { code: 42, kind: Uncategorized, message: "Protocol not available" })
(ENOPROTOOPT) whenever a Participant tried to configure IP TTL, multicast TTL,
or DSCP on Apple platforms.

Fix: replace the hardcoded numbers with the corresponding libc::* constants
so the correct per-platform value is resolved at compile time.

Constant Linux (old hardcoded) macOS/BSD Now
IP_MULTICAST_TTL 33 10 libc::IP_MULTICAST_TTL
IP_TTL 2 4 libc::IP_TTL
IP_TOS 1 3 libc::IP_TOS
IPPROTO_IP 0 0 libc::IPPROTO_IP

Linux behavior is byte-for-byte unchanged (the libc::* values resolve to
the same numeric constants). Windows paths already went through socket2
and are untouched.

Files:

  • crates/hdds/src/transport/ttl.rs
  • crates/hdds/src/transport/dscp.rs

Related Issue

N/A — no upstream issue was open. Discovered while building a downstream
TransportMode::UdpMulticast publisher on macOS 15 (Apple Silicon).

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist

  • My code follows the style guidelines of this project (cargo fmt --all -- --check passes)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas (existing // SAFETY: blocks preserved verbatim)
  • I have made corresponding changes to the documentation (no public API changed)
  • My changes generate no new warnings (cargo clippy on touched files is clean)
  • I have added tests that prove my fix is effective or that my feature works (existing unit tests already exercise both code paths; they now pass on macOS as well as Linux)
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules (none required)
  • Commits are DCO-signed (Signed-off-by: trailer on every commit)

Testing

Linux (containerized rust:latest, aarch64):

docker run --rm -e CARGO_TARGET_DIR=/tmp/tgt -v "$PWD":/work -w /work rust:latest bash -c "
  cargo fmt --all -- --check &&
  cargo test -p hdds --lib transport::ttl &&
  cargo test -p hdds --lib transport::dscp
"
# Result: 7/7 ttl + 5/5 dscp = 12/12 passed

@kristapssk
kristapssk marked this pull request as ready for review August 11, 2026 15:49
@kristapssk
kristapssk force-pushed the fix/ttl-dscp-portable-sockopt-constants branch from da4ddab to 131a843 Compare August 11, 2026 15:53
Hardcoded Linux values (2, 33) caused ENOPROTOOPT on macOS/BSD where they are 4 and 10; libc constants resolve correctly per-platform.

Signed-off-by: Kristaps Skujiņš <kristaps.skujins@gmail.com>
Hardcoded IP_TOS=1 (Linux) returned ENOPROTOOPT on macOS/BSD where it is 3; libc::IP_TOS resolves correctly per-platform.

Signed-off-by: Kristaps Skujiņš <kristaps.skujins@gmail.com>
@kristapssk
kristapssk force-pushed the fix/ttl-dscp-portable-sockopt-constants branch from 131a843 to fcecd95 Compare August 11, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant