Message ID | 20210207151600.804998-1-arseny.krasnov@kaspersky.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | virtio/vsock: introduce SOCK_SEQPACKET support | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | fail | Series longer than 15 patches |
netdev/tree_selection | success | Guessed tree name to be net-next |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | warning | 1 maintainers not CCed: alex.popov@linux.com |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 1 this patch: 1 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | warning | WARNING: function definition argument 'struct vsock_sock *' should also have an identifier name WARNING: line length of 82 exceeds 80 columns |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 1 this patch: 1 |
netdev/header_inline | success | Link |
netdev/stable | success | Stable not CCed |
On Sun, Feb 07, 2021 at 06:15:57PM +0300, Arseny Krasnov wrote: >This adds some logic to current stream enqueue function for SEQPACKET >support: >1) Send record's begin/end marker. >2) Return value from enqueue function is whole record length or error > for SOCK_SEQPACKET. > >Signed-off-by: Arseny Krasnov <arseny.krasnov@kaspersky.com> >--- > include/net/af_vsock.h | 2 ++ > net/vmw_vsock/af_vsock.c | 22 ++++++++++++++++++++-- > 2 files changed, 22 insertions(+), 2 deletions(-) > >diff --git a/include/net/af_vsock.h b/include/net/af_vsock.h >index 19f6f22821ec..198d58c4c7ee 100644 >--- a/include/net/af_vsock.h >+++ b/include/net/af_vsock.h >@@ -136,6 +136,8 @@ struct vsock_transport { > bool (*stream_allow)(u32 cid, u32 port); > > /* SEQ_PACKET. */ >+ int (*seqpacket_seq_send_len)(struct vsock_sock *, size_t len, int flags); >+ int (*seqpacket_seq_send_eor)(struct vsock_sock *, int flags); As before, we could add the identifier of the parameters. Other than that, the patch LGTM. Stefano > size_t (*seqpacket_seq_get_len)(struct vsock_sock *); > int (*seqpacket_dequeue)(struct vsock_sock *, struct msghdr *, > int flags, bool *msg_ready); >diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c >index ea99261e88ac..a033d3340ac4 100644 >--- a/net/vmw_vsock/af_vsock.c >+++ b/net/vmw_vsock/af_vsock.c >@@ -1806,6 +1806,12 @@ static int vsock_connectible_sendmsg(struct socket *sock, struct msghdr *msg, > if (err < 0) > goto out; > >+ if (sk->sk_type == SOCK_SEQPACKET) { >+ err = transport->seqpacket_seq_send_len(vsk, len, msg->msg_flags); >+ if (err < 0) >+ goto out; >+ } >+ > while (total_written < len) { > ssize_t written; > >@@ -1852,9 +1858,21 @@ static int vsock_connectible_sendmsg(struct socket *sock, struct msghdr *msg, > > } > >+ if (sk->sk_type == SOCK_SEQPACKET) { >+ err = transport->seqpacket_seq_send_eor(vsk, msg->msg_flags); >+ if (err < 0) >+ goto out; >+ } >+ > out_err: >- if (total_written > 0) >- err = total_written; >+ if (total_written > 0) { >+ /* Return number of written bytes only if: >+ * 1) SOCK_STREAM socket. >+ * 2) SOCK_SEQPACKET socket when whole buffer is sent. >+ */ >+ if (sk->sk_type == SOCK_STREAM || total_written == len) >+ err = total_written; >+ } > out: > release_sock(sk); > return err; >-- >2.25.1 >
diff --git a/include/net/af_vsock.h b/include/net/af_vsock.h index 19f6f22821ec..198d58c4c7ee 100644 --- a/include/net/af_vsock.h +++ b/include/net/af_vsock.h @@ -136,6 +136,8 @@ struct vsock_transport { bool (*stream_allow)(u32 cid, u32 port); /* SEQ_PACKET. */ + int (*seqpacket_seq_send_len)(struct vsock_sock *, size_t len, int flags); + int (*seqpacket_seq_send_eor)(struct vsock_sock *, int flags); size_t (*seqpacket_seq_get_len)(struct vsock_sock *); int (*seqpacket_dequeue)(struct vsock_sock *, struct msghdr *, int flags, bool *msg_ready); diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index ea99261e88ac..a033d3340ac4 100644 --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c @@ -1806,6 +1806,12 @@ static int vsock_connectible_sendmsg(struct socket *sock, struct msghdr *msg, if (err < 0) goto out; + if (sk->sk_type == SOCK_SEQPACKET) { + err = transport->seqpacket_seq_send_len(vsk, len, msg->msg_flags); + if (err < 0) + goto out; + } + while (total_written < len) { ssize_t written; @@ -1852,9 +1858,21 @@ static int vsock_connectible_sendmsg(struct socket *sock, struct msghdr *msg, } + if (sk->sk_type == SOCK_SEQPACKET) { + err = transport->seqpacket_seq_send_eor(vsk, msg->msg_flags); + if (err < 0) + goto out; + } + out_err: - if (total_written > 0) - err = total_written; + if (total_written > 0) { + /* Return number of written bytes only if: + * 1) SOCK_STREAM socket. + * 2) SOCK_SEQPACKET socket when whole buffer is sent. + */ + if (sk->sk_type == SOCK_STREAM || total_written == len) + err = total_written; + } out: release_sock(sk); return err;
This adds some logic to current stream enqueue function for SEQPACKET support: 1) Send record's begin/end marker. 2) Return value from enqueue function is whole record length or error for SOCK_SEQPACKET. Signed-off-by: Arseny Krasnov <arseny.krasnov@kaspersky.com> --- include/net/af_vsock.h | 2 ++ net/vmw_vsock/af_vsock.c | 22 ++++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-)