Skip to contentSkip to conversation

tipc: sockopt(TIPC_SO_RCVBUF) for setting receive buffer

PATCH In review Jon Maloy 2 participants 2 messages Feb 27, 2018 – Feb 28, 2018

Subsystems (3)
lore
Share & tools
lore

Jon Maloy

author
#0 lore raw

PATCH 1/1 tipc: sockopt(TIPC_SO_RCVBUF) for setting receive buffer

From: Hoang Le <[email protected]>

We introduce a set/getsockopt for setting socket receive buffer per individual socket. This has turned out to sometimes be necessary for anycast and multicast receivers when used without flow control.

---
 include/uapi/linux/tipc.h | 1 +
 net/tipc/socket.c         | 8 ++++++++
 2 files changed, 9 insertions(+)
include/uapi/linux/tipc.h +1 -0
index 14bacc7..8ce4a69 100644
@@ -233,6 +233,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_SO_RCVBUF          137     /* Range tipc_rmem_min:tipc_rmem_max */
 
 /*
  * Flag values
net/tipc/socket.c +8 -0
index 8b04e60..cfd519b 100644
@@ -2829,6 +2829,7 @@ static int tipc_setsockopt(struct socket *sock, int lvl, int opt,
 	case TIPC_SRC_DROPPABLE:
 	case TIPC_DEST_DROPPABLE:
 	case TIPC_CONN_TIMEOUT:
+	case TIPC_SO_RCVBUF:
 		if (ol < sizeof(value))
 			return -EINVAL;
 		if (get_user(value, (u32 __user *)ov))
@@ -2877,6 +2878,10 @@ static int tipc_setsockopt(struct socket *sock, int lvl, int opt,
 	case TIPC_GROUP_LEAVE:
 		res = tipc_sk_leave(tsk);
 		break;
+	case TIPC_SO_RCVBUF:
+		value = max_t(int, value, sysctl_tipc_rmem[0]);
+		sk->sk_rcvbuf = min_t(int, value, sysctl_tipc_rmem[2]);
+		break;
 	default:
 		res = -EINVAL;
 	}
@@ -2945,6 +2950,9 @@ static int tipc_getsockopt(struct socket *sock, int lvl, int opt,
 			tipc_group_self(tsk->group, &seq, &scope);
 		value = seq.type;
 		break;
+	case TIPC_SO_RCVBUF:
+		value = sk->sk_rcvbuf;
+		break;
 	default:
 		res = -EINVAL;
 	}
Signature · 6 lines
2.1.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
maintainer
#1 lore raw

From: Jon Maloy <[email protected]>
Date: Tue, 27 Feb 2018 20:47:09 +0100

Quoted 8 lines

From: Hoang Le <[email protected]>

We introduce a set/getsockopt for setting socket receive buffer per individual socket. This has turned out to sometimes be necessary for anycast and multicast receivers when used without flow control.

I really don't want things to start going down this road.

The semantics for foo_rmem[] is that the [1] value indicates the default on a new socket, and [2] determines how large sk->sk_rcvbuf will grow through automatic receive buffer autosizing as done by TCP.

It is not a limit value to impose upon the user's request.

Furthermore, the user can just do a SO_RCVBUF setsockopt to bypass these limits.

So this change is undesirable on many levels.

I'm not applying this, sorry. Please get TIPC sockets to behave and enforce limits just like other socket families do, avoid custom family specific behavior at all costs.

Thank you.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot