Stream: git-wasmtime

Topic: wasmtime / PR #3711 DRAFT: Implement `sock_accept` and ba...


view this post on Zulip Wasmtime GitHub notifications bot (Jan 21 2022 at 13:56):

haraldh opened PR #3711 from wasmtime_sock_accept to main:

Together with https://github.com/rust-lang/rust/pull/93158 this enables basic networking in rust.

The split of listen and stream modules where mainly done because of the difference in ::num_ready_bytes().

TODO:
[ ] Windows support
[ ] Put the ListenFd feature behind a cli options
[ ] Document the ListenFd feature

view this post on Zulip Wasmtime GitHub notifications bot (Jan 21 2022 at 14:01):

haraldh edited PR #3711 from wasmtime_sock_accept to main:

Together with https://github.com/rust-lang/rust/pull/93158 this enables basic networking in rust.

The split of listen and stream modules where mainly done because of the difference in ::num_ready_bytes().

TODO:
[ ] Windows support
[ ] Put the ListenFd feature behind a cli option
[ ] Document the ListenFd feature

view this post on Zulip Wasmtime GitHub notifications bot (Jan 21 2022 at 14:33):

bjorn3 created PR review comment:

I think this shouldn't be done by default. I think it should only give access if a commandline argument is passed to enable it. In addition it would be nice to have a commandline argument to manually specify ports to listen to without having to use systemd or some other external program to create the socket.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 21 2022 at 14:33):

bjorn3 submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 21 2022 at 14:36):

haraldh edited PR #3711 from wasmtime_sock_accept to main:

Together with https://github.com/rust-lang/rust/pull/93158 this enables basic networking in rust.

The split of listen and stream modules where mainly done because of the difference in ::num_ready_bytes().

TODO:

view this post on Zulip Wasmtime GitHub notifications bot (Jan 21 2022 at 14:37):

haraldh submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 21 2022 at 14:37):

haraldh created PR review comment:

See the TODO section in the PR comment :)

view this post on Zulip Wasmtime GitHub notifications bot (Jan 21 2022 at 14:38):

haraldh edited PR #3711 from wasmtime_sock_accept to main:

Together with https://github.com/rust-lang/rust/pull/93158 this enables basic networking in rust.

The split of listen and stream modules where mainly done because of the difference in ::num_ready_bytes().

TODO:

view this post on Zulip Wasmtime GitHub notifications bot (Jan 21 2022 at 14:39):

haraldh submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 21 2022 at 14:39):

haraldh created PR review comment:

Happy to receive PRs to this draft :) Will add you as a co-author

view this post on Zulip Wasmtime GitHub notifications bot (Jan 21 2022 at 14:40):

bjorn3 submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 21 2022 at 14:40):

bjorn3 created PR review comment:

Right. I honestly only looked at the source and barely at the description :sweat_smile:

view this post on Zulip Wasmtime GitHub notifications bot (Jan 21 2022 at 14:51):

haraldh edited PR #3711 from wasmtime_sock_accept to main:

Together with https://github.com/rust-lang/rust/pull/93158 this enables basic networking in rust.

The split of listen and stream modules where mainly done because of the difference in ::num_ready_bytes().

TODO:

        Ok((
            TcpStream::from_inner(unsafe { Socket::from_raw_fd(fd as _) }),
            // WASI has no concept of SocketAddr yet
            // return an unspecified IPv4Addr
            SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), 0),
        ))

view this post on Zulip Wasmtime GitHub notifications bot (Jan 25 2022 at 13:34):

haraldh updated PR #3711 from wasmtime_sock_accept to main.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 25 2022 at 13:53):

haraldh updated PR #3711 from wasmtime_sock_accept to main.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 25 2022 at 13:53):

haraldh edited PR #3711 from wasmtime_sock_accept to main:

Together with https://github.com/rust-lang/rust/pull/93158 this enables basic networking in rust.

The split of listen and stream modules where mainly done because of the difference in ::num_ready_bytes().

