Skip to content

Commit

Permalink
don't open-code kernel_setsockopt()
Browse files Browse the repository at this point in the history
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Apr 6, 2017
1 parent c1ae3cf commit e73a67f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 32 deletions.
25 changes: 4 additions & 21 deletions fs/ocfs2/cluster/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1460,35 +1460,18 @@ static void o2net_rx_until_empty(struct work_struct *work)

static int o2net_set_nodelay(struct socket *sock)
{
int ret, val = 1;
mm_segment_t oldfs;
int val = 1;

oldfs = get_fs();
set_fs(KERNEL_DS);

/*
* 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;
return kernel_setsockopt(sock, SOL_TCP, TCP_NODELAY,
(void *)&val, sizeof(val));
}

static int o2net_set_usertimeout(struct socket *sock)
{
int user_timeout = O2NET_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)
Expand Down
5 changes: 1 addition & 4 deletions net/rds/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,10 @@ static struct ctl_table rds_tcp_sysctl_table[] = {
/* doing it this way avoids calling tcp_sk() */
void rds_tcp_nonagle(struct socket *sock)
{
mm_segment_t oldfs = get_fs();
int val = 1;

set_fs(KERNEL_DS);
sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
kernel_setsockopt(sock, SOL_TCP, TCP_NODELAY, (void *)&val,
sizeof(val));
set_fs(oldfs);
}

u32 rds_tcp_snd_nxt(struct rds_tcp_connection *tc)
Expand Down
8 changes: 1 addition & 7 deletions net/rds/tcp_send.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,7 @@

static void rds_tcp_cork(struct socket *sock, int val)
{
mm_segment_t oldfs;

oldfs = get_fs();
set_fs(KERNEL_DS);
sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
sizeof(val));
set_fs(oldfs);
kernel_setsockopt(sock, SOL_TCP, TCP_CORK, (void *)&val, sizeof(val));
}

void rds_tcp_xmit_path_prepare(struct rds_conn_path *cp)
Expand Down

0 comments on commit e73a67f

Please sign in to comment.