2 * net/dccp/ccids/ccid2.c
4 * Copyright (c) 2005, 2006 Andrea Bittau <a.bittau@cs.ucl.ac.uk>
6 * Changes to meet Linux coding standards, and DCCP infrastructure fixes.
8 * Copyright (c) 2006 Arnaldo Carvalho de Melo <acme@conectiva.com.br>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 * This implementation should follow: draft-ietf-dccp-ccid2-10.txt
29 * - sequence number wrapping
36 static int ccid2_debug;
38 #ifdef CONFIG_IP_DCCP_CCID2_DEBUG
39 #define ccid2_pr_debug(format, a...) \
40 do { if (ccid2_debug) \
41 printk(KERN_DEBUG "%s: " format, __FUNCTION__, ##a); \
44 #define ccid2_pr_debug(format, a...)
47 #ifdef CONFIG_IP_DCCP_CCID2_DEBUG
48 static void ccid2_hc_tx_check_sanity(const struct ccid2_hc_tx_sock *hctx)
52 struct ccid2_seq *seqp = hctx->ccid2hctx_seqh;
54 /* there is data in the chain */
55 if (seqp != hctx->ccid2hctx_seqt) {
56 seqp = seqp->ccid2s_prev;
58 if (!seqp->ccid2s_acked)
61 while (seqp != hctx->ccid2hctx_seqt) {
62 struct ccid2_seq *prev = seqp->ccid2s_prev;
65 if (!prev->ccid2s_acked)
68 /* packets are sent sequentially */
69 BUG_ON(seqp->ccid2s_seq <= prev->ccid2s_seq);
70 BUG_ON(time_before(seqp->ccid2s_sent,
77 BUG_ON(pipe != hctx->ccid2hctx_pipe);
78 ccid2_pr_debug("len of chain=%d\n", len);
81 seqp = seqp->ccid2s_prev;
83 } while (seqp != hctx->ccid2hctx_seqh);
85 ccid2_pr_debug("total len=%d\n", len);
86 BUG_ON(len != hctx->ccid2hctx_seqbufc * CCID2_SEQBUF_LEN);
89 #define ccid2_hc_tx_check_sanity(hctx) do {} while (0)
92 static int ccid2_hc_tx_alloc_seq(struct ccid2_hc_tx_sock *hctx, int num,
95 struct ccid2_seq *seqp;
98 /* check if we have space to preserve the pointer to the buffer */
99 if (hctx->ccid2hctx_seqbufc >= (sizeof(hctx->ccid2hctx_seqbuf) /
100 sizeof(struct ccid2_seq*)))
103 /* allocate buffer and initialize linked list */
104 seqp = kmalloc(sizeof(*seqp) * num, gfp);
108 for (i = 0; i < (num - 1); i++) {
109 seqp[i].ccid2s_next = &seqp[i + 1];
110 seqp[i + 1].ccid2s_prev = &seqp[i];
112 seqp[num - 1].ccid2s_next = seqp;
113 seqp->ccid2s_prev = &seqp[num - 1];
115 /* This is the first allocation. Initiate the head and tail. */
116 if (hctx->ccid2hctx_seqbufc == 0)
117 hctx->ccid2hctx_seqh = hctx->ccid2hctx_seqt = seqp;
119 /* link the existing list with the one we just created */
120 hctx->ccid2hctx_seqh->ccid2s_next = seqp;
121 seqp->ccid2s_prev = hctx->ccid2hctx_seqh;
123 hctx->ccid2hctx_seqt->ccid2s_prev = &seqp[num - 1];
124 seqp[num - 1].ccid2s_next = hctx->ccid2hctx_seqt;
127 /* store the original pointer to the buffer so we can free it */
128 hctx->ccid2hctx_seqbuf[hctx->ccid2hctx_seqbufc] = seqp;
129 hctx->ccid2hctx_seqbufc++;
134 static int ccid2_hc_tx_send_packet(struct sock *sk,
135 struct sk_buff *skb, int len)
137 struct ccid2_hc_tx_sock *hctx;
139 switch (DCCP_SKB_CB(skb)->dccpd_type) {
140 case 0: /* XXX data packets from userland come through like this */
142 case DCCP_PKT_DATAACK:
144 /* No congestion control on other packets */
149 hctx = ccid2_hc_tx_sk(sk);
151 ccid2_pr_debug("pipe=%d cwnd=%d\n", hctx->ccid2hctx_pipe,
152 hctx->ccid2hctx_cwnd);
154 if (hctx->ccid2hctx_pipe < hctx->ccid2hctx_cwnd) {
155 /* OK we can send... make sure previous packet was sent off */
156 if (!hctx->ccid2hctx_sendwait) {
157 hctx->ccid2hctx_sendwait = 1;
162 return 1; /* XXX CCID should dequeue when ready instead of polling */
165 static void ccid2_change_l_ack_ratio(struct sock *sk, int val)
167 struct dccp_sock *dp = dccp_sk(sk);
169 * XXX I don't really agree with val != 2. If cwnd is 1, ack ratio
170 * should be 1... it shouldn't be allowed to become 2.
174 const struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
175 int max = hctx->ccid2hctx_cwnd / 2;
178 if (hctx->ccid2hctx_cwnd & 1)
185 ccid2_pr_debug("changing local ack ratio to %d\n", val);
187 dp->dccps_l_ack_ratio = val;
190 static void ccid2_change_cwnd(struct ccid2_hc_tx_sock *hctx, int val)
195 /* XXX do we need to change ack ratio? */
196 ccid2_pr_debug("change cwnd to %d\n", val);
199 hctx->ccid2hctx_cwnd = val;
202 static void ccid2_start_rto_timer(struct sock *sk);
204 static void ccid2_hc_tx_rto_expire(unsigned long data)
206 struct sock *sk = (struct sock *)data;
207 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
211 if (sock_owned_by_user(sk)) {
212 sk_reset_timer(sk, &hctx->ccid2hctx_rtotimer,
217 ccid2_pr_debug("RTO_EXPIRE\n");
219 ccid2_hc_tx_check_sanity(hctx);
222 hctx->ccid2hctx_rto <<= 1;
224 s = hctx->ccid2hctx_rto / HZ;
226 hctx->ccid2hctx_rto = 60 * HZ;
228 ccid2_start_rto_timer(sk);
230 /* adjust pipe, cwnd etc */
231 hctx->ccid2hctx_pipe = 0;
232 hctx->ccid2hctx_ssthresh = hctx->ccid2hctx_cwnd >> 1;
233 if (hctx->ccid2hctx_ssthresh < 2)
234 hctx->ccid2hctx_ssthresh = 2;
235 ccid2_change_cwnd(hctx, 1);
237 /* clear state about stuff we sent */
238 hctx->ccid2hctx_seqt = hctx->ccid2hctx_seqh;
239 hctx->ccid2hctx_ssacks = 0;
240 hctx->ccid2hctx_acks = 0;
241 hctx->ccid2hctx_sent = 0;
243 /* clear ack ratio state. */
244 hctx->ccid2hctx_arsent = 0;
245 hctx->ccid2hctx_ackloss = 0;
246 hctx->ccid2hctx_rpseq = 0;
247 hctx->ccid2hctx_rpdupack = -1;
248 ccid2_change_l_ack_ratio(sk, 1);
249 ccid2_hc_tx_check_sanity(hctx);
255 static void ccid2_start_rto_timer(struct sock *sk)
257 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
259 ccid2_pr_debug("setting RTO timeout=%ld\n", hctx->ccid2hctx_rto);
261 BUG_ON(timer_pending(&hctx->ccid2hctx_rtotimer));
262 sk_reset_timer(sk, &hctx->ccid2hctx_rtotimer,
263 jiffies + hctx->ccid2hctx_rto);
266 static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, int len)
268 struct dccp_sock *dp = dccp_sk(sk);
269 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
270 struct ccid2_seq *next;
273 ccid2_hc_tx_check_sanity(hctx);
275 BUG_ON(!hctx->ccid2hctx_sendwait);
276 hctx->ccid2hctx_sendwait = 0;
277 hctx->ccid2hctx_pipe++;
278 BUG_ON(hctx->ccid2hctx_pipe < 0);
280 /* There is an issue. What if another packet is sent between
281 * packet_send() and packet_sent(). Then the sequence number would be
287 hctx->ccid2hctx_seqh->ccid2s_seq = seq;
288 hctx->ccid2hctx_seqh->ccid2s_acked = 0;
289 hctx->ccid2hctx_seqh->ccid2s_sent = jiffies;
291 next = hctx->ccid2hctx_seqh->ccid2s_next;
292 /* check if we need to alloc more space */
293 if (next == hctx->ccid2hctx_seqt) {
296 ccid2_pr_debug("allocating more space in history\n");
297 rc = ccid2_hc_tx_alloc_seq(hctx, CCID2_SEQBUF_LEN, GFP_KERNEL);
298 BUG_ON(rc); /* XXX what do we do? */
300 next = hctx->ccid2hctx_seqh->ccid2s_next;
301 BUG_ON(next == hctx->ccid2hctx_seqt);
303 hctx->ccid2hctx_seqh = next;
305 ccid2_pr_debug("cwnd=%d pipe=%d\n", hctx->ccid2hctx_cwnd,
306 hctx->ccid2hctx_pipe);
308 hctx->ccid2hctx_sent++;
310 /* Ack Ratio. Need to maintain a concept of how many windows we sent */
311 hctx->ccid2hctx_arsent++;
312 /* We had an ack loss in this window... */
313 if (hctx->ccid2hctx_ackloss) {
314 if (hctx->ccid2hctx_arsent >= hctx->ccid2hctx_cwnd) {
315 hctx->ccid2hctx_arsent = 0;
316 hctx->ccid2hctx_ackloss = 0;
319 /* No acks lost up to now... */
320 /* decrease ack ratio if enough packets were sent */
321 if (dp->dccps_l_ack_ratio > 1) {
322 /* XXX don't calculate denominator each time */
323 int denom = dp->dccps_l_ack_ratio * dp->dccps_l_ack_ratio -
324 dp->dccps_l_ack_ratio;
326 denom = hctx->ccid2hctx_cwnd * hctx->ccid2hctx_cwnd / denom;
328 if (hctx->ccid2hctx_arsent >= denom) {
329 ccid2_change_l_ack_ratio(sk, dp->dccps_l_ack_ratio - 1);
330 hctx->ccid2hctx_arsent = 0;
333 /* we can't increase ack ratio further [1] */
334 hctx->ccid2hctx_arsent = 0; /* or maybe set it to cwnd*/
338 /* setup RTO timer */
339 if (!timer_pending(&hctx->ccid2hctx_rtotimer))
340 ccid2_start_rto_timer(sk);
342 #ifdef CONFIG_IP_DCCP_CCID2_DEBUG
343 ccid2_pr_debug("pipe=%d\n", hctx->ccid2hctx_pipe);
344 ccid2_pr_debug("Sent: seq=%llu\n", seq);
346 struct ccid2_seq *seqp = hctx->ccid2hctx_seqt;
348 while (seqp != hctx->ccid2hctx_seqh) {
349 ccid2_pr_debug("out seq=%llu acked=%d time=%lu\n",
350 seqp->ccid2s_seq, seqp->ccid2s_acked,
352 seqp = seqp->ccid2s_next;
355 ccid2_pr_debug("=========\n");
356 ccid2_hc_tx_check_sanity(hctx);
360 /* XXX Lame code duplication!
361 * returns -1 if none was found.
362 * else returns the next offset to use in the function call.
364 static int ccid2_ackvector(struct sock *sk, struct sk_buff *skb, int offset,
365 unsigned char **vec, unsigned char *veclen)
367 const struct dccp_hdr *dh = dccp_hdr(skb);
368 unsigned char *options = (unsigned char *)dh + dccp_hdr_len(skb);
369 unsigned char *opt_ptr;
370 const unsigned char *opt_end = (unsigned char *)dh +
371 (dh->dccph_doff * 4);
372 unsigned char opt, len;
373 unsigned char *value;
378 if (opt_ptr >= opt_end)
381 while (opt_ptr != opt_end) {
386 /* Check if this isn't a single byte option */
387 if (opt > DCCPO_MAX_RESERVED) {
388 if (opt_ptr == opt_end)
389 goto out_invalid_option;
393 goto out_invalid_option;
395 * Remove the type and len fields, leaving
396 * just the value size
402 if (opt_ptr > opt_end)
403 goto out_invalid_option;
407 case DCCPO_ACK_VECTOR_0:
408 case DCCPO_ACK_VECTOR_1:
411 return offset + (opt_ptr - options);
418 BUG_ON(1); /* should never happen... options were previously parsed ! */
422 static void ccid2_hc_tx_kill_rto_timer(struct sock *sk)
424 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
426 sk_stop_timer(sk, &hctx->ccid2hctx_rtotimer);
427 ccid2_pr_debug("deleted RTO timer\n");
430 static inline void ccid2_new_ack(struct sock *sk,
431 struct ccid2_seq *seqp,
432 unsigned int *maxincr)
434 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
437 if (hctx->ccid2hctx_cwnd < hctx->ccid2hctx_ssthresh) {
438 hctx->ccid2hctx_acks = 0;
440 /* We can increase cwnd at most maxincr [ack_ratio/2] */
442 /* increase every 2 acks */
443 hctx->ccid2hctx_ssacks++;
444 if (hctx->ccid2hctx_ssacks == 2) {
445 ccid2_change_cwnd(hctx, hctx->ccid2hctx_cwnd+1);
446 hctx->ccid2hctx_ssacks = 0;
447 *maxincr = *maxincr - 1;
450 /* increased cwnd enough for this single ack */
451 hctx->ccid2hctx_ssacks = 0;
454 hctx->ccid2hctx_ssacks = 0;
455 hctx->ccid2hctx_acks++;
457 if (hctx->ccid2hctx_acks >= hctx->ccid2hctx_cwnd) {
458 ccid2_change_cwnd(hctx, hctx->ccid2hctx_cwnd + 1);
459 hctx->ccid2hctx_acks = 0;
464 if (hctx->ccid2hctx_srtt == -1 ||
465 time_after(jiffies, hctx->ccid2hctx_lastrtt + hctx->ccid2hctx_srtt)) {
466 unsigned long r = (long)jiffies - (long)seqp->ccid2s_sent;
469 /* first measurement */
470 if (hctx->ccid2hctx_srtt == -1) {
471 ccid2_pr_debug("R: %lu Time=%lu seq=%llu\n",
472 r, jiffies, seqp->ccid2s_seq);
473 hctx->ccid2hctx_srtt = r;
474 hctx->ccid2hctx_rttvar = r >> 1;
477 long tmp = hctx->ccid2hctx_srtt - r;
482 hctx->ccid2hctx_rttvar *= 3;
483 hctx->ccid2hctx_rttvar >>= 2;
484 hctx->ccid2hctx_rttvar += tmp;
487 hctx->ccid2hctx_srtt *= 7;
488 hctx->ccid2hctx_srtt >>= 3;
490 hctx->ccid2hctx_srtt += tmp;
492 s = hctx->ccid2hctx_rttvar << 2;
493 /* clock granularity is 1 when based on jiffies */
496 hctx->ccid2hctx_rto = hctx->ccid2hctx_srtt + s;
498 /* must be at least a second */
499 s = hctx->ccid2hctx_rto / HZ;
500 /* DCCP doesn't require this [but I like it cuz my code sux] */
503 hctx->ccid2hctx_rto = HZ;
507 hctx->ccid2hctx_rto = HZ * 60;
509 hctx->ccid2hctx_lastrtt = jiffies;
511 ccid2_pr_debug("srtt: %ld rttvar: %ld rto: %ld (HZ=%d) R=%lu\n",
512 hctx->ccid2hctx_srtt, hctx->ccid2hctx_rttvar,
513 hctx->ccid2hctx_rto, HZ, r);
514 hctx->ccid2hctx_sent = 0;
517 /* we got a new ack, so re-start RTO timer */
518 ccid2_hc_tx_kill_rto_timer(sk);
519 ccid2_start_rto_timer(sk);
522 static void ccid2_hc_tx_dec_pipe(struct sock *sk)
524 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
526 hctx->ccid2hctx_pipe--;
527 BUG_ON(hctx->ccid2hctx_pipe < 0);
529 if (hctx->ccid2hctx_pipe == 0)
530 ccid2_hc_tx_kill_rto_timer(sk);
533 static void ccid2_congestion_event(struct ccid2_hc_tx_sock *hctx,
534 struct ccid2_seq *seqp)
536 if (time_before(seqp->ccid2s_sent, hctx->ccid2hctx_last_cong)) {
537 ccid2_pr_debug("Multiple losses in an RTT---treating as one\n");
541 hctx->ccid2hctx_last_cong = jiffies;
543 ccid2_change_cwnd(hctx, hctx->ccid2hctx_cwnd >> 1);
544 hctx->ccid2hctx_ssthresh = hctx->ccid2hctx_cwnd;
545 if (hctx->ccid2hctx_ssthresh < 2)
546 hctx->ccid2hctx_ssthresh = 2;
549 static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
551 struct dccp_sock *dp = dccp_sk(sk);
552 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
554 struct ccid2_seq *seqp;
555 unsigned char *vector;
556 unsigned char veclen;
559 unsigned int maxincr = 0;
561 ccid2_hc_tx_check_sanity(hctx);
562 /* check reverse path congestion */
563 seqno = DCCP_SKB_CB(skb)->dccpd_seq;
565 /* XXX this whole "algorithm" is broken. Need to fix it to keep track
566 * of the seqnos of the dupacks so that rpseq and rpdupack are correct
569 /* need to bootstrap */
570 if (hctx->ccid2hctx_rpdupack == -1) {
571 hctx->ccid2hctx_rpdupack = 0;
572 hctx->ccid2hctx_rpseq = seqno;
574 /* check if packet is consecutive */
575 if ((hctx->ccid2hctx_rpseq + 1) == seqno)
576 hctx->ccid2hctx_rpseq++;
577 /* it's a later packet */
578 else if (after48(seqno, hctx->ccid2hctx_rpseq)) {
579 hctx->ccid2hctx_rpdupack++;
581 /* check if we got enough dupacks */
582 if (hctx->ccid2hctx_rpdupack >=
583 hctx->ccid2hctx_numdupack) {
584 hctx->ccid2hctx_rpdupack = -1; /* XXX lame */
585 hctx->ccid2hctx_rpseq = 0;
587 ccid2_change_l_ack_ratio(sk, dp->dccps_l_ack_ratio << 1);
592 /* check forward path congestion */
593 /* still didn't send out new data packets */
594 if (hctx->ccid2hctx_seqh == hctx->ccid2hctx_seqt)
597 switch (DCCP_SKB_CB(skb)->dccpd_type) {
599 case DCCP_PKT_DATAACK:
605 ackno = DCCP_SKB_CB(skb)->dccpd_ack_seq;
606 seqp = hctx->ccid2hctx_seqh->ccid2s_prev;
608 /* If in slow-start, cwnd can increase at most Ack Ratio / 2 packets for
609 * this single ack. I round up.
612 maxincr = dp->dccps_l_ack_ratio >> 1;
615 /* go through all ack vectors */
616 while ((offset = ccid2_ackvector(sk, skb, offset,
617 &vector, &veclen)) != -1) {
618 /* go through this ack vector */
620 const u8 rl = *vector & DCCP_ACKVEC_LEN_MASK;
623 dccp_set_seqno(&ackno_end_rl, ackno - rl);
624 ccid2_pr_debug("ackvec start:%llu end:%llu\n", ackno,
626 /* if the seqno we are analyzing is larger than the
627 * current ackno, then move towards the tail of our
630 while (after48(seqp->ccid2s_seq, ackno)) {
631 if (seqp == hctx->ccid2hctx_seqt) {
635 seqp = seqp->ccid2s_prev;
640 /* check all seqnos in the range of the vector
643 while (between48(seqp->ccid2s_seq,ackno_end_rl,ackno)) {
644 const u8 state = *vector &
645 DCCP_ACKVEC_STATE_MASK;
647 /* new packet received or marked */
648 if (state != DCCP_ACKVEC_STATE_NOT_RECEIVED &&
649 !seqp->ccid2s_acked) {
651 DCCP_ACKVEC_STATE_ECN_MARKED) {
652 ccid2_congestion_event(hctx,
655 ccid2_new_ack(sk, seqp,
658 seqp->ccid2s_acked = 1;
659 ccid2_pr_debug("Got ack for %llu\n",
661 ccid2_hc_tx_dec_pipe(sk);
663 if (seqp == hctx->ccid2hctx_seqt) {
667 seqp = seqp->ccid2s_next;
673 dccp_set_seqno(&ackno, ackno_end_rl - 1);
680 /* The state about what is acked should be correct now
681 * Check for NUMDUPACK
683 seqp = hctx->ccid2hctx_seqh->ccid2s_prev;
686 if (seqp->ccid2s_acked) {
688 if (done == hctx->ccid2hctx_numdupack)
691 if (seqp == hctx->ccid2hctx_seqt)
693 seqp = seqp->ccid2s_prev;
696 /* If there are at least 3 acknowledgements, anything unacknowledged
697 * below the last sequence number is considered lost
699 if (done == hctx->ccid2hctx_numdupack) {
700 struct ccid2_seq *last_acked = seqp;
702 /* check for lost packets */
704 if (!seqp->ccid2s_acked) {
705 ccid2_pr_debug("Packet lost: %llu\n",
707 /* XXX need to traverse from tail -> head in
708 * order to detect multiple congestion events in
711 ccid2_congestion_event(hctx, seqp);
712 ccid2_hc_tx_dec_pipe(sk);
714 if (seqp == hctx->ccid2hctx_seqt)
716 seqp = seqp->ccid2s_prev;
719 hctx->ccid2hctx_seqt = last_acked;
722 /* trim acked packets in tail */
723 while (hctx->ccid2hctx_seqt != hctx->ccid2hctx_seqh) {
724 if (!hctx->ccid2hctx_seqt->ccid2s_acked)
727 hctx->ccid2hctx_seqt = hctx->ccid2hctx_seqt->ccid2s_next;
730 ccid2_hc_tx_check_sanity(hctx);
733 static int ccid2_hc_tx_init(struct ccid *ccid, struct sock *sk)
735 struct ccid2_hc_tx_sock *hctx = ccid_priv(ccid);
737 ccid2_change_cwnd(hctx, 1);
738 /* Initialize ssthresh to infinity. This means that we will exit the
739 * initial slow-start after the first packet loss. This is what we
742 hctx->ccid2hctx_ssthresh = ~0;
743 hctx->ccid2hctx_numdupack = 3;
744 hctx->ccid2hctx_seqbufc = 0;
746 /* XXX init ~ to window size... */
747 if (ccid2_hc_tx_alloc_seq(hctx, CCID2_SEQBUF_LEN, GFP_ATOMIC) != 0)
750 hctx->ccid2hctx_sent = 0;
751 hctx->ccid2hctx_rto = 3 * HZ;
752 hctx->ccid2hctx_srtt = -1;
753 hctx->ccid2hctx_rttvar = -1;
754 hctx->ccid2hctx_lastrtt = 0;
755 hctx->ccid2hctx_rpdupack = -1;
756 hctx->ccid2hctx_last_cong = jiffies;
758 hctx->ccid2hctx_rtotimer.function = &ccid2_hc_tx_rto_expire;
759 hctx->ccid2hctx_rtotimer.data = (unsigned long)sk;
760 init_timer(&hctx->ccid2hctx_rtotimer);
762 ccid2_hc_tx_check_sanity(hctx);
766 static void ccid2_hc_tx_exit(struct sock *sk)
768 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
771 ccid2_hc_tx_kill_rto_timer(sk);
773 for (i = 0; i < hctx->ccid2hctx_seqbufc; i++)
774 kfree(hctx->ccid2hctx_seqbuf[i]);
775 hctx->ccid2hctx_seqbufc = 0;
778 static void ccid2_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
780 const struct dccp_sock *dp = dccp_sk(sk);
781 struct ccid2_hc_rx_sock *hcrx = ccid2_hc_rx_sk(sk);
783 switch (DCCP_SKB_CB(skb)->dccpd_type) {
785 case DCCP_PKT_DATAACK:
786 hcrx->ccid2hcrx_data++;
787 if (hcrx->ccid2hcrx_data >= dp->dccps_r_ack_ratio) {
789 hcrx->ccid2hcrx_data = 0;
795 static struct ccid_operations ccid2 = {
797 .ccid_name = "ccid2",
798 .ccid_owner = THIS_MODULE,
799 .ccid_hc_tx_obj_size = sizeof(struct ccid2_hc_tx_sock),
800 .ccid_hc_tx_init = ccid2_hc_tx_init,
801 .ccid_hc_tx_exit = ccid2_hc_tx_exit,
802 .ccid_hc_tx_send_packet = ccid2_hc_tx_send_packet,
803 .ccid_hc_tx_packet_sent = ccid2_hc_tx_packet_sent,
804 .ccid_hc_tx_packet_recv = ccid2_hc_tx_packet_recv,
805 .ccid_hc_rx_obj_size = sizeof(struct ccid2_hc_rx_sock),
806 .ccid_hc_rx_packet_recv = ccid2_hc_rx_packet_recv,
809 module_param(ccid2_debug, int, 0444);
810 MODULE_PARM_DESC(ccid2_debug, "Enable debug messages");
812 static __init int ccid2_module_init(void)
814 return ccid_register(&ccid2);
816 module_init(ccid2_module_init);
818 static __exit void ccid2_module_exit(void)
820 ccid_unregister(&ccid2);
822 module_exit(ccid2_module_exit);
824 MODULE_AUTHOR("Andrea Bittau <a.bittau@cs.ucl.ac.uk>");
825 MODULE_DESCRIPTION("DCCP TCP-Like (CCID2) CCID");
826 MODULE_LICENSE("GPL");
827 MODULE_ALIAS("net-dccp-ccid-2");