X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=net%2Ftux%2Fredirect.c;fp=net%2Ftux%2Fredirect.c;h=b55c322b09858f798057d708047b6c72317ec120;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=86b5300fb80e2f8a121c122e1114612336f919cf;hpb=cee37fe97739d85991964371c1f3a745c00dd236;p=linux-2.6.git diff --git a/net/tux/redirect.c b/net/tux/redirect.c index 86b5300fb..b55c322b0 100644 --- a/net/tux/redirect.c +++ b/net/tux/redirect.c @@ -7,6 +7,8 @@ */ #include +#include +#include /**************************************************************** * This program is free software; you can redistribute it and/or modify @@ -25,23 +27,19 @@ * ****************************************************************/ -static void dummy_destructor(struct open_request *req) +static void nop_destructor(struct request_sock *req) { } -static struct or_calltable dummy = +static struct request_sock_ops tux_req = { - 0, - NULL, - NULL, - &dummy_destructor, - NULL + .destructor = &nop_destructor, }; static int redirect_sock (tux_req_t *req, const int port) { struct socket *sock = req->sock; - struct open_request *tcpreq; + struct request_sock *tcpreq; struct sock *sk, *oldsk; int err = -1; @@ -49,7 +47,7 @@ static int redirect_sock (tux_req_t *req, const int port) * Look up (optional) listening user-space socket. */ local_bh_disable(); - sk = tcp_v4_lookup_listener(INADDR_ANY, port, 0); + sk = inet_lookup_listener(&tcp_hashinfo, INADDR_ANY, port, 0); /* * Look up localhost listeners as well. */ @@ -59,13 +57,17 @@ static int redirect_sock (tux_req_t *req, const int port) ((unsigned char *)&daddr)[1] = 0; ((unsigned char *)&daddr)[2] = 0; ((unsigned char *)&daddr)[3] = 1; - sk = tcp_v4_lookup_listener(daddr, port, 0); + sk = inet_lookup_listener(&tcp_hashinfo, daddr, port, 0); } local_bh_enable(); /* No secondary server found */ if (!sk) goto out; + if (sk->sk_family != AF_INET) { + sock_put(sk); + goto out; + } /* * Requeue the 'old' socket as an accept-socket of @@ -80,7 +82,7 @@ static int redirect_sock (tux_req_t *req, const int port) if (sk->sk_state != TCP_LISTEN) goto out_unlock; - tcpreq = tcp_openreq_alloc(); + tcpreq = reqsk_alloc(&tux_req); if (!tcpreq) goto out_unlock; @@ -89,7 +91,6 @@ static int redirect_sock (tux_req_t *req, const int port) sock->sk = NULL; sock->state = SS_UNCONNECTED; - tcpreq->class = &dummy; write_lock_irq(&oldsk->sk_callback_lock); oldsk->sk_socket = NULL; oldsk->sk_sleep = NULL; @@ -97,7 +98,7 @@ static int redirect_sock (tux_req_t *req, const int port) tcp_sk(oldsk)->nonagle = 0; - tcp_acceptq_queue(sk, tcpreq, oldsk); + inet_csk_reqsk_queue_add(sk, tcpreq, oldsk); sk->sk_data_ready(sk, 0); @@ -105,7 +106,11 @@ static int redirect_sock (tux_req_t *req, const int port) * It's now completely up to the secondary * server to handle this request. */ - sock_release(req->sock); + if (req->fd != -1) { + tux_close(req->fd); + req->fd = -1; + } else + sock_release(req->sock); req->sock = NULL; req->parsed_len = 0; err = 0; @@ -152,3 +157,16 @@ out_flush: flush_request(req, cachemiss); } +int init_tux_request_slabs(void) +{ + tux_req.slab = kmem_cache_create("tux-request", + sizeof(struct request_sock), 0, SLAB_HWCACHE_ALIGN, + NULL, NULL); + + return tux_req.slab == NULL; +} + +void free_tux_request_slabs(void) +{ + kmem_cache_destroy(tux_req.slab); +}