forked from luck/tmp_suning_uos_patched
net: sock: replace sk_state_load with inet_sk_state_load and remove sk_state_store
sk_state_load is only used by AF_INET/AF_INET6, so rename it to inet_sk_state_load and move it into inet_sock.h. sk_state_store is removed as it is not used any more. Signed-off-by: Yafang Shao <laoar.shao@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
563e0bb0dc
commit
986ffdfd08
|
@ -290,9 +290,32 @@ static inline void inet_sk_copy_descendant(struct sock *sk_to,
|
|||
#endif
|
||||
|
||||
int inet_sk_rebuild_header(struct sock *sk);
|
||||
void inet_sk_set_state(struct sock *sk, int state);
|
||||
|
||||
/**
|
||||
* inet_sk_state_load - read sk->sk_state for lockless contexts
|
||||
* @sk: socket pointer
|
||||
*
|
||||
* Paired with inet_sk_state_store(). Used in places we don't hold socket lock:
|
||||
* tcp_diag_get_info(), tcp_get_info(), tcp_poll(), get_tcp4_sock() ...
|
||||
*/
|
||||
static inline int inet_sk_state_load(const struct sock *sk)
|
||||
{
|
||||
/* state change might impact lockless readers. */
|
||||
return smp_load_acquire(&sk->sk_state);
|
||||
}
|
||||
|
||||
/**
|
||||
* inet_sk_state_store - update sk->sk_state
|
||||
* @sk: socket pointer
|
||||
* @newstate: new state
|
||||
*
|
||||
* Paired with inet_sk_state_load(). Should be used in contexts where
|
||||
* state change might impact lockless readers.
|
||||
*/
|
||||
void inet_sk_state_store(struct sock *sk, int newstate);
|
||||
|
||||
void inet_sk_set_state(struct sock *sk, int state);
|
||||
|
||||
static inline unsigned int __inet_ehashfn(const __be32 laddr,
|
||||
const __u16 lport,
|
||||
const __be32 faddr,
|
||||
|
|
|
@ -2333,31 +2333,6 @@ static inline bool sk_listener(const struct sock *sk)
|
|||
return (1 << sk->sk_state) & (TCPF_LISTEN | TCPF_NEW_SYN_RECV);
|
||||
}
|
||||
|
||||
/**
|
||||
* sk_state_load - read sk->sk_state for lockless contexts
|
||||
* @sk: socket pointer
|
||||
*
|
||||
* Paired with sk_state_store(). Used in places we do not hold socket lock :
|
||||
* tcp_diag_get_info(), tcp_get_info(), tcp_poll(), get_tcp4_sock() ...
|
||||
*/
|
||||
static inline int sk_state_load(const struct sock *sk)
|
||||
{
|
||||
return smp_load_acquire(&sk->sk_state);
|
||||
}
|
||||
|
||||
/**
|
||||
* sk_state_store - update sk->sk_state
|
||||
* @sk: socket pointer
|
||||
* @newstate: new state
|
||||
*
|
||||
* Paired with sk_state_load(). Should be used in contexts where
|
||||
* state change might impact lockless readers.
|
||||
*/
|
||||
static inline void sk_state_store(struct sock *sk, int newstate)
|
||||
{
|
||||
smp_store_release(&sk->sk_state, newstate);
|
||||
}
|
||||
|
||||
void sock_enable_timestamp(struct sock *sk, int flag);
|
||||
int sock_get_timestamp(struct sock *, struct timeval __user *);
|
||||
int sock_get_timestampns(struct sock *, struct timespec __user *);
|
||||
|
|
|
@ -685,7 +685,7 @@ static void reqsk_timer_handler(struct timer_list *t)
|
|||
int max_retries, thresh;
|
||||
u8 defer_accept;
|
||||
|
||||
if (sk_state_load(sk_listener) != TCP_LISTEN)
|
||||
if (inet_sk_state_load(sk_listener) != TCP_LISTEN)
|
||||
goto drop;
|
||||
|
||||
max_retries = icsk->icsk_syn_retries ? : net->ipv4.sysctl_tcp_synack_retries;
|
||||
|
|
|
@ -502,7 +502,7 @@ unsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
|
|||
|
||||
sock_poll_wait(file, sk_sleep(sk), wait);
|
||||
|
||||
state = sk_state_load(sk);
|
||||
state = inet_sk_state_load(sk);
|
||||
if (state == TCP_LISTEN)
|
||||
return inet_csk_listen_poll(sk);
|
||||
|
||||
|
@ -2916,7 +2916,7 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info)
|
|||
if (sk->sk_type != SOCK_STREAM)
|
||||
return;
|
||||
|
||||
info->tcpi_state = sk_state_load(sk);
|
||||
info->tcpi_state = inet_sk_state_load(sk);
|
||||
|
||||
/* Report meaningful fields for all TCP states, including listeners */
|
||||
rate = READ_ONCE(sk->sk_pacing_rate);
|
||||
|
|
|
@ -24,7 +24,7 @@ static void tcp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,
|
|||
{
|
||||
struct tcp_info *info = _info;
|
||||
|
||||
if (sk_state_load(sk) == TCP_LISTEN) {
|
||||
if (inet_sk_state_load(sk) == TCP_LISTEN) {
|
||||
r->idiag_rqueue = sk->sk_ack_backlog;
|
||||
r->idiag_wqueue = sk->sk_max_ack_backlog;
|
||||
} else if (sk->sk_type == SOCK_STREAM) {
|
||||
|
|
|
@ -2281,7 +2281,7 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i)
|
|||
timer_expires = jiffies;
|
||||
}
|
||||
|
||||
state = sk_state_load(sk);
|
||||
state = inet_sk_state_load(sk);
|
||||
if (state == TCP_LISTEN)
|
||||
rx_queue = sk->sk_ack_backlog;
|
||||
else
|
||||
|
|
|
@ -1795,7 +1795,7 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
|
|||
timer_expires = jiffies;
|
||||
}
|
||||
|
||||
state = sk_state_load(sp);
|
||||
state = inet_sk_state_load(sp);
|
||||
if (state == TCP_LISTEN)
|
||||
rx_queue = sp->sk_ack_backlog;
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue
Block a user