This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / net / ipv6 / tcp_ipv6.c
index 2668fc8..4a198fb 100644 (file)
@@ -51,6 +51,7 @@
 #include <net/transp_v6.h>
 #include <net/addrconf.h>
 #include <net/ip6_route.h>
+#include <net/ip6_checksum.h>
 #include <net/inet_ecn.h>
 #include <net/protocol.h>
 #include <net/xfrm.h>
@@ -1153,7 +1154,11 @@ static void tcp_v6_synq_add(struct sock *sk, struct open_request *req)
        lopt->syn_table[h] = req;
        write_unlock(&tp->syn_wait_lock);
 
+#ifdef CONFIG_ACCEPT_QUEUES
+       tcp_synq_added(sk, req);
+#else
        tcp_synq_added(sk);
+#endif
 }
 
 
@@ -1166,6 +1171,9 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
        struct tcp_opt tmptp, *tp = tcp_sk(sk);
        struct open_request *req = NULL;
        __u32 isn = TCP_SKB_CB(skb)->when;
+#ifdef CONFIG_ACCEPT_QUEUES
+       int class = 0;
+#endif
 
        if (skb->protocol == htons(ETH_P_IP))
                return tcp_v4_conn_request(sk, skb);
@@ -1173,6 +1181,7 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
        if (!ipv6_unicast_destination(skb))
                goto drop; 
 
+
        /*
         *      There are no SYN attacks on IPv6, yet...        
         */
@@ -1182,9 +1191,27 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
                goto drop;              
        }
 
+#ifdef CONFIG_ACCEPT_QUEUES
+        class = (skb->nfmark <= 0) ? 0 :
+                       ((skb->nfmark >= NUM_ACCEPT_QUEUES) ? 0: skb->nfmark);
+        /*
+        * Accept only if the class has shares set or if the default class
+        * i.e. class 0 has shares
+        */
+        if (!(tcp_sk(sk)->acceptq[class].aq_ratio)) {
+               if (tcp_sk(sk)->acceptq[0].aq_ratio) 
+                       class = 0; 
+               else 
+                       goto drop;
+       }
+
+       if (sk_acceptq_is_full(sk, class) && tcp_synq_young(sk, class) > 1)
+#else
        if (sk_acceptq_is_full(sk) && tcp_synq_young(sk) > 1)
+#endif
                goto drop;
 
+
        req = tcp_openreq_alloc();
        if (req == NULL)
                goto drop;
@@ -1197,7 +1224,10 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
 
        tmptp.tstamp_ok = tmptp.saw_tstamp;
        tcp_openreq_init(req, &tmptp, skb);
-
+#ifdef CONFIG_ACCEPT_QUEUES
+       req->acceptq_class = class;
+       req->acceptq_time_stamp = jiffies;
+#endif
        req->class = &or_ipv6;
        ipv6_addr_copy(&req->af.v6_req.rmt_addr, &skb->nh.ipv6h->saddr);
        ipv6_addr_copy(&req->af.v6_req.loc_addr, &skb->nh.ipv6h->daddr);
@@ -1299,7 +1329,11 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
 
        opt = np->opt;
 
+#ifdef CONFIG_ACCEPT_QUEUES
+       if (sk_acceptq_is_full(sk, req->acceptq_class))
+#else
        if (sk_acceptq_is_full(sk))
+#endif
                goto out_overflow;
 
        if (np->rxopt.bits.srcrt == 2 &&
@@ -1878,7 +1912,7 @@ static int tcp_v6_init_sock(struct sock *sk)
 
        tp->af_specific = &ipv6_specific;
 
-       sk->sk_write_space = tcp_write_space;
+       sk->sk_write_space = sk_stream_write_space;
        sk->sk_use_write_queue = 1;
 
        sk->sk_sndbuf = sysctl_tcp_wmem[1];
@@ -1891,30 +1925,9 @@ static int tcp_v6_init_sock(struct sock *sk)
 
 static int tcp_v6_destroy_sock(struct sock *sk)
 {
-       struct tcp_opt *tp = tcp_sk(sk);
-       struct inet_opt *inet = inet_sk(sk);
-
-       tcp_clear_xmit_timers(sk);
-
-       /* Cleanup up the write buffer. */
-       tcp_writequeue_purge(sk);
-
-       /* Cleans up our, hopefully empty, out_of_order_queue. */
-       __skb_queue_purge(&tp->out_of_order_queue);
-
-       /* Clean prequeue, it must be empty really */
-       __skb_queue_purge(&tp->ucopy.prequeue);
-
-       /* Clean up a referenced TCP bind bucket. */
-       if (tcp_sk(sk)->bind_hash)
-               tcp_put_port(sk);
-
-       /* If sendmsg cached page exists, toss it. */
-       if (inet->sndmsg_page != NULL)
-               __free_page(inet->sndmsg_page);
-
-       atomic_dec(&tcp_sockets_allocated);
+       extern int tcp_v4_destroy_sock(struct sock *sk);
 
+       tcp_v4_destroy_sock(sk);
        return inet6_destroy_sock(sk);
 }
 
@@ -2082,23 +2095,31 @@ void tcp6_proc_exit(void)
 #endif
 
 struct proto tcpv6_prot = {
-       .name           =       "TCPv6",
-       .close          =       tcp_close,
-       .connect        =       tcp_v6_connect,
-       .disconnect     =       tcp_disconnect,
-       .accept         =       tcp_accept,
-       .ioctl          =       tcp_ioctl,
-       .init           =       tcp_v6_init_sock,
-       .destroy        =       tcp_v6_destroy_sock,
-       .shutdown       =       tcp_shutdown,
-       .setsockopt     =       tcp_setsockopt,
-       .getsockopt     =       tcp_getsockopt,
-       .sendmsg        =       tcp_sendmsg,
-       .recvmsg        =       tcp_recvmsg,
-       .backlog_rcv    =       tcp_v6_do_rcv,
-       .hash           =       tcp_v6_hash,
-       .unhash         =       tcp_unhash,
-       .get_port       =       tcp_v6_get_port,
+       .name                   = "TCPv6",
+       .close                  = tcp_close,
+       .connect                = tcp_v6_connect,
+       .disconnect             = tcp_disconnect,
+       .accept                 = tcp_accept,
+       .ioctl                  = tcp_ioctl,
+       .init                   = tcp_v6_init_sock,
+       .destroy                = tcp_v6_destroy_sock,
+       .shutdown               = tcp_shutdown,
+       .setsockopt             = tcp_setsockopt,
+       .getsockopt             = tcp_getsockopt,
+       .sendmsg                = tcp_sendmsg,
+       .recvmsg                = tcp_recvmsg,
+       .backlog_rcv            = tcp_v6_do_rcv,
+       .hash                   = tcp_v6_hash,
+       .unhash                 = tcp_unhash,
+       .get_port               = tcp_v6_get_port,
+       .enter_memory_pressure  = tcp_enter_memory_pressure,
+       .sockets_allocated      = &tcp_sockets_allocated,
+       .memory_allocated       = &tcp_memory_allocated,
+       .memory_pressure        = &tcp_memory_pressure,
+       .sysctl_mem             = sysctl_tcp_mem,
+       .sysctl_wmem            = sysctl_tcp_wmem,
+       .sysctl_rmem            = sysctl_tcp_rmem,
+       .max_header             = MAX_TCP_HEADER,
 };
 
 static struct inet6_protocol tcpv6_protocol = {