diff mbox series

[RFC,v3,2/4] vsock/vmci: convert VMCI error code to -ENOMEM on receive

Message ID 4d34fac8-7170-5a3e-5043-42a9f7e4b5b3@sberdevices.ru (mailing list archive)
State New, archived
Headers show
Series vsock: return errors other than -ENOMEM to socket | expand

Commit Message

Arseniy Krasnov March 30, 2023, 8:13 p.m. UTC
This adds conversion of VMCI specific error code to general -ENOMEM. It
is needed, because af_vsock.c passes error value returned from transport
to the user, which does not expect to get VMCI_ERROR_* values.

Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
---
 net/vmw_vsock/vmci_transport.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

Arseniy Krasnov March 30, 2023, 8:18 p.m. UTC | #1
On 30.03.2023 23:13, Arseniy Krasnov wrote:
> This adds conversion of VMCI specific error code to general -ENOMEM. It
> is needed, because af_vsock.c passes error value returned from transport
> to the user, which does not expect to get VMCI_ERROR_* values.

@Stefano, I have some doubts about this commit message, as it says "... af_vsock.c
passes error value returned from transport to the user ...", but this
behaviour is implemented only in the next patch. Is it ok, if both patches
are in a single patchset?

For patch 1 I think it is ok, as it fixes current implementation.

Thanks, Arseniy

