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;
/* 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;
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 */
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
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
{
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);
if (!tux_keepalive_timeout)
TUX_BUG();
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
if (!spin_is_locked(&req->ti->work_lock))
TUX_BUG();
#endif
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))
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);
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);
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);
void unlink_tux_socket (tux_req_t *req)
{
struct sock *sk;
-
+
if (!req->sock || !req->sock->sk)
return;
sk = req->sock->sk;
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;
{
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)
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;