TODO:

        Ok((
            TcpStream::from_inner(unsafe { Socket::from_raw_fd(fd as _) }),
            // WASI has no concept of SocketAddr yet
            // return an unspecified IPv4Addr
            SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), 0),
        ))

view this post on Zulip Wasmtime GitHub notifications bot (Jan 25 2022 at 13:53):

haraldh edited PR #3711 from wasmtime_sock_accept to main:

Together with https://github.com/rust-lang/rust/pull/93158 this enables basic networking in rust.

The split of listen and stream modules where mainly done because of the difference in ::num_ready_bytes().

TODO:

        Ok((
            TcpStream::from_inner(unsafe { Socket::from_raw_fd(fd as _) }),
            // WASI has no concept of SocketAddr yet
            // return an unspecified IPv4Addr
            SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), 0),
        ))

view this post on Zulip Wasmtime GitHub notifications bot (Jan 25 2022 at 14:07):

haraldh updated PR #3711 from wasmtime_sock_accept to main.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 25 2022 at 14:52):

haraldh updated PR #3711 from wasmtime_sock_accept to main.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 25 2022 at 15:04):

haraldh updated PR #3711 from wasmtime_sock_accept to main.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 25 2022 at 15:32):

haraldh edited PR #3711 from wasmtime_sock_accept to main:

Together with https://github.com/rust-lang/rust/pull/93158 this enables basic networking in rust.

The split of listen and stream modules where mainly done because of the difference in ::num_ready_bytes().

TODO:

        Ok((
            TcpStream::from_inner(unsafe { Socket::from_raw_fd(fd as _) }),
            // WASI has no concept of SocketAddr yet
            // return an unspecified IPv4Addr
            SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), 0),
        ))

view this post on Zulip Wasmtime GitHub notifications bot (Jan 25 2022 at 16:36):

haraldh updated PR #3711 from wasmtime_sock_accept to main.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 26 2022 at 10:14):

haraldh updated PR #3711 from wasmtime_sock_accept to main.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 26 2022 at 15:17):

haraldh updated PR #3711 from wasmtime_sock_accept to main.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 26 2022 at 15:20):

haraldh edited PR #3711 from wasmtime_sock_accept to main:

Together with https://github.com/rust-lang/rust/pull/93158 this enables basic networking in rust.

The split of listen and stream modules where mainly done because of the difference in ::num_ready_bytes().

TODO:

        Ok((
            TcpStream::from_inner(unsafe { Socket::from_raw_fd(fd as _) }),
            // WASI has no concept of SocketAddr yet
            // return an unspecified IPv4Addr
            SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), 0),
        ))

view this post on Zulip Wasmtime GitHub notifications bot (Jan 26 2022 at 15:20):

haraldh edited PR #3711 from wasmtime_sock_accept to main:

Together with https://github.com/rust-lang/rust/pull/93158 this enables basic networking in rust.

The split of listen and stream modules where mainly done because of the difference in ::num_ready_bytes().

TODO:

        Ok((
            TcpStream::from_inner(unsafe { Socket::from_raw_fd(fd as _) }),
            // WASI has no concept of SocketAddr yet
            // return an unspecified IPv4Addr
            SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), 0),
        ))

view this post on Zulip Wasmtime GitHub notifications bot (Jan 26 2022 at 15:22):

haraldh edited PR #3711 from wasmtime_sock_accept to main:

Together with https://github.com/rust-lang/rust/pull/93158 this enables basic networking in rust.

The split of listen and stream modules where mainly done because of the difference in ::num_ready_bytes().

TODO:

        Ok((
            TcpStream::from_inner(unsafe { Socket::from_raw_fd(fd as _) }),
            // WASI has no concept of SocketAddr yet
            // return an unspecified IPv4Addr
            SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), 0),
        ))

view this post on Zulip Wasmtime GitHub notifications bot (Jan 26 2022 at 15:23):

haraldh edited PR #3711 from wasmtime_sock_accept to main:

Together with https://github.com/rust-lang/rust/pull/93158 this enables basic networking in rust.

