Stream: git-wasmtime

Topic: wasmtime / PR #3711 Implement `sock_accept` and basic net...


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

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

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

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

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

haraldh submitted PR review.

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

haraldh created PR review comment:

moved CLI PR to https://github.com/bytecodealliance/wasmtime/pull/3729

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

haraldh submitted PR review.

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

haraldh created PR review comment:

moved CLI PR to https://github.com/bytecodealliance/wasmtime/pull/3729

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

haraldh has marked PR #3711 as ready for review.

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

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.

See https://github.com/bytecodealliance/wasmtime/issues/3730 for the tracking issue.

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

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

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.

See https://github.com/bytecodealliance/wasmtime/issues/3730 for the tracking issue.

Todo

Followup Todo

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

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.

See https://github.com/bytecodealliance/wasmtime/issues/3730 for the tracking issue.

Todo

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

haraldh updated PR #3711 from wasmtime_sock_accept to main.

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

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.

See https://github.com/bytecodealliance/wasmtime/issues/3730 for the tracking issue.

With the addition of sock_accept() in wasi-0.11.0, wasmtime can now
implement basic networking for pre-opened sockets.

For Windows AsHandle was replaced with AsRawHandleOrSocket to cope
with the duality of Handles and Sockets.

For Unix a wasi_cap_std_sync::net::Socket enum was created to handle
the {Tcp,Unix}{Listener,Stream} more efficiently in
WasiCtxBuilder::preopened_socket().

The addition of that many WasiFile implementors was mainly necessary,
because of the difference in the num_ready_bytes() function.

A known issue is Windows now busy polling on sockets, because except
for stdin, nothing is querying the status of windows handles/sockets.

Todo

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

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.

See https://github.com/bytecodealliance/wasmtime/issues/3730 for the tracking issue.

With the addition of sock_accept() in wasi-0.11.0, wasmtime can now implement basic networking for pre-opened sockets.

For Windows AsHandle was replaced with AsRawHandleOrSocket to cope with the duality of Handles and Sockets.

For Unix a wasi_cap_std_sync::net::Socket enum was created to handle the {Tcp,Unix}{Listener,Stream} more efficiently in
WasiCtxBuilder::preopened_socket().

The addition of that many WasiFile implementors was mainly necessary, because of the difference in the num_ready_bytes() function.

A known issue is Windows now busy polling on sockets, because except for stdin, nothing is querying the status of windows handles/sockets.

Todo

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

sunfishcode submitted PR review.

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

sunfishcode submitted PR review.

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

sunfishcode created PR review comment:

Another option here would be to make Socket be a simple struct that holds an OwnedFd, and uses rustix::net calls to implement the functions rather than cap_std::net/std::net. Rustix even supports the socket APIs on Windows, so this ought to work. And you could probably unify the "stream" vs. "listener" implementations below. That said, either way seems fine for now, so feel free to make a judgement call here.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 28 2022 at 12:43):

haraldh updated PR #3711 from wasmtime_sock_accept to main.

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

haraldh submitted PR review.

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

haraldh created PR review comment:

Yeah, I didn't want to change all the other parts too much.

What you are proposing can be done in a separate PR, which will change much more, I guess.

With the Socket abstraction, I think I didn't make the "user" facing API incompatible with your proposal.

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

haraldh updated PR #3711 from wasmtime_sock_accept to main.

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

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.

See https://github.com/bytecodealliance/wasmtime/issues/3730 for the tracking issue.

With the addition of sock_accept() in wasi-0.11.0, wasmtime can now implement basic networking for pre-opened sockets.

For Windows AsHandle was replaced with AsRawHandleOrSocket to cope with the duality of Handles and Sockets.

For Unix a wasi_cap_std_sync::net::Socket enum was created to handle the {Tcp,Unix}{Listener,Stream} more efficiently in
WasiCtxBuilder::preopened_socket().

The addition of that many WasiFile implementors was mainly necessary, because of the difference in the num_ready_bytes() function.

A known issue is Windows now busy polling on sockets, because except for stdin, nothing is querying the status of windows handles/sockets.

Another know issue on Windows, is that there is no crate providing
support for fcntl(fd, F_GETFL, 0).

Todo

view this post on Zulip Wasmtime GitHub notifications bot (Jan 28 2022 at 13: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.

See https://github.com/bytecodealliance/wasmtime/issues/3730 for the tracking issue.

With the addition of sock_accept() in wasi-0.11.0, wasmtime can now implement basic networking for pre-opened sockets.

For Windows AsHandle was replaced with AsRawHandleOrSocket to cope with the duality of Handles and Sockets.

For Unix a wasi_cap_std_sync::net::Socket enum was created to handle the {Tcp,Unix}{Listener,Stream} more efficiently in
WasiCtxBuilder::preopened_socket().

The addition of that many WasiFile implementors was mainly necessary, because of the difference in the num_ready_bytes() function.

A known issue is Windows now busy polling on sockets, because except for stdin, nothing is querying the status of windows handles/sockets.

Another know issue on Windows, is that there is no crate providing
support for fcntl(fd, F_GETFL, 0) for sockets.

Todo

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

haraldh updated PR #3711 from wasmtime_sock_accept to main.

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

haraldh updated PR #3711 from wasmtime_sock_accept to main.

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

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.

See https://github.com/bytecodealliance/wasmtime/issues/3730 for the tracking issue.

With the addition of sock_accept() in wasi-0.11.0, wasmtime can now implement basic networking for pre-opened sockets.

For Windows AsHandle was replaced with AsRawHandleOrSocket to cope with the duality of Handles and Sockets.

For Unix a wasi_cap_std_sync::net::Socket enum was created to handle the {Tcp,Unix}{Listener,Stream} more efficiently in
WasiCtxBuilder::preopened_socket().

The addition of that many WasiFile implementors was mainly necessary, because of the difference in the num_ready_bytes() function.

A known issue is Windows now busy polling on sockets, because except for stdin, nothing is querying the status of windows handles/sockets.

Another know issue on Windows, is that there is no crate providing support for fcntl(fd, F_GETFL, 0) for sockets, so WasiFile::get_fdflags() always returns 0.

Todo

view this post on Zulip Wasmtime GitHub notifications bot (Feb 01 2022 at 00:25):

sunfishcode merged PR #3711.


Last updated: Nov 22 2024 at 17:03 UTC