mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC PATCH v1 0/2] return errors other than -ENOMEM to socket
@ 2023-03-25 22:12 Arseniy Krasnov
  2023-03-25 22:13 ` [RFC PATCH v1 1/2] vsock: " Arseniy Krasnov
  2023-03-25 22:14 ` [RFC PATCH v1 2/2] vsock/test: update expected return values Arseniy Krasnov
  0 siblings, 2 replies; 11+ messages in thread
From: Arseniy Krasnov @ 2023-03-25 22:12 UTC (permalink / raw)
  To: Stefan Hajnoczi, Stefano Garzarella, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Bobby Eshleman
  Cc: kvm, virtualization, netdev, linux-kernel, kernel, oxffffaa, avkrasnov

Hello,

this patchset removes behaviour, where error code returned from any
transport was always switched to ENOMEM. This works in the same way as
patch from Bobby Eshleman:
commit c43170b7e157 ("vsock: return errors other than -ENOMEM to socket"),
but for receive calls.

vsock_test suite is also updated.

Arseniy Krasnov (2):
  vsock: return errors other than -ENOMEM to socket
  vsock/test: update expected return values

 net/vmw_vsock/af_vsock.c         | 4 ++--
 tools/testing/vsock/vsock_test.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

-- 
2.25.1

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [RFC PATCH v1 1/2] vsock: return errors other than -ENOMEM to socket
  2023-03-25 22:12 [RFC PATCH v1 0/2] return errors other than -ENOMEM to socket Arseniy Krasnov
@ 2023-03-25 22:13 ` Arseniy Krasnov
  2023-03-28  9:39   ` Stefano Garzarella
  2023-03-25 22:14 ` [RFC PATCH v1 2/2] vsock/test: update expected return values Arseniy Krasnov
  1 sibling, 1 reply; 11+ messages in thread
From: Arseniy Krasnov @ 2023-03-25 22:13 UTC (permalink / raw)
  To: Stefan Hajnoczi, Stefano Garzarella, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Bobby Eshleman
  Cc: kvm, virtualization, netdev, linux-kernel, kernel, oxffffaa, avkrasnov

This removes behaviour, where error code returned from any transport
was always switched to ENOMEM. This works in the same way as:
commit
c43170b7e157 ("vsock: return errors other than -ENOMEM to socket"),
but for receive calls.

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

diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 19aea7cba26e..9262e0b77d47 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -2007,7 +2007,7 @@ static int __vsock_stream_recvmsg(struct sock *sk, struct msghdr *msg,
 
 		read = transport->stream_dequeue(vsk, msg, len - copied, flags);
 		if (read < 0) {
-			err = -ENOMEM;
+			err = read;
 			break;
 		}
 
@@ -2058,7 +2058,7 @@ static int __vsock_seqpacket_recvmsg(struct sock *sk, struct msghdr *msg,
 	msg_len = transport->seqpacket_dequeue(vsk, msg, flags);
 
 	if (msg_len < 0) {
-		err = -ENOMEM;
+		err = msg_len;
 		goto out;
 	}
 
-- 
2.25.1

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [RFC PATCH v1 2/2] vsock/test: update expected return values
  2023-03-25 22:12 [RFC PATCH v1 0/2] return errors other than -ENOMEM to socket Arseniy Krasnov
  2023-03-25 22:13 ` [RFC PATCH v1 1/2] vsock: " Arseniy Krasnov
@ 2023-03-25 22:14 ` Arseniy Krasnov
  2023-03-28  9:44   ` Stefano Garzarella
  1 sibling, 1 reply; 11+ messages in thread
From: Arseniy Krasnov @ 2023-03-25 22:14 UTC (permalink / raw)
  To: Stefan Hajnoczi, Stefano Garzarella, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Bobby Eshleman
  Cc: kvm, virtualization, netdev, linux-kernel, kernel, oxffffaa, avkrasnov

This updates expected return values for invalid buffer test. Now such
values are returned from transport, not from af_vsock.c.

Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
---
 tools/testing/vsock/vsock_test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c
index 3de10dbb50f5..a91d0ef963be 100644
--- a/tools/testing/vsock/vsock_test.c
+++ b/tools/testing/vsock/vsock_test.c
@@ -723,7 +723,7 @@ static void test_seqpacket_invalid_rec_buffer_server(const struct test_opts *opt
 		exit(EXIT_FAILURE);
 	}
 
-	if (errno != ENOMEM) {
+	if (errno != EFAULT) {
 		perror("unexpected errno of 'broken_buf'");
 		exit(EXIT_FAILURE);
 	}
@@ -887,7 +887,7 @@ static void test_inv_buf_client(const struct test_opts *opts, bool stream)
 		exit(EXIT_FAILURE);
 	}
 
