Chinaunix首页 | 论坛 | 博客
  • 博客访问: 419751
  • 博文数量: 124
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 872
  • 用 户 组: 普通用户
  • 注册时间: 2018-03-29 14:38
个人简介

默默的一块石头

文章分类

全部博文(124)

文章存档

2022年(26)

2021年(10)

2020年(28)

2019年(60)

我的朋友

分类: LINUX

2022-02-22 14:36:47

accept睡眠
int __sys_accept4(int fd, struct sockaddr __user *upeer_sockaddr,
  int __user *upeer_addrlen, int flags)
{
err = sock->ops->accept(sock, newsock, sock->file->f_flags, false);
}

int inet_accept(struct socket *sock, struct socket *newsock, int flags,
bool kern)
{
struct sock *sk2 = sk1->sk_prot->accept(sk1, flags, &err, kern);
}

/*
 * This will accept the next outstanding connection.
 */
struct sock *inet_csk_accept(struct sock *sk, int flags, int *err, bool kern)
{
struct inet_connection_sock *icsk = inet_csk(sk);
struct request_sock_queue *queue = &icsk->icsk_accept_queue;
struct request_sock *req;
struct sock *newsk;
int error;

lock_sock(sk);

/* We need to make sure that this socket is listening,
* and that it has something pending.
*/
error = -EINVAL;
if (sk->sk_state != TCP_LISTEN)
goto out_err;

/* Find already established connection */
if (reqsk_queue_empty(queue)) {
long timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK);

/* If this is a non blocking socket don't sleep */
error = -EAGAIN;
if (!timeo)
goto out_err;

error = inet_csk_wait_for_connect(sk, timeo);
if (error)
goto out_err;
}
req = reqsk_queue_remove(queue, sk);
newsk = req->sk;

if (sk->sk_protocol == IPPROTO_TCP &&
    tcp_rsk(req)->tfo_listener) {
spin_lock_bh(&queue->fastopenq.lock);
if (tcp_rsk(req)->tfo_listener) {
/* We are still waiting for the final ACK from 3WHS
* so can't free req now. Instead, we set req->sk to
* NULL to signify that the child socket is taken
* so reqsk_fastopen_remove() will free the req
* when 3WHS finishes (or is aborted).
*/
req->sk = NULL;
req = NULL;
}
spin_unlock_bh(&queue->fastopenq.lock);
}
out:
release_sock(sk);
if (req)
reqsk_put(req);
return newsk;
out_err:
newsk = NULL;
req = NULL;
*err = error;
goto out;
}
EXPORT_SYMBOL(inet_csk_accept);

static inline bool reqsk_queue_empty(const struct request_sock_queue *queue)
{
return READ_ONCE(queue->rskq_accept_head) == NULL;
}

static inline struct request_sock *reqsk_queue_remove(
                            struct request_sock_queue *queue,struct sock *parent)
{
struct request_sock *req;

spin_lock_bh(&queue->rskq_lock);
req = queue->rskq_accept_head;
if (req) {
sk_acceptq_removed(parent);
WRITE_ONCE(queue->rskq_accept_head, req->dl_next);
if (queue->rskq_accept_head == NULL)
queue->rskq_accept_tail = NULL;
}
spin_unlock_bh(&queue->rskq_lock);
return req;
}

struct sock *inet_csk_reqsk_queue_add(struct sock *sk,
      struct request_sock *req,
      struct sock *child)
{
struct request_sock_queue *queue = &inet_csk(sk)->icsk_accept_queue;

spin_lock(&queue->rskq_lock);
if (unlikely(sk->sk_state != TCP_LISTEN)) {
inet_child_forget(sk, req, child);
child = NULL;
} else {
req->sk = child;
req->dl_next = NULL;
if (queue->rskq_accept_head == NULL)
WRITE_ONCE(queue->rskq_accept_head, req);
else
queue->rskq_accept_tail->dl_next = req;
queue->rskq_accept_tail = req;
sk_acceptq_added(sk);
}
spin_unlock(&queue->rskq_lock);
return child;
}
EXPORT_SYMBOL(inet_csk_reqsk_queue_add);

/*
 * Process an incoming packet for SYN_RECV sockets represented as a
 * request_sock. Normally sk is the listener socket but for TFO it
 * points to the child socket.
 *
 * XXX (TFO) - The current impl contains a special check for ack
 * validation and inside tcp_v4_reqsk_send_ack(). Can we do better?
 *
 * We don't need to initialize tmp_opt.sack_ok as we don't use the results
 */
struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,
   struct request_sock *req,
   bool fastopen, bool *req_stolen)
{
/* OK, ACK is valid, create big socket and
* feed this segment to it. It will repeat all
* the tests. THIS SEGMENT MUST MOVE SOCKET TO
* ESTABLISHED STATE. If it will be dropped after
* socket is created, wait for troubles.
*/
child = inet_csk(sk)->icsk_af_ops->syn_recv_sock(sk, skb, req, NULL,req, &own_req);
if (!child)
goto listen_overflow;

sock_rps_save_rxhash(child, skb);
tcp_synack_rtt_meas(child, req);
*req_stolen = !own_req;
return inet_csk_complete_hashdance(sk, child, req, own_req);
}