> 
> Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
> ---
>  net/vmw_vsock/vmci_transport.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/net/vmw_vsock/vmci_transport.c b/net/vmw_vsock/vmci_transport.c
> index 95cc4d79ba29..b370070194fa 100644
> --- a/net/vmw_vsock/vmci_transport.c
> +++ b/net/vmw_vsock/vmci_transport.c
> @@ -1831,10 +1831,17 @@ static ssize_t vmci_transport_stream_dequeue(
>  	size_t len,
>  	int flags)
>  {
> +	ssize_t err;
> +
>  	if (flags & MSG_PEEK)
> -		return vmci_qpair_peekv(vmci_trans(vsk)->qpair, msg, len, 0);
> +		err = vmci_qpair_peekv(vmci_trans(vsk)->qpair, msg, len, 0);
>  	else
> -		return vmci_qpair_dequev(vmci_trans(vsk)->qpair, msg, len, 0);
> +		err = vmci_qpair_dequev(vmci_trans(vsk)->qpair, msg, len, 0);
> +
> +	if (err < 0)
> +		err = -ENOMEM;
> +
> +	return err;
>  }
>  
>  static ssize_t vmci_transport_stream_enqueue(
Vishnu Dasa March 30, 2023, 9:49 p.m. UTC | #2
> On Mar 30, 2023, at 1:18 PM, Arseniy Krasnov <AVKrasnov@sberdevices.ru> wrote:
> 
> !! External Email
> 
> On 30.03.2023 23:13, Arseniy Krasnov wrote:
>> This adds conversion of VMCI specific error code to general -ENOMEM. It
>> is needed, because af_vsock.c passes error value returned from transport
>> to the user, which does not expect to get VMCI_ERROR_* values.
> 
> @Stefano, I have some doubts about this commit message, as it says "... af_vsock.c
> passes error value returned from transport to the user ...", but this
> behaviour is implemented only in the next patch. Is it ok, if both patches
> are in a single patchset?
> 
> For patch 1 I think it is ok, as it fixes current implementation.
> 
> Thanks, Arseniy
> 
>> 
>> Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>

Code change looks good to me.  Will let you figure out the commit message
with Stefano. Thanks!

Reviewed-by: Vishnu Dasa <vdasa@vmware.com>

>> ---
>> net/vmw_vsock/vmci_transport.c | 11 +++++++++--
>> 1 file changed, 9 insertions(+), 2 deletions(-)
>> 
>> diff --git a/net/vmw_vsock/vmci_transport.c b/net/vmw_vsock/vmci_transport.c
>> index 95cc4d79ba29..b370070194fa 100644
>> --- a/net/vmw_vsock/vmci_transport.c
>> +++ b/net/vmw_vsock/vmci_transport.c
>> @@ -1831,10 +1831,17 @@ static ssize_t vmci_transport_stream_dequeue(
>>      size_t len,
>>      int flags)
>> {
>> +     ssize_t err;
>> +
>>      if (flags & MSG_PEEK)
>> -             return vmci_qpair_peekv(vmci_trans(vsk)->qpair, msg, len, 0);
>> +             err = vmci_qpair_peekv(vmci_trans(vsk)->qpair, msg, len, 0);
>>      else
>> -             return vmci_qpair_dequev(vmci_trans(vsk)->qpair, msg, len, 0);
>> +             err = vmci_qpair_dequev(vmci_trans(vsk)->qpair, msg, len, 0);
>> +
>> +     if (err < 0)
>> +             err = -ENOMEM;
>> +
>> +     return err;
>> }
>> 
>> static ssize_t vmci_transport_stream_enqueue(
> 
> !! External Email: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender.
Stefano Garzarella March 31, 2023, 7:12 a.m. UTC | #3
On Thu, Mar 30, 2023 at 11:18:36PM +0300, Arseniy Krasnov wrote:
>
>
>On 30.03.2023 23:13, Arseniy Krasnov wrote:
>> This adds conversion of VMCI specific error code to general -ENOMEM. It
>> is needed, because af_vsock.c passes error value returned from transport
>> to the user, which does not expect to get VMCI_ERROR_* values.
>
>@Stefano, I have some doubts about this commit message, as it says "... af_vsock.c
>passes error value returned from transport to the user ...", but this
>behaviour is implemented only in the next patch. Is it ok, if both patches
>are in a single patchset?

Yes indeed it is not clear. In my opinion we can do one of these 2
things:

1. Update the message, where we can say that this is a preparation patch
    for the next changes where af_vsock.c will directly return transport
    values to the user, so we need to return an errno.

2. Merge this patch and patch 3 in a single patch.

Both are fine for my point of view, take your choice ;-)

Thanks,
Stefano
Arseniy Krasnov March 31, 2023, 7:57 a.m. UTC | #4
On 31.03.2023 10:12, Stefano Garzarella wrote:
> On Thu, Mar 30, 2023 at 11:18:36PM +0300, Arseniy Krasnov wrote:
>>
>>
>> On 30.03.2023 23:13, Arseniy Krasnov wrote:
>>> This adds conversion of VMCI specific error code to general -ENOMEM. It
>>> is needed, because af_vsock.c passes error value returned from transport
>>> to the user, which does not expect to get VMCI_ERROR_* values.
>>
>> @Stefano, I have some doubts about this commit message, as it says "... af_vsock.c
>> passes error value returned from transport to the user ...", but this
>> behaviour is implemented only in the next patch. Is it ok, if both patches
>> are in a single patchset?
> 
> Yes indeed it is not clear. In my opinion we can do one of these 2
> things:
> 
> 1. Update the message, where we can say that this is a preparation patch
>    for the next changes where af_vsock.c will directly return transport
>    values to the user, so we need to return an errno.
> 
> 2. Merge this patch and patch 3 in a single patch.
> 
> Both are fine for my point of view, take your choice ;-)

Ok! Thanks for this!

Thanks, Arseniy

> 
> Thanks,
> Stefano
>
diff mbox series

Patch

diff --git a/net/vmw_vsock/vmci_transport.c b/net/vmw_vsock/vmci_transport.c
index 95cc4d79ba29..b370070194fa 100644
--- a/net/vmw_vsock/vmci_transport.c
+++ b/net/vmw_vsock/vmci_transport.c
@@ -1831,10 +1831,17 @@  static ssize_t vmci_transport_stream_dequeue(
 	size_t len,
 	int flags)
 {
+	ssize_t err;
+
 	if (flags & MSG_PEEK)
-		return vmci_qpair_peekv(vmci_trans(vsk)->qpair, msg, len, 0);
+		err = vmci_qpair_peekv(vmci_trans(vsk)->qpair, msg, len, 0);
 	else
-		return vmci_qpair_dequev(vmci_trans(vsk)->qpair, msg, len, 0);
+		err = vmci_qpair_dequev(vmci_trans(vsk)->qpair, msg, len, 0);
+
+	if (err < 0)
+		err = -ENOMEM;
+
+	return err;
 }
 
 static ssize_t vmci_transport_stream_enqueue(