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
33 #include <linux/config.h>
38 static int ccid2_debug;
45 #define ccid2_pr_debug(format, a...) \
46 do { if (ccid2_debug) \
47 printk(KERN_DEBUG "%s: " format, __FUNCTION__, ##a); \
50 #define ccid2_pr_debug(format, a...)
53 static const int ccid2_seq_len = 128;
55 static inline struct ccid2_hc_tx_sock *ccid2_hc_tx_sk(const struct sock *sk)
57 return dccp_sk(sk)->dccps_hc_tx_ccid_private;
60 static inline struct ccid2_hc_rx_sock *ccid2_hc_rx_sk(const struct sock *sk)
62 return dccp_sk(sk)->dccps_hc_rx_ccid_private;
66 static void ccid2_hc_tx_check_sanity(const struct ccid2_hc_tx_sock *hctx)
69 struct ccid2_seq *seqp;
72 seqp = hctx->ccid2hctx_seqh;
74 /* there is data in the chain */
75 if (seqp != hctx->ccid2hctx_seqt) {
76 seqp = seqp->ccid2s_prev;
78 if (!seqp->ccid2s_acked)
81 while (seqp != hctx->ccid2hctx_seqt) {
82 struct ccid2_seq *prev;
84 prev = seqp->ccid2s_prev;
86 if (!prev->ccid2s_acked)
89 /* packets are sent sequentially */
90 BUG_ON(seqp->ccid2s_seq <= prev->ccid2s_seq);
91 BUG_ON(seqp->ccid2s_sent < prev->ccid2s_sent);
92 BUG_ON(len > ccid2_seq_len);
98 BUG_ON(pipe != hctx->ccid2hctx_pipe);
99 ccid2_pr_debug("len of chain=%d\n", len);
102 seqp = seqp->ccid2s_prev;
104 BUG_ON(len > ccid2_seq_len);
105 } while(seqp != hctx->ccid2hctx_seqh);
107 BUG_ON(len != ccid2_seq_len);
108 ccid2_pr_debug("total len=%d\n", len);
111 #define ccid2_hc_tx_check_sanity(hctx) do {} while (0)
114 static int ccid2_hc_tx_send_packet(struct sock *sk,
115 struct sk_buff *skb, int len)
117 struct ccid2_hc_tx_sock *hctx;
119 switch (DCCP_SKB_CB(skb)->dccpd_type) {
120 case 0: /* XXX data packets from userland come through like this */
122 case DCCP_PKT_DATAACK:
124 /* No congestion control on other packets */
129 hctx = ccid2_hc_tx_sk(sk);
131 ccid2_pr_debug("pipe=%d cwnd=%d\n", hctx->ccid2hctx_pipe,
132 hctx->ccid2hctx_cwnd);
134 if (hctx->ccid2hctx_pipe < hctx->ccid2hctx_cwnd) {
135 /* OK we can send... make sure previous packet was sent off */
136 if (!hctx->ccid2hctx_sendwait) {
137 hctx->ccid2hctx_sendwait = 1;
142 return 100; /* XXX */
145 static void ccid2_change_l_ack_ratio(struct sock *sk, int val)
147 struct dccp_sock *dp = dccp_sk(sk);
149 * XXX I don't really agree with val != 2. If cwnd is 1, ack ratio
150 * should be 1... it shouldn't be allowed to become 2.
154 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
155 int max = hctx->ccid2hctx_cwnd / 2;
158 if (hctx->ccid2hctx_cwnd & 1)
165 ccid2_pr_debug("changing local ack ratio to %d\n", val);
167 dp->dccps_l_ack_ratio = val;
170 static void ccid2_change_cwnd(struct sock *sk, int val)
172 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
177 /* XXX do we need to change ack ratio? */
178 ccid2_pr_debug("change cwnd to %d\n", val);
181 hctx->ccid2hctx_cwnd = val;
184 static void ccid2_start_rto_timer(struct sock *sk);
186 static void ccid2_hc_tx_rto_expire(unsigned long data)
188 struct sock *sk = (struct sock *)data;
189 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
192 /* XXX I don't think i'm locking correctly
196 if (sock_owned_by_user(sk)) {
197 sk_reset_timer(sk, &hctx->ccid2hctx_rtotimer,
202 ccid2_pr_debug("RTO_EXPIRE\n");
204 ccid2_hc_tx_check_sanity(hctx);
207 hctx->ccid2hctx_rto <<= 1;
209 s = hctx->ccid2hctx_rto / HZ;
211 hctx->ccid2hctx_rto = 60 * HZ;
213 ccid2_start_rto_timer(sk);
215 /* adjust pipe, cwnd etc */
216 hctx->ccid2hctx_pipe = 0;
217 hctx->ccid2hctx_ssthresh = hctx->ccid2hctx_cwnd >> 1;
218 if (hctx->ccid2hctx_ssthresh < 2)
219 hctx->ccid2hctx_ssthresh = 2;
220 ccid2_change_cwnd(sk, 1);
222 /* clear state about stuff we sent */
223 hctx->ccid2hctx_seqt = hctx->ccid2hctx_seqh;
224 hctx->ccid2hctx_ssacks = 0;
225 hctx->ccid2hctx_acks = 0;
226 hctx->ccid2hctx_sent = 0;
228 /* clear ack ratio state. */
229 hctx->ccid2hctx_arsent = 0;
230 hctx->ccid2hctx_ackloss = 0;
231 hctx->ccid2hctx_rpseq = 0;
232 hctx->ccid2hctx_rpdupack = -1;
233 ccid2_change_l_ack_ratio(sk, 1);
234 ccid2_hc_tx_check_sanity(hctx);
240 static void ccid2_start_rto_timer(struct sock *sk)
242 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
244 ccid2_pr_debug("setting RTO timeout=%ld\n", hctx->ccid2hctx_rto);
246 BUG_ON(timer_pending(&hctx->ccid2hctx_rtotimer));
247 sk_reset_timer(sk, &hctx->ccid2hctx_rtotimer,
248 jiffies + hctx->ccid2hctx_rto);
251 static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, int len)
253 struct dccp_sock *dp = dccp_sk(sk);
254 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
257 ccid2_hc_tx_check_sanity(hctx);
259 BUG_ON(!hctx->ccid2hctx_sendwait);
260 hctx->ccid2hctx_sendwait = 0;
261 hctx->ccid2hctx_pipe++;
262 BUG_ON(hctx->ccid2hctx_pipe < 0);
264 /* There is an issue. What if another packet is sent between
265 * packet_send() and packet_sent(). Then the sequence number would be
271 hctx->ccid2hctx_seqh->ccid2s_seq = seq;
272 hctx->ccid2hctx_seqh->ccid2s_acked = 0;
273 hctx->ccid2hctx_seqh->ccid2s_sent = jiffies;
274 hctx->ccid2hctx_seqh = hctx->ccid2hctx_seqh->ccid2s_next;
276 ccid2_pr_debug("cwnd=%d pipe=%d\n", hctx->ccid2hctx_cwnd,
277 hctx->ccid2hctx_pipe);
279 if (hctx->ccid2hctx_seqh == hctx->ccid2hctx_seqt) {
280 /* XXX allocate more space */
284 hctx->ccid2hctx_sent++;
286 /* Ack Ratio. Need to maintain a concept of how many windows we sent */
287 hctx->ccid2hctx_arsent++;
288 /* We had an ack loss in this window... */
289 if (hctx->ccid2hctx_ackloss) {
290 if (hctx->ccid2hctx_arsent >= hctx->ccid2hctx_cwnd) {
291 hctx->ccid2hctx_arsent = 0;
292 hctx->ccid2hctx_ackloss = 0;
295 /* No acks lost up to now... */
297 /* decrease ack ratio if enough packets were sent */
298 if (dp->dccps_l_ack_ratio > 1) {
299 /* XXX don't calculate denominator each time */
302 denom = dp->dccps_l_ack_ratio * dp->dccps_l_ack_ratio -
303 dp->dccps_l_ack_ratio;
304 denom = hctx->ccid2hctx_cwnd * hctx->ccid2hctx_cwnd / denom;
306 if (hctx->ccid2hctx_arsent >= denom) {
307 ccid2_change_l_ack_ratio(sk, dp->dccps_l_ack_ratio - 1);
308 hctx->ccid2hctx_arsent = 0;
311 /* we can't increase ack ratio further [1] */
313 hctx->ccid2hctx_arsent = 0; /* or maybe set it to cwnd*/
317 /* setup RTO timer */
318 if (!timer_pending(&hctx->ccid2hctx_rtotimer)) {
319 ccid2_start_rto_timer(sk);
322 ccid2_pr_debug("pipe=%d\n", hctx->ccid2hctx_pipe);
323 ccid2_pr_debug("Sent: seq=%llu\n", seq);
325 struct ccid2_seq *seqp = hctx->ccid2hctx_seqt;
327 while (seqp != hctx->ccid2hctx_seqh) {
328 ccid2_pr_debug("out seq=%llu acked=%d time=%lu\n",
329 seqp->ccid2s_seq, seqp->ccid2s_acked,
331 seqp = seqp->ccid2s_next;
334 ccid2_pr_debug("=========\n");
335 ccid2_hc_tx_check_sanity(hctx);
339 /* XXX Lame code duplication!
340 * returns -1 if none was found.
341 * else returns the next offset to use in the function call.
343 static int ccid2_ackvector(struct sock *sk, struct sk_buff *skb, int offset,
344 unsigned char **vec, unsigned char *veclen)
346 const struct dccp_hdr *dh = dccp_hdr(skb);
347 unsigned char *options = (unsigned char *)dh + dccp_hdr_len(skb);
348 unsigned char *opt_ptr;
349 const unsigned char *opt_end = (unsigned char *)dh +
350 (dh->dccph_doff * 4);
351 unsigned char opt, len;
352 unsigned char *value;
357 if (opt_ptr >= opt_end)
360 while (opt_ptr != opt_end) {
365 /* Check if this isn't a single byte option */
366 if (opt > DCCPO_MAX_RESERVED) {
367 if (opt_ptr == opt_end)
368 goto out_invalid_option;
372 goto out_invalid_option;
374 * Remove the type and len fields, leaving
375 * just the value size
381 if (opt_ptr > opt_end)
382 goto out_invalid_option;
386 case DCCPO_ACK_VECTOR_0:
387 case DCCPO_ACK_VECTOR_1:
390 return offset + (opt_ptr - options);
398 BUG_ON(1); /* should never happen... options were previously parsed ! */
402 static void ccid2_hc_tx_kill_rto_timer(struct ccid2_hc_tx_sock *hctx)
404 if (del_timer(&hctx->ccid2hctx_rtotimer))
405 ccid2_pr_debug("deleted RTO timer\n");
408 static inline void ccid2_new_ack(struct sock *sk,
409 struct ccid2_seq *seqp,
410 unsigned int *maxincr)
412 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
415 if (hctx->ccid2hctx_cwnd < hctx->ccid2hctx_ssthresh) {
416 hctx->ccid2hctx_acks = 0;
418 /* We can increase cwnd at most maxincr [ack_ratio/2] */
420 /* increase every 2 acks */
421 hctx->ccid2hctx_ssacks++;
422 if (hctx->ccid2hctx_ssacks == 2) {
423 ccid2_change_cwnd(sk, hctx->ccid2hctx_cwnd + 1);
424 hctx->ccid2hctx_ssacks = 0;
425 *maxincr = *maxincr - 1;
428 /* increased cwnd enough for this single ack */
430 hctx->ccid2hctx_ssacks = 0;
434 hctx->ccid2hctx_ssacks = 0;
435 hctx->ccid2hctx_acks++;
437 if (hctx->ccid2hctx_acks >= hctx->ccid2hctx_cwnd) {
438 ccid2_change_cwnd(sk, hctx->ccid2hctx_cwnd + 1);
439 hctx->ccid2hctx_acks = 0;
444 if (hctx->ccid2hctx_srtt == -1 ||
445 (jiffies - hctx->ccid2hctx_lastrtt) >= hctx->ccid2hctx_srtt) {
446 unsigned long r = jiffies - seqp->ccid2s_sent;
449 /* first measurement */
450 if (hctx->ccid2hctx_srtt == -1) {
451 ccid2_pr_debug("R: %lu Time=%lu seq=%llu\n",
452 r, jiffies, seqp->ccid2s_seq);
453 hctx->ccid2hctx_srtt = r;
454 hctx->ccid2hctx_rttvar = r >> 1;
458 long tmp = hctx->ccid2hctx_srtt - r;
463 hctx->ccid2hctx_rttvar *= 3;
464 hctx->ccid2hctx_rttvar >>= 2;
465 hctx->ccid2hctx_rttvar += tmp;
468 hctx->ccid2hctx_srtt *= 7;
469 hctx->ccid2hctx_srtt >>= 3;
471 hctx->ccid2hctx_srtt += tmp;
473 s = hctx->ccid2hctx_rttvar << 2;
474 /* clock granularity is 1 when based on jiffies */
477 hctx->ccid2hctx_rto = hctx->ccid2hctx_srtt + s;
479 /* must be at least a second */
480 s = hctx->ccid2hctx_rto / HZ;
481 /* DCCP doesn't require this [but I like it cuz my code sux] */
484 hctx->ccid2hctx_rto = HZ;
488 hctx->ccid2hctx_rto = HZ * 60;
490 hctx->ccid2hctx_lastrtt = jiffies;
492 ccid2_pr_debug("srtt: %ld rttvar: %ld rto: %ld (HZ=%d) R=%lu\n",
493 hctx->ccid2hctx_srtt, hctx->ccid2hctx_rttvar,
494 hctx->ccid2hctx_rto, HZ, r);
495 hctx->ccid2hctx_sent = 0;
498 /* we got a new ack, so re-start RTO timer */
499 ccid2_hc_tx_kill_rto_timer(hctx);
500 ccid2_start_rto_timer(sk);
503 static void ccid2_hc_tx_dec_pipe(struct ccid2_hc_tx_sock *hctx)
505 hctx->ccid2hctx_pipe--;
506 BUG_ON(hctx->ccid2hctx_pipe < 0);
508 if (hctx->ccid2hctx_pipe == 0)
509 ccid2_hc_tx_kill_rto_timer(hctx);
512 static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
514 struct dccp_sock *dp = dccp_sk(sk);
515 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
517 struct ccid2_seq *seqp;
518 unsigned char *vector;
519 unsigned char veclen;
523 unsigned int maxincr = 0;
525 ccid2_hc_tx_check_sanity(hctx);
526 /* check reverse path congestion */
527 seqno = DCCP_SKB_CB(skb)->dccpd_seq;
529 /* XXX this whole "algorithm" is broken. Need to fix it to keep track
530 * of the seqnos of the dupacks so that rpseq and rpdupack are correct
533 /* need to bootstrap */
534 if (hctx->ccid2hctx_rpdupack == -1) {
535 hctx->ccid2hctx_rpdupack = 0;
536 hctx->ccid2hctx_rpseq = seqno;
539 /* check if packet is consecutive */
540 if ((hctx->ccid2hctx_rpseq + 1) == seqno) {
541 hctx->ccid2hctx_rpseq++;
543 /* it's a later packet */
544 else if (after48(seqno, hctx->ccid2hctx_rpseq)) {
545 hctx->ccid2hctx_rpdupack++;
547 /* check if we got enough dupacks */
548 if (hctx->ccid2hctx_rpdupack >=
549 hctx->ccid2hctx_numdupack) {
551 hctx->ccid2hctx_rpdupack = -1; /* XXX lame */
552 hctx->ccid2hctx_rpseq = 0;
554 ccid2_change_l_ack_ratio(sk, dp->dccps_l_ack_ratio << 1);
559 /* check forward path congestion */
560 /* still didn't send out new data packets */
561 if (hctx->ccid2hctx_seqh == hctx->ccid2hctx_seqt)
564 switch (DCCP_SKB_CB(skb)->dccpd_type) {
566 case DCCP_PKT_DATAACK:
573 ackno = DCCP_SKB_CB(skb)->dccpd_ack_seq;
574 seqp = hctx->ccid2hctx_seqh->ccid2s_prev;
576 /* If in slow-start, cwnd can increase at most Ack Ratio / 2 packets for
577 * this single ack. I round up.
580 maxincr = dp->dccps_l_ack_ratio >> 1;
583 /* go through all ack vectors */
584 while ((offset = ccid2_ackvector(sk, skb, offset,
585 &vector, &veclen)) != -1) {
586 /* go through this ack vector */
588 const u8 rl = *vector & DCCP_ACKVEC_LEN_MASK;
591 dccp_set_seqno(&ackno_end_rl, ackno - rl);
592 ccid2_pr_debug("ackvec start:%llu end:%llu\n", ackno,
594 /* if the seqno we are analyzing is larger than the
595 * current ackno, then move towards the tail of our
598 while (after48(seqp->ccid2s_seq, ackno)) {
599 if (seqp == hctx->ccid2hctx_seqt) {
603 seqp = seqp->ccid2s_prev;
608 /* check all seqnos in the range of the vector
611 while (between48(seqp->ccid2s_seq,ackno_end_rl,ackno)) {
612 const u8 state = (*vector &
613 DCCP_ACKVEC_STATE_MASK) >> 6;
615 /* new packet received or marked */
616 if (state != DCCP_ACKVEC_STATE_NOT_RECEIVED &&
617 !seqp->ccid2s_acked) {
619 DCCP_ACKVEC_STATE_ECN_MARKED) {
623 ccid2_new_ack(sk, seqp,
627 seqp->ccid2s_acked = 1;
628 ccid2_pr_debug("Got ack for %llu\n",
630 ccid2_hc_tx_dec_pipe(hctx);
632 if (seqp == hctx->ccid2hctx_seqt) {
636 seqp = seqp->ccid2s_next;
642 dccp_set_seqno(&ackno, ackno_end_rl - 1);
649 /* The state about what is acked should be correct now
650 * Check for NUMDUPACK
652 seqp = hctx->ccid2hctx_seqh->ccid2s_prev;
655 if (seqp->ccid2s_acked) {
657 if (done == hctx->ccid2hctx_numdupack) {
661 if (seqp == hctx->ccid2hctx_seqt) {
664 seqp = seqp->ccid2s_prev;
667 /* If there are at least 3 acknowledgements, anything unacknowledged
668 * below the last sequence number is considered lost
670 if (done == hctx->ccid2hctx_numdupack) {
671 struct ccid2_seq *last_acked = seqp;
673 /* check for lost packets */
675 if (!seqp->ccid2s_acked) {
677 ccid2_hc_tx_dec_pipe(hctx);
679 if (seqp == hctx->ccid2hctx_seqt)
681 seqp = seqp->ccid2s_prev;
684 hctx->ccid2hctx_seqt = last_acked;
687 /* trim acked packets in tail */
688 while (hctx->ccid2hctx_seqt != hctx->ccid2hctx_seqh) {
689 if (!hctx->ccid2hctx_seqt->ccid2s_acked)
692 hctx->ccid2hctx_seqt = hctx->ccid2hctx_seqt->ccid2s_next;
696 /* XXX do bit shifts guarantee a 0 as the new bit? */
697 ccid2_change_cwnd(sk, hctx->ccid2hctx_cwnd >> 1);
698 hctx->ccid2hctx_ssthresh = hctx->ccid2hctx_cwnd;
699 if (hctx->ccid2hctx_ssthresh < 2)
700 hctx->ccid2hctx_ssthresh = 2;
703 ccid2_hc_tx_check_sanity(hctx);
706 static int ccid2_hc_tx_init(struct sock *sk)
708 struct dccp_sock *dp = dccp_sk(sk);
709 struct ccid2_hc_tx_sock *hctx;
710 int seqcount = ccid2_seq_len;
713 dp->dccps_hc_tx_ccid_private = kzalloc(sizeof(*hctx), gfp_any());
714 if (dp->dccps_hc_tx_ccid_private == NULL)
717 hctx = ccid2_hc_tx_sk(sk);
719 /* XXX init variables with proper values */
720 hctx->ccid2hctx_cwnd = 1;
721 hctx->ccid2hctx_ssthresh = 10;
722 hctx->ccid2hctx_numdupack = 3;
724 /* XXX init ~ to window size... */
725 hctx->ccid2hctx_seqbuf = kmalloc(sizeof(*hctx->ccid2hctx_seqbuf) *
726 seqcount, gfp_any());
727 if (hctx->ccid2hctx_seqbuf == NULL) {
728 kfree(dp->dccps_hc_tx_ccid_private);
729 dp->dccps_hc_tx_ccid_private = NULL;
732 for (i = 0; i < (seqcount - 1); i++) {
733 hctx->ccid2hctx_seqbuf[i].ccid2s_next =
734 &hctx->ccid2hctx_seqbuf[i + 1];
735 hctx->ccid2hctx_seqbuf[i + 1].ccid2s_prev =
736 &hctx->ccid2hctx_seqbuf[i];
738 hctx->ccid2hctx_seqbuf[seqcount - 1].ccid2s_next =
739 hctx->ccid2hctx_seqbuf;
740 hctx->ccid2hctx_seqbuf->ccid2s_prev =
741 &hctx->ccid2hctx_seqbuf[seqcount - 1];
743 hctx->ccid2hctx_seqh = hctx->ccid2hctx_seqbuf;
744 hctx->ccid2hctx_seqt = hctx->ccid2hctx_seqh;
745 hctx->ccid2hctx_sent = 0;
746 hctx->ccid2hctx_rto = 3 * HZ;
747 hctx->ccid2hctx_srtt = -1;
748 hctx->ccid2hctx_rttvar = -1;
749 hctx->ccid2hctx_lastrtt = 0;
750 hctx->ccid2hctx_rpdupack = -1;
752 hctx->ccid2hctx_rtotimer.function = &ccid2_hc_tx_rto_expire;
753 hctx->ccid2hctx_rtotimer.data = (unsigned long)sk;
754 init_timer(&hctx->ccid2hctx_rtotimer);
756 ccid2_hc_tx_check_sanity(hctx);
760 static void ccid2_hc_tx_exit(struct sock *sk)
762 struct dccp_sock *dp = dccp_sk(sk);
763 struct ccid2_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private;
765 ccid2_hc_tx_kill_rto_timer(hctx);
767 kfree(hctx->ccid2hctx_seqbuf);
769 kfree(dp->dccps_hc_tx_ccid_private);
770 dp->dccps_hc_tx_ccid_private = NULL;
773 static void ccid2_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
775 const struct dccp_sock *dp = dccp_sk(sk);
776 struct ccid2_hc_rx_sock *hcrx = ccid2_hc_rx_sk(sk);
778 switch (DCCP_SKB_CB(skb)->dccpd_type) {
780 case DCCP_PKT_DATAACK:
781 hcrx->ccid2hcrx_data++;
782 if (hcrx->ccid2hcrx_data >= dp->dccps_r_ack_ratio) {
784 hcrx->ccid2hcrx_data = 0;
790 static int ccid2_hc_rx_init(struct sock *sk)
792 struct dccp_sock *dp = dccp_sk(sk);
793 dp->dccps_hc_rx_ccid_private = kzalloc(sizeof(struct ccid2_hc_rx_sock),
795 return dp->dccps_hc_rx_ccid_private == NULL ? -ENOMEM : 0;
798 static void ccid2_hc_rx_exit(struct sock *sk)
800 struct dccp_sock *dp = dccp_sk(sk);
802 kfree(dp->dccps_hc_rx_ccid_private);
803 dp->dccps_hc_rx_ccid_private = NULL;
806 static struct ccid ccid2 = {
808 .ccid_name = "ccid2",
809 .ccid_owner = THIS_MODULE,
810 .ccid_hc_tx_init = ccid2_hc_tx_init,
811 .ccid_hc_tx_exit = ccid2_hc_tx_exit,
812 .ccid_hc_tx_send_packet = ccid2_hc_tx_send_packet,
813 .ccid_hc_tx_packet_sent = ccid2_hc_tx_packet_sent,
814 .ccid_hc_tx_packet_recv = ccid2_hc_tx_packet_recv,
815 .ccid_hc_rx_init = ccid2_hc_rx_init,
816 .ccid_hc_rx_exit = ccid2_hc_rx_exit,
817 .ccid_hc_rx_packet_recv = ccid2_hc_rx_packet_recv,
820 module_param(ccid2_debug, int, 0444);
821 MODULE_PARM_DESC(ccid2_debug, "Enable debug messages");
823 static __init int ccid2_module_init(void)
825 return ccid_register(&ccid2);
827 module_init(ccid2_module_init);
829 static __exit void ccid2_module_exit(void)
831 ccid_unregister(&ccid2);
833 module_exit(ccid2_module_exit);
835 MODULE_AUTHOR("Andrea Bittau <a.bittau@cs.ucl.ac.uk>");
836 MODULE_DESCRIPTION("DCCP TCP CCID2 CCID");
837 MODULE_LICENSE("GPL");
838 MODULE_ALIAS("net-dccp-ccid-2");