The split of listen and stream modules where mainly done because of the difference in ::num_ready_bytes().

TODO:

        Ok((
            TcpStream::from_inner(unsafe { Socket::from_raw_fd(fd as _) }),
            // WASI has no concept of SocketAddr yet
            // return an unspecified IPv4Addr
            SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), 0),
        ))

view this post on Zulip Wasmtime GitHub notifications bot (Jan 26 2022 at 15:47):

bjorn3 submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 26 2022 at 15:47):

bjorn3 created PR review comment:

Wouldn't it make more sense to add a new preopen type returned by fd_prestat_get rather than using env vars? Also won't the current code conflict with the fds for pre-opened dirs?

view this post on Zulip Wasmtime GitHub notifications bot (Jan 26 2022 at 16:31):

haraldh submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 26 2022 at 16:31):

haraldh created PR review comment:

My goal was to mimic the listenfd behavior 1:1 so you could reuse already written code.

The preopened dirs are inserted later on, IIRC.. I can recheck again.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 26 2022 at 16:39):

haraldh updated PR #3711 from wasmtime_sock_accept to main.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 26 2022 at 17:14):

haraldh updated PR #3711 from wasmtime_sock_accept to main.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2022 at 09:30):

haraldh updated PR #3711 from wasmtime_sock_accept to main.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2022 at 09:31):

haraldh edited PR #3711 from wasmtime_sock_accept to main:

Together with https://github.com/rust-lang/rust/pull/93158 this enables basic networking in rust.

The split of listen and stream modules where mainly done because of the difference in ::num_ready_bytes().

TODO:

        Ok((
            TcpStream::from_inner(unsafe { Socket::from_raw_fd(fd as _) }),
            // WASI has no concept of SocketAddr yet
            // return an unspecified IPv4Addr
            SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), 0),
        ))

view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2022 at 09:32):

haraldh edited PR #3711 from wasmtime_sock_accept to main:

Together with https://github.com/rust-lang/rust/pull/93158 this enables basic networking in rust.

The split of listen and stream modules where mainly done because of the difference in ::num_ready_bytes().

TODO:

        Ok((
            TcpStream::from_inner(unsafe { Socket::from_raw_fd(fd as _) }),
            // WASI has no concept of SocketAddr yet
            // return an unspecified IPv4Addr
            SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), 0),
        ))

view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2022 at 09:33):

haraldh edited PR #3711 from wasmtime_sock_accept to main:

Together with https://github.com/rust-lang/rust/pull/93158 this enables basic networking in rust.

The split of listen and stream modules where mainly done because of the difference in ::num_ready_bytes().

TODO:

        Ok((
            TcpStream::from_inner(unsafe { Socket::from_raw_fd(fd as _) }),
            // WASI has no concept of SocketAddr yet
            // return an unspecified IPv4Addr
            SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), 0),
        ))

view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2022 at 10:25):

haraldh updated PR #3711 from wasmtime_sock_accept to main.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2022 at 10:36):

haraldh edited PR #3711 from wasmtime_sock_accept to main:

Together with https://github.com/rust-lang/rust/pull/93158 this enables basic networking in rust.

TODO:

        Ok((
            TcpStream::from_inner(unsafe { Socket::from_raw_fd(fd as _) }),
            // WASI has no concept of SocketAddr yet
            // return an unspecified IPv4Addr
            SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), 0),
        ))

view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2022 at 11:51):

haraldh edited PR #3711 from wasmtime_sock_accept to main:

Together with https://github.com/rust-lang/rust/pull/93158 this enables basic networking in rust.

TODO:

        Ok((
            TcpStream::from_inner(unsafe { Socket::from_raw_fd(fd as _) }),
            // WASI has no concept of SocketAddr yet
            // return an unspecified IPv4Addr
            SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), 0),
        ))

Followup Todo: * [ ] PR with CLI option to specify ListenFds * [ ] Wasi definition of Preopentype for sockets (listener and stream, tcp and unix) * [ ] Non-busy polling on Windows


Last updated: Nov 22 2024 at 17:03 UTC