]> err.no Git - linux-2.6/blobdiff - net/dccp/ccids/ccid2.c
[DCCP]: Simplified conditions due to use of enum:8 states
[linux-2.6] / net / dccp / ccids / ccid2.c
index 162032baeac0acb4fddece61def024fe370c684f..207f7f9b36ca86324c02f5d093883f001c40fdc4 100644 (file)
 #include "../dccp.h"
 #include "ccid2.h"
 
-static int ccid2_debug;
 
 #ifdef CONFIG_IP_DCCP_CCID2_DEBUG
-#define ccid2_pr_debug(format, a...) \
-        do { if (ccid2_debug) \
-                printk(KERN_DEBUG "%s: " format, __FUNCTION__, ##a); \
-        } while (0)
-#else
-#define ccid2_pr_debug(format, a...)
-#endif
+static int ccid2_debug;
+#define ccid2_pr_debug(format, a...)   DCCP_PR_DEBUG(ccid2_debug, format, ##a)
 
-#ifdef CONFIG_IP_DCCP_CCID2_DEBUG
 static void ccid2_hc_tx_check_sanity(const struct ccid2_hc_tx_sock *hctx)
 {
        int len = 0;
@@ -86,7 +79,8 @@ static void ccid2_hc_tx_check_sanity(const struct ccid2_hc_tx_sock *hctx)
        BUG_ON(len != hctx->ccid2hctx_seqbufc * CCID2_SEQBUF_LEN);
 }
 #else
-#define ccid2_hc_tx_check_sanity(hctx) do {} while (0)
+#define ccid2_pr_debug(format, a...)
+#define ccid2_hc_tx_check_sanity(hctx)
 #endif
 
 static int ccid2_hc_tx_alloc_seq(struct ccid2_hc_tx_sock *hctx, int num,
@@ -426,7 +420,7 @@ static int ccid2_ackvector(struct sock *sk, struct sk_buff *skb, int offset,
        return -1;
 
 out_invalid_option:
-       BUG_ON(1); /* should never happen... options were previously parsed ! */
+       DCCP_BUG("Invalid option - this should not happen (previous parsing)!");
        return -1;
 }
 
@@ -619,7 +613,17 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
        }
 
        ackno = DCCP_SKB_CB(skb)->dccpd_ack_seq;
-       seqp = hctx->ccid2hctx_seqh->ccid2s_prev;
+       if (after48(ackno, hctx->ccid2hctx_high_ack))
+               hctx->ccid2hctx_high_ack = ackno;
+
+       seqp = hctx->ccid2hctx_seqt;
+       while (before48(seqp->ccid2s_seq, ackno)) {
+               seqp = seqp->ccid2s_next;
+               if (seqp == hctx->ccid2hctx_seqh) {
+                       seqp = hctx->ccid2hctx_seqh->ccid2s_prev;
+                       break;
+               }
+       }
 
        /* If in slow-start, cwnd can increase at most Ack Ratio / 2 packets for
         * this single ack.  I round up.
@@ -697,7 +701,14 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
        /* The state about what is acked should be correct now
         * Check for NUMDUPACK
         */
-       seqp = hctx->ccid2hctx_seqh->ccid2s_prev;
+       seqp = hctx->ccid2hctx_seqt;
+       while (before48(seqp->ccid2s_seq, hctx->ccid2hctx_high_ack)) {
+               seqp = seqp->ccid2s_next;
+               if (seqp == hctx->ccid2hctx_seqh) {
+                       seqp = hctx->ccid2hctx_seqh->ccid2s_prev;
+                       break;
+               }
+       }
        done = 0;
        while (1) {
                if (seqp->ccid2s_acked) {
@@ -771,6 +782,7 @@ static int ccid2_hc_tx_init(struct ccid *ccid, struct sock *sk)
        hctx->ccid2hctx_lastrtt  = 0;
        hctx->ccid2hctx_rpdupack = -1;
        hctx->ccid2hctx_last_cong = jiffies;
+       hctx->ccid2hctx_high_ack = 0;
 
        hctx->ccid2hctx_rtotimer.function = &ccid2_hc_tx_rto_expire;
        hctx->ccid2hctx_rtotimer.data     = (unsigned long)sk;
@@ -823,8 +835,10 @@ static struct ccid_operations ccid2 = {
        .ccid_hc_rx_packet_recv = ccid2_hc_rx_packet_recv,
 };
 
+#ifdef CONFIG_IP_DCCP_CCID2_DEBUG
 module_param(ccid2_debug, int, 0444);
 MODULE_PARM_DESC(ccid2_debug, "Enable debug messages");
+#endif
 
 static __init int ccid2_module_init(void)
 {