diff mbox series

[RFC,v1,11/16] afvsock: add 'seqpacket_drop()'

Message ID 20210628100415.571391-1-arseny.krasnov@kaspersky.com
State New
Headers show
Series Improve SOCK_SEQPACKET receive logic | expand

Commit Message

Arseny Krasnov June 28, 2021, 10:04 a.m. UTC
Add special callback for SEQPACKET socket which is called when
we need to drop current in-progress record: part of record was
copied successfully, reader wait rest of record, but signal
interrupts it and reader leaves it's loop, leaving packets of
current record still in queue. So to avoid copy of "orphaned"
record, we tell transport to drop every packet until EOR will
be found.

Signed-off-by: Arseny Krasnov <arseny.krasnov@kaspersky.com>
---
 include/net/af_vsock.h   | 1 +
 net/vmw_vsock/af_vsock.c | 1 +
 2 files changed, 2 insertions(+)

Comments

Stefano Garzarella June 30, 2021, 12:12 p.m. UTC | #1
On Mon, Jun 28, 2021 at 01:04:12PM +0300, Arseny Krasnov wrote:
>Add special callback for SEQPACKET socket which is called when

>we need to drop current in-progress record: part of record was

>copied successfully, reader wait rest of record, but signal

>interrupts it and reader leaves it's loop, leaving packets of

>current record still in queue. So to avoid copy of "orphaned"

>record, we tell transport to drop every packet until EOR will

>be found.

>

>Signed-off-by: Arseny Krasnov <arseny.krasnov@kaspersky.com>

>---

> include/net/af_vsock.h   | 1 +

> net/vmw_vsock/af_vsock.c | 1 +

> 2 files changed, 2 insertions(+)


And also for this change, I think you can merge with patches 12, 13, 14, 
15, otherwise if we bisect and we build at this patch, the 
seqpacket_drop pointer is not valid.

Thanks,
Stefano

>

>diff --git a/include/net/af_vsock.h b/include/net/af_vsock.h

>index 1747c0b564ef..356878aabbd4 100644

>--- a/include/net/af_vsock.h

>+++ b/include/net/af_vsock.h

>@@ -141,6 +141,7 @@ struct vsock_transport {

>       int (*seqpacket_enqueue)(struct vsock_sock *vsk, struct msghdr *msg,

>                                size_t len);

>       bool (*seqpacket_allow)(u32 remote_cid);

>+      void (*seqpacket_drop)(struct vsock_sock *vsk);

>

>       /* Notification. */

>       int (*notify_poll_in)(struct vsock_sock *, size_t, bool *);

>diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c

>index ec54e4222cbf..27fa38090e13 100644

>--- a/net/vmw_vsock/af_vsock.c

>+++ b/net/vmw_vsock/af_vsock.c

>@@ -2024,6 +2024,7 @@ static int __vsock_seqpacket_recvmsg(struct sock *sk, struct msghdr *msg,

>               intr_err = vsock_connectible_wait_data(sk, &wait, timeout, NULL, 0);

>               if (intr_err <= 0) {

>                       err = intr_err;

>+                      transport->seqpacket_drop(vsk);

>                       break;

>               }

>

>--

>2.25.1

>
Arseny Krasnov June 30, 2021, 5:48 p.m. UTC | #2
On 30.06.2021 15:12, Stefano Garzarella wrote:
> On Mon, Jun 28, 2021 at 01:04:12PM +0300, Arseny Krasnov wrote:

>> Add special callback for SEQPACKET socket which is called when

>> we need to drop current in-progress record: part of record was

>> copied successfully, reader wait rest of record, but signal

>> interrupts it and reader leaves it's loop, leaving packets of

>> current record still in queue. So to avoid copy of "orphaned"

>> record, we tell transport to drop every packet until EOR will

>> be found.

>>

>> Signed-off-by: Arseny Krasnov <arseny.krasnov@kaspersky.com>

>> ---

>> include/net/af_vsock.h   | 1 +

>> net/vmw_vsock/af_vsock.c | 1 +

>> 2 files changed, 2 insertions(+)

> And also for this change, I think you can merge with patches 12, 13, 14, 

> 15, otherwise if we bisect and we build at this patch, the 

> seqpacket_drop pointer is not valid.

>

> Thanks,

> Stefano

Ack
>

>> diff --git a/include/net/af_vsock.h b/include/net/af_vsock.h

>> index 1747c0b564ef..356878aabbd4 100644

>> --- a/include/net/af_vsock.h

>> +++ b/include/net/af_vsock.h

>> @@ -141,6 +141,7 @@ struct vsock_transport {

>>       int (*seqpacket_enqueue)(struct vsock_sock *vsk, struct msghdr *msg,

>>                                size_t len);

>>       bool (*seqpacket_allow)(u32 remote_cid);

>> +      void (*seqpacket_drop)(struct vsock_sock *vsk);

>>

>>       /* Notification. */

>>       int (*notify_poll_in)(struct vsock_sock *, size_t, bool *);

>> diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c

>> index ec54e4222cbf..27fa38090e13 100644

>> --- a/net/vmw_vsock/af_vsock.c

>> +++ b/net/vmw_vsock/af_vsock.c

>> @@ -2024,6 +2024,7 @@ static int __vsock_seqpacket_recvmsg(struct sock *sk, struct msghdr *msg,

>>               intr_err = vsock_connectible_wait_data(sk, &wait, timeout, NULL, 0);

>>               if (intr_err <= 0) {

>>                       err = intr_err;

>> +                      transport->seqpacket_drop(vsk);

>>                       break;

>>               }

>>

>> --

>> 2.25.1

>>

>
diff mbox series

Patch

diff --git a/include/net/af_vsock.h b/include/net/af_vsock.h
index 1747c0b564ef..356878aabbd4 100644
--- a/include/net/af_vsock.h
+++ b/include/net/af_vsock.h
@@ -141,6 +141,7 @@  struct vsock_transport {
 	int (*seqpacket_enqueue)(struct vsock_sock *vsk, struct msghdr *msg,
 				 size_t len);
 	bool (*seqpacket_allow)(u32 remote_cid);
+	void (*seqpacket_drop)(struct vsock_sock *vsk);
 
 	/* Notification. */
 	int (*notify_poll_in)(struct vsock_sock *, size_t, bool *);
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index ec54e4222cbf..27fa38090e13 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -2024,6 +2024,7 @@  static int __vsock_seqpacket_recvmsg(struct sock *sk, struct msghdr *msg,
 		intr_err = vsock_connectible_wait_data(sk, &wait, timeout, NULL, 0);
 		if (intr_err <= 0) {
 			err = intr_err;
+			transport->seqpacket_drop(vsk);
 			break;
 		}