-	if (errno != ENOMEM) {
+	if (errno != EFAULT) {
 		fprintf(stderr, "unexpected recv(2) errno %d\n", errno);
 		exit(EXIT_FAILURE);
 	}
-- 
2.25.1

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC PATCH v1 1/2] vsock: return errors other than -ENOMEM to socket
  2023-03-25 22:13 ` [RFC PATCH v1 1/2] vsock: " Arseniy Krasnov
@ 2023-03-28  9:39   ` Stefano Garzarella
  2023-03-28  9:42     ` Stefano Garzarella
  0 siblings, 1 reply; 11+ messages in thread
From: Stefano Garzarella @ 2023-03-28  9:39 UTC (permalink / raw)
  To: Arseniy Krasnov
  Cc: Stefan Hajnoczi, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Bobby Eshleman, kvm, virtualization, netdev,
	linux-kernel, kernel, oxffffaa

On Sun, Mar 26, 2023 at 01:13:11AM +0300, Arseniy Krasnov wrote:
>This removes behaviour, where error code returned from any transport
>was always switched to ENOMEM. This works in the same way as:
>commit
>c43170b7e157 ("vsock: return errors other than -ENOMEM to socket"),
>but for receive calls.
>
>Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
>---
> net/vmw_vsock/af_vsock.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
>diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
>index 19aea7cba26e..9262e0b77d47 100644
>--- a/net/vmw_vsock/af_vsock.c
>+++ b/net/vmw_vsock/af_vsock.c
>@@ -2007,7 +2007,7 @@ static int __vsock_stream_recvmsg(struct sock *sk, struct msghdr *msg,
>
> 		read = transport->stream_dequeue(vsk, msg, len - copied, flags);

In vmci_transport_stream_dequeue() vmci_qpair_peekv() and
vmci_qpair_dequev() return VMCI_ERROR_* in case of errors.

Maybe we should return -ENOMEM in vmci_transport_stream_dequeue() if
those functions fail to keep the same behavior.

CCing Bryan, Vishnu, and pv-drivers@vmware.com

The other transports seem okay to me.

Thanks,
Stefano

> 		if (read < 0) {
>-			err = -ENOMEM;
>+			err = read;
> 			break;
> 		}
>
>@@ -2058,7 +2058,7 @@ static int __vsock_seqpacket_recvmsg(struct sock *sk, struct msghdr *msg,
> 	msg_len = transport->seqpacket_dequeue(vsk, msg, flags);
>
> 	if (msg_len < 0) {
>-		err = -ENOMEM;
>+		err = msg_len;
> 		goto out;
> 	}
>
>-- 
>2.25.1
>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC PATCH v1 1/2] vsock: return errors other than -ENOMEM to socket
  2023-03-28  9:39   ` Stefano Garzarella
@ 2023-03-28  9:42     ` Stefano Garzarella
  2023-03-28 10:42       ` Arseniy Krasnov
  0 siblings, 1 reply; 11+ messages in thread
From: Stefano Garzarella @ 2023-03-28  9:42 UTC (permalink / raw)
  To: Arseniy Krasnov, Bryan Tan, Vishnu Dasa, VMware PV-Drivers Reviewers
  Cc: Stefan Hajnoczi, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Bobby Eshleman, kvm, virtualization, netdev,
	linux-kernel, kernel, oxffffaa

I pressed send too early...

CCing Bryan, Vishnu, and pv-drivers@vmware.com

