Commit 40ef92c6 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David S. Miller

sctp: add sctp_sock_set_nodelay

Add a helper to directly set the SCTP_NODELAY sockopt from kernel space
without going through a fake uaccess.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Acked-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f26e9b2c
...@@ -914,7 +914,6 @@ static int sctp_bind_addrs(struct connection *con, uint16_t port) ...@@ -914,7 +914,6 @@ static int sctp_bind_addrs(struct connection *con, uint16_t port)
static void sctp_connect_to_sock(struct connection *con) static void sctp_connect_to_sock(struct connection *con)
{ {
struct sockaddr_storage daddr; struct sockaddr_storage daddr;
int one = 1;
int result; int result;
int addr_len; int addr_len;
struct socket *sock; struct socket *sock;
...@@ -961,8 +960,7 @@ static void sctp_connect_to_sock(struct connection *con) ...@@ -961,8 +960,7 @@ static void sctp_connect_to_sock(struct connection *con)
log_print("connecting to %d", con->nodeid); log_print("connecting to %d", con->nodeid);
/* Turn off Nagle's algorithm */ /* Turn off Nagle's algorithm */
kernel_setsockopt(sock, SOL_SCTP, SCTP_NODELAY, (char *)&one, sctp_sock_set_nodelay(sock->sk);
sizeof(one));
/* /*
* Make sock->ops->connect() function return in specified time, * Make sock->ops->connect() function return in specified time,
...@@ -1176,7 +1174,6 @@ static int sctp_listen_for_all(void) ...@@ -1176,7 +1174,6 @@ static int sctp_listen_for_all(void)
struct socket *sock = NULL; struct socket *sock = NULL;
int result = -EINVAL; int result = -EINVAL;
struct connection *con = nodeid2con(0, GFP_NOFS); struct connection *con = nodeid2con(0, GFP_NOFS);
int one = 1;
if (!con) if (!con)
return -ENOMEM; return -ENOMEM;
...@@ -1191,10 +1188,7 @@ static int sctp_listen_for_all(void) ...@@ -1191,10 +1188,7 @@ static int sctp_listen_for_all(void)
} }
sock_set_rcvbuf(sock->sk, NEEDED_RMEM); sock_set_rcvbuf(sock->sk, NEEDED_RMEM);
result = kernel_setsockopt(sock, SOL_SCTP, SCTP_NODELAY, (char *)&one, sctp_sock_set_nodelay(sock->sk);
sizeof(one));
if (result < 0)
log_print("Could not set SCTP NODELAY error %d\n", result);
write_lock_bh(&sock->sk->sk_callback_lock); write_lock_bh(&sock->sk->sk_callback_lock);
/* Init con struct */ /* Init con struct */
......
...@@ -615,4 +615,11 @@ static inline bool sctp_newsk_ready(const struct sock *sk) ...@@ -615,4 +615,11 @@ static inline bool sctp_newsk_ready(const struct sock *sk)
return sock_flag(sk, SOCK_DEAD) || sk->sk_socket; return sock_flag(sk, SOCK_DEAD) || sk->sk_socket;
} }
static inline void sctp_sock_set_nodelay(struct sock *sk)
{
lock_sock(sk);
sctp_sk(sk)->nodelay = true;
release_sock(sk);
}
#endif /* __net_sctp_h__ */ #endif /* __net_sctp_h__ */
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