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 sock *sk, int val)
192 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
197 /* XXX do we need to change ack ratio? */
198 ccid2_pr_debug("change cwnd to %d\n", val);
201 hctx->ccid2hctx_cwnd = val;
204 static void ccid2_start_rto_timer(struct sock *sk);
206 static void ccid2_hc_tx_rto_expire(unsigned long data)
208 struct sock *sk = (struct sock *)data;
209 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
213 if (sock_owned_by_user(sk)) {
214 sk_reset_timer(sk, &hctx->ccid2hctx_rtotimer,
219 ccid2_pr_debug("RTO_EXPIRE\n");
221 ccid2_hc_tx_check_sanity(hctx);
224 hctx->ccid2hctx_rto <<= 1;
226 s = hctx->ccid2hctx_rto / HZ;
228 hctx->ccid2hctx_rto = 60 * HZ;
230 ccid2_start_rto_timer(sk);
232 /* adjust pipe, cwnd etc */
233 hctx->ccid2hctx_pipe = 0;
234 hctx->ccid2hctx_ssthresh = hctx->ccid2hctx_cwnd >> 1;
235 if (hctx->ccid2hctx_ssthresh < 2)
236 hctx->ccid2hctx_ssthresh = 2;
237 ccid2_change_cwnd(sk, 1);
239 /* clear state about stuff we sent */
240 hctx->ccid2hctx_seqt = hctx->ccid2hctx_seqh;
241 hctx->ccid2hctx_ssacks = 0;
242 hctx->ccid2hctx_acks = 0;
243 hctx->ccid2hctx_sent = 0;
245 /* clear ack ratio state. */
246 hctx->ccid2hctx_arsent = 0;
247 hctx->ccid2hctx_ackloss = 0;
248 hctx->ccid2hctx_rpseq = 0;
249 hctx->ccid2hctx_rpdupack = -1;
250 ccid2_change_l_ack_ratio(sk, 1);
251 ccid2_hc_tx_check_sanity(hctx);
257 static void ccid2_start_rto_timer(struct sock *sk)
259 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
261 ccid2_pr_debug("setting RTO timeout=%ld\n", hctx->ccid2hctx_rto);
263 BUG_ON(timer_pending(&hctx->ccid2hctx_rtotimer));
264 sk_reset_timer(sk, &hctx->ccid2hctx_rtotimer,
265 jiffies + hctx->ccid2hctx_rto);
268 static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, int len)
270 struct dccp_sock *dp = dccp_sk(sk);
271 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
272 struct ccid2_seq *next;
275 ccid2_hc_tx_check_sanity(hctx);
277 BUG_ON(!hctx->ccid2hctx_sendwait);
278 hctx->ccid2hctx_sendwait = 0;
279 hctx->ccid2hctx_pipe++;
280 BUG_ON(hctx->ccid2hctx_pipe < 0);
282 /* There is an issue. What if another packet is sent between
283 * packet_send() and packet_sent(). Then the sequence number would be
289 hctx->ccid2hctx_seqh->ccid2s_seq = seq;
290 hctx->ccid2hctx_seqh->ccid2s_acked = 0;
291 hctx->ccid2hctx_seqh->ccid2s_sent = jiffies;
293 next = hctx->ccid2hctx_seqh->ccid2s_next;
294 /* check if we need to alloc more space */
295 if (next == hctx->ccid2hctx_seqt) {
298 ccid2_pr_debug("allocating more space in history\n");
299 rc = ccid2_hc_tx_alloc_seq(hctx, CCID2_SEQBUF_LEN, GFP_KERNEL);
300 BUG_ON(rc); /* XXX what do we do? */
302 next = hctx->ccid2hctx_seqh->ccid2s_next;
303 BUG_ON(next == hctx->ccid2hctx_seqt);
305 hctx->ccid2hctx_seqh = next;
307 ccid2_pr_debug("cwnd=%d pipe=%d\n", hctx->ccid2hctx_cwnd,
308 hctx->ccid2hctx_pipe);
310 hctx->ccid2hctx_sent++;
312 /* Ack Ratio. Need to maintain a concept of how many windows we sent */
313 hctx->ccid2hctx_arsent++;
314 /* We had an ack loss in this window... */
315 if (hctx->ccid2hctx_ackloss) {
316 if (hctx->ccid2hctx_arsent >= hctx->ccid2hctx_cwnd) {
317 hctx->ccid2hctx_arsent = 0;
318 hctx->ccid2hctx_ackloss = 0;
321 /* No acks lost up to now... */
322 /* decrease ack ratio if enough packets were sent */
323 if (dp->dccps_l_ack_ratio > 1) {
324 /* XXX don't calculate denominator each time */
325 int denom = dp->dccps_l_ack_ratio * dp->dccps_l_ack_ratio -
326 dp->dccps_l_ack_ratio;
328 denom = hctx->ccid2hctx_cwnd * hctx->ccid2hctx_cwnd / denom;
330 if (hctx->ccid2hctx_arsent >= denom) {
331 ccid2_change_l_ack_ratio(sk, dp->dccps_l_ack_ratio - 1);
332 hctx->ccid2hctx_arsent = 0;
335 /* we can't increase ack ratio further [1] */
336 hctx->ccid2hctx_arsent = 0; /* or maybe set it to cwnd*/
340 /* setup RTO timer */
341 if (!timer_pending(&hctx->ccid2hctx_rtotimer))
342 ccid2_start_rto_timer(sk);
344 #ifdef CONFIG_IP_DCCP_CCID2_DEBUG
345 ccid2_pr_debug("pipe=%d\n", hctx->ccid2hctx_pipe);
346 ccid2_pr_debug("Sent: seq=%llu\n", seq);
348 struct ccid2_seq *seqp = hctx->ccid2hctx_seqt;
350 while (seqp != hctx->ccid2hctx_seqh) {
351 ccid2_pr_debug("out seq=%llu acked=%d time=%lu\n",
352 seqp->ccid2s_seq, seqp->ccid2s_acked,
354 seqp = seqp->ccid2s_next;
357 ccid2_pr_debug("=========\n");
358 ccid2_hc_tx_check_sanity(hctx);
362 /* XXX Lame code duplication!
363 * returns -1 if none was found.
364 * else returns the next offset to use in the function call.
366 static int ccid2_ackvector(struct sock *sk, struct sk_buff *skb, int offset,
367 unsigned char **vec, unsigned char *veclen)
369 const struct dccp_hdr *dh = dccp_hdr(skb);
370 unsigned char *options = (unsigned char *)dh + dccp_hdr_len(skb);
371 unsigned char *opt_ptr;
372 const unsigned char *opt_end = (unsigned char *)dh +
373 (dh->dccph_doff * 4);
374 unsigned char opt, len;
375 unsigned char *value;
380 if (opt_ptr >= opt_end)
383 while (opt_ptr != opt_end) {
388 /* Check if this isn't a single byte option */
389 if (opt > DCCPO_MAX_RESERVED) {
390 if (opt_ptr == opt_end)
391 goto out_invalid_option;
395 goto out_invalid_option;
397 * Remove the type and len fields, leaving
398 * just the value size
404 if (opt_ptr > opt_end)
405 goto out_invalid_option;
409 case DCCPO_ACK_VECTOR_0:
410 case DCCPO_ACK_VECTOR_1:
413 return offset + (opt_ptr - options);
420 BUG_ON(1); /* should never happen... options were previously parsed ! */
424 static void ccid2_hc_tx_kill_rto_timer(struct sock *sk)
426 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
428 sk_stop_timer(sk, &hctx->ccid2hctx_rtotimer);
429 ccid2_pr_debug("deleted RTO timer\n");
432 static inline void ccid2_new_ack(struct sock *sk,
433 struct ccid2_seq *seqp,
434 unsigned int *maxincr)
436 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
439 if (hctx->ccid2hctx_cwnd < hctx->ccid2hctx_ssthresh) {
440 hctx->ccid2hctx_acks = 0;
442 /* We can increase cwnd at most maxincr [ack_ratio/2] */
444 /* increase every 2 acks */
445 hctx->ccid2hctx_ssacks++;
446 if (hctx->ccid2hctx_ssacks == 2) {
447 ccid2_change_cwnd(sk, hctx->ccid2hctx_cwnd + 1);
448 hctx->ccid2hctx_ssacks = 0;
449 *maxincr = *maxincr - 1;
452 /* increased cwnd enough for this single ack */
453 hctx->ccid2hctx_ssacks = 0;
456 hctx->ccid2hctx_ssacks = 0;
457 hctx->ccid2hctx_acks++;
459 if (hctx->ccid2hctx_acks >= hctx->ccid2hctx_cwnd) {
460 ccid2_change_cwnd(sk, hctx->ccid2hctx_cwnd + 1);
461 hctx->ccid2hctx_acks = 0;
466 if (hctx->ccid2hctx_srtt == -1 ||
467 time_after(jiffies, hctx->ccid2hctx_lastrtt + hctx->ccid2hctx_srtt)) {
468 unsigned long r = (long)jiffies - (long)seqp->ccid2s_sent;
471 /* first measurement */
472 if (hctx->ccid2hctx_srtt == -1) {
473 ccid2_pr_debug("R: %lu Time=%lu seq=%llu\n",
474 r, jiffies, seqp->ccid2s_seq);
475 hctx->ccid2hctx_srtt = r;
476 hctx->ccid2hctx_rttvar = r >> 1;
479 long tmp = hctx->ccid2hctx_srtt - r;
484 hctx->ccid2hctx_rttvar *= 3;
485 hctx->ccid2hctx_rttvar >>= 2;
486 hctx->ccid2hctx_rttvar += tmp;
489 hctx->ccid2hctx_srtt *= 7;
490 hctx->ccid2hctx_srtt >>= 3;
492 hctx->ccid2hctx_srtt += tmp;
494 s = hctx->ccid2hctx_rttvar << 2;
495 /* clock granularity is 1 when based on jiffies */
498 hctx->ccid2hctx_rto = hctx->ccid2hctx_srtt + s;
500 /* must be at least a second */
501 s = hctx->ccid2hctx_rto / HZ;
502 /* DCCP doesn't require this [but I like it cuz my code sux] */
505 hctx->ccid2hctx_rto = HZ;
509 hctx->ccid2hctx_rto = HZ * 60;
511 hctx->ccid2hctx_lastrtt = jiffies;
513 ccid2_pr_debug("srtt: %ld rttvar: %ld rto: %ld (HZ=%d) R=%lu\n",
514 hctx->ccid2hctx_srtt, hctx->ccid2hctx_rttvar,
515 hctx->ccid2hctx_rto, HZ, r);
516 hctx->ccid2hctx_sent = 0;
519 /* we got a new ack, so re-start RTO timer */
520 ccid2_hc_tx_kill_rto_timer(sk);
521 ccid2_start_rto_timer(sk);
524 static void ccid2_hc_tx_dec_pipe(struct sock *sk)
526 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
528 hctx->ccid2hctx_pipe--;
529 BUG_ON(hctx->ccid2hctx_pipe < 0);
531 if (hctx->ccid2hctx_pipe == 0)
532 ccid2_hc_tx_kill_rto_timer(sk);
535 static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
537 struct dccp_sock *dp = dccp_sk(sk);
538 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
540 struct ccid2_seq *seqp;
541 unsigned char *vector;
542 unsigned char veclen;
546 unsigned int maxincr = 0;
548 ccid2_hc_tx_check_sanity(hctx);
549 /* check reverse path congestion */
550 seqno = DCCP_SKB_CB(skb)->dccpd_seq;
552 /* XXX this whole "algorithm" is broken. Need to fix it to keep track
553 * of the seqnos of the dupacks so that rpseq and rpdupack are correct
556 /* need to bootstrap */
557 if (hctx->ccid2hctx_rpdupack == -1) {
558 hctx->ccid2hctx_rpdupack = 0;
559 hctx->ccid2hctx_rpseq = seqno;
561 /* check if packet is consecutive */
562 if ((hctx->ccid2hctx_rpseq + 1) == seqno)
563 hctx->ccid2hctx_rpseq++;
564 /* it's a later packet */
565 else if (after48(seqno, hctx->ccid2hctx_rpseq)) {
566 hctx->ccid2hctx_rpdupack++;
568 /* check if we got enough dupacks */
569 if (hctx->ccid2hctx_rpdupack >=
570 hctx->ccid2hctx_numdupack) {
571 hctx->ccid2hctx_rpdupack = -1; /* XXX lame */
572 hctx->ccid2hctx_rpseq = 0;
574 ccid2_change_l_ack_ratio(sk, dp->dccps_l_ack_ratio << 1);
579 /* check forward path congestion */
580 /* still didn't send out new data packets */
581 if (hctx->ccid2hctx_seqh == hctx->ccid2hctx_seqt)
584 switch (DCCP_SKB_CB(skb)->dccpd_type) {
586 case DCCP_PKT_DATAACK:
592 ackno = DCCP_SKB_CB(skb)->dccpd_ack_seq;
593 seqp = hctx->ccid2hctx_seqh->ccid2s_prev;
595 /* If in slow-start, cwnd can increase at most Ack Ratio / 2 packets for
596 * this single ack. I round up.
599 maxincr = dp->dccps_l_ack_ratio >> 1;
602 /* go through all ack vectors */
603 while ((offset = ccid2_ackvector(sk, skb, offset,
604 &vector, &veclen)) != -1) {
605 /* go through this ack vector */
607 const u8 rl = *vector & DCCP_ACKVEC_LEN_MASK;
610 dccp_set_seqno(&ackno_end_rl, ackno - rl);
611 ccid2_pr_debug("ackvec start:%llu end:%llu\n", ackno,
613 /* if the seqno we are analyzing is larger than the
614 * current ackno, then move towards the tail of our
617 while (after48(seqp->ccid2s_seq, ackno)) {
618 if (seqp == hctx->ccid2hctx_seqt) {
622 seqp = seqp->ccid2s_prev;
627 /* check all seqnos in the range of the vector
630 while (between48(seqp->ccid2s_seq,ackno_end_rl,ackno)) {
631 const u8 state = *vector &
632 DCCP_ACKVEC_STATE_MASK;
634 /* new packet received or marked */
635 if (state != DCCP_ACKVEC_STATE_NOT_RECEIVED &&
636 !seqp->ccid2s_acked) {
638 DCCP_ACKVEC_STATE_ECN_MARKED) {
641 ccid2_new_ack(sk, seqp,
644 seqp->ccid2s_acked = 1;
645 ccid2_pr_debug("Got ack for %llu\n",
647 ccid2_hc_tx_dec_pipe(sk);
649 if (seqp == hctx->ccid2hctx_seqt) {
653 seqp = seqp->ccid2s_next;
659 dccp_set_seqno(&ackno, ackno_end_rl - 1);
666 /* The state about what is acked should be correct now
667 * Check for NUMDUPACK
669 seqp = hctx->ccid2hctx_seqh->ccid2s_prev;
672 if (seqp->ccid2s_acked) {
674 if (done == hctx->ccid2hctx_numdupack)
677 if (seqp == hctx->ccid2hctx_seqt)
679 seqp = seqp->ccid2s_prev;
682 /* If there are at least 3 acknowledgements, anything unacknowledged
683 * below the last sequence number is considered lost
685 if (done == hctx->ccid2hctx_numdupack) {
686 struct ccid2_seq *last_acked = seqp;
688 /* check for lost packets */
690 if (!seqp->ccid2s_acked) {
692 ccid2_hc_tx_dec_pipe(sk);
694 if (seqp == hctx->ccid2hctx_seqt)
696 seqp = seqp->ccid2s_prev;
699 hctx->ccid2hctx_seqt = last_acked;
702 /* trim acked packets in tail */
703 while (hctx->ccid2hctx_seqt != hctx->ccid2hctx_seqh) {
704 if (!hctx->ccid2hctx_seqt->ccid2s_acked)
707 hctx->ccid2hctx_seqt = hctx->ccid2hctx_seqt->ccid2s_next;
711 /* XXX do bit shifts guarantee a 0 as the new bit? */
712 ccid2_change_cwnd(sk, hctx->ccid2hctx_cwnd >> 1);
713 hctx->ccid2hctx_ssthresh = hctx->ccid2hctx_cwnd;
714 if (hctx->ccid2hctx_ssthresh < 2)
715 hctx->ccid2hctx_ssthresh = 2;
718 ccid2_hc_tx_check_sanity(hctx);
721 static int ccid2_hc_tx_init(struct ccid *ccid, struct sock *sk)
723 struct ccid2_hc_tx_sock *hctx = ccid_priv(ccid);
725 hctx->ccid2hctx_cwnd = 1;
726 /* Initialize ssthresh to infinity. This means that we will exit the
727 * initial slow-start after the first packet loss. This is what we
730 hctx->ccid2hctx_ssthresh = ~0;
731 hctx->ccid2hctx_numdupack = 3;
732 hctx->ccid2hctx_seqbufc = 0;
734 /* XXX init ~ to window size... */
735 if (ccid2_hc_tx_alloc_seq(hctx, CCID2_SEQBUF_LEN, GFP_ATOMIC) != 0)
738 hctx->ccid2hctx_sent = 0;
739 hctx->ccid2hctx_rto = 3 * HZ;
740 hctx->ccid2hctx_srtt = -1;
741 hctx->ccid2hctx_rttvar = -1;
742 hctx->ccid2hctx_lastrtt = 0;
743 hctx->ccid2hctx_rpdupack = -1;
745 hctx->ccid2hctx_rtotimer.function = &ccid2_hc_tx_rto_expire;
746 hctx->ccid2hctx_rtotimer.data = (unsigned long)sk;
747 init_timer(&hctx->ccid2hctx_rtotimer);
749 ccid2_hc_tx_check_sanity(hctx);
753 static void ccid2_hc_tx_exit(struct sock *sk)
755 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
758 ccid2_hc_tx_kill_rto_timer(sk);
760 for (i = 0; i < hctx->ccid2hctx_seqbufc; i++)
761 kfree(hctx->ccid2hctx_seqbuf[i]);
762 hctx->ccid2hctx_seqbufc = 0;
765 static void ccid2_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
767 const struct dccp_sock *dp = dccp_sk(sk);
768 struct ccid2_hc_rx_sock *hcrx = ccid2_hc_rx_sk(sk);
770 switch (DCCP_SKB_CB(skb)->dccpd_type) {
772 case DCCP_PKT_DATAACK:
773 hcrx->ccid2hcrx_data++;
774 if (hcrx->ccid2hcrx_data >= dp->dccps_r_ack_ratio) {
776 hcrx->ccid2hcrx_data = 0;
782 static struct ccid_operations ccid2 = {
784 .ccid_name = "ccid2",
785 .ccid_owner = THIS_MODULE,
786 .ccid_hc_tx_obj_size = sizeof(struct ccid2_hc_tx_sock),
787 .ccid_hc_tx_init = ccid2_hc_tx_init,
788 .ccid_hc_tx_exit = ccid2_hc_tx_exit,
789 .ccid_hc_tx_send_packet = ccid2_hc_tx_send_packet,
790 .ccid_hc_tx_packet_sent = ccid2_hc_tx_packet_sent,
791 .ccid_hc_tx_packet_recv = ccid2_hc_tx_packet_recv,
792 .ccid_hc_rx_obj_size = sizeof(struct ccid2_hc_rx_sock),
793 .ccid_hc_rx_packet_recv = ccid2_hc_rx_packet_recv,
796 module_param(ccid2_debug, int, 0444);
797 MODULE_PARM_DESC(ccid2_debug, "Enable debug messages");
799 static __init int ccid2_module_init(void)
801 return ccid_register(&ccid2);
803 module_init(ccid2_module_init);
805 static __exit void ccid2_module_exit(void)
807 ccid_unregister(&ccid2);
809 module_exit(ccid2_module_exit);
811 MODULE_AUTHOR("Andrea Bittau <a.bittau@cs.ucl.ac.uk>");
812 MODULE_DESCRIPTION("DCCP TCP-Like (CCID2) CCID");
813 MODULE_LICENSE("GPL");
814 MODULE_ALIAS("net-dccp-ccid-2");