blob: 02d126d9a7110308c577726a8be4944d6f69db14 [file] [log] [blame]
Andrea Bittau2a91aa32006-03-20 17:41:47 -08001/*
2 * net/dccp/ccids/ccid2.c
3 *
4 * Copyright (c) 2005, 2006 Andrea Bittau <a.bittau@cs.ucl.ac.uk>
5 *
6 * Changes to meet Linux coding standards, and DCCP infrastructure fixes.
7 *
8 * Copyright (c) 2006 Arnaldo Carvalho de Melo <acme@conectiva.com.br>
9 *
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.
14 *
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.
19 *
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.
23 */
24
25/*
Gerrit Renker0e64e942006-10-24 16:17:51 -070026 * This implementation should follow RFC 4341
Andrea Bittau2a91aa32006-03-20 17:41:47 -080027 */
28
Andrea Bittau2a91aa32006-03-20 17:41:47 -080029#include "../ccid.h"
30#include "../dccp.h"
31#include "ccid2.h"
32
Gerrit Renker84116712006-11-20 18:26:03 -020033
34#ifdef CONFIG_IP_DCCP_CCID2_DEBUG
Andrea Bittau2a91aa32006-03-20 17:41:47 -080035static int ccid2_debug;
Gerrit Renker84116712006-11-20 18:26:03 -020036#define ccid2_pr_debug(format, a...) DCCP_PR_DEBUG(ccid2_debug, format, ##a)
Andrea Bittau2a91aa32006-03-20 17:41:47 -080037
Andrea Bittau2a91aa32006-03-20 17:41:47 -080038static void ccid2_hc_tx_check_sanity(const struct ccid2_hc_tx_sock *hctx)
39{
40 int len = 0;
Andrea Bittau2a91aa32006-03-20 17:41:47 -080041 int pipe = 0;
Arnaldo Carvalho de Meloc0c736d2006-03-20 22:05:37 -080042 struct ccid2_seq *seqp = hctx->ccid2hctx_seqh;
Andrea Bittau2a91aa32006-03-20 17:41:47 -080043
44 /* there is data in the chain */
45 if (seqp != hctx->ccid2hctx_seqt) {
46 seqp = seqp->ccid2s_prev;
47 len++;
48 if (!seqp->ccid2s_acked)
49 pipe++;
50
51 while (seqp != hctx->ccid2hctx_seqt) {
Arnaldo Carvalho de Meloc0c736d2006-03-20 22:05:37 -080052 struct ccid2_seq *prev = seqp->ccid2s_prev;
Andrea Bittau2a91aa32006-03-20 17:41:47 -080053
Andrea Bittau2a91aa32006-03-20 17:41:47 -080054 len++;
55 if (!prev->ccid2s_acked)
56 pipe++;
57
58 /* packets are sent sequentially */
Gerrit Renker5e285992007-10-04 14:43:09 -070059 BUG_ON(dccp_delta_seqno(seqp->ccid2s_seq,
60 prev->ccid2s_seq ) >= 0);
Andrea Bittau29651cd2006-09-19 13:06:46 -070061 BUG_ON(time_before(seqp->ccid2s_sent,
62 prev->ccid2s_sent));
Andrea Bittau2a91aa32006-03-20 17:41:47 -080063
64 seqp = prev;
65 }
66 }
67
68 BUG_ON(pipe != hctx->ccid2hctx_pipe);
69 ccid2_pr_debug("len of chain=%d\n", len);
70
71 do {
72 seqp = seqp->ccid2s_prev;
73 len++;
Arnaldo Carvalho de Meloc0c736d2006-03-20 22:05:37 -080074 } while (seqp != hctx->ccid2hctx_seqh);
Andrea Bittau2a91aa32006-03-20 17:41:47 -080075
Andrea Bittau2a91aa32006-03-20 17:41:47 -080076 ccid2_pr_debug("total len=%d\n", len);
Andrea Bittau07978aa2006-09-19 13:13:37 -070077 BUG_ON(len != hctx->ccid2hctx_seqbufc * CCID2_SEQBUF_LEN);
Andrea Bittau2a91aa32006-03-20 17:41:47 -080078}
79#else
Gerrit Renker84116712006-11-20 18:26:03 -020080#define ccid2_pr_debug(format, a...)
81#define ccid2_hc_tx_check_sanity(hctx)
Andrea Bittau2a91aa32006-03-20 17:41:47 -080082#endif
83
Gerrit Renkercd1f7d32007-10-04 14:41:00 -070084static int ccid2_hc_tx_alloc_seq(struct ccid2_hc_tx_sock *hctx)
Andrea Bittau07978aa2006-09-19 13:13:37 -070085{
86 struct ccid2_seq *seqp;
87 int i;
88
89 /* check if we have space to preserve the pointer to the buffer */
90 if (hctx->ccid2hctx_seqbufc >= (sizeof(hctx->ccid2hctx_seqbuf) /
91 sizeof(struct ccid2_seq*)))
92 return -ENOMEM;
93
94 /* allocate buffer and initialize linked list */
Gerrit Renkercd1f7d32007-10-04 14:41:00 -070095 seqp = kmalloc(CCID2_SEQBUF_LEN * sizeof(struct ccid2_seq), gfp_any());
Andrea Bittau07978aa2006-09-19 13:13:37 -070096 if (seqp == NULL)
97 return -ENOMEM;
98
Gerrit Renkercd1f7d32007-10-04 14:41:00 -070099 for (i = 0; i < (CCID2_SEQBUF_LEN - 1); i++) {
Andrea Bittau07978aa2006-09-19 13:13:37 -0700100 seqp[i].ccid2s_next = &seqp[i + 1];
101 seqp[i + 1].ccid2s_prev = &seqp[i];
102 }
Gerrit Renkercd1f7d32007-10-04 14:41:00 -0700103 seqp[CCID2_SEQBUF_LEN - 1].ccid2s_next = seqp;
104 seqp->ccid2s_prev = &seqp[CCID2_SEQBUF_LEN - 1];
Andrea Bittau07978aa2006-09-19 13:13:37 -0700105
106 /* This is the first allocation. Initiate the head and tail. */
107 if (hctx->ccid2hctx_seqbufc == 0)
108 hctx->ccid2hctx_seqh = hctx->ccid2hctx_seqt = seqp;
109 else {
110 /* link the existing list with the one we just created */
111 hctx->ccid2hctx_seqh->ccid2s_next = seqp;
112 seqp->ccid2s_prev = hctx->ccid2hctx_seqh;
113
Gerrit Renkercd1f7d32007-10-04 14:41:00 -0700114 hctx->ccid2hctx_seqt->ccid2s_prev = &seqp[CCID2_SEQBUF_LEN - 1];
115 seqp[CCID2_SEQBUF_LEN - 1].ccid2s_next = hctx->ccid2hctx_seqt;
Andrea Bittau07978aa2006-09-19 13:13:37 -0700116 }
117
118 /* store the original pointer to the buffer so we can free it */
119 hctx->ccid2hctx_seqbuf[hctx->ccid2hctx_seqbufc] = seqp;
120 hctx->ccid2hctx_seqbufc++;
121
122 return 0;
123}
124
Gerrit Renker6b57c932006-11-28 19:55:06 -0200125static int ccid2_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb)
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800126{
Gerrit Renker6c583242007-10-04 14:42:19 -0700127 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800128
Gerrit Renker83399362007-11-24 22:09:35 -0200129 if (hctx->ccid2hctx_pipe < hctx->ccid2hctx_cwnd)
130 return 0;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800131
Andrea Bittau446dec32006-09-19 13:10:11 -0700132 return 1; /* XXX CCID should dequeue when ready instead of polling */
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800133}
134
Gerrit Renkerdf054e12007-11-24 21:32:53 -0200135static void ccid2_change_l_ack_ratio(struct sock *sk, u32 val)
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800136{
137 struct dccp_sock *dp = dccp_sk(sk);
Gerrit Renkerd50ad162007-11-24 21:40:24 -0200138 u32 max_ratio = DIV_ROUND_UP(ccid2_hc_tx_sk(sk)->ccid2hctx_cwnd, 2);
139
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800140 /*
Gerrit Renkerd50ad162007-11-24 21:40:24 -0200141 * Ensure that Ack Ratio does not exceed ceil(cwnd/2), which is (2) from
142 * RFC 4341, 6.1.2. We ignore the statement that Ack Ratio 2 is always
143 * acceptable since this causes starvation/deadlock whenever cwnd < 2.
144 * The same problem arises when Ack Ratio is 0 (ie. Ack Ratio disabled).
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800145 */
Gerrit Renkerd50ad162007-11-24 21:40:24 -0200146 if (val == 0 || val > max_ratio) {
147 DCCP_WARN("Limiting Ack Ratio (%u) to %u\n", val, max_ratio);
148 val = max_ratio;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800149 }
Gerrit Renkerdf054e12007-11-24 21:32:53 -0200150 if (val > 0xFFFF) /* RFC 4340, 11.3 */
151 val = 0xFFFF;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800152
Gerrit Renkerd50ad162007-11-24 21:40:24 -0200153 if (val == dp->dccps_l_ack_ratio)
154 return;
155
Gerrit Renkerdf054e12007-11-24 21:32:53 -0200156 ccid2_pr_debug("changing local ack ratio to %u\n", val);
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800157 dp->dccps_l_ack_ratio = val;
158}
159
Andrea Bittau593f16a2006-09-19 13:15:33 -0700160static void ccid2_change_srtt(struct ccid2_hc_tx_sock *hctx, long val)
161{
162 ccid2_pr_debug("change SRTT to %ld\n", val);
163 hctx->ccid2hctx_srtt = val;
164}
165
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800166static void ccid2_start_rto_timer(struct sock *sk);
167
168static void ccid2_hc_tx_rto_expire(unsigned long data)
169{
170 struct sock *sk = (struct sock *)data;
171 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
172 long s;
173
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800174 bh_lock_sock(sk);
175 if (sock_owned_by_user(sk)) {
176 sk_reset_timer(sk, &hctx->ccid2hctx_rtotimer,
177 jiffies + HZ / 5);
178 goto out;
179 }
180
181 ccid2_pr_debug("RTO_EXPIRE\n");
182
183 ccid2_hc_tx_check_sanity(hctx);
184
185 /* back-off timer */
186 hctx->ccid2hctx_rto <<= 1;
187
188 s = hctx->ccid2hctx_rto / HZ;
189 if (s > 60)
190 hctx->ccid2hctx_rto = 60 * HZ;
191
192 ccid2_start_rto_timer(sk);
193
194 /* adjust pipe, cwnd etc */
Gerrit Renker3deeadd2007-11-24 22:05:51 -0200195 hctx->ccid2hctx_ssthresh = hctx->ccid2hctx_cwnd / 2;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800196 if (hctx->ccid2hctx_ssthresh < 2)
197 hctx->ccid2hctx_ssthresh = 2;
Gerrit Renker3deeadd2007-11-24 22:05:51 -0200198 hctx->ccid2hctx_cwnd = 1;
Gerrit Renker95b21d72007-11-24 22:06:52 -0200199 hctx->ccid2hctx_pipe = 0;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800200
201 /* clear state about stuff we sent */
Gerrit Renkera3020022007-11-24 22:10:29 -0200202 hctx->ccid2hctx_seqt = hctx->ccid2hctx_seqh;
203 hctx->ccid2hctx_packets_acked = 0;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800204
205 /* clear ack ratio state. */
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800206 hctx->ccid2hctx_rpseq = 0;
207 hctx->ccid2hctx_rpdupack = -1;
208 ccid2_change_l_ack_ratio(sk, 1);
209 ccid2_hc_tx_check_sanity(hctx);
210out:
211 bh_unlock_sock(sk);
Andrea Bittau77ff72d2006-03-20 17:57:52 -0800212 sock_put(sk);
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800213}
214
215static void ccid2_start_rto_timer(struct sock *sk)
216{
217 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
218
219 ccid2_pr_debug("setting RTO timeout=%ld\n", hctx->ccid2hctx_rto);
220
221 BUG_ON(timer_pending(&hctx->ccid2hctx_rtotimer));
222 sk_reset_timer(sk, &hctx->ccid2hctx_rtotimer,
223 jiffies + hctx->ccid2hctx_rto);
224}
225
Gerrit Renker6b57c932006-11-28 19:55:06 -0200226static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, unsigned int len)
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800227{
228 struct dccp_sock *dp = dccp_sk(sk);
229 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
Andrea Bittau07978aa2006-09-19 13:13:37 -0700230 struct ccid2_seq *next;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800231 u64 seq;
232
Gerrit Renker95b21d72007-11-24 22:06:52 -0200233 hctx->ccid2hctx_pipe++;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800234
235 /* There is an issue. What if another packet is sent between
236 * packet_send() and packet_sent(). Then the sequence number would be
237 * wrong.
238 * -sorbo.
239 */
240 seq = dp->dccps_gss;
241
242 hctx->ccid2hctx_seqh->ccid2s_seq = seq;
243 hctx->ccid2hctx_seqh->ccid2s_acked = 0;
244 hctx->ccid2hctx_seqh->ccid2s_sent = jiffies;
Andrea Bittau07978aa2006-09-19 13:13:37 -0700245
246 next = hctx->ccid2hctx_seqh->ccid2s_next;
247 /* check if we need to alloc more space */
248 if (next == hctx->ccid2hctx_seqt) {
Gerrit Renker7d9e8932007-10-04 14:41:26 -0700249 if (ccid2_hc_tx_alloc_seq(hctx)) {
250 DCCP_CRIT("packet history - out of memory!");
251 /* FIXME: find a more graceful way to bail out */
252 return;
253 }
Andrea Bittau07978aa2006-09-19 13:13:37 -0700254 next = hctx->ccid2hctx_seqh->ccid2s_next;
255 BUG_ON(next == hctx->ccid2hctx_seqt);
256 }
257 hctx->ccid2hctx_seqh = next;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800258
259 ccid2_pr_debug("cwnd=%d pipe=%d\n", hctx->ccid2hctx_cwnd,
260 hctx->ccid2hctx_pipe);
261
Gerrit Renker900bfed2007-11-24 21:58:33 -0200262 /*
263 * FIXME: The code below is broken and the variables have been removed
264 * from the socket struct. The `ackloss' variable was always set to 0,
265 * and with arsent there are several problems:
266 * (i) it doesn't just count the number of Acks, but all sent packets;
267 * (ii) it is expressed in # of packets, not # of windows, so the
268 * comparison below uses the wrong formula: Appendix A of RFC 4341
269 * comes up with the number K = cwnd / (R^2 - R) of consecutive windows
270 * of data with no lost or marked Ack packets. If arsent were the # of
271 * consecutive Acks received without loss, then Ack Ratio needs to be
272 * decreased by 1 when
273 * arsent >= K * cwnd / R = cwnd^2 / (R^3 - R^2)
274 * where cwnd / R is the number of Acks received per window of data
275 * (cf. RFC 4341, App. A). The problems are that
276 * - arsent counts other packets as well;
277 * - the comparison uses a formula different from RFC 4341;
278 * - computing a cubic/quadratic equation each time is too complicated.
279 * Hence a different algorithm is needed.
280 */
281#if 0
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800282 /* Ack Ratio. Need to maintain a concept of how many windows we sent */
283 hctx->ccid2hctx_arsent++;
284 /* We had an ack loss in this window... */
285 if (hctx->ccid2hctx_ackloss) {
286 if (hctx->ccid2hctx_arsent >= hctx->ccid2hctx_cwnd) {
Arnaldo Carvalho de Meloc0c736d2006-03-20 22:05:37 -0800287 hctx->ccid2hctx_arsent = 0;
288 hctx->ccid2hctx_ackloss = 0;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800289 }
Arnaldo Carvalho de Meloc0c736d2006-03-20 22:05:37 -0800290 } else {
291 /* No acks lost up to now... */
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800292 /* decrease ack ratio if enough packets were sent */
293 if (dp->dccps_l_ack_ratio > 1) {
294 /* XXX don't calculate denominator each time */
Arnaldo Carvalho de Meloc0c736d2006-03-20 22:05:37 -0800295 int denom = dp->dccps_l_ack_ratio * dp->dccps_l_ack_ratio -
296 dp->dccps_l_ack_ratio;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800297
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800298 denom = hctx->ccid2hctx_cwnd * hctx->ccid2hctx_cwnd / denom;
299
300 if (hctx->ccid2hctx_arsent >= denom) {
301 ccid2_change_l_ack_ratio(sk, dp->dccps_l_ack_ratio - 1);
302 hctx->ccid2hctx_arsent = 0;
303 }
Arnaldo Carvalho de Meloc0c736d2006-03-20 22:05:37 -0800304 } else {
305 /* we can't increase ack ratio further [1] */
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800306 hctx->ccid2hctx_arsent = 0; /* or maybe set it to cwnd*/
307 }
308 }
Gerrit Renker900bfed2007-11-24 21:58:33 -0200309#endif
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800310
311 /* setup RTO timer */
Arnaldo Carvalho de Meloc0c736d2006-03-20 22:05:37 -0800312 if (!timer_pending(&hctx->ccid2hctx_rtotimer))
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800313 ccid2_start_rto_timer(sk);
Arnaldo Carvalho de Meloc0c736d2006-03-20 22:05:37 -0800314
Andrea Bittau8d424f62006-09-19 13:12:44 -0700315#ifdef CONFIG_IP_DCCP_CCID2_DEBUG
Randy Dunlap234af482006-10-29 16:03:30 -0800316 ccid2_pr_debug("Sent: seq=%llu\n", (unsigned long long)seq);
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800317 do {
318 struct ccid2_seq *seqp = hctx->ccid2hctx_seqt;
319
320 while (seqp != hctx->ccid2hctx_seqh) {
321 ccid2_pr_debug("out seq=%llu acked=%d time=%lu\n",
Arnaldo Carvalho de Melo8109b022006-12-10 16:01:18 -0200322 (unsigned long long)seqp->ccid2s_seq,
Randy Dunlap234af482006-10-29 16:03:30 -0800323 seqp->ccid2s_acked, seqp->ccid2s_sent);
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800324 seqp = seqp->ccid2s_next;
325 }
Arnaldo Carvalho de Meloc0c736d2006-03-20 22:05:37 -0800326 } while (0);
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800327 ccid2_pr_debug("=========\n");
328 ccid2_hc_tx_check_sanity(hctx);
329#endif
330}
331
332/* XXX Lame code duplication!
333 * returns -1 if none was found.
334 * else returns the next offset to use in the function call.
335 */
336static int ccid2_ackvector(struct sock *sk, struct sk_buff *skb, int offset,
337 unsigned char **vec, unsigned char *veclen)
338{
YOSHIFUJI Hideakic9eaf172007-02-09 23:24:38 +0900339 const struct dccp_hdr *dh = dccp_hdr(skb);
340 unsigned char *options = (unsigned char *)dh + dccp_hdr_len(skb);
341 unsigned char *opt_ptr;
342 const unsigned char *opt_end = (unsigned char *)dh +
343 (dh->dccph_doff * 4);
344 unsigned char opt, len;
345 unsigned char *value;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800346
347 BUG_ON(offset < 0);
348 options += offset;
349 opt_ptr = options;
350 if (opt_ptr >= opt_end)
351 return -1;
352
353 while (opt_ptr != opt_end) {
YOSHIFUJI Hideakic9eaf172007-02-09 23:24:38 +0900354 opt = *opt_ptr++;
355 len = 0;
356 value = NULL;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800357
YOSHIFUJI Hideakic9eaf172007-02-09 23:24:38 +0900358 /* Check if this isn't a single byte option */
359 if (opt > DCCPO_MAX_RESERVED) {
360 if (opt_ptr == opt_end)
361 goto out_invalid_option;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800362
YOSHIFUJI Hideakic9eaf172007-02-09 23:24:38 +0900363 len = *opt_ptr++;
364 if (len < 3)
365 goto out_invalid_option;
366 /*
367 * Remove the type and len fields, leaving
368 * just the value size
369 */
370 len -= 2;
371 value = opt_ptr;
372 opt_ptr += len;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800373
YOSHIFUJI Hideakic9eaf172007-02-09 23:24:38 +0900374 if (opt_ptr > opt_end)
375 goto out_invalid_option;
376 }
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800377
378 switch (opt) {
379 case DCCPO_ACK_VECTOR_0:
380 case DCCPO_ACK_VECTOR_1:
381 *vec = value;
382 *veclen = len;
383 return offset + (opt_ptr - options);
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800384 }
385 }
386
387 return -1;
388
389out_invalid_option:
Gerrit Renker59348b12006-11-20 18:39:23 -0200390 DCCP_BUG("Invalid option - this should not happen (previous parsing)!");
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800391 return -1;
392}
393
Andrea Bittau77ff72d2006-03-20 17:57:52 -0800394static void ccid2_hc_tx_kill_rto_timer(struct sock *sk)
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800395{
Andrea Bittau77ff72d2006-03-20 17:57:52 -0800396 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
397
398 sk_stop_timer(sk, &hctx->ccid2hctx_rtotimer);
399 ccid2_pr_debug("deleted RTO timer\n");
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800400}
401
402static inline void ccid2_new_ack(struct sock *sk,
YOSHIFUJI Hideakic9eaf172007-02-09 23:24:38 +0900403 struct ccid2_seq *seqp,
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800404 unsigned int *maxincr)
405{
406 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
407
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800408 if (hctx->ccid2hctx_cwnd < hctx->ccid2hctx_ssthresh) {
Gerrit Renkera3020022007-11-24 22:10:29 -0200409 if (*maxincr > 0 && ++hctx->ccid2hctx_packets_acked == 2) {
410 hctx->ccid2hctx_cwnd += 1;
411 *maxincr -= 1;
412 hctx->ccid2hctx_packets_acked = 0;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800413 }
Gerrit Renkera3020022007-11-24 22:10:29 -0200414 } else if (++hctx->ccid2hctx_packets_acked >= hctx->ccid2hctx_cwnd) {
415 hctx->ccid2hctx_cwnd += 1;
416 hctx->ccid2hctx_packets_acked = 0;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800417 }
418
419 /* update RTO */
420 if (hctx->ccid2hctx_srtt == -1 ||
Andrea Bittau29651cd2006-09-19 13:06:46 -0700421 time_after(jiffies, hctx->ccid2hctx_lastrtt + hctx->ccid2hctx_srtt)) {
422 unsigned long r = (long)jiffies - (long)seqp->ccid2s_sent;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800423 int s;
424
425 /* first measurement */
426 if (hctx->ccid2hctx_srtt == -1) {
427 ccid2_pr_debug("R: %lu Time=%lu seq=%llu\n",
Arnaldo Carvalho de Melo8109b022006-12-10 16:01:18 -0200428 r, jiffies,
Randy Dunlap234af482006-10-29 16:03:30 -0800429 (unsigned long long)seqp->ccid2s_seq);
Andrea Bittau593f16a2006-09-19 13:15:33 -0700430 ccid2_change_srtt(hctx, r);
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800431 hctx->ccid2hctx_rttvar = r >> 1;
Arnaldo Carvalho de Meloc0c736d2006-03-20 22:05:37 -0800432 } else {
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800433 /* RTTVAR */
434 long tmp = hctx->ccid2hctx_srtt - r;
Andrea Bittau593f16a2006-09-19 13:15:33 -0700435 long srtt;
436
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800437 if (tmp < 0)
438 tmp *= -1;
439
440 tmp >>= 2;
441 hctx->ccid2hctx_rttvar *= 3;
442 hctx->ccid2hctx_rttvar >>= 2;
443 hctx->ccid2hctx_rttvar += tmp;
444
445 /* SRTT */
Andrea Bittau593f16a2006-09-19 13:15:33 -0700446 srtt = hctx->ccid2hctx_srtt;
447 srtt *= 7;
448 srtt >>= 3;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800449 tmp = r >> 3;
Andrea Bittau593f16a2006-09-19 13:15:33 -0700450 srtt += tmp;
451 ccid2_change_srtt(hctx, srtt);
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800452 }
453 s = hctx->ccid2hctx_rttvar << 2;
454 /* clock granularity is 1 when based on jiffies */
455 if (!s)
456 s = 1;
457 hctx->ccid2hctx_rto = hctx->ccid2hctx_srtt + s;
458
459 /* must be at least a second */
460 s = hctx->ccid2hctx_rto / HZ;
461 /* DCCP doesn't require this [but I like it cuz my code sux] */
462#if 1
463 if (s < 1)
464 hctx->ccid2hctx_rto = HZ;
465#endif
466 /* max 60 seconds */
467 if (s > 60)
468 hctx->ccid2hctx_rto = HZ * 60;
469
470 hctx->ccid2hctx_lastrtt = jiffies;
471
472 ccid2_pr_debug("srtt: %ld rttvar: %ld rto: %ld (HZ=%d) R=%lu\n",
Arnaldo Carvalho de Melo8109b022006-12-10 16:01:18 -0200473 hctx->ccid2hctx_srtt, hctx->ccid2hctx_rttvar,
474 hctx->ccid2hctx_rto, HZ, r);
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800475 }
476
477 /* we got a new ack, so re-start RTO timer */
Andrea Bittau77ff72d2006-03-20 17:57:52 -0800478 ccid2_hc_tx_kill_rto_timer(sk);
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800479 ccid2_start_rto_timer(sk);
480}
481
Andrea Bittau77ff72d2006-03-20 17:57:52 -0800482static void ccid2_hc_tx_dec_pipe(struct sock *sk)
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800483{
Andrea Bittau77ff72d2006-03-20 17:57:52 -0800484 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
485
Gerrit Renker95b21d72007-11-24 22:06:52 -0200486 if (hctx->ccid2hctx_pipe == 0)
487 DCCP_BUG("pipe == 0");
488 else
489 hctx->ccid2hctx_pipe--;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800490
491 if (hctx->ccid2hctx_pipe == 0)
Andrea Bittau77ff72d2006-03-20 17:57:52 -0800492 ccid2_hc_tx_kill_rto_timer(sk);
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800493}
494
Gerrit Renkerd50ad162007-11-24 21:40:24 -0200495static void ccid2_congestion_event(struct sock *sk, struct ccid2_seq *seqp)
Andrea Bittau374bcf32006-09-19 13:14:43 -0700496{
Gerrit Renkerd50ad162007-11-24 21:40:24 -0200497 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
498
Andrea Bittau374bcf32006-09-19 13:14:43 -0700499 if (time_before(seqp->ccid2s_sent, hctx->ccid2hctx_last_cong)) {
500 ccid2_pr_debug("Multiple losses in an RTT---treating as one\n");
501 return;
502 }
503
504 hctx->ccid2hctx_last_cong = jiffies;
505
Gerrit Renker3deeadd2007-11-24 22:05:51 -0200506 hctx->ccid2hctx_cwnd = hctx->ccid2hctx_cwnd / 2 ? : 1U;
507 hctx->ccid2hctx_ssthresh = max(hctx->ccid2hctx_cwnd, 2U);
Gerrit Renkerd50ad162007-11-24 21:40:24 -0200508
509 /* Avoid spurious timeouts resulting from Ack Ratio > cwnd */
510 if (dccp_sk(sk)->dccps_l_ack_ratio > hctx->ccid2hctx_cwnd)
511 ccid2_change_l_ack_ratio(sk, hctx->ccid2hctx_cwnd);
Andrea Bittau374bcf32006-09-19 13:14:43 -0700512}
513
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800514static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
515{
516 struct dccp_sock *dp = dccp_sk(sk);
517 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
518 u64 ackno, seqno;
519 struct ccid2_seq *seqp;
520 unsigned char *vector;
521 unsigned char veclen;
522 int offset = 0;
523 int done = 0;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800524 unsigned int maxincr = 0;
525
526 ccid2_hc_tx_check_sanity(hctx);
527 /* check reverse path congestion */
528 seqno = DCCP_SKB_CB(skb)->dccpd_seq;
529
530 /* XXX this whole "algorithm" is broken. Need to fix it to keep track
531 * of the seqnos of the dupacks so that rpseq and rpdupack are correct
532 * -sorbo.
533 */
534 /* need to bootstrap */
535 if (hctx->ccid2hctx_rpdupack == -1) {
536 hctx->ccid2hctx_rpdupack = 0;
537 hctx->ccid2hctx_rpseq = seqno;
Arnaldo Carvalho de Meloc0c736d2006-03-20 22:05:37 -0800538 } else {
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800539 /* check if packet is consecutive */
Gerrit Renker5e285992007-10-04 14:43:09 -0700540 if (dccp_delta_seqno(hctx->ccid2hctx_rpseq, seqno) == 1)
541 hctx->ccid2hctx_rpseq = seqno;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800542 /* it's a later packet */
543 else if (after48(seqno, hctx->ccid2hctx_rpseq)) {
544 hctx->ccid2hctx_rpdupack++;
545
546 /* check if we got enough dupacks */
Gerrit Renker63df18a2007-11-24 22:04:35 -0200547 if (hctx->ccid2hctx_rpdupack >= NUMDUPACK) {
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800548 hctx->ccid2hctx_rpdupack = -1; /* XXX lame */
549 hctx->ccid2hctx_rpseq = 0;
550
Gerrit Renkerdf054e12007-11-24 21:32:53 -0200551 ccid2_change_l_ack_ratio(sk, 2 * dp->dccps_l_ack_ratio);
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800552 }
553 }
554 }
555
556 /* check forward path congestion */
557 /* still didn't send out new data packets */
558 if (hctx->ccid2hctx_seqh == hctx->ccid2hctx_seqt)
559 return;
560
561 switch (DCCP_SKB_CB(skb)->dccpd_type) {
562 case DCCP_PKT_ACK:
563 case DCCP_PKT_DATAACK:
564 break;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800565 default:
566 return;
567 }
568
569 ackno = DCCP_SKB_CB(skb)->dccpd_ack_seq;
Andrea Bittau32aac182006-11-16 14:28:40 -0200570 if (after48(ackno, hctx->ccid2hctx_high_ack))
571 hctx->ccid2hctx_high_ack = ackno;
572
573 seqp = hctx->ccid2hctx_seqt;
574 while (before48(seqp->ccid2s_seq, ackno)) {
575 seqp = seqp->ccid2s_next;
576 if (seqp == hctx->ccid2hctx_seqh) {
577 seqp = hctx->ccid2hctx_seqh->ccid2s_prev;
578 break;
579 }
580 }
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800581
Gerrit Renkera3020022007-11-24 22:10:29 -0200582 /*
583 * In slow-start, cwnd can increase up to a maximum of Ack Ratio/2
584 * packets per acknowledgement. Rounding up avoids that cwnd is not
585 * advanced when Ack Ratio is 1 and gives a slight edge otherwise.
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800586 */
Gerrit Renkera3020022007-11-24 22:10:29 -0200587 if (hctx->ccid2hctx_cwnd < hctx->ccid2hctx_ssthresh)
588 maxincr = DIV_ROUND_UP(dp->dccps_l_ack_ratio, 2);
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800589
590 /* go through all ack vectors */
591 while ((offset = ccid2_ackvector(sk, skb, offset,
592 &vector, &veclen)) != -1) {
593 /* go through this ack vector */
594 while (veclen--) {
595 const u8 rl = *vector & DCCP_ACKVEC_LEN_MASK;
Gerrit Renkercfbbeab2007-11-24 20:43:59 -0200596 u64 ackno_end_rl = SUB48(ackno, rl);
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800597
Randy Dunlap234af482006-10-29 16:03:30 -0800598 ccid2_pr_debug("ackvec start:%llu end:%llu\n",
599 (unsigned long long)ackno,
600 (unsigned long long)ackno_end_rl);
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800601 /* if the seqno we are analyzing is larger than the
602 * current ackno, then move towards the tail of our
603 * seqnos.
604 */
605 while (after48(seqp->ccid2s_seq, ackno)) {
606 if (seqp == hctx->ccid2hctx_seqt) {
607 done = 1;
608 break;
609 }
610 seqp = seqp->ccid2s_prev;
611 }
612 if (done)
613 break;
614
615 /* check all seqnos in the range of the vector
616 * run length
617 */
618 while (between48(seqp->ccid2s_seq,ackno_end_rl,ackno)) {
Andrea Bittau8e27e462006-09-19 13:05:35 -0700619 const u8 state = *vector &
620 DCCP_ACKVEC_STATE_MASK;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800621
622 /* new packet received or marked */
623 if (state != DCCP_ACKVEC_STATE_NOT_RECEIVED &&
624 !seqp->ccid2s_acked) {
Arnaldo Carvalho de Melo8109b022006-12-10 16:01:18 -0200625 if (state ==
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800626 DCCP_ACKVEC_STATE_ECN_MARKED) {
Gerrit Renkerd50ad162007-11-24 21:40:24 -0200627 ccid2_congestion_event(sk,
Andrea Bittau374bcf32006-09-19 13:14:43 -0700628 seqp);
Arnaldo Carvalho de Meloc0c736d2006-03-20 22:05:37 -0800629 } else
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800630 ccid2_new_ack(sk, seqp,
631 &maxincr);
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800632
633 seqp->ccid2s_acked = 1;
634 ccid2_pr_debug("Got ack for %llu\n",
Randy Dunlap234af482006-10-29 16:03:30 -0800635 (unsigned long long)seqp->ccid2s_seq);
Andrea Bittau77ff72d2006-03-20 17:57:52 -0800636 ccid2_hc_tx_dec_pipe(sk);
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800637 }
638 if (seqp == hctx->ccid2hctx_seqt) {
639 done = 1;
640 break;
641 }
Gerrit Renker3de54892007-11-24 20:37:48 -0200642 seqp = seqp->ccid2s_prev;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800643 }
644 if (done)
645 break;
646
Gerrit Renkercfbbeab2007-11-24 20:43:59 -0200647 ackno = SUB48(ackno_end_rl, 1);
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800648 vector++;
649 }
650 if (done)
651 break;
652 }
653
654 /* The state about what is acked should be correct now
655 * Check for NUMDUPACK
656 */
Andrea Bittau32aac182006-11-16 14:28:40 -0200657 seqp = hctx->ccid2hctx_seqt;
658 while (before48(seqp->ccid2s_seq, hctx->ccid2hctx_high_ack)) {
659 seqp = seqp->ccid2s_next;
660 if (seqp == hctx->ccid2hctx_seqh) {
661 seqp = hctx->ccid2hctx_seqh->ccid2s_prev;
662 break;
663 }
664 }
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800665 done = 0;
666 while (1) {
667 if (seqp->ccid2s_acked) {
668 done++;
Gerrit Renker63df18a2007-11-24 22:04:35 -0200669 if (done == NUMDUPACK)
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800670 break;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800671 }
Arnaldo Carvalho de Meloc0c736d2006-03-20 22:05:37 -0800672 if (seqp == hctx->ccid2hctx_seqt)
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800673 break;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800674 seqp = seqp->ccid2s_prev;
675 }
676
677 /* If there are at least 3 acknowledgements, anything unacknowledged
678 * below the last sequence number is considered lost
679 */
Gerrit Renker63df18a2007-11-24 22:04:35 -0200680 if (done == NUMDUPACK) {
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800681 struct ccid2_seq *last_acked = seqp;
682
683 /* check for lost packets */
684 while (1) {
685 if (!seqp->ccid2s_acked) {
Andrea Bittau374bcf32006-09-19 13:14:43 -0700686 ccid2_pr_debug("Packet lost: %llu\n",
Randy Dunlap234af482006-10-29 16:03:30 -0800687 (unsigned long long)seqp->ccid2s_seq);
Andrea Bittau374bcf32006-09-19 13:14:43 -0700688 /* XXX need to traverse from tail -> head in
689 * order to detect multiple congestion events in
690 * one ack vector.
691 */
Gerrit Renkerd50ad162007-11-24 21:40:24 -0200692 ccid2_congestion_event(sk, seqp);
Andrea Bittau77ff72d2006-03-20 17:57:52 -0800693 ccid2_hc_tx_dec_pipe(sk);
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800694 }
695 if (seqp == hctx->ccid2hctx_seqt)
696 break;
697 seqp = seqp->ccid2s_prev;
698 }
699
700 hctx->ccid2hctx_seqt = last_acked;
701 }
702
703 /* trim acked packets in tail */
704 while (hctx->ccid2hctx_seqt != hctx->ccid2hctx_seqh) {
705 if (!hctx->ccid2hctx_seqt->ccid2s_acked)
706 break;
707
708 hctx->ccid2hctx_seqt = hctx->ccid2hctx_seqt->ccid2s_next;
709 }
710
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800711 ccid2_hc_tx_check_sanity(hctx);
712}
713
Arnaldo Carvalho de Melo91f0ebf2006-03-20 19:21:44 -0800714static int ccid2_hc_tx_init(struct ccid *ccid, struct sock *sk)
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800715{
YOSHIFUJI Hideakic9eaf172007-02-09 23:24:38 +0900716 struct ccid2_hc_tx_sock *hctx = ccid_priv(ccid);
Gerrit Renkerb00d2bb2007-11-24 21:44:30 -0200717 struct dccp_sock *dp = dccp_sk(sk);
718 u32 max_ratio;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800719
Gerrit Renkerb00d2bb2007-11-24 21:44:30 -0200720 /* RFC 4341, 5: initialise ssthresh to arbitrarily high (max) value */
Gerrit Renker3deeadd2007-11-24 22:05:51 -0200721 hctx->ccid2hctx_ssthresh = ~0U;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800722
Gerrit Renkerb00d2bb2007-11-24 21:44:30 -0200723 /*
724 * RFC 4341, 5: "The cwnd parameter is initialized to at most four
725 * packets for new connections, following the rules from [RFC3390]".
726 * We need to convert the bytes of RFC3390 into the packets of RFC 4341.
727 */
728 hctx->ccid2hctx_cwnd = min(4U, max(2U, 4380U / dp->dccps_mss_cache));
729
730 /* Make sure that Ack Ratio is enabled and within bounds. */
731 max_ratio = DIV_ROUND_UP(hctx->ccid2hctx_cwnd, 2);
732 if (dp->dccps_l_ack_ratio == 0 || dp->dccps_l_ack_ratio > max_ratio)
733 dp->dccps_l_ack_ratio = max_ratio;
734
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800735 /* XXX init ~ to window size... */
Gerrit Renkercd1f7d32007-10-04 14:41:00 -0700736 if (ccid2_hc_tx_alloc_seq(hctx))
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800737 return -ENOMEM;
Arnaldo Carvalho de Melo91f0ebf2006-03-20 19:21:44 -0800738
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800739 hctx->ccid2hctx_rto = 3 * HZ;
Andrea Bittau593f16a2006-09-19 13:15:33 -0700740 ccid2_change_srtt(hctx, -1);
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800741 hctx->ccid2hctx_rttvar = -1;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800742 hctx->ccid2hctx_rpdupack = -1;
Andrea Bittau374bcf32006-09-19 13:14:43 -0700743 hctx->ccid2hctx_last_cong = jiffies;
Pavel Emelyanovb24b8a22008-01-23 21:20:07 -0800744 setup_timer(&hctx->ccid2hctx_rtotimer, ccid2_hc_tx_rto_expire,
745 (unsigned long)sk);
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800746
747 ccid2_hc_tx_check_sanity(hctx);
748 return 0;
749}
750
751static void ccid2_hc_tx_exit(struct sock *sk)
752{
YOSHIFUJI Hideakic9eaf172007-02-09 23:24:38 +0900753 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
Andrea Bittau07978aa2006-09-19 13:13:37 -0700754 int i;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800755
Andrea Bittau77ff72d2006-03-20 17:57:52 -0800756 ccid2_hc_tx_kill_rto_timer(sk);
Andrea Bittau07978aa2006-09-19 13:13:37 -0700757
758 for (i = 0; i < hctx->ccid2hctx_seqbufc; i++)
759 kfree(hctx->ccid2hctx_seqbuf[i]);
760 hctx->ccid2hctx_seqbufc = 0;
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800761}
762
763static void ccid2_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
764{
765 const struct dccp_sock *dp = dccp_sk(sk);
766 struct ccid2_hc_rx_sock *hcrx = ccid2_hc_rx_sk(sk);
767
768 switch (DCCP_SKB_CB(skb)->dccpd_type) {
769 case DCCP_PKT_DATA:
770 case DCCP_PKT_DATAACK:
771 hcrx->ccid2hcrx_data++;
772 if (hcrx->ccid2hcrx_data >= dp->dccps_r_ack_ratio) {
773 dccp_send_ack(sk);
774 hcrx->ccid2hcrx_data = 0;
775 }
776 break;
777 }
778}
779
Arnaldo Carvalho de Melo91f0ebf2006-03-20 19:21:44 -0800780static struct ccid_operations ccid2 = {
Ian McDonald3dd9a7c2006-09-22 14:26:44 +1200781 .ccid_id = DCCPC_CCID2,
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800782 .ccid_name = "ccid2",
783 .ccid_owner = THIS_MODULE,
Arnaldo Carvalho de Melo91f0ebf2006-03-20 19:21:44 -0800784 .ccid_hc_tx_obj_size = sizeof(struct ccid2_hc_tx_sock),
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800785 .ccid_hc_tx_init = ccid2_hc_tx_init,
786 .ccid_hc_tx_exit = ccid2_hc_tx_exit,
787 .ccid_hc_tx_send_packet = ccid2_hc_tx_send_packet,
788 .ccid_hc_tx_packet_sent = ccid2_hc_tx_packet_sent,
789 .ccid_hc_tx_packet_recv = ccid2_hc_tx_packet_recv,
Arnaldo Carvalho de Melo91f0ebf2006-03-20 19:21:44 -0800790 .ccid_hc_rx_obj_size = sizeof(struct ccid2_hc_rx_sock),
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800791 .ccid_hc_rx_packet_recv = ccid2_hc_rx_packet_recv,
792};
793
Gerrit Renker84116712006-11-20 18:26:03 -0200794#ifdef CONFIG_IP_DCCP_CCID2_DEBUG
Gerrit Renker042d18f2007-10-04 14:39:53 -0700795module_param(ccid2_debug, bool, 0444);
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800796MODULE_PARM_DESC(ccid2_debug, "Enable debug messages");
Gerrit Renker84116712006-11-20 18:26:03 -0200797#endif
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800798
799static __init int ccid2_module_init(void)
800{
801 return ccid_register(&ccid2);
802}
803module_init(ccid2_module_init);
804
805static __exit void ccid2_module_exit(void)
806{
807 ccid_unregister(&ccid2);
808}
809module_exit(ccid2_module_exit);
810
811MODULE_AUTHOR("Andrea Bittau <a.bittau@cs.ucl.ac.uk>");
Arnaldo Carvalho de Meloc0c736d2006-03-20 22:05:37 -0800812MODULE_DESCRIPTION("DCCP TCP-Like (CCID2) CCID");
Andrea Bittau2a91aa32006-03-20 17:41:47 -0800813MODULE_LICENSE("GPL");
814MODULE_ALIAS("net-dccp-ccid-2");