X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=net%2Ftux%2Faccept.c;h=6668f5d6e23752104b0d84dc3be1ab466ad84794;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=16f611cf10ee6e8e51ddfd778e5687f00a02a7eb;hpb=cee37fe97739d85991964371c1f3a745c00dd236;p=linux-2.6.git diff --git a/net/tux/accept.c b/net/tux/accept.c index 16f611cf1..6668f5d6e 100644 --- a/net/tux/accept.c +++ b/net/tux/accept.c @@ -37,7 +37,8 @@ struct socket * start_listening(tux_socket_t *listen, int nr) struct sockaddr_in sin; struct socket *sock = NULL; struct sock *sk; - struct tcp_opt *tp; + struct tcp_sock *tp; + struct inet_connection_sock *icsk; int err; u16 port = listen->port; u32 addr = listen->ip; @@ -45,7 +46,7 @@ struct socket * start_listening(tux_socket_t *listen, int nr) /* Create a listening socket: */ - err = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock); + err = sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock); if (err) { printk(KERN_ERR "TUX: error %d creating socket.\n", err); goto error; @@ -58,27 +59,28 @@ struct socket * start_listening(tux_socket_t *listen, int nr) sin.sin_port = htons(port); sk = sock->sk; + icsk = inet_csk(sk); sk->sk_reuse = 1; sock_set_flag(sk, SOCK_URGINLINE); err = sock->ops->bind(sock, (struct sockaddr*)&sin, sizeof(sin)); if (err) { - printk(KERN_ERR "TUX: error %d binding socket. This means that probably some other process is (or was a short time ago) using addr %s://%d.%d.%d.%d:%d.\n", + printk(KERN_ERR "TUX: error %d binding socket. This means that probably some other process is (or was a short time ago) using addr %s://%d.%d.%d.%d:%d.\n", err, proto->name, HIPQUAD(addr), port); goto error; } tp = tcp_sk(sk); - Dprintk("listen sk accept_queue: %p/%p.\n", - tp->accept_queue, tp->accept_queue_tail); - tp->ack.pingpong = tux_ack_pingpong; + Dprintk("listen sk accept_queue: %d.\n", + !reqsk_queue_empty(&icsk->icsk_accept_queue)); + icsk->icsk_ack.pingpong = tux_ack_pingpong; sock_reset_flag(sk, SOCK_LINGER); sk->sk_lingertime = 0; tp->linger2 = tux_keepalive_timeout * HZ; if (proto->defer_accept && !tux_keepalive_timeout && tux_defer_accept) - tp->defer_accept = 1; + icsk->icsk_accept_queue.rskq_defer_accept = 1; /* Now, start listening on the socket */ @@ -226,7 +228,7 @@ void add_req_to_workqueue (tux_req_t *req) void del_output_timer (tux_req_t *req) { -#if CONFIG_SMP +#ifdef CONFIG_SMP if (!spin_is_locked(&req->ti->work_lock)) TUX_BUG(); #endif @@ -275,7 +277,7 @@ void output_timeout (tux_req_t *req) void __del_keepalive_timer (tux_req_t *req) { -#if CONFIG_SMP +#ifdef CONFIG_SMP if (!spin_is_locked(&req->ti->work_lock)) TUX_BUG(); #endif @@ -292,7 +294,7 @@ static void keepalive_timeout_fn (unsigned long data) { tux_req_t *req = (tux_req_t *)data; -#if CONFIG_TUX_DEBUG +#ifdef CONFIG_TUX_DEBUG Dprintk("req %p timed out after %d sec!\n", req, tux_keepalive_timeout); if (tux_Dprintk) print_req(req); @@ -309,7 +311,7 @@ void __add_keepalive_timer (tux_req_t *req) if (!tux_keepalive_timeout) TUX_BUG(); -#if CONFIG_SMP +#ifdef CONFIG_SMP if (!spin_is_locked(&req->ti->work_lock)) TUX_BUG(); #endif @@ -377,7 +379,7 @@ int output_space_event (tux_req_t *req) static int __idle_event (tux_req_t *req) { - struct tcp_opt *tp; + struct inet_connection_sock *icsk; threadinfo_t *ti; if (!req || (req->magic != TUX_MAGIC)) @@ -394,9 +396,9 @@ static int __idle_event (tux_req_t *req) del_output_timer(req); DEC_STAT(nr_idle_input_pending); - tp = tcp_sk(req->sock->sk); + icsk = inet_csk(req->sock->sk); - tp->ack.pingpong = tux_ack_pingpong; + icsk->icsk_ack.pingpong = tux_ack_pingpong; SET_TIMESTAMP(req->accept_timestamp); __add_req_to_workqueue(req); @@ -463,7 +465,7 @@ static void tux_write_space (struct sock *sk) Dprintk("sk->sk_wmem_queued: %d, sk->sk_sndbuf: %d.\n", sk->sk_wmem_queued, sk->sk_sndbuf); - if (tcp_wspace(sk) >= tcp_min_write_space(sk)) { + if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk)) { clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags); if (!idle_event(req)) output_space_event(req); @@ -523,7 +525,7 @@ static void tux_ftp_write_space (struct sock *sk) Dprintk("sk->sk_wmem_queued: %d, sk->sk_sndbuf: %d.\n", sk->sk_wmem_queued, sk->sk_sndbuf); - if (tcp_wspace(sk) >= sk->sk_sndbuf/10*8) { + if (sk_stream_wspace(sk) >= sk->sk_sndbuf/10*8) { clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags); if (!idle_event(req)) output_space_event(req); @@ -674,7 +676,7 @@ void link_tux_data_socket (tux_req_t *req, struct socket *sock) void unlink_tux_socket (tux_req_t *req) { struct sock *sk; - + if (!req->sock || !req->sock->sk) return; sk = req->sock->sk; @@ -710,7 +712,7 @@ void unlink_tux_socket (tux_req_t *req) void unlink_tux_data_socket (tux_req_t *req) { struct sock *sk; - + if (!req->data_sock || !req->data_sock->sk) return; sk = req->data_sock->sk; @@ -786,7 +788,8 @@ int accept_requests (threadinfo_t *ti) { int count = 0, last_count = 0, error, socknr = 0; struct socket *sock, *new_sock; - struct tcp_opt *tp1, *tp2; + struct tcp_sock *tp2; + struct inet_connection_sock *icsk1, *icsk2; tux_req_t *req; if (ti->nr_requests > tux_max_connect) @@ -803,48 +806,49 @@ repeat: if (unlikely(test_thread_flag(TIF_NEED_RESCHED))) break; - tp1 = tcp_sk(sock->sk); - /* - * Quick test to see if there are connections on the queue. - * This is cheaper than accept() itself because this saves us - * the allocation of a new socket. (Which doesn't seem to be - * used anyway) - */ - if (tp1->accept_queue) { - tux_proto_t *proto; - - if (!count++) - __set_task_state(current, TASK_RUNNING); - - new_sock = sock_alloc(); - if (!new_sock) - goto out; - - new_sock->type = sock->type; - new_sock->ops = sock->ops; - - error = sock->ops->accept(sock, new_sock, O_NONBLOCK); - if (error < 0) - goto err; - if (new_sock->sk->sk_state != TCP_ESTABLISHED) - goto err; - - tp2 = tcp_sk(new_sock->sk); - tp2->nonagle = 2; - tp2->ack.pingpong = tux_ack_pingpong; - new_sock->sk->sk_reuse = 1; - sock_set_flag(new_sock->sk, SOCK_URGINLINE); - - /* Allocate a request-entry for the connection */ - req = kmalloc_req(ti); - if (!req) - BUG(); - link_tux_socket(req, new_sock); - - proto = req->proto = tux_listen->proto; - - proto->got_request(req); - } + icsk1 = inet_csk(sock->sk); + /* + * Quick test to see if there are connections on the queue. + * This is cheaper than accept() itself because this saves us + * the allocation of a new socket. (Which doesn't seem to be + * used anyway) + */ + if (!reqsk_queue_empty(&icsk1->icsk_accept_queue)) { + tux_proto_t *proto; + + if (!count++) + __set_task_state(current, TASK_RUNNING); + + new_sock = sock_alloc(); + if (!new_sock) + goto out; + + new_sock->type = sock->type; + new_sock->ops = sock->ops; + + error = sock->ops->accept(sock, new_sock, O_NONBLOCK); + if (error < 0) + goto err; + if (new_sock->sk->sk_state != TCP_ESTABLISHED) + goto err; + + tp2 = tcp_sk(new_sock->sk); + icsk2 = inet_csk(new_sock->sk); + tp2->nonagle = 2; + icsk2->icsk_ack.pingpong = tux_ack_pingpong; + new_sock->sk->sk_reuse = 1; + sock_set_flag(new_sock->sk, SOCK_URGINLINE); + + /* Allocate a request-entry for the connection */ + req = kmalloc_req(ti); + if (!req) + BUG(); + link_tux_socket(req, new_sock); + + proto = req->proto = tux_listen->proto; + + proto->got_request(req); + } } if (count != last_count) { last_count = count;