* [tipc-discussion][net-next v1] tipc: introduce new socket option TIPC_SOCK_RECVQ_USED
@ 2019-04-18 14:02 Tung Nguyen
2019-04-19 21:40 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Tung Nguyen @ 2019-04-18 14:02 UTC (permalink / raw)
To: davem, netdev; +Cc: tipc-discussion
When using TIPC_SOCK_RECVQ_DEPTH for getsockopt(), it returns the
number of buffers in receive socket buffer which is not so helpful
for user space applications.
This commit introduces the new option TIPC_SOCK_RECVQ_USED which
returns the current allocated bytes of the receive socket buffer.
This helps user space applications dimension its buffer usage to
avoid buffer overload issue.
Signed-off-by: Tung Nguyen <tung.q.nguyen@dektech.com.au>
---
include/uapi/linux/tipc.h | 1 +
net/tipc/socket.c | 3 +++
2 files changed, 4 insertions(+)
diff --git a/include/uapi/linux/tipc.h b/include/uapi/linux/tipc.h
index 6b2fd4d9655f..7df026ea6aff 100644
--- a/include/uapi/linux/tipc.h
+++ b/include/uapi/linux/tipc.h
@@ -190,6 +190,7 @@ struct sockaddr_tipc {
#define TIPC_MCAST_REPLICAST 134 /* Default: TIPC selects. No arg */
#define TIPC_GROUP_JOIN 135 /* Takes struct tipc_group_req* */
#define TIPC_GROUP_LEAVE 136 /* No argument */
+#define TIPC_SOCK_RECVQ_USED 137 /* Default: none (read only) */
/*
* Flag values
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 8ac8ddf1e324..1385207a301f 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -3070,6 +3070,9 @@ static int tipc_getsockopt(struct socket *sock, int lvl, int opt,
case TIPC_SOCK_RECVQ_DEPTH:
value = skb_queue_len(&sk->sk_receive_queue);
break;
+ case TIPC_SOCK_RECVQ_USED:
+ value = sk_rmem_alloc_get(sk);
+ break;
case TIPC_GROUP_JOIN:
seq.type = 0;
if (tsk->group)
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [tipc-discussion][net-next v1] tipc: introduce new socket option TIPC_SOCK_RECVQ_USED
2019-04-18 14:02 [tipc-discussion][net-next v1] tipc: introduce new socket option TIPC_SOCK_RECVQ_USED Tung Nguyen
@ 2019-04-19 21:40 ` David Miller
2019-04-19 21:51 ` Jon Maloy
0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2019-04-19 21:40 UTC (permalink / raw)
To: tung.q.nguyen; +Cc: netdev, tipc-discussion
From: Tung Nguyen <tung.q.nguyen@dektech.com.au>
Date: Thu, 18 Apr 2019 21:02:19 +0700
> When using TIPC_SOCK_RECVQ_DEPTH for getsockopt(), it returns the
> number of buffers in receive socket buffer which is not so helpful
> for user space applications.
>
> This commit introduces the new option TIPC_SOCK_RECVQ_USED which
> returns the current allocated bytes of the receive socket buffer.
> This helps user space applications dimension its buffer usage to
> avoid buffer overload issue.
>
> Signed-off-by: Tung Nguyen <tung.q.nguyen@dektech.com.au>
TIPC folks, please review.
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [tipc-discussion][net-next v1] tipc: introduce new socket option TIPC_SOCK_RECVQ_USED
2019-04-19 21:40 ` David Miller
@ 2019-04-19 21:51 ` Jon Maloy
2019-04-19 21:59 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Jon Maloy @ 2019-04-19 21:51 UTC (permalink / raw)
To: David Miller, Tung Quang Nguyen; +Cc: netdev, tipc-discussion
> -----Original Message-----
> From: netdev-owner@vger.kernel.org <netdev-owner@vger.kernel.org>
> On Behalf Of David Miller
> Sent: 19-Apr-19 17:41
> To: Tung Quang Nguyen <tung.q.nguyen@dektech.com.au>
> Cc: netdev@vger.kernel.org; tipc-discussion@lists.sourceforge.net
> Subject: Re: [tipc-discussion][net-next v1] tipc: introduce new socket option
> TIPC_SOCK_RECVQ_USED
>
> From: Tung Nguyen <tung.q.nguyen@dektech.com.au>
> Date: Thu, 18 Apr 2019 21:02:19 +0700
>
> > When using TIPC_SOCK_RECVQ_DEPTH for getsockopt(), it returns the
> > number of buffers in receive socket buffer which is not so helpful for
> > user space applications.
> >
> > This commit introduces the new option TIPC_SOCK_RECVQ_USED which
> > returns the current allocated bytes of the receive socket buffer.
> > This helps user space applications dimension its buffer usage to avoid
> > buffer overload issue.
> >
> > Signed-off-by: Tung Nguyen <tung.q.nguyen@dektech.com.au>
>
> TIPC folks, please review.
Acked-by: Jon Maloy <jon.maloy@ericsson.com>
It would of course be nicer if we could recycle TIPC_SOCK_RECV_QUEUE_DEPTH for this purpose, but that would mean altering the current ABI and incur a (probably very low) risk of breaking existing application.
I am not particularly happy with this, but do we have users who claim it would be useful for them.
///jon
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [tipc-discussion][net-next v1] tipc: introduce new socket option TIPC_SOCK_RECVQ_USED
2019-04-19 21:51 ` Jon Maloy
@ 2019-04-19 21:59 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2019-04-19 21:59 UTC (permalink / raw)
To: jon.maloy; +Cc: tung.q.nguyen, netdev, tipc-discussion
From: Jon Maloy <jon.maloy@ericsson.com>
Date: Fri, 19 Apr 2019 21:51:31 +0000
>
>
>> -----Original Message-----
>> From: netdev-owner@vger.kernel.org <netdev-owner@vger.kernel.org>
>> On Behalf Of David Miller
>> Sent: 19-Apr-19 17:41
>> To: Tung Quang Nguyen <tung.q.nguyen@dektech.com.au>
>> Cc: netdev@vger.kernel.org; tipc-discussion@lists.sourceforge.net
>> Subject: Re: [tipc-discussion][net-next v1] tipc: introduce new socket option
>> TIPC_SOCK_RECVQ_USED
>>
>> From: Tung Nguyen <tung.q.nguyen@dektech.com.au>
>> Date: Thu, 18 Apr 2019 21:02:19 +0700
>>
>> > When using TIPC_SOCK_RECVQ_DEPTH for getsockopt(), it returns the
>> > number of buffers in receive socket buffer which is not so helpful for
>> > user space applications.
>> >
>> > This commit introduces the new option TIPC_SOCK_RECVQ_USED which
>> > returns the current allocated bytes of the receive socket buffer.
>> > This helps user space applications dimension its buffer usage to avoid
>> > buffer overload issue.
>> >
>> > Signed-off-by: Tung Nguyen <tung.q.nguyen@dektech.com.au>
>>
>> TIPC folks, please review.
>
> Acked-by: Jon Maloy <jon.maloy@ericsson.com>
Applied, thanks for reviewing.
> It would of course be nicer if we could recycle
> TIPC_SOCK_RECV_QUEUE_DEPTH for this purpose, but that would mean
> altering the current ABI and incur a (probably very low) risk of
> breaking existing application. I am not particularly happy with
> this, but do we have users who claim it would be useful for them.
Better safe than sorry when it comes to user facing ABIs.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-04-19 21:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-18 14:02 [tipc-discussion][net-next v1] tipc: introduce new socket option TIPC_SOCK_RECVQ_USED Tung Nguyen
2019-04-19 21:40 ` David Miller
2019-04-19 21:51 ` Jon Maloy
2019-04-19 21:59 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).