History

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.

Tung Nguyen committed 7 years ago

Commit 42e54251 parent a26deec2 files · +4 −0Browse files

Unified · Split

2 files
  1. include/uapi/linux/tipc.h +1 −0
  2. net/tipc/socket.c +3 −0
include/uapi/linux/tipc.h+1−0
@@ -190,6 +190,7 @@ struct sockaddr_tipc { · 189 unmodified lines
190190 #define TIPC_MCAST_REPLICAST 134 /* Default: TIPC selects. No arg */
191191 #define TIPC_GROUP_JOIN 135 /* Takes struct tipc_group_req* */
192192 #define TIPC_GROUP_LEAVE 136 /* No argument */
193+#define TIPC_SOCK_RECVQ_USED 137 /* Default: none (read only) */
193194
194195 /*
195196 * Flag values
net/tipc/socket.c+3−0
@@ -3070,6 +3070,9 @@ static int tipc_getsockopt(struct socket *sock, int lvl, int opt, · 3069 unmodified lines
30703070 case TIPC_SOCK_RECVQ_DEPTH:
30713071 value = skb_queue_len(&sk->sk_receive_queue);
30723072 break;
3073+ case TIPC_SOCK_RECVQ_USED:
3074+ value = sk_rmem_alloc_get(sk);
3075+ break;
30733076 case TIPC_GROUP_JOIN:
30743077 seq.type = 0;
30753078 if (tsk->group)