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.
Unified · Split
| @@ -190,6 +190,7 @@ struct sockaddr_tipc { · 189 unmodified lines | |||
| 190 | #define TIPC_MCAST_REPLICAST 134 /* Default: TIPC selects. No arg */ | 190 | #define TIPC_MCAST_REPLICAST 134 /* Default: TIPC selects. No arg */ |
| 191 | #define TIPC_GROUP_JOIN 135 /* Takes struct tipc_group_req* */ | 191 | #define TIPC_GROUP_JOIN 135 /* Takes struct tipc_group_req* */ |
| 192 | #define TIPC_GROUP_LEAVE 136 /* No argument */ | 192 | #define TIPC_GROUP_LEAVE 136 /* No argument */ |
| 193 | #define TIPC_SOCK_RECVQ_USED 137 /* Default: none (read only) */ | ||
| 193 | 194 | ||
| 194 | /* | 195 | /* |
| 195 | * Flag values | 196 | * Flag values |
| @@ -3070,6 +3070,9 @@ static int tipc_getsockopt(struct socket *sock, int lvl, int opt, · 3069 unmodified lines | |||
| 3070 | case TIPC_SOCK_RECVQ_DEPTH: | 3070 | case TIPC_SOCK_RECVQ_DEPTH: |
| 3071 | value = skb_queue_len(&sk->sk_receive_queue); | 3071 | value = skb_queue_len(&sk->sk_receive_queue); |
| 3072 | break; | 3072 | break; |
| 3073 | case TIPC_SOCK_RECVQ_USED: | ||
| 3074 | value = sk_rmem_alloc_get(sk); | ||
| 3075 | break; | ||
| 3073 | case TIPC_GROUP_JOIN: | 3076 | case TIPC_GROUP_JOIN: |
| 3074 | seq.type = 0; | 3077 | seq.type = 0; |
| 3075 | if (tsk->group) | 3078 | if (tsk->group) |