Commit 08e39c0d authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

inet: move inet->defer_connect to inet->inet_flags

Make room in struct inet_sock by removing this bit field,
using one available bit in inet_flags instead.

Also move local_port_range to fill the resulting hole,
saving 8 bytes on 64bit arches.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Acked-by: default avatarSoheil Hassas Yeganeh <soheil@google.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Reviewed-by: default avatarMatthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ca571e2e
...@@ -229,21 +229,18 @@ struct inet_sock { ...@@ -229,21 +229,18 @@ struct inet_sock {
__u8 min_ttl; __u8 min_ttl;
__u8 mc_ttl; __u8 mc_ttl;
__u8 pmtudisc; __u8 pmtudisc;
__u8 defer_connect:1; /* Indicates that fastopen_connect is set
* and cookie exists so we defer connect
* until first data frame is written
*/
__u8 rcv_tos; __u8 rcv_tos;
__u8 convert_csum; __u8 convert_csum;
int uc_index; int uc_index;
int mc_index; int mc_index;
__be32 mc_addr; __be32 mc_addr;
struct ip_mc_socklist __rcu *mc_list;
struct inet_cork_full cork;
struct { struct {
__u16 lo; __u16 lo;
__u16 hi; __u16 hi;
} local_port_range; } local_port_range;
struct ip_mc_socklist __rcu *mc_list;
struct inet_cork_full cork;
}; };
#define IPCORK_OPT 1 /* ip-options has been held in ipcork.opt */ #define IPCORK_OPT 1 /* ip-options has been held in ipcork.opt */
...@@ -270,6 +267,7 @@ enum { ...@@ -270,6 +267,7 @@ enum {
INET_FLAGS_IS_ICSK = 16, INET_FLAGS_IS_ICSK = 16,
INET_FLAGS_NODEFRAG = 17, INET_FLAGS_NODEFRAG = 17,
INET_FLAGS_BIND_ADDRESS_NO_PORT = 18, INET_FLAGS_BIND_ADDRESS_NO_PORT = 18,
INET_FLAGS_DEFER_CONNECT = 19,
}; };
/* cmsg flags for inet */ /* cmsg flags for inet */
......
...@@ -656,7 +656,7 @@ int __inet_stream_connect(struct socket *sock, struct sockaddr *uaddr, ...@@ -656,7 +656,7 @@ int __inet_stream_connect(struct socket *sock, struct sockaddr *uaddr,
err = -EISCONN; err = -EISCONN;
goto out; goto out;
case SS_CONNECTING: case SS_CONNECTING:
if (inet_sk(sk)->defer_connect) if (inet_test_bit(DEFER_CONNECT, sk))
err = is_sendmsg ? -EINPROGRESS : -EISCONN; err = is_sendmsg ? -EINPROGRESS : -EISCONN;
else else
err = -EALREADY; err = -EALREADY;
...@@ -679,7 +679,7 @@ int __inet_stream_connect(struct socket *sock, struct sockaddr *uaddr, ...@@ -679,7 +679,7 @@ int __inet_stream_connect(struct socket *sock, struct sockaddr *uaddr,
sock->state = SS_CONNECTING; sock->state = SS_CONNECTING;
if (!err && inet_sk(sk)->defer_connect) if (!err && inet_test_bit(DEFER_CONNECT, sk))
goto out; goto out;
/* Just entered SS_CONNECTING state; the only /* Just entered SS_CONNECTING state; the only
......
...@@ -192,7 +192,7 @@ int inet_diag_msg_attrs_fill(struct sock *sk, struct sk_buff *skb, ...@@ -192,7 +192,7 @@ int inet_diag_msg_attrs_fill(struct sock *sk, struct sk_buff *skb,
inet_sockopt.nodefrag = inet_test_bit(NODEFRAG, sk); inet_sockopt.nodefrag = inet_test_bit(NODEFRAG, sk);
inet_sockopt.bind_address_no_port = inet_test_bit(BIND_ADDRESS_NO_PORT, sk); inet_sockopt.bind_address_no_port = inet_test_bit(BIND_ADDRESS_NO_PORT, sk);
inet_sockopt.recverr_rfc4884 = inet_test_bit(RECVERR_RFC4884, sk); inet_sockopt.recverr_rfc4884 = inet_test_bit(RECVERR_RFC4884, sk);
inet_sockopt.defer_connect = inet->defer_connect; inet_sockopt.defer_connect = inet_test_bit(DEFER_CONNECT, sk);
if (nla_put(skb, INET_DIAG_SOCKOPT, sizeof(inet_sockopt), if (nla_put(skb, INET_DIAG_SOCKOPT, sizeof(inet_sockopt),
&inet_sockopt)) &inet_sockopt))
goto errout; goto errout;
......
...@@ -583,7 +583,8 @@ __poll_t tcp_poll(struct file *file, struct socket *sock, poll_table *wait) ...@@ -583,7 +583,8 @@ __poll_t tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
if (urg_data & TCP_URG_VALID) if (urg_data & TCP_URG_VALID)
mask |= EPOLLPRI; mask |= EPOLLPRI;
} else if (state == TCP_SYN_SENT && inet_sk(sk)->defer_connect) { } else if (state == TCP_SYN_SENT &&
inet_test_bit(DEFER_CONNECT, sk)) {
/* Active TCP fastopen socket with defer_connect /* Active TCP fastopen socket with defer_connect
* Return EPOLLOUT so application can call write() * Return EPOLLOUT so application can call write()
* in order for kernel to generate SYN+data * in order for kernel to generate SYN+data
...@@ -1007,7 +1008,7 @@ int tcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg, int *copied, ...@@ -1007,7 +1008,7 @@ int tcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg, int *copied,
tp->fastopen_req->size = size; tp->fastopen_req->size = size;
tp->fastopen_req->uarg = uarg; tp->fastopen_req->uarg = uarg;
if (inet->defer_connect) { if (inet_test_bit(DEFER_CONNECT, sk)) {
err = tcp_connect(sk); err = tcp_connect(sk);
/* Same failure procedure as in tcp_v4/6_connect */ /* Same failure procedure as in tcp_v4/6_connect */
if (err) { if (err) {
...@@ -1025,7 +1026,7 @@ int tcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg, int *copied, ...@@ -1025,7 +1026,7 @@ int tcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg, int *copied,
if (tp->fastopen_req) { if (tp->fastopen_req) {
*copied = tp->fastopen_req->copied; *copied = tp->fastopen_req->copied;
tcp_free_fastopen_req(tp); tcp_free_fastopen_req(tp);
inet->defer_connect = 0; inet_clear_bit(DEFER_CONNECT, sk);
} }
return err; return err;
} }
...@@ -1066,7 +1067,8 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size) ...@@ -1066,7 +1067,8 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
zc = MSG_SPLICE_PAGES; zc = MSG_SPLICE_PAGES;
} }
if (unlikely(flags & MSG_FASTOPEN || inet_sk(sk)->defer_connect) && if (unlikely(flags & MSG_FASTOPEN ||
inet_test_bit(DEFER_CONNECT, sk)) &&
!tp->repair) { !tp->repair) {
err = tcp_sendmsg_fastopen(sk, msg, &copied_syn, size, uarg); err = tcp_sendmsg_fastopen(sk, msg, &copied_syn, size, uarg);
if (err == -EINPROGRESS && copied_syn > 0) if (err == -EINPROGRESS && copied_syn > 0)
...@@ -3088,7 +3090,7 @@ int tcp_disconnect(struct sock *sk, int flags) ...@@ -3088,7 +3090,7 @@ int tcp_disconnect(struct sock *sk, int flags)
/* Clean up fastopen related fields */ /* Clean up fastopen related fields */
tcp_free_fastopen_req(tp); tcp_free_fastopen_req(tp);
inet->defer_connect = 0; inet_clear_bit(DEFER_CONNECT, sk);
tp->fastopen_client_fail = 0; tp->fastopen_client_fail = 0;
WARN_ON(inet->inet_num && !icsk->icsk_bind_hash); WARN_ON(inet->inet_num && !icsk->icsk_bind_hash);
......
...@@ -451,7 +451,7 @@ bool tcp_fastopen_defer_connect(struct sock *sk, int *err) ...@@ -451,7 +451,7 @@ bool tcp_fastopen_defer_connect(struct sock *sk, int *err)
if (tp->fastopen_connect && !tp->fastopen_req) { if (tp->fastopen_connect && !tp->fastopen_req) {
if (tcp_fastopen_cookie_check(sk, &mss, &cookie)) { if (tcp_fastopen_cookie_check(sk, &mss, &cookie)) {
inet_sk(sk)->defer_connect = 1; inet_set_bit(DEFER_CONNECT, sk);
return true; return true;
} }
......
...@@ -1686,7 +1686,7 @@ static int mptcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg, ...@@ -1686,7 +1686,7 @@ static int mptcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg,
if (!mptcp_disconnect(sk, 0)) if (!mptcp_disconnect(sk, 0))
sk->sk_socket->state = SS_UNCONNECTED; sk->sk_socket->state = SS_UNCONNECTED;
} }
inet_sk(sk)->defer_connect = 0; inet_clear_bit(DEFER_CONNECT, sk);
return ret; return ret;
} }
...@@ -1704,7 +1704,8 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) ...@@ -1704,7 +1704,8 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
lock_sock(sk); lock_sock(sk);
if (unlikely(inet_sk(sk)->defer_connect || msg->msg_flags & MSG_FASTOPEN)) { if (unlikely(inet_test_bit(DEFER_CONNECT, sk) ||
msg->msg_flags & MSG_FASTOPEN)) {
int copied_syn = 0; int copied_syn = 0;
ret = mptcp_sendmsg_fastopen(sk, msg, len, &copied_syn); ret = mptcp_sendmsg_fastopen(sk, msg, len, &copied_syn);
...@@ -3601,7 +3602,7 @@ static int mptcp_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) ...@@ -3601,7 +3602,7 @@ static int mptcp_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
if (err < 0) if (err < 0)
goto out; goto out;
inet_sk(sk)->defer_connect = inet_sk(ssk)->defer_connect; inet_assign_bit(DEFER_CONNECT, sk, inet_test_bit(DEFER_CONNECT, ssk));
out: out:
if (!msk->fastopening) if (!msk->fastopening)
...@@ -3827,7 +3828,8 @@ static __poll_t mptcp_poll(struct file *file, struct socket *sock, ...@@ -3827,7 +3828,8 @@ static __poll_t mptcp_poll(struct file *file, struct socket *sock,
mask |= EPOLLOUT | EPOLLWRNORM; mask |= EPOLLOUT | EPOLLWRNORM;
else else
mask |= mptcp_check_writeable(msk); mask |= mptcp_check_writeable(msk);
} else if (state == TCP_SYN_SENT && inet_sk(sk)->defer_connect) { } else if (state == TCP_SYN_SENT &&
inet_test_bit(DEFER_CONNECT, sk)) {
/* cf tcp_poll() note about TFO */ /* cf tcp_poll() note about TFO */
mask |= EPOLLOUT | EPOLLWRNORM; mask |= EPOLLOUT | EPOLLWRNORM;
} }
......
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