]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - net/dccp/proto.c
[NET]: change layout of ehash table
[linux-2.6.git] / net / dccp / proto.c
index 0225bdacd3b1dfb5237819cba9d4dd2e64c224ce..48438565d70f8da9b6d7938d22b2d61512582c6f 100644 (file)
@@ -52,6 +52,9 @@ struct inet_hashinfo __cacheline_aligned dccp_hashinfo = {
 
 EXPORT_SYMBOL_GPL(dccp_hashinfo);
 
+/* the maximum queue length for tx in packets. 0 is no limit */
+int sysctl_dccp_tx_qlen __read_mostly = 5;
+
 void dccp_set_state(struct sock *sk, const int state)
 {
        const int oldstate = sk->sk_state;
@@ -193,7 +196,7 @@ int dccp_init_sock(struct sock *sk, const __u8 ctl_sock_initialized)
                                                      sk, GFP_KERNEL);
                dp->dccps_hc_tx_ccid = ccid_hc_tx_new(dmsk->dccpms_tx_ccid,
                                                      sk, GFP_KERNEL);
-               if (unlikely(dp->dccps_hc_rx_ccid == NULL ||
+               if (unlikely(dp->dccps_hc_rx_ccid == NULL ||
                             dp->dccps_hc_tx_ccid == NULL)) {
                        ccid_hc_rx_delete(dp->dccps_hc_rx_ccid, sk);
                        ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk);
@@ -387,7 +390,7 @@ static int dccp_setsockopt_service(struct sock *sk, const __be32 service,
        struct dccp_sock *dp = dccp_sk(sk);
        struct dccp_service_list *sl = NULL;
 
-       if (service == DCCP_SERVICE_INVALID_VALUE || 
+       if (service == DCCP_SERVICE_INVALID_VALUE ||
            optlen > DCCP_SERVICE_LIST_MAX_LEN * sizeof(u32))
                return -EINVAL;
 
@@ -467,7 +470,8 @@ static int do_dccp_setsockopt(struct sock *sk, int level, int optname,
        lock_sock(sk);
        switch (optname) {
        case DCCP_SOCKOPT_PACKET_SIZE:
-               dp->dccps_packet_size = val;
+               DCCP_WARN("sockopt(PACKET_SIZE) is deprecated: fix your app\n");
+               err = 0;
                break;
        case DCCP_SOCKOPT_CHANGE_L:
                if (optlen != sizeof(struct dccp_so_feat))
@@ -578,9 +582,8 @@ static int do_dccp_getsockopt(struct sock *sk, int level, int optname,
 
        switch (optname) {
        case DCCP_SOCKOPT_PACKET_SIZE:
-               val = dp->dccps_packet_size;
-               len = sizeof(dp->dccps_packet_size);
-               break;
+               DCCP_WARN("sockopt(PACKET_SIZE) is deprecated: fix your app\n");
+               return 0;
        case DCCP_SOCKOPT_SERVICE:
                return dccp_getsockopt_service(sk, len,
                                               (__be32 __user *)optval, optlen);
@@ -645,6 +648,13 @@ int dccp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
                return -EMSGSIZE;
 
        lock_sock(sk);
+
+       if (sysctl_dccp_tx_qlen &&
+           (sk->sk_write_queue.qlen >= sysctl_dccp_tx_qlen)) {
+               rc = -EAGAIN;
+               goto out_release;
+       }
+
        timeo = sock_sndtimeo(sk, noblock);
 
        /*
@@ -820,7 +830,7 @@ EXPORT_SYMBOL_GPL(inet_dccp_listen);
 static const unsigned char dccp_new_state[] = {
        /* current state:   new state:      action:     */
        [0]               = DCCP_CLOSED,
-       [DCCP_OPEN]       = DCCP_CLOSING | DCCP_ACTION_FIN,
+       [DCCP_OPEN]       = DCCP_CLOSING | DCCP_ACTION_FIN,
        [DCCP_REQUESTING] = DCCP_CLOSED,
        [DCCP_PARTOPEN]   = DCCP_CLOSING | DCCP_ACTION_FIN,
        [DCCP_LISTEN]     = DCCP_CLOSED,
@@ -1014,7 +1024,6 @@ static int __init dccp_init(void)
        do {
                dccp_hashinfo.ehash_size = (1UL << ehash_order) * PAGE_SIZE /
                                        sizeof(struct inet_ehash_bucket);
-               dccp_hashinfo.ehash_size >>= 1;
                while (dccp_hashinfo.ehash_size &
                       (dccp_hashinfo.ehash_size - 1))
                        dccp_hashinfo.ehash_size--;
@@ -1023,14 +1032,14 @@ static int __init dccp_init(void)
        } while (!dccp_hashinfo.ehash && --ehash_order > 0);
 
        if (!dccp_hashinfo.ehash) {
-               printk(KERN_CRIT "Failed to allocate DCCP "
-                                "established hash table\n");
+               DCCP_CRIT("Failed to allocate DCCP established hash table");
                goto out_free_bind_bucket_cachep;
        }
 
-       for (i = 0; i < (dccp_hashinfo.ehash_size << 1); i++) {
+       for (i = 0; i < dccp_hashinfo.ehash_size; i++) {
                rwlock_init(&dccp_hashinfo.ehash[i].lock);
                INIT_HLIST_HEAD(&dccp_hashinfo.ehash[i].chain);
+               INIT_HLIST_HEAD(&dccp_hashinfo.ehash[i].twchain);
        }
 
        bhash_order = ehash_order;
@@ -1046,7 +1055,7 @@ static int __init dccp_init(void)
        } while (!dccp_hashinfo.bhash && --bhash_order >= 0);
 
        if (!dccp_hashinfo.bhash) {
-               printk(KERN_CRIT "Failed to allocate DCCP bind hash table\n");
+               DCCP_CRIT("Failed to allocate DCCP bind hash table");
                goto out_free_dccp_ehash;
        }