Feb 22 10:34:38 chro kernel: [  130.640427]  dump_stack+0x6d/0x95
Feb 22 10:34:38 chro kernel: [  130.640432]  inet_csk_reqsk_queue_add+0xa7/0x100
Feb 22 10:34:38 chro kernel: [  130.640436]  inet_csk_complete_hashdance+0x4a/0xb0
Feb 22 10:34:38 chro kernel: [  130.640440]  tcp_check_req+0x424/0x540
Feb 22 10:34:38 chro kernel: [  130.640445]  tcp_v4_rcv+0x785/0xad0
Feb 22 10:34:38 chro kernel: [  130.640451]  ip_protocol_deliver_rcu+0x31/0x1b0
Feb 22 10:34:38 chro kernel: [  130.640456]  ip_local_deliver_finish+0x48/0x50
Feb 22 10:34:38 chro kernel: [  130.640460]  ip_local_deliver+0x7e/0xe0
Feb 22 10:34:38 chro kernel: [  130.640465]  ? ip_protocol_deliver_rcu+0x1b0/0x1b0
Feb 22 10:34:38 chro kernel: [  130.640470]  ip_rcv_finish+0x84/0xa0
Feb 22 10:34:38 chro kernel: [  130.640475]  ip_rcv+0xbc/0xd0
Feb 22 10:34:38 chro kernel: [  130.640480]  ? ip_rcv_finish_core.isra.18+0x3b0/0x3b0
Feb 22 10:34:38 chro kernel: [  130.640484]  __netif_receive_skb_one_core+0x84/0xa0
Feb 22 10:34:38 chro kernel: [  130.640487]  __netif_receive_skb+0x18/0x60
Feb 22 10:34:38 chro kernel: [  130.640491]  process_backlog+0xa0/0x170
Feb 22 10:34:38 chro kernel: [  130.640494]  net_rx_action+0x140/0x3c0
Feb 22 10:34:38 chro kernel: [  130.640499]  __do_softirq+0xe4/0x2da
Feb 22 10:34:38 chro kernel: [  130.640502]  do_softirq_own_stack+0x2a/0x40
Feb 22 10:34:38 chro kernel: [  130.640503] 
Feb 22 10:34:38 chro kernel: [  130.640507]  do_softirq.part.20+0x46/0x50
Feb 22 10:34:38 chro kernel: [  130.640511]  __local_bh_enable_ip+0x50/0x60
Feb 22 10:34:38 chro kernel: [  130.640514]  ip_finish_output2+0x1ac/0x5a0
Feb 22 10:34:38 chro kernel: [  130.640531]  ? nf_ct_deliver_cached_events+0xa9/0x110 [nf_conntrack]
Feb 22 10:34:38 chro kernel: [  130.640535]  __ip_finish_output+0xfa/0x1c0
Feb 22 10:34:38 chro kernel: [  130.640537]  ? __ip_finish_output+0xfa/0x1c0
Feb 22 10:34:38 chro kernel: [  130.640540]  ip_finish_output+0x2c/0xa0
Feb 22 10:34:38 chro kernel: [  130.640543]  ip_output+0x6d/0xe0
Feb 22 10:34:38 chro kernel: [  130.640546]  ? __ip_finish_output+0x1c0/0x1c0
Feb 22 10:34:38 chro kernel: [  130.640549]  ip_local_out+0x3b/0x50
Feb 22 10:34:38 chro kernel: [  130.640552]  __ip_queue_xmit+0x165/0x400
Feb 22 10:34:38 chro kernel: [  130.640557]  ? __kmalloc_node_track_caller+0x1bd/0x2e0
Feb 22 10:34:38 chro kernel: [  130.640561]  ip_queue_xmit+0x10/0x20
Feb 22 10:34:38 chro kernel: [  130.640563]  __tcp_transmit_skb+0x58d/0xb20
Feb 22 10:34:38 chro kernel: [  130.640567]  __tcp_send_ack.part.47+0xa4/0x110
Feb 22 10:34:38 chro kernel: [  130.640570]  tcp_send_ack+0x1c/0x20
Feb 22 10:34:38 chro kernel: [  130.640575]  tcp_rcv_state_process+0xdc8/0xe31
Feb 22 10:34:38 chro kernel: [  130.640578]  ? tcp_connect+0x884/0xd90
Feb 22 10:34:38 chro kernel: [  130.640582]  tcp_v4_do_rcv+0x127/0x1d0
Feb 22 10:34:38 chro kernel: [  130.640585]  ? tcp_v4_do_rcv+0x127/0x1d0
Feb 22 10:34:38 chro kernel: [  130.640589]  __release_sock+0x88/0xe0
Feb 22 10:34:38 chro kernel: [  130.640593]  release_sock+0x30/0xa0
Feb 22 10:34:38 chro kernel: [  130.640598]  __inet_stream_connect+0x178/0x390
Feb 22 10:34:38 chro kernel: [  130.640601]  ? do_wait_intr_irq+0x90/0x90
Feb 22 10:34:38 chro kernel: [  130.640605]  inet_stream_connect+0x3b/0x60
Feb 22 10:34:38 chro kernel: [  130.640611]  __sys_connect+0xa3/0x120
Feb 22 10:34:38 chro kernel: [  130.640614]  ? ip_setsockopt+0x30/0xa0
Feb 22 10:34:38 chro kernel: [  130.640618]  ? tcp_setsockopt+0x28/0x40
Feb 22 10:34:38 chro kernel: [  130.640620]  ? sock_common_setsockopt+0x1a/0x20
Feb 22 10:34:38 chro kernel: [  130.640625]  ? __sys_setsockopt+0xf4/0x1a0
Feb 22 10:34:38 chro kernel: [  130.640629]  __x64_sys_connect+0x1a/0x20
Feb 22 10:34:38 chro kernel: [  130.640634]  do_syscall_64+0x57/0x190



阅读(548) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~