Skip to content

Add set_min_ttl_v4 and set_min_hopcount_v6 - #672

Merged
Thomasdezeeuw merged 1 commit into
rust-lang:masterfrom
taspelund:trey/min-ttl
Oct 3, 2026
Merged

Thomasdezeeuw merged 1 commit into
rust-lang:masterfrom
taspelund:trey/min-ttl

Conversation

@taspelund

Copy link
Copy Markdown
Contributor

Adds linux/illumos Socket methods for setting IP_MINTTL and IPV6_MINHOPCOUNT along with associated unit tests.

@taspelund

Copy link
Copy Markdown
Contributor Author

Tests pass on both platforms this new wrapper is being added for (linux and illumos):

# illumos
trey@korgano 07:06:08 PM | ~/git/socket2
‣ cargo test --all-features --test socket min_
    Updating crates.io index
     Locking 1 package to latest compatible version
    Updating libc v0.2.186 -> v0.2.189
   Compiling libc v0.2.189
   Compiling socket2 v0.6.5 (/home/trey/git/socket2)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 2.66s
     Running tests/socket.rs (target/debug/deps/socket-1129f55d11df1d5a)

running 4 tests
test min_hopcount_v6 ... ok
test min_hopcount_v6_preserves_outbound_hops ... ok
test min_ttl_v4_preserves_outbound_ttl ... ok
test min_ttl_v4 ... ok

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


# ubuntu 24.04
treyaspelund@lima-ubuntu-24-04:~/git/socket2$ cargo test --all-features --test socket min_
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.01s
     Running tests/socket.rs (target/debug/deps/socket-8ef69f38d614db53)

running 4 tests
test min_hopcount_v6_preserves_outbound_hops ... ok
test min_hopcount_v6 ... ok
test min_ttl_v4_preserves_outbound_ttl ... ok
test min_ttl_v4 ... ok

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

@taspelund

Copy link
Copy Markdown
Contributor Author

The CI failure seems unrelated to my changes. Is there something I need to do to move past it?

Adds linux/illumos Socket methods for setting IP_MINTTL and
IPV6_MINHOPCOUNT along with associated unit tests.

Signed-off-by: Trey Aspelund <trey@oxidecomputer.com>

@Thomasdezeeuw Thomasdezeeuw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that both Linux and illumos only accept a value in the range 0-255, maybe we should use an u8 for this option?

Comment thread tests/socket.rs
@Thomasdezeeuw

Copy link
Copy Markdown
Collaborator

The CI failure seems unrelated to my changes. Is there something I need to do to move past it?

You can ignore that CI failure it's unrelated to this pr.

@taspelund

Copy link
Copy Markdown
Contributor Author

It seems that both Linux and illumos only accept a value in the range 0-255, maybe we should use an u8 for this option?

I went with a u32 because set_ttl_v4()/set_hoplimit_v6() accept a u32 despite their valid range being 0-255 as well. My thought was that consistency across methods would probably be more appreciated than making the signature more constrained. That said, I'm certainly open to making it a u8. What are your thoughts?

@Thomasdezeeuw
Thomasdezeeuw merged commit a9aca12 into rust-lang:master Oct 3, 2026
54 of 55 checks passed
@Thomasdezeeuw

Copy link
Copy Markdown
Collaborator

That makes sense.

Thanks @taspelund

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.

2 participants