From: Jon M. <jon...@er...> - 2019-04-18 14:02:44
|
Acked-by: Jon Maloy <jon...@er...> Just make sure you don't send a banner patch ([PATCH 0/1] ) when you send this to netdev. For single patches that isn't necessary. And remember to tag it [net-next] . ///jon > -----Original Message----- > From: Tung Nguyen <tun...@de...> > Sent: 18-Apr-19 07:22 > To: tip...@li...; Jon Maloy > <jon...@er...>; ma...@do...; yin...@wi... > Subject: [PATCH v2 1/1] tipc: introduce new socket option > TIPC_SOCK_RECVQ_USED > > 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 <tun...@de...> > --- > 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 |