diff options
author | Gerrit Renker <gerrit@erg.abdn.ac.uk> | 2010-11-14 11:26:02 -0500 |
---|---|---|
committer | Gerrit Renker <gerrit@erg.abdn.ac.uk> | 2010-11-15 01:12:00 -0500 |
commit | 52394eecec4e6fa677a61af26f0bd35de665344e (patch) | |
tree | 283c99722c63a05a748916caaec876732309ceaf /net/dccp/ackvec.c | |
parent | d83447f0944e73d690218d79c07762ffa4ceb9e4 (diff) |
dccp ccid-2: Remove old infrastructure
This removes
* functions for which updates have been provided in the preceding patches and
* the @av_vec_len field - it is no longer necessary since the buffer length is
now always computed dynamically.
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Diffstat (limited to 'net/dccp/ackvec.c')
-rw-r--r-- | net/dccp/ackvec.c | 251 |
1 files changed, 0 insertions, 251 deletions
diff --git a/net/dccp/ackvec.c b/net/dccp/ackvec.c index f7e647e608bb..66b8a51300c0 100644 --- a/net/dccp/ackvec.c +++ b/net/dccp/ackvec.c | |||
@@ -9,18 +9,10 @@ | |||
9 | * under the terms of the GNU General Public License as published by the | 9 | * under the terms of the GNU General Public License as published by the |
10 | * Free Software Foundation; version 2 of the License; | 10 | * Free Software Foundation; version 2 of the License; |
11 | */ | 11 | */ |
12 | |||
13 | #include "ackvec.h" | ||
14 | #include "dccp.h" | 12 | #include "dccp.h" |
15 | |||
16 | #include <linux/init.h> | ||
17 | #include <linux/errno.h> | ||
18 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
19 | #include <linux/skbuff.h> | ||
20 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
21 | 15 | ||
22 | #include <net/sock.h> | ||
23 | |||
24 | static struct kmem_cache *dccp_ackvec_slab; | 16 | static struct kmem_cache *dccp_ackvec_slab; |
25 | static struct kmem_cache *dccp_ackvec_record_slab; | 17 | static struct kmem_cache *dccp_ackvec_record_slab; |
26 | 18 | ||
@@ -281,249 +273,6 @@ void dccp_ackvec_input(struct dccp_ackvec *av, struct sk_buff *skb) | |||
281 | } | 273 | } |
282 | } | 274 | } |
283 | 275 | ||
284 | /* | ||
285 | * If several packets are missing, the HC-Receiver may prefer to enter multiple | ||
286 | * bytes with run length 0, rather than a single byte with a larger run length; | ||
287 | * this simplifies table updates if one of the missing packets arrives. | ||
288 | */ | ||
289 | static inline int dccp_ackvec_set_buf_head_state(struct dccp_ackvec *av, | ||
290 | const unsigned int packets, | ||
291 | const unsigned char state) | ||
292 | { | ||
293 | long gap; | ||
294 | long new_head; | ||
295 | |||
296 | if (av->av_vec_len + packets > DCCPAV_MAX_ACKVEC_LEN) | ||
297 | return -ENOBUFS; | ||
298 | |||
299 | gap = packets - 1; | ||
300 | new_head = av->av_buf_head - packets; | ||
301 | |||
302 | if (new_head < 0) { | ||
303 | if (gap > 0) { | ||
304 | memset(av->av_buf, DCCPAV_NOT_RECEIVED, | ||
305 | gap + new_head + 1); | ||
306 | gap = -new_head; | ||
307 | } | ||
308 | new_head += DCCPAV_MAX_ACKVEC_LEN; | ||
309 | } | ||
310 | |||
311 | av->av_buf_head = new_head; | ||
312 | |||
313 | if (gap > 0) | ||
314 | memset(av->av_buf + av->av_buf_head + 1, | ||
315 | DCCPAV_NOT_RECEIVED, gap); | ||
316 | |||
317 | av->av_buf[av->av_buf_head] = state; | ||
318 | av->av_vec_len += packets; | ||
319 | return 0; | ||
320 | } | ||
321 | |||
322 | /* | ||
323 | * Implements the RFC 4340, Appendix A | ||
324 | */ | ||
325 | int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk, | ||
326 | const u64 ackno, const u8 state) | ||
327 | { | ||
328 | u8 *cur_head = av->av_buf + av->av_buf_head, | ||
329 | *buf_end = av->av_buf + DCCPAV_MAX_ACKVEC_LEN; | ||
330 | /* | ||
331 | * Check at the right places if the buffer is full, if it is, tell the | ||
332 | * caller to start dropping packets till the HC-Sender acks our ACK | ||
333 | * vectors, when we will free up space in av_buf. | ||
334 | * | ||
335 | * We may well decide to do buffer compression, etc, but for now lets | ||
336 | * just drop. | ||
337 | * | ||
338 | * From Appendix A.1.1 (`New Packets'): | ||
339 | * | ||
340 | * Of course, the circular buffer may overflow, either when the | ||
341 | * HC-Sender is sending data at a very high rate, when the | ||
342 | * HC-Receiver's acknowledgements are not reaching the HC-Sender, | ||
343 | * or when the HC-Sender is forgetting to acknowledge those acks | ||
344 | * (so the HC-Receiver is unable to clean up old state). In this | ||
345 | * case, the HC-Receiver should either compress the buffer (by | ||
346 | * increasing run lengths when possible), transfer its state to | ||
347 | * a larger buffer, or, as a last resort, drop all received | ||
348 | * packets, without processing them whatsoever, until its buffer | ||
349 | * shrinks again. | ||
350 | */ | ||
351 | |||
352 | /* See if this is the first ackno being inserted */ | ||
353 | if (av->av_vec_len == 0) { | ||
354 | *cur_head = state; | ||
355 | av->av_vec_len = 1; | ||
356 | } else if (after48(ackno, av->av_buf_ackno)) { | ||
357 | const u64 delta = dccp_delta_seqno(av->av_buf_ackno, ackno); | ||
358 | |||
359 | /* | ||
360 | * Look if the state of this packet is the same as the | ||
361 | * previous ackno and if so if we can bump the head len. | ||
362 | */ | ||
363 | if (delta == 1 && dccp_ackvec_state(cur_head) == state && | ||
364 | dccp_ackvec_runlen(cur_head) < DCCPAV_MAX_RUNLEN) | ||
365 | *cur_head += 1; | ||
366 | else if (dccp_ackvec_set_buf_head_state(av, delta, state)) | ||
367 | return -ENOBUFS; | ||
368 | } else { | ||
369 | /* | ||
370 | * A.1.2. Old Packets | ||
371 | * | ||
372 | * When a packet with Sequence Number S <= buf_ackno | ||
373 | * arrives, the HC-Receiver will scan the table for | ||
374 | * the byte corresponding to S. (Indexing structures | ||
375 | * could reduce the complexity of this scan.) | ||
376 | */ | ||
377 | u64 delta = dccp_delta_seqno(ackno, av->av_buf_ackno); | ||
378 | |||
379 | while (1) { | ||
380 | const u8 len = dccp_ackvec_runlen(cur_head); | ||
381 | /* | ||
382 | * valid packets not yet in av_buf have a reserved | ||
383 | * entry, with a len equal to 0. | ||
384 | */ | ||
385 | if (*cur_head == DCCPAV_NOT_RECEIVED && delta == 0) { | ||
386 | dccp_pr_debug("Found %llu reserved seat!\n", | ||
387 | (unsigned long long)ackno); | ||
388 | *cur_head = state; | ||
389 | goto out; | ||
390 | } | ||
391 | /* len == 0 means one packet */ | ||
392 | if (delta < len + 1) | ||
393 | goto out_duplicate; | ||
394 | |||
395 | delta -= len + 1; | ||
396 | if (++cur_head == buf_end) | ||
397 | cur_head = av->av_buf; | ||
398 | } | ||
399 | } | ||
400 | |||
401 | av->av_buf_ackno = ackno; | ||
402 | out: | ||
403 | return 0; | ||
404 | |||
405 | out_duplicate: | ||
406 | /* Duplicate packet */ | ||
407 | dccp_pr_debug("Received a dup or already considered lost " | ||
408 | "packet: %llu\n", (unsigned long long)ackno); | ||
409 | return -EILSEQ; | ||
410 | } | ||
411 | |||
412 | static void dccp_ackvec_throw_record(struct dccp_ackvec *av, | ||
413 | struct dccp_ackvec_record *avr) | ||
414 | { | ||
415 | struct dccp_ackvec_record *next; | ||
416 | |||
417 | /* sort out vector length */ | ||
418 | if (av->av_buf_head <= avr->avr_ack_ptr) | ||
419 | av->av_vec_len = avr->avr_ack_ptr - av->av_buf_head; | ||
420 | else | ||
421 | av->av_vec_len = DCCPAV_MAX_ACKVEC_LEN - 1 - | ||
422 | av->av_buf_head + avr->avr_ack_ptr; | ||
423 | |||
424 | /* free records */ | ||
425 | list_for_each_entry_safe_from(avr, next, &av->av_records, avr_node) { | ||
426 | list_del(&avr->avr_node); | ||
427 | kmem_cache_free(dccp_ackvec_record_slab, avr); | ||
428 | } | ||
429 | } | ||
430 | |||
431 | void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av, struct sock *sk, | ||
432 | const u64 ackno) | ||
433 | { | ||
434 | struct dccp_ackvec_record *avr; | ||
435 | |||
436 | /* | ||
437 | * If we traverse backwards, it should be faster when we have large | ||
438 | * windows. We will be receiving ACKs for stuff we sent a while back | ||
439 | * -sorbo. | ||
440 | */ | ||
441 | list_for_each_entry_reverse(avr, &av->av_records, avr_node) { | ||
442 | if (ackno == avr->avr_ack_seqno) { | ||
443 | dccp_pr_debug("%s ACK packet 0, len=%d, ack_seqno=%llu, " | ||
444 | "ack_ackno=%llu, ACKED!\n", | ||
445 | dccp_role(sk), avr->avr_ack_runlen, | ||
446 | (unsigned long long)avr->avr_ack_seqno, | ||
447 | (unsigned long long)avr->avr_ack_ackno); | ||
448 | dccp_ackvec_throw_record(av, avr); | ||
449 | break; | ||
450 | } else if (avr->avr_ack_seqno > ackno) | ||
451 | break; /* old news */ | ||
452 | } | ||
453 | } | ||
454 | |||
455 | static void dccp_ackvec_check_rcv_ackvector(struct dccp_ackvec *av, | ||
456 | struct sock *sk, u64 *ackno, | ||
457 | const unsigned char len, | ||
458 | const unsigned char *vector) | ||
459 | { | ||
460 | unsigned char i; | ||
461 | struct dccp_ackvec_record *avr; | ||
462 | |||
463 | /* Check if we actually sent an ACK vector */ | ||
464 | if (list_empty(&av->av_records)) | ||
465 | return; | ||
466 | |||
467 | i = len; | ||
468 | /* | ||
469 | * XXX | ||
470 | * I think it might be more efficient to work backwards. See comment on | ||
471 | * rcv_ackno. -sorbo. | ||
472 | */ | ||
473 | avr = list_entry(av->av_records.next, struct dccp_ackvec_record, avr_node); | ||
474 | while (i--) { | ||
475 | const u8 rl = dccp_ackvec_runlen(vector); | ||
476 | u64 ackno_end_rl; | ||
477 | |||
478 | dccp_set_seqno(&ackno_end_rl, *ackno - rl); | ||
479 | |||
480 | /* | ||
481 | * If our AVR sequence number is greater than the ack, go | ||
482 | * forward in the AVR list until it is not so. | ||
483 | */ | ||
484 | list_for_each_entry_from(avr, &av->av_records, avr_node) { | ||
485 | if (!after48(avr->avr_ack_seqno, *ackno)) | ||
486 | goto found; | ||
487 | } | ||
488 | /* End of the av_records list, not found, exit */ | ||
489 | break; | ||
490 | found: | ||
491 | if (between48(avr->avr_ack_seqno, ackno_end_rl, *ackno)) { | ||
492 | if (dccp_ackvec_state(vector) != DCCPAV_NOT_RECEIVED) { | ||
493 | dccp_pr_debug("%s ACK vector 0, len=%d, " | ||
494 | "ack_seqno=%llu, ack_ackno=%llu, " | ||
495 | "ACKED!\n", | ||
496 | dccp_role(sk), len, | ||
497 | (unsigned long long) | ||
498 | avr->avr_ack_seqno, | ||
499 | (unsigned long long) | ||
500 | avr->avr_ack_ackno); | ||
501 | dccp_ackvec_throw_record(av, avr); | ||
502 | break; | ||
503 | } | ||
504 | /* | ||
505 | * If it wasn't received, continue scanning... we might | ||
506 | * find another one. | ||
507 | */ | ||
508 | } | ||
509 | |||
510 | dccp_set_seqno(ackno, ackno_end_rl - 1); | ||
511 | ++vector; | ||
512 | } | ||
513 | } | ||
514 | |||
515 | int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb, | ||
516 | u64 *ackno, const u8 opt, const u8 *value, const u8 len) | ||
517 | { | ||
518 | if (len > DCCP_SINGLE_OPT_MAXLEN) | ||
519 | return -1; | ||
520 | |||
521 | /* dccp_ackvector_print(DCCP_SKB_CB(skb)->dccpd_ack_seq, value, len); */ | ||
522 | dccp_ackvec_check_rcv_ackvector(dccp_sk(sk)->dccps_hc_rx_ackvec, sk, | ||
523 | ackno, len, value); | ||
524 | return 0; | ||
525 | } | ||
526 | |||
527 | /** | 276 | /** |
528 | * dccp_ackvec_clear_state - Perform house-keeping / garbage-collection | 277 | * dccp_ackvec_clear_state - Perform house-keeping / garbage-collection |
529 | * This routine is called when the peer acknowledges the receipt of Ack Vectors | 278 | * This routine is called when the peer acknowledges the receipt of Ack Vectors |