summaryrefslogtreecommitdiffstats
path: root/net/tipc/socket.c
diff options
context:
space:
mode:
authorYing Xue <ying.xue@windriver.com>2013-06-17 10:54:37 -0400
committerDavid S. Miller <davem@davemloft.net>2013-06-17 18:53:00 -0400
commitcc79dd1ba9c1021c2ac6ae200a65ec38ee8db351 (patch)
tree86ffd4e43a1fb2d833a750ea713ce81b0af5df63 /net/tipc/socket.c
parent8941bbcd572a8860ad03c76e2f3d1dafa820b842 (diff)
tipc: change socket buffer overflow control to respect sk_rcvbuf
As per feedback from the netdev community, we change the buffer overflow protection algorithm in receiving sockets so that it always respects the nominal upper limit set in sk_rcvbuf. Instead of scaling up from a small sk_rcvbuf value, which leads to violation of the configured sk_rcvbuf limit, we now calculate the weighted per-message limit by scaling down from a much bigger value, still in the same field, according to the importance priority of the received message. To allow for administrative tunability of the socket receive buffer size, we create a tipc_rmem sysctl variable to allow the user to configure an even bigger value via sysctl command. It is a size of three (min/default/max) to be consistent with things like tcp_rmem. By default, the value initialized in tipc_rmem[1] is equal to the receive socket size needed by a TIPC_CRITICAL_IMPORTANCE message. This value is also set as the default value of sk_rcvbuf. Originally-by: Jon Maloy <jon.maloy@ericsson.com> Cc: Neil Horman <nhorman@tuxdriver.com> Cc: Jon Maloy <jon.maloy@ericsson.com> [Ying: added sysctl variation to Jon's original patch] Signed-off-by: Ying Xue <ying.xue@windriver.com> [PG: don't compile sysctl.c if not config'd; add Documentation] Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/socket.c')
-rw-r--r--net/tipc/socket.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 515ce38e4f4c..aba4255f297b 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -43,8 +43,6 @@
43#define SS_LISTENING -1 /* socket is listening */ 43#define SS_LISTENING -1 /* socket is listening */
44#define SS_READY -2 /* socket is connectionless */ 44#define SS_READY -2 /* socket is connectionless */
45 45
46#define CONN_OVERLOAD_LIMIT ((TIPC_FLOW_CONTROL_WIN * 2 + 1) * \
47 SKB_TRUESIZE(TIPC_MAX_USER_MSG_SIZE))
48#define CONN_TIMEOUT_DEFAULT 8000 /* default connect timeout = 8s */ 46#define CONN_TIMEOUT_DEFAULT 8000 /* default connect timeout = 8s */
49 47
50struct tipc_sock { 48struct tipc_sock {
@@ -203,6 +201,7 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol,
203 201
204 sock_init_data(sock, sk); 202 sock_init_data(sock, sk);
205 sk->sk_backlog_rcv = backlog_rcv; 203 sk->sk_backlog_rcv = backlog_rcv;
204 sk->sk_rcvbuf = sysctl_tipc_rmem[1];
206 sk->sk_data_ready = tipc_data_ready; 205 sk->sk_data_ready = tipc_data_ready;
207 sk->sk_write_space = tipc_write_space; 206 sk->sk_write_space = tipc_write_space;
208 tipc_sk(sk)->p = tp_ptr; 207 tipc_sk(sk)->p = tp_ptr;
@@ -1233,10 +1232,10 @@ static u32 filter_connect(struct tipc_sock *tsock, struct sk_buff **buf)
1233 * For all connectionless messages, by default new queue limits are 1232 * For all connectionless messages, by default new queue limits are
1234 * as belows: 1233 * as belows:
1235 * 1234 *
1236 * TIPC_LOW_IMPORTANCE (5MB) 1235 * TIPC_LOW_IMPORTANCE (4 MB)
1237 * TIPC_MEDIUM_IMPORTANCE (10MB) 1236 * TIPC_MEDIUM_IMPORTANCE (8 MB)
1238 * TIPC_HIGH_IMPORTANCE (20MB) 1237 * TIPC_HIGH_IMPORTANCE (16 MB)
1239 * TIPC_CRITICAL_IMPORTANCE (40MB) 1238 * TIPC_CRITICAL_IMPORTANCE (32 MB)
1240 * 1239 *
1241 * Returns overload limit according to corresponding message importance 1240 * Returns overload limit according to corresponding message importance
1242 */ 1241 */
@@ -1246,9 +1245,10 @@ static unsigned int rcvbuf_limit(struct sock *sk, struct sk_buff *buf)
1246 unsigned int limit; 1245 unsigned int limit;
1247 1246
1248 if (msg_connected(msg)) 1247 if (msg_connected(msg))
1249 limit = CONN_OVERLOAD_LIMIT; 1248 limit = sysctl_tipc_rmem[2];
1250 else 1249 else
1251 limit = sk->sk_rcvbuf << (msg_importance(msg) + 5); 1250 limit = sk->sk_rcvbuf >> TIPC_CRITICAL_IMPORTANCE <<
1251 msg_importance(msg);
1252 return limit; 1252 return limit;
1253} 1253}
1254 1254
@@ -1847,7 +1847,8 @@ static const struct net_proto_family tipc_family_ops = {
1847static struct proto tipc_proto = { 1847static struct proto tipc_proto = {
1848 .name = "TIPC", 1848 .name = "TIPC",
1849 .owner = THIS_MODULE, 1849 .owner = THIS_MODULE,
1850 .obj_size = sizeof(struct tipc_sock) 1850 .obj_size = sizeof(struct tipc_sock),
1851 .sysctl_rmem = sysctl_tipc_rmem
1851}; 1852};
1852 1853
1853/** 1854/**