Skip to content

[FEATURE] Rust tokio network support #19360

Description

@wllenyj

Is your feature request related to a problem? Please describe.

Currently the nuttx rust app is not compiled, when using the tokio net feature.
So I added the interrelated definitions for Nuttx target in libc and other crates as follows.

rust-lang/libc#5258
tokio-rs/tokio#8259
lambda-fairy/rust-errno#129
tokio-rs/mio#1966
rust-lang/socket2#663
rust-lang/socket2#664

However, I'm worried some details might be incorrect, so I'd appreciate it if the NuttX maintainers could review this together. Thank you.

Describe the solution you'd like

  1. Enabled keepalive in socket2.
  2. Disabled unsupported capabilities.
    These flags are not supported in Nuttx target.
    SO_REUSEPORT
    IP_HDRINCL
    IP_RECVTOS
    IPV6_RECVTCLASS
    IPV6_ADD_MEMBERSHIP
    IPV6_DROP_MEMBERSHIP
  3. Used poll as the selector instead of epoll. because the epoll_event structure is defined differently from the linux_like. Therefore, additional support may be needed; for now, let's get tokio working. Supporting epoll is the final solution. It may open other pr to progress epoll support.
  4. Linked errno crate to use __errno symbol.
  5. Disabled reuseport in tokio.
  6. Use impl_noproc to handle get_peer_cred,in tokio for working. In future, may be needed coding to support.
  7. Added some definitions in libc.
  8. Type IovLen to c_ulong in socket2. Using msg_iovlen with unsigned long is not entirely consistent with POSIX. Other platform is defined c_int.

Describe alternatives you've considered

No response

Verification

  • I have verified before submitting the report.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions