syscalls/socket: return 0 for unimplemented SOL_SOCKET options in sys_setsockopt - #2490
syscalls/socket: return 0 for unimplemented SOL_SOCKET options in sys_setsockopt#2490Rodrigo-Ichaso wants to merge 1 commit into
Conversation
…_setsockopt SOL_SOCKET is defined as 4095 in hermit-abi. The value does not fit in a u8, so the Ipproto::try_from conversion that follows the SOL_SOCKET check always fails and returns EINVAL for every SOL_SOCKET option except SO_REUSEADDR. This causes Rust std's TCP socket setup to fail on hermit: during connect() and accept(), std calls setsockopt with SOL_SOCKET level (e.g. SO_RCVTIMEO, SO_SNDTIMEO, SO_KEEPALIVE) and the resulting EINVAL surfaces as os error 22, making plain HTTP connections impossible. Fix: match on SOL_SOCKET level before the Ipproto conversion and return 0 for all options at that level. Unimplemented options are silently no-ops, which is consistent with what Linux does for options it doesn't support on a given socket type.
There was a problem hiding this comment.
Benchmark Results
Details
| Benchmark | Current: d4af8e1 | Previous: f83a235 | Performance Ratio |
|---|---|---|---|
| startup_benchmark Build Time | 77.59 s |
77.08 s |
1.01 ❗ |
| startup_benchmark File Size | 0.73 MB |
0.73 MB |
1.00 ❗ |
| Startup Time - 1 core | 0.74 s (±0.02 s) |
0.73 s (±0.02 s) |
1.01 |
| Startup Time - 2 cores | 0.74 s (±0.02 s) |
0.75 s (±0.02 s) |
0.98 |
| Startup Time - 4 cores | 0.77 s (±0.02 s) |
0.76 s (±0.02 s) |
1.01 |
| multithreaded_benchmark Build Time | 81.00 s |
80.66 s |
1.00 ❗ |
| multithreaded_benchmark File Size | 0.86 MB |
0.86 MB |
1.00 ❗ |
| Multithreaded Pi Efficiency - 2 Threads | 88.04 % (±7.75 %) |
89.44 % (±5.91 %) |
0.98 |
| Multithreaded Pi Efficiency - 4 Threads | 44.07 % (±2.68 %) |
44.06 % (±2.65 %) |
1.00 |
| Multithreaded Pi Efficiency - 8 Threads | 25.44 % (±1.63 %) |
25.56 % (±1.89 %) |
1.00 |
| micro_benchmarks Build Time | 87.76 s |
87.20 s |
1.01 ❗ |
| micro_benchmarks File Size | 0.87 MB |
0.87 MB |
1.00 ❗ |
| Scheduling time - 1 thread | 67.30 ticks (±2.40 ticks) |
67.04 ticks (±1.91 ticks) |
1.00 |
| Scheduling time - 2 threads | 37.13 ticks (±4.20 ticks) |
39.33 ticks (±3.42 ticks) |
0.94 |
| Micro - Time for syscall (getpid) | 3.51 ticks (±0.29 ticks) |
3.43 ticks (±0.24 ticks) |
1.02 |
| Memcpy speed - (built_in) block size 4096 | 83487.47 MByte/s (±57579.19 MByte/s) |
84527.91 MByte/s (±58322.62 MByte/s) |
0.99 |
| Memcpy speed - (built_in) block size 1048576 | 30962.29 MByte/s (±25147.68 MByte/s) |
30845.87 MByte/s (±25037.16 MByte/s) |
1.00 |
| Memcpy speed - (built_in) block size 16777216 | 27389.24 MByte/s (±22674.44 MByte/s) |
27492.52 MByte/s (±22708.20 MByte/s) |
1.00 |
| Memset speed - (built_in) block size 4096 | 83353.47 MByte/s (±57488.64 MByte/s) |
84666.80 MByte/s (±58421.97 MByte/s) |
0.98 |
| Memset speed - (built_in) block size 1048576 | 31683.59 MByte/s (±25547.75 MByte/s) |
31593.14 MByte/s (±25470.12 MByte/s) |
1.00 |
| Memset speed - (built_in) block size 16777216 | 28156.16 MByte/s (±23146.46 MByte/s) |
28269.66 MByte/s (±23193.64 MByte/s) |
1.00 |
| Memcpy speed - (rust) block size 4096 | 74461.95 MByte/s (±51937.87 MByte/s) |
74722.10 MByte/s (±52209.99 MByte/s) |
1.00 |
| Memcpy speed - (rust) block size 1048576 | 30868.07 MByte/s (±25103.90 MByte/s) |
30824.11 MByte/s (±25054.28 MByte/s) |
1.00 |
| Memcpy speed - (rust) block size 16777216 | 27069.18 MByte/s (±22332.84 MByte/s) |
27597.67 MByte/s (±22766.03 MByte/s) |
0.98 |
| Memset speed - (rust) block size 4096 | 74666.60 MByte/s (±52073.47 MByte/s) |
74865.22 MByte/s (±52302.23 MByte/s) |
1.00 |
| Memset speed - (rust) block size 1048576 | 31610.83 MByte/s (±25521.63 MByte/s) |
31565.59 MByte/s (±25484.76 MByte/s) |
1.00 |
| Memset speed - (rust) block size 16777216 | 27833.53 MByte/s (±22810.79 MByte/s) |
28374.92 MByte/s (±23250.83 MByte/s) |
0.98 |
| alloc_benchmarks Build Time | 80.27 s |
81.01 s |
0.99 ❗ |
| alloc_benchmarks File Size | 0.81 MB |
0.81 MB |
1.00 ❗ |
| Allocations - Allocation success | 91.32 % |
91.32 % |
1 |
| Allocations - Deallocation success | 100.00 % |
100.00 % |
1 |
| Allocations - Pre-fail Allocations | 61.46 % |
61.46 % |
1 |
| Allocations - Average Allocation time | 6121.01 Ticks (±134.89 Ticks) |
6133.98 Ticks (±129.62 Ticks) |
1.00 |
| Allocations - Average Allocation time (no fail) | 6760.79 Ticks (±172.70 Ticks) |
6784.80 Ticks (±184.79 Ticks) |
1.00 |
| Allocations - Average Deallocation time | 1265.47 Ticks (±248.24 Ticks) |
1292.85 Ticks (±344.36 Ticks) |
0.98 |
| mutex_benchmark Build Time | 81.92 s |
81.90 s |
1.00 ❗ |
| mutex_benchmark File Size | 0.87 MB |
0.87 MB |
1.00 ❗ |
| Mutex Stress Test Average Time per Iteration - 1 Threads | 12.06 ns (±0.51 ns) |
12.08 ns (±0.27 ns) |
1.00 |
| Mutex Stress Test Average Time per Iteration - 2 Threads | 17.56 ns (±2.75 ns) |
17.94 ns (±3.62 ns) |
0.98 |
This comment was automatically generated by workflow using github-action-benchmark.
mkroening
left a comment
There was a problem hiding this comment.
What is the option that ureq needs?
Your patch makes setsockopt return 0 for all options. It would be preferable to first see what option is needed and whether we can implement or stub that one specifically instead of stubbing all options.
You seem to be using LLMs heavily. Please completely rework your PR description as well as your code comment. They seem not to be concise and are sometimes wrong.
|
I tried with: [dependencies]
ureq = { version = "3", default-features = false }fn main() {
ureq::get("http://example.com")
.header("Example-Header", "header value")
.call()
.unwrap()
.body_mut()
.read_to_string()
.unwrap();
}Which runs successfully, and the only Please provide a reproduction and reopen the PR. :) |
|
Ah, I can reproduce with ureq 2. |
|
I have opened #2711 to discuss what we should do. |
Problem
SOL_SOCKETis defined as4095in hermit-abi. This value cannot be represented asu8, so theIpproto::try_fromconversion that follows the existingSOL_SOCKETcheck always fails and returnsEINVALfor everySOL_SOCKEToption exceptSO_REUSEADDR.This causes Rust std's TCP socket setup to fail on hermit: during
connect()andaccept(), std internally callssetsockoptwithSOL_SOCKETlevel (e.g.SO_RCVTIMEO,SO_SNDTIMEO,SO_KEEPALIVE) and the resultingEINVAL(os error 22) surfaces to userspace, making plain HTTP connections impossible.Reproduced while running a Rust HTTP client (ureq 2.x) inside a hermit unikernel on uhyve with virtio-net. Every
connect()returnedos error 22before this fix.Fix
Match on
SOL_SOCKETbefore theIpprotoconversion and return0for all options at that level. Unimplemented options are silently treated as no-ops — consistent with Linux behaviour for unsupported socket options on a given socket type.SO_REUSEADDRcontinues to work as before (it was already returning0).Testing
Verified with a ureq-based HTTP client compiled for
x86_64-unknown-hermitmaking GET/POST requests over virtio-net to a LAN server. Before this fix: every call failed withos error 22. After: connections succeed normally.