Skip to content

net: preserve socket errors across syscall boundaries - #460

Open
xuchang-vivo wants to merge 1 commit into
vivoblueos:mainfrom
xuchang-vivo:xc/preserve-socket-errno
Open

net: preserve socket errors across syscall boundaries#460
xuchang-vivo wants to merge 1 commit into
vivoblueos:mainfrom
xuchang-vivo:xc/preserve-socket-errno

Conversation

@xuchang-vivo

Copy link
Copy Markdown
Contributor

Summary

  • Map ConnectionError and SocketError variants to specific negative POSIX errno values.
  • Preserve those errors through socket syscalls instead of collapsing every failure to -1.
  • Preserve socket read/write errors through sockfs instead of returning the generic code::ERROR.
  • Add unit coverage for common mappings and nested error forwarding.

Motivation

The BlueOS network stack already distinguishes conditions such as timeout, would-block, invalid file descriptor, queue exhaustion, and address conflicts. The socket syscall and VFS boundaries previously collapsed these failures to a generic -1, losing the original reason before it reached libc.

For example, a timeout should leave the kernel as -ETIMEDOUT, allowing the libc wrapper to return -1 with errno = ETIMEDOUT. Returning a bare -1 from the kernel instead makes the libc layer interpret the error number as 1 or observe stale errno.

This complements vivoblueos/librs#38, which converts negative kernel errno results to the POSIX libc -1 plus errno convention.

This PR only preserves reported errors. It does not implement socket timeout enforcement or change network operation behavior.

POSIX references

Testing

  • Added unit tests for connection and socket errno mappings.
  • rustfmt --check kernel/src/net/connection_err.rs kernel/src/net/socket/socket_err.rs kernel/src/net/syscalls.rs kernel/src/vfs/sockfs.rs
  • git diff --check
  • No board build was run.

@xuchang-vivo

Copy link
Copy Markdown
Contributor Author

build_prs

@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

✅ All jobs completed successfully, see https://github.com/vivoblueos/kernel/actions/runs/32947049817.

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