On Tue, Mar 28, 2023 at 11:39 AM Stefano Garzarella <sgarzare@redhat.com> wrote:
>
> On Sun, Mar 26, 2023 at 01:13:11AM +0300, Arseniy Krasnov wrote:
> >This removes behaviour, where error code returned from any transport
> >was always switched to ENOMEM. This works in the same way as:
> >commit
> >c43170b7e157 ("vsock: return errors other than -ENOMEM to socket"),
> >but for receive calls.
> >
> >Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
> >---
> > net/vmw_vsock/af_vsock.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> >diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
> >index 19aea7cba26e..9262e0b77d47 100644
> >--- a/net/vmw_vsock/af_vsock.c
> >+++ b/net/vmw_vsock/af_vsock.c
> >@@ -2007,7 +2007,7 @@ static int __vsock_stream_recvmsg(struct sock *sk, struct msghdr *msg,
> >
> >               read = transport->stream_dequeue(vsk, msg, len - copied, flags);
>
> In vmci_transport_stream_dequeue() vmci_qpair_peekv() and
> vmci_qpair_dequev() return VMCI_ERROR_* in case of errors.
>
> Maybe we should return -ENOMEM in vmci_transport_stream_dequeue() if
> those functions fail to keep the same behavior.
>
> CCing Bryan, Vishnu, and pv-drivers@vmware.com
>
> The other transports seem okay to me.
>
> Thanks,
> Stefano
>
> >               if (read < 0) {
> >-                      err = -ENOMEM;
> >+                      err = read;
> >                       break;
> >               }
> >
> >@@ -2058,7 +2058,7 @@ static int __vsock_seqpacket_recvmsg(struct sock *sk, struct msghdr *msg,
> >       msg_len = transport->seqpacket_dequeue(vsk, msg, flags);
> >
> >       if (msg_len < 0) {
> >-              err = -ENOMEM;
> >+              err = msg_len;
> >               goto out;
> >       }
> >
> >--
> >2.25.1
> >


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC PATCH v1 2/2] vsock/test: update expected return values
  2023-03-25 22:14 ` [RFC PATCH v1 2/2] vsock/test: update expected return values Arseniy Krasnov
@ 2023-03-28  9:44   ` Stefano Garzarella
  0 siblings, 0 replies; 11+ messages in thread
From: Stefano Garzarella @ 2023-03-28  9:44 UTC (permalink / raw)
  To: Arseniy Krasnov
  Cc: Stefan Hajnoczi, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Bobby Eshleman, kvm, virtualization, netdev,
	linux-kernel, kernel, oxffffaa

On Sun, Mar 26, 2023 at 01:14:01AM +0300, Arseniy Krasnov wrote:
>This updates expected return values for invalid buffer test. Now such
>values are returned from transport, not from af_vsock.c.

Since only virtio transport supports it for now, it's okay.
In the future we should make sure that we have the same behavior between 
transports.

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>

>
>Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
>---
> tools/testing/vsock/vsock_test.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
>diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c
>index 3de10dbb50f5..a91d0ef963be 100644
>--- a/tools/testing/vsock/vsock_test.c
>+++ b/tools/testing/vsock/vsock_test.c
>@@ -723,7 +723,7 @@ static void test_seqpacket_invalid_rec_buffer_server(const struct test_opts *opt
> 		exit(EXIT_FAILURE);
> 	}
>
>-	if (errno != ENOMEM) {
>+	if (errno != EFAULT) {
> 		perror("unexpected errno of 'broken_buf'");
> 		exit(EXIT_FAILURE);
> 	}
>@@ -887,7 +887,7 @@ static void test_inv_buf_client(const struct test_opts *opts, bool stream)
> 		exit(EXIT_FAILURE);
> 	}
>
>-	if (errno != ENOMEM) {
>+	if (errno != EFAULT) {
> 		fprintf(stderr, "unexpected recv(2) errno %d\n", errno);
> 		exit(EXIT_FAILURE);
> 	}
>-- 
>2.25.1
>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC PATCH v1 1/2] vsock: return errors other than -ENOMEM to socket
  2023-03-28  9:42     ` Stefano Garzarella
@ 2023-03-28 10:42       ` Arseniy Krasnov
  2023-03-28 11:19         ` Stefano Garzarella
  0 siblings, 1 reply; 11+ messages in thread
From: Arseniy Krasnov @ 2023-03-28 10:42 UTC (permalink / raw)
  To: Stefano Garzarella, Bryan Tan, Vishnu Dasa, VMware PV-Drivers Reviewers
  Cc: Stefan Hajnoczi, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Bobby Eshleman, kvm, virtualization, netdev,
	linux-kernel, kernel, oxffffaa



On 28.03.2023 12:42, Stefano Garzarella wrote:
> I pressed send too early...
> 
> CCing Bryan, Vishnu, and pv-drivers@vmware.com
> 
> On Tue, Mar 28, 2023 at 11:39 AM Stefano Garzarella <sgarzare@redhat.com> wrote:
>>
>> On Sun, Mar 26, 2023 at 01:13:11AM +0300, Arseniy Krasnov wrote:
>>> This removes behaviour, where error code returned from any transport
>>> was always switched to ENOMEM. This works in the same way as:
>>> commit
>>> c43170b7e157 ("vsock: return errors other than -ENOMEM to socket"),
>>> but for receive calls.
>>>
>>> Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
>>> ---
>>> net/vmw_vsock/af_vsock.c | 4 ++--
>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
>>> index 19aea7cba26e..9262e0b77d47 100644
>>> --- a/net/vmw_vsock/af_vsock.c
>>> +++ b/net/vmw_vsock/af_vsock.c
>>> @@ -2007,7 +2007,7 @@ static int __vsock_stream_recvmsg(struct sock *sk, struct msghdr *msg,
>>>
>>>               read = transport->stream_dequeue(vsk, msg, len - copied, flags);
>>
>> In vmci_transport_stream_dequeue() vmci_qpair_peekv() and
>> vmci_qpair_dequev() return VMCI_ERROR_* in case of errors.
>>
>> Maybe we should return -ENOMEM in vmci_transport_stream_dequeue() if
>> those functions fail to keep the same behavior.

Yes, seems i missed it, because several months ago we had similar question for send
logic:
https://www.spinics.net/lists/kernel/msg4611091.html
And it was ok to not handle VMCI send path in this way. So i think current implementation
for tx is a little bit buggy, because VMCI specific error from 'vmci_qpair_enquev()' is
returned to af_vsock.c. I think error conversion must be added to VMCI transport for tx
also.

Good thing is that Hyper-V uses general error codes.

Thanks, Arseniy
>>
>> CCing Bryan, Vishnu, and pv-drivers@vmware.com
>>
>> The other transports seem okay to me.
>>
>> Thanks,
>> Stefano
>>
>>>               if (read < 0) {
>>> -                      err = -ENOMEM;
>>> +                      err = read;
>>>                       break;
>>>               }
>>>
>>> @@ -2058,7 +2058,7 @@ static int __vsock_seqpacket_recvmsg(struct sock *sk, struct msghdr *msg,
>>>       msg_len = transport->seqpacket_dequeue(vsk, msg, flags);
>>>
>>>       if (msg_len < 0) {
>>> -              err = -ENOMEM;
>>> +              err = msg_len;
>>>               goto out;
>>>       }
>>>
>>> --
>>> 2.25.1
>>>
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC PATCH v1 1/2] vsock: return errors other than -ENOMEM to socket
  2023-03-28 10:42       ` Arseniy Krasnov
@ 2023-03-28 11:19         ` Stefano Garzarella
  2023-03-28 11:20           ` Arseniy Krasnov
  0 siblings, 1 reply; 11+ messages in thread
From: Stefano Garzarella @ 2023-03-28 11:19 UTC (permalink / raw)
  To: Arseniy Krasnov, Vishnu Dasa
  Cc: Bryan Tan, VMware PV-Drivers Reviewers, Stefan Hajnoczi,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Bobby Eshleman, kvm, virtualization, netdev, linux-kernel,
	kernel, oxffffaa

On Tue, Mar 28, 2023 at 01:42:19PM +0300, Arseniy Krasnov wrote:
>
>
>On 28.03.2023 12:42, Stefano Garzarella wrote:
>> I pressed send too early...
>>
>> CCing Bryan, Vishnu, and pv-drivers@vmware.com
>>
>> On Tue, Mar 28, 2023 at 11:39 AM Stefano Garzarella <sgarzare@redhat.com> wrote:
>>>
>>> On Sun, Mar 26, 2023 at 01:13:11AM +0300, Arseniy Krasnov wrote:
>>>> This removes behaviour, where error code returned from any transport
>>>> was always switched to ENOMEM. This works in the same way as:
>>>> commit
>>>> c43170b7e157 ("vsock: return errors other than -ENOMEM to socket"),
>>>> but for receive calls.
>>>>
>>>> Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
>>>> ---
>>>> net/vmw_vsock/af_vsock.c | 4 ++--
>>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
>>>> index 19aea7cba26e..9262e0b77d47 100644
>>>> --- a/net/vmw_vsock/af_vsock.c
>>>> +++ b/net/vmw_vsock/af_vsock.c
>>>> @@ -2007,7 +2007,7 @@ static int __vsock_stream_recvmsg(struct sock *sk, struct msghdr *msg,
>>>>
>>>>               read = transport->stream_dequeue(vsk, msg, len - copied, flags);
>>>
>>> In vmci_transport_stream_dequeue() vmci_qpair_peekv() and
>>> vmci_qpair_dequev() return VMCI_ERROR_* in case of errors.
>>>
>>> Maybe we should return -ENOMEM in vmci_transport_stream_dequeue() if
>>> those functions fail to keep the same behavior.
>
>Yes, seems i missed it, because several months ago we had similar question for send
>logic:
>https://www.spinics.net/lists/kernel/msg4611091.html
>And it was ok to not handle VMCI send path in this way. So i think current implementation
>for tx is a little bit buggy, because VMCI specific error from 'vmci_qpair_enquev()' is
>returned to af_vsock.c. I think error conversion must be added to VMCI transport for tx
>also.

Good point!

These are negative values, so there are no big problems, but I don't
know what the user expects in this case.

@Vishnu Do we want to return an errno to the user or a VMCI_ERROR_*?

In both cases I think we should do the same for both enqueue and
dequeue.

>
>Good thing is that Hyper-V uses general error codes.

Yeah!

Thanks,
Stefano

>
>Thanks, Arseniy
>>>
>>> CCing Bryan, Vishnu, and pv-drivers@vmware.com
>>>
>>> The other transports seem okay to me.
>>>
>>> Thanks,
>>> Stefano
>>>
>>>>               if (read < 0) {
>>>> -                      err = -ENOMEM;
>>>> +                      err = read;
>>>>                       break;
>>>>               }
>>>>
>>>> @@ -2058,7 +2058,7 @@ static int __vsock_seqpacket_recvmsg(struct sock *sk, struct msghdr *msg,
>>>>       msg_len = transport->seqpacket_dequeue(vsk, msg, flags);
>>>>
>>>>       if (msg_len < 0) {
>>>> -              err = -ENOMEM;
>>>> +              err = msg_len;
>>>>               goto out;
>>>>       }
>>>>
>>>> --
>>>> 2.25.1
>>>>
>>
>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC PATCH v1 1/2] vsock: return errors other than -ENOMEM to socket
  2023-03-28 11:19         ` Stefano Garzarella
@ 2023-03-28 11:20           ` Arseniy Krasnov
  2023-03-29 21:44             ` Vishnu Dasa
  0 siblings, 1 reply; 11+ messages in thread
From: Arseniy Krasnov @ 2023-03-28 11:20 UTC (permalink / raw)
  To: Stefano Garzarella, Vishnu Dasa
  Cc: Bryan Tan, VMware PV-Drivers Reviewers, Stefan Hajnoczi,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Bobby Eshleman, kvm, virtualization, netdev, linux-kernel,
	kernel, oxffffaa



On 28.03.2023 14:19, Stefano Garzarella wrote:
> On Tue, Mar 28, 2023 at 01:42:19PM +0300, Arseniy Krasnov wrote:
>>
>>
>> On 28.03.2023 12:42, Stefano Garzarella wrote:
>>> I pressed send too early...
>>>
>>> CCing Bryan, Vishnu, and pv-drivers@vmware.com
>>>
>>> On Tue, Mar 28, 2023 at 11:39 AM Stefano Garzarella <sgarzare@redhat.com> wrote:
>>>>
>>>> On Sun, Mar 26, 2023 at 01:13:11AM +0300, Arseniy Krasnov wrote:
>>>>> This removes behaviour, where error code returned from any transport
>>>>> was always switched to ENOMEM. This works in the same way as:
>>>>> commit
>>>>> c43170b7e157 ("vsock: return errors other than -ENOMEM to socket"),
>>>>> but for receive calls.
>>>>>
>>>>> Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
>>>>> ---
>>>>> net/vmw_vsock/af_vsock.c | 4 ++--
>>>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
>>>>> index 19aea7cba26e..9262e0b77d47 100644
>>>>> --- a/net/vmw_vsock/af_vsock.c
>>>>> +++ b/net/vmw_vsock/af_vsock.c
>>>>> @@ -2007,7 +2007,7 @@ static int __vsock_stream_recvmsg(struct sock *sk, struct msghdr *msg,
>>>>>
>>>>>               read = transport->stream_dequeue(vsk, msg, len - copied, flags);
>>>>
>>>> In vmci_transport_stream_dequeue() vmci_qpair_peekv() and
>>>> vmci_qpair_dequev() return VMCI_ERROR_* in case of errors.
>>>>
>>>> Maybe we should return -ENOMEM in vmci_transport_stream_dequeue() if
>>>> those functions fail to keep the same behavior.
>>
>> Yes, seems i missed it, because several months ago we had similar question for send
>> logic:
>> https://www.spinics.net/lists/kernel/msg4611091.html
>> And it was ok to not handle VMCI send path in this way. So i think current implementation
>> for tx is a little bit buggy, because VMCI specific error from 'vmci_qpair_enquev()' is
>> returned to af_vsock.c. I think error conversion must be added to VMCI transport for tx
>> also.
> 
> Good point!
> 
> These are negative values, so there are no big problems, but I don't
> know what the user expects in this case.
> 
> @Vishnu Do we want to return an errno to the user or a VMCI_ERROR_*?

Small remark, as i can see, VMCI_ERROR_ is not exported to user in include/uapi,
so IIUC user won't be able to interpret such values correctly.

Thanks, Arseniy

> 
> In both cases I think we should do the same for both enqueue and
> dequeue.
> 
>>
>> Good thing is that Hyper-V uses general error codes.
> 
> Yeah!
> 
> Thanks,
> Stefano
> 
>>
>> Thanks, Arseniy
>>>>
>>>> CCing Bryan, Vishnu, and pv-drivers@vmware.com
>>>>
>>>> The other transports seem okay to me.
>>>>
>>>> Thanks,
>>>> Stefano
>>>>
>>>>>               if (read < 0) {
>>>>> -                      err = -ENOMEM;
>>>>> +                      err = read;
>>>>>                       break;
>>>>>               }
>>>>>
>>>>> @@ -2058,7 +2058,7 @@ static int __vsock_seqpacket_recvmsg(struct sock *sk, struct msghdr *msg,
>>>>>       msg_len = transport->seqpacket_dequeue(vsk, msg, flags);
>>>>>
>>>>>       if (msg_len < 0) {
>>>>> -              err = -ENOMEM;
>>>>> +              err = msg_len;
>>>>>               goto out;
>>>>>       }
>>>>>
>>>>> -- 
>>>>> 2.25.1
>>>>>
>>>
>>
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC PATCH v1 1/2] vsock: return errors other than -ENOMEM to socket
  2023-03-28 11:20           ` Arseniy Krasnov
@ 2023-03-29 21:44             ` Vishnu Dasa
  2023-03-30  5:13               ` Arseniy Krasnov
  0 siblings, 1 reply; 11+ messages in thread
From: Vishnu Dasa @ 2023-03-29 21:44 UTC (permalink / raw)
  To: Arseniy Krasnov, Stefano Garzarella
  Cc: Bryan Tan, Pv-drivers, Stefan Hajnoczi, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Bobby Eshleman, kvm,
	Linux Virtualization, netdev, LKML, kernel, Krasnov Arseniy



> On Mar 28, 2023, at 4:20 AM, Arseniy Krasnov <AVKrasnov@sberdevices.ru> wrote:
> 
> !! External Email
> 
> On 28.03.2023 14:19, Stefano Garzarella wrote:
>> On Tue, Mar 28, 2023 at 01:42:19PM +0300, Arseniy Krasnov wrote:
>>> 
>>> 
>>> On 28.03.2023 12:42, Stefano Garzarella wrote:
>>>> I pressed send too early...
>>>> 
>>>> CCing Bryan, Vishnu, and pv-drivers@vmware.com
>>>> 
>>>> On Tue, Mar 28, 2023 at 11:39 AM Stefano Garzarella <sgarzare@redhat.com> wrote:
>>>>> 
>>>>> On Sun, Mar 26, 2023 at 01:13:11AM +0300, Arseniy Krasnov wrote:
>>>>>> This removes behaviour, where error code returned from any transport
>>>>>> was always switched to ENOMEM. This works in the same way as:
>>>>>> commit
>>>>>> c43170b7e157 ("vsock: return errors other than -ENOMEM to socket"),
>>>>>> but for receive calls.
>>>>>> 
>>>>>> Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
>>>>>> ---
>>>>>> net/vmw_vsock/af_vsock.c | 4 ++--
>>>>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>>>> 
>>>>>> diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
>>>>>> index 19aea7cba26e..9262e0b77d47 100644
>>>>>> --- a/net/vmw_vsock/af_vsock.c
>>>>>> +++ b/net/vmw_vsock/af_vsock.c
>>>>>> @@ -2007,7 +2007,7 @@ static int __vsock_stream_recvmsg(struct sock *sk, struct msghdr *msg,
>>>>>> 
>>>>>>              read = transport->stream_dequeue(vsk, msg, len - copied, flags);
>>>>> 
>>>>> In vmci_transport_stream_dequeue() vmci_qpair_peekv() and
>>>>> vmci_qpair_dequev() return VMCI_ERROR_* in case of errors.
>>>>> 
>>>>> Maybe we should return -ENOMEM in vmci_transport_stream_dequeue() if
>>>>> those functions fail to keep the same behavior.
>>> 
>>> Yes, seems i missed it, because several months ago we had similar question for send
>>> logic:
>>> https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.spinics.net%2Flists%2Fkernel%2Fmsg4611091.html&data=05%7C01%7Cvdasa%40vmware.com%7C3b17793425384debe75708db2f7eec8c%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C0%7C638155994413494900%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=MMfFcKuFFvMcJrbToKvWvIB%2FZmzp%2BdGGVWFVWztuSzg%3D&reserved=0
>>> And it was ok to not handle VMCI send path in this way. So i think current implementation
>>> for tx is a little bit buggy, because VMCI specific error from 'vmci_qpair_enquev()' is
>>> returned to af_vsock.c. I think error conversion must be added to VMCI transport for tx
>>> also.
>> 
>> Good point!
>> 
>> These are negative values, so there are no big problems, but I don't
>> know what the user expects in this case.
>> 
>> @Vishnu Do we want to return an errno to the user or a VMCI_ERROR_*?
> 
> Small remark, as i can see, VMCI_ERROR_ is not exported to user in include/uapi,
> so IIUC user won't be able to interpret such values correctly.
> 
> Thanks, Arseniy

Let's just return -ENOMEM from vmci transport in case of error in
vmci_transport_stream_enqueue and vmci_transport_stream_dequeue.

@Arseniy,
Could you please add a separate patch in this set to handle the above?

Thanks,
Vishnu

> 
>> 
>> In both cases I think we should do the same for both enqueue and
>> dequeue.
>> 
>>> 
>>> Good thing is that Hyper-V uses general error codes.
>> 
>> Yeah!
>> 
>> Thanks,
>> Stefano
>> 
>>> 
>>> Thanks, Arseniy
>>>>> 
>>>>> CCing Bryan, Vishnu, and pv-drivers@vmware.com
>>>>> 
>>>>> The other transports seem okay to me.
>>>>> 
>>>>> Thanks,
>>>>> Stefano
>>>>> 
>>>>>>              if (read < 0) {
>>>>>> -                      err = -ENOMEM;
>>>>>> +                      err = read;
>>>>>>                      break;
>>>>>>              }
>>>>>> 
>>>>>> @@ -2058,7 +2058,7 @@ static int __vsock_seqpacket_recvmsg(struct sock *sk, struct msghdr *msg,
>>>>>>      msg_len = transport->seqpacket_dequeue(vsk, msg, flags);
>>>>>> 
>>>>>>      if (msg_len < 0) {
>>>>>> -              err = -ENOMEM;
>>>>>> +              err = msg_len;
>>>>>>              goto out;
>>>>>>      }
>>>>>> 
>>>>>> --
>>>>>> 2.25.1
>>>>>> 
>>>> 
>>> 
>> 
> 
> !! External Email: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC PATCH v1 1/2] vsock: return errors other than -ENOMEM to socket
  2023-03-29 21:44             ` Vishnu Dasa
@ 2023-03-30  5:13               ` Arseniy Krasnov
  0 siblings, 0 replies; 11+ messages in thread
From: Arseniy Krasnov @ 2023-03-30  5:13 UTC (permalink / raw)
  To: Vishnu Dasa, Stefano Garzarella
  Cc: Bryan Tan, Pv-drivers, Stefan Hajnoczi, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Bobby Eshleman, kvm,
	Linux Virtualization, netdev, LKML, kernel, Krasnov Arseniy



On 30.03.2023 00:44, Vishnu Dasa wrote:
> 
> 
>> On Mar 28, 2023, at 4:20 AM, Arseniy Krasnov <AVKrasnov@sberdevices.ru> wrote:
>>
>> !! External Email
>>
>> On 28.03.2023 14:19, Stefano Garzarella wrote:
>>> On Tue, Mar 28, 2023 at 01:42:19PM +0300, Arseniy Krasnov wrote:
>>>>
>>>>
>>>> On 28.03.2023 12:42, Stefano Garzarella wrote:
>>>>> I pressed send too early...
>>>>>
>>>>> CCing Bryan, Vishnu, and pv-drivers@vmware.com
>>>>>
>>>>> On Tue, Mar 28, 2023 at 11:39 AM Stefano Garzarella <sgarzare@redhat.com> wrote:
>>>>>>
>>>>>> On Sun, Mar 26, 2023 at 01:13:11AM +0300, Arseniy Krasnov wrote:
>>>>>>> This removes behaviour, where error code returned from any transport
>>>>>>> was always switched to ENOMEM. This works in the same way as:
>>>>>>> commit
>>>>>>> c43170b7e157 ("vsock: return errors other than -ENOMEM to socket"),
>>>>>>> but for receive calls.
>>>>>>>
>>>>>>> Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
>>>>>>> ---
>>>>>>> net/vmw_vsock/af_vsock.c | 4 ++--
>>>>>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>>>>>
>>>>>>> diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
>>>>>>> index 19aea7cba26e..9262e0b77d47 100644
>>>>>>> --- a/net/vmw_vsock/af_vsock.c
>>>>>>> +++ b/net/vmw_vsock/af_vsock.c
>>>>>>> @@ -2007,7 +2007,7 @@ static int __vsock_stream_recvmsg(struct sock *sk, struct msghdr *msg,
>>>>>>>
>>>>>>>              read = transport->stream_dequeue(vsk, msg, len - copied, flags);
>>>>>>
>>>>>> In vmci_transport_stream_dequeue() vmci_qpair_peekv() and
>>>>>> vmci_qpair_dequev() return VMCI_ERROR_* in case of errors.
>>>>>>
>>>>>> Maybe we should return -ENOMEM in vmci_transport_stream_dequeue() if
>>>>>> those functions fail to keep the same behavior.
>>>>
>>>> Yes, seems i missed it, because several months ago we had similar question for send
>>>> logic:
>>>> https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.spinics.net%2Flists%2Fkernel%2Fmsg4611091.html&data=05%7C01%7Cvdasa%40vmware.com%7C3b17793425384debe75708db2f7eec8c%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C0%7C638155994413494900%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=MMfFcKuFFvMcJrbToKvWvIB%2FZmzp%2BdGGVWFVWztuSzg%3D&reserved=0
>>>> And it was ok to not handle VMCI send path in this way. So i think current implementation
>>>> for tx is a little bit buggy, because VMCI specific error from 'vmci_qpair_enquev()' is
>>>> returned to af_vsock.c. I think error conversion must be added to VMCI transport for tx
>>>> also.
>>>
>>> Good point!
>>>
>>> These are negative values, so there are no big problems, but I don't
>>> know what the user expects in this case.
>>>
>>> @Vishnu Do we want to return an errno to the user or a VMCI_ERROR_*?
>>
>> Small remark, as i can see, VMCI_ERROR_ is not exported to user in include/uapi,
>> so IIUC user won't be able to interpret such values correctly.
>>
>> Thanks, Arseniy
> 
> Let's just return -ENOMEM from vmci transport in case of error in
> vmci_transport_stream_enqueue and vmci_transport_stream_dequeue.
> 
> @Arseniy,
> Could you please add a separate patch in this set to handle the above?

Sure, ack, in the next few days!

Thanks, Arseniy

> 
> Thanks,
> Vishnu
> 
>>
>>>
>>> In both cases I think we should do the same for both enqueue and
>>> dequeue.
>>>
>>>>
>>>> Good thing is that Hyper-V uses general error codes.
>>>
>>> Yeah!
>>>
>>> Thanks,
>>> Stefano
>>>
>>>>
>>>> Thanks, Arseniy
>>>>>>
>>>>>> CCing Bryan, Vishnu, and pv-drivers@vmware.com
>>>>>>
>>>>>> The other transports seem okay to me.
>>>>>>
>>>>>> Thanks,
>>>>>> Stefano
>>>>>>
>>>>>>>              if (read < 0) {
>>>>>>> -                      err = -ENOMEM;
>>>>>>> +                      err = read;
>>>>>>>                      break;
>>>>>>>              }
>>>>>>>
>>>>>>> @@ -2058,7 +2058,7 @@ static int __vsock_seqpacket_recvmsg(struct sock *sk, struct msghdr *msg,
>>>>>>>      msg_len = transport->seqpacket_dequeue(vsk, msg, flags);
>>>>>>>
>>>>>>>      if (msg_len < 0) {
>>>>>>> -              err = -ENOMEM;
>>>>>>> +              err = msg_len;
>>>>>>>              goto out;
>>>>>>>      }
>>>>>>>
>>>>>>> --
>>>>>>> 2.25.1
>>>>>>>
>>>>>
>>>>
>>>
>>
>> !! External Email: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender.
> 
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-03-30  5:16 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-25 22:12 [RFC PATCH v1 0/2] return errors other than -ENOMEM to socket Arseniy Krasnov
2023-03-25 22:13 ` [RFC PATCH v1 1/2] vsock: " Arseniy Krasnov
2023-03-28  9:39   ` Stefano Garzarella
2023-03-28  9:42     ` Stefano Garzarella
2023-03-28 10:42       ` Arseniy Krasnov
2023-03-28 11:19         ` Stefano Garzarella
2023-03-28 11:20           ` Arseniy Krasnov
2023-03-29 21:44             ` Vishnu Dasa
2023-03-30  5:13               ` Arseniy Krasnov
2023-03-25 22:14 ` [RFC PATCH v1 2/2] vsock/test: update expected return values Arseniy Krasnov
2023-03-28  9:44   ` Stefano Garzarella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®