Commit e73a67f7 authored by Al Viro's avatar Al Viro

don't open-code kernel_setsockopt()

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent c1ae3cfa
...@@ -1460,27 +1460,10 @@ static void o2net_rx_until_empty(struct work_struct *work) ...@@ -1460,27 +1460,10 @@ static void o2net_rx_until_empty(struct work_struct *work)
static int o2net_set_nodelay(struct socket *sock) static int o2net_set_nodelay(struct socket *sock)
{ {
int ret, val = 1; int val = 1;
mm_segment_t oldfs;
oldfs = get_fs(); return kernel_setsockopt(sock, SOL_TCP, TCP_NODELAY,
set_fs(KERNEL_DS); (void *)&val, sizeof(val));
/*
* Dear unsuspecting programmer,
*
* Don't use sock_setsockopt() for SOL_TCP. It doesn't check its level
* argument and assumes SOL_SOCKET so, say, your TCP_NODELAY will
* silently turn into SO_DEBUG.
*
* Yours,
* Keeper of hilariously fragile interfaces.
*/
ret = sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY,
(char __user *)&val, sizeof(val));
set_fs(oldfs);
return ret;
} }
static int o2net_set_usertimeout(struct socket *sock) static int o2net_set_usertimeout(struct socket *sock)
...@@ -1488,7 +1471,7 @@ static int o2net_set_usertimeout(struct socket *sock) ...@@ -1488,7 +1471,7 @@ static int o2net_set_usertimeout(struct socket *sock)
int user_timeout = O2NET_TCP_USER_TIMEOUT; int user_timeout = O2NET_TCP_USER_TIMEOUT;
return kernel_setsockopt(sock, SOL_TCP, TCP_USER_TIMEOUT, return kernel_setsockopt(sock, SOL_TCP, TCP_USER_TIMEOUT,
(char *)&user_timeout, sizeof(user_timeout)); (void *)&user_timeout, sizeof(user_timeout));
} }
static void o2net_initialize_handshake(void) static void o2net_initialize_handshake(void)
......
...@@ -84,13 +84,10 @@ static struct ctl_table rds_tcp_sysctl_table[] = { ...@@ -84,13 +84,10 @@ static struct ctl_table rds_tcp_sysctl_table[] = {
/* doing it this way avoids calling tcp_sk() */ /* doing it this way avoids calling tcp_sk() */
void rds_tcp_nonagle(struct socket *sock) void rds_tcp_nonagle(struct socket *sock)
{ {
mm_segment_t oldfs = get_fs();
int val = 1; int val = 1;
set_fs(KERNEL_DS); kernel_setsockopt(sock, SOL_TCP, TCP_NODELAY, (void *)&val,
sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
sizeof(val)); sizeof(val));
set_fs(oldfs);
} }
u32 rds_tcp_snd_nxt(struct rds_tcp_connection *tc) u32 rds_tcp_snd_nxt(struct rds_tcp_connection *tc)
......
...@@ -40,13 +40,7 @@ ...@@ -40,13 +40,7 @@
static void rds_tcp_cork(struct socket *sock, int val) static void rds_tcp_cork(struct socket *sock, int val)
{ {
mm_segment_t oldfs; kernel_setsockopt(sock, SOL_TCP, TCP_CORK, (void *)&val, sizeof(val));
oldfs = get_fs();
set_fs(KERNEL_DS);
sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
sizeof(val));
set_fs(oldfs);
} }
void rds_tcp_xmit_path_prepare(struct rds_conn_path *cp) void rds_tcp_xmit_path_prepare(struct rds_conn_path *cp)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment