aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/ccids
diff options
context:
space:
mode:
authorGerrit Renker <gerrit@erg.abdn.ac.uk>2008-09-04 01:30:19 -0400
committerGerrit Renker <gerrit@erg.abdn.ac.uk>2008-09-04 01:45:38 -0400
commitc6f0f2e71f3088a0f05502d6adb0f667b84028c3 (patch)
tree6ab76387d836075f75fcb7ece70c0b76f241b509 /net/dccp/ccids
parent83337dae6ca94d801b6700600244865cd694205b (diff)
dccp ccid-2: Remove redundant sanity tests
This removes the ccid2_hc_tx_check_sanity function: it is redundant. Details: ======== The tx_check_sanity function performs three tests: 1) it checks that the circular TX list is sorted - in ascending order of sequence number (ccid2s_seq) - and time (ccid2s_sent), - in the direction from `tail' (hctx_seqt) to `head' (hctx_seqh); 2) it ensures that the entire list has the length seqbufc * CCID2_SEQBUF_LEN; 3) it ensures that pipe equals the number of packets that were not marked `acked' (ccid2s_acked) between `tail' and `head'. The following argues that each of these tests is redundant, this can be verified by going through the code. (1) is not necessary, since both time and GSS increase from one packet to the next, so that subsequent insertions in tx_packet_sent (which advance the `head' pointer) will be in ascending order of time and sequence number. In (2), the length of the list is always equal to seqbufc times CCID2_SEQBUF_LEN (set to 1024) unless allocation caused an earlier failure, because: * at initialisation (tx_init), there is one chunk of size 1024 and seqbufc=1; * subsequent calls to tx_alloc_seq take place whenever head->next == tail in tx_packet_sent; then a new chunk of size 1024 is inserted between head and tail, and seqbufc is incremented by one. To show that (3) is redundant requires looking at two cases. The `pipe' variable of the TX socket is incremented only in tx_packet_sent, and decremented in tx_packet_recv. When head == tail (TX history empty) then pipe should be 0, which is the case directly after initialisation and after a retransmission timeout has occurred (ccid2_hc_tx_rto_expire). The first case involves parsing Ack Vectors for packets recorded in the live portion of the buffer, between tail and head. For each packet marked by the receiver as received (state 0) or ECN-marked (state 1), pipe is decremented by one, so for all such packets the BUG_ON in tx_check_sanity will not trigger. The second case is the loss detection in the second half of tx_packet_recv, below the comment "Check for NUMDUPACK". The first while-loop here ensures that the sequence number of `seqp' is either above or equal to `high_ack', or otherwise equal to the highest sequence number sent so far (of the entry head->prev, as head points to the next unsent entry). The next while-loop ("while (1)") counts the number of acked packets starting from that position of seqp, going backwards in the direction from head->prev to tail. If NUMDUPACK=3 such packets were counted within this loop, `seqp' points to the last acknowledged packet of these, and the "if (done == NUMDUPACK)" block is entered next. The while-loop contained within that block in turn traverses the list backwards, from head to tail; the position of `seqp' is saved in the variable `last_acked'. For each packet not marked as `acked', a congestion event is triggered within the loop, and pipe is decremented. The loop terminates when `seqp' has reached `tail', whereupon tail is set to the position previously stored in `last_acked'. Thus, between `last_acked' and the previous position of `tail', - pipe has been decremented earlier if the packet was marked as state 0 or 1; - pipe was decremented if the packet was not marked as acked. That is, pipe has been decremented by the number of packets between `last_acked' and the previous position of `tail'. As a consequence, pipe now again reflects the number of packets which have not (yet) been acked between the new position of tail (at `last_acked') and head->prev, or 0 if head==tail. The result is that the BUG_ON condition in check_sanity will also not be triggered, hence the test (3) is also redundant. Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Diffstat (limited to 'net/dccp/ccids')
-rw-r--r--net/dccp/ccids/ccid2.c51
1 files changed, 0 insertions, 51 deletions
diff --git a/net/dccp/ccids/ccid2.c b/net/dccp/ccids/ccid2.c
index c7d83e3c1648..3b2548bd73f3 100644
--- a/net/dccp/ccids/ccid2.c
+++ b/net/dccp/ccids/ccid2.c
@@ -34,51 +34,8 @@
34#ifdef CONFIG_IP_DCCP_CCID2_DEBUG 34#ifdef CONFIG_IP_DCCP_CCID2_DEBUG
35static int ccid2_debug; 35static int ccid2_debug;
36#define ccid2_pr_debug(format, a...) DCCP_PR_DEBUG(ccid2_debug, format, ##a) 36#define ccid2_pr_debug(format, a...) DCCP_PR_DEBUG(ccid2_debug, format, ##a)
37
38static void ccid2_hc_tx_check_sanity(const struct ccid2_hc_tx_sock *hctx)
39{
40 int len = 0;
41 int pipe = 0;
42 struct ccid2_seq *seqp = hctx->seqh;
43
44 /* there is data in the chain */
45 if (seqp != hctx->seqt) {
46 seqp = seqp->ccid2s_prev;
47 len++;
48 if (!seqp->ccid2s_acked)
49 pipe++;
50
51 while (seqp != hctx->seqt) {
52 struct ccid2_seq *prev = seqp->ccid2s_prev;
53
54 len++;
55 if (!prev->ccid2s_acked)
56 pipe++;
57
58 /* packets are sent sequentially */
59 BUG_ON(dccp_delta_seqno(seqp->ccid2s_seq,
60 prev->ccid2s_seq ) >= 0);
61 BUG_ON(time_before(seqp->ccid2s_sent,
62 prev->ccid2s_sent));
63
64 seqp = prev;
65 }
66 }
67
68 BUG_ON(pipe != hctx->pipe);
69 ccid2_pr_debug("len of chain=%d\n", len);
70
71 do {
72 seqp = seqp->ccid2s_prev;
73 len++;
74 } while (seqp != hctx->seqh);
75
76 ccid2_pr_debug("total len=%d\n", len);
77 BUG_ON(len != hctx->seqbufc * CCID2_SEQBUF_LEN);
78}
79#else 37#else
80#define ccid2_pr_debug(format, a...) 38#define ccid2_pr_debug(format, a...)
81#define ccid2_hc_tx_check_sanity(hctx)
82#endif 39#endif
83 40
84static int ccid2_hc_tx_alloc_seq(struct ccid2_hc_tx_sock *hctx) 41static int ccid2_hc_tx_alloc_seq(struct ccid2_hc_tx_sock *hctx)
@@ -176,8 +133,6 @@ static void ccid2_hc_tx_rto_expire(unsigned long data)
176 133
177 ccid2_pr_debug("RTO_EXPIRE\n"); 134 ccid2_pr_debug("RTO_EXPIRE\n");
178 135
179 ccid2_hc_tx_check_sanity(hctx);
180
181 /* back-off timer */ 136 /* back-off timer */
182 hctx->rto <<= 1; 137 hctx->rto <<= 1;
183 138
@@ -200,7 +155,6 @@ static void ccid2_hc_tx_rto_expire(unsigned long data)
200 hctx->rpseq = 0; 155 hctx->rpseq = 0;
201 hctx->rpdupack = -1; 156 hctx->rpdupack = -1;
202 ccid2_change_l_ack_ratio(sk, 1); 157 ccid2_change_l_ack_ratio(sk, 1);
203 ccid2_hc_tx_check_sanity(hctx);
204 158
205 /* if we were blocked before, we may now send cwnd=1 packet */ 159 /* if we were blocked before, we may now send cwnd=1 packet */
206 if (sender_was_blocked) 160 if (sender_was_blocked)
@@ -314,7 +268,6 @@ static void ccid2_hc_tx_packet_sent(struct sock *sk, unsigned int len)
314 } 268 }
315 } while (0); 269 } while (0);
316 ccid2_pr_debug("=========\n"); 270 ccid2_pr_debug("=========\n");
317 ccid2_hc_tx_check_sanity(hctx);
318#endif 271#endif
319} 272}
320 273
@@ -463,7 +416,6 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
463 int done = 0; 416 int done = 0;
464 unsigned int maxincr = 0; 417 unsigned int maxincr = 0;
465 418
466 ccid2_hc_tx_check_sanity(hctx);
467 /* check reverse path congestion */ 419 /* check reverse path congestion */
468 seqno = DCCP_SKB_CB(skb)->dccpd_seq; 420 seqno = DCCP_SKB_CB(skb)->dccpd_seq;
469 421
@@ -640,7 +592,6 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
640 hctx->seqt = hctx->seqt->ccid2s_next; 592 hctx->seqt = hctx->seqt->ccid2s_next;
641 } 593 }
642 594
643 ccid2_hc_tx_check_sanity(hctx);
644done: 595done:
645 /* check if incoming Acks allow pending packets to be sent */ 596 /* check if incoming Acks allow pending packets to be sent */
646 if (sender_was_blocked && !ccid2_cwnd_network_limited(hctx)) 597 if (sender_was_blocked && !ccid2_cwnd_network_limited(hctx))
@@ -680,8 +631,6 @@ static int ccid2_hc_tx_init(struct ccid *ccid, struct sock *sk)
680 hctx->last_cong = jiffies; 631 hctx->last_cong = jiffies;
681 setup_timer(&hctx->rtotimer, ccid2_hc_tx_rto_expire, (unsigned long)sk); 632 setup_timer(&hctx->rtotimer, ccid2_hc_tx_rto_expire, (unsigned long)sk);
682 INIT_LIST_HEAD(&hctx->av_chunks); 633 INIT_LIST_HEAD(&hctx->av_chunks);
683
684 ccid2_hc_tx_check_sanity(hctx);
685 return 0; 634 return 0;
686} 635}
687 636