aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp
diff options
context:
space:
mode:
authorGerrit Renker <gerrit@erg.abdn.ac.uk>2010-11-14 11:26:02 -0500
committerGerrit Renker <gerrit@erg.abdn.ac.uk>2010-11-15 01:12:00 -0500
commit52394eecec4e6fa677a61af26f0bd35de665344e (patch)
tree283c99722c63a05a748916caaec876732309ceaf /net/dccp
parentd83447f0944e73d690218d79c07762ffa4ceb9e4 (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')
-rw-r--r--net/dccp/ackvec.c251
-rw-r--r--net/dccp/ackvec.h14
2 files changed, 0 insertions, 265 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
24static struct kmem_cache *dccp_ackvec_slab; 16static struct kmem_cache *dccp_ackvec_slab;
25static struct kmem_cache *dccp_ackvec_record_slab; 17static 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 */
289static 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 */
325int 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;
402out:
403 return 0;
404
405out_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
412static 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
431void 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
455static 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;
490found:
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
515int 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
diff --git a/net/dccp/ackvec.h b/net/dccp/ackvec.h
index 21c4212d1be0..e19b8d5ee05f 100644
--- a/net/dccp/ackvec.h
+++ b/net/dccp/ackvec.h
@@ -64,7 +64,6 @@ static inline u8 dccp_ackvec_state(const u8 *cell)
64 * %DCCP_SINGLE_OPT_MAXLEN cells in the live portion of @av_buf 64 * %DCCP_SINGLE_OPT_MAXLEN cells in the live portion of @av_buf
65 * @av_overflow: if 1 then buf_head == buf_tail indicates buffer wraparound 65 * @av_overflow: if 1 then buf_head == buf_tail indicates buffer wraparound
66 * @av_records: list of %dccp_ackvec_record (Ack Vectors sent previously) 66 * @av_records: list of %dccp_ackvec_record (Ack Vectors sent previously)
67 * @av_veclen: length of the live portion of @av_buf
68 */ 67 */
69struct dccp_ackvec { 68struct dccp_ackvec {
70 u8 av_buf[DCCPAV_MAX_ACKVEC_LEN]; 69 u8 av_buf[DCCPAV_MAX_ACKVEC_LEN];
@@ -75,7 +74,6 @@ struct dccp_ackvec {
75 bool av_buf_nonce[DCCPAV_NUM_ACKVECS]; 74 bool av_buf_nonce[DCCPAV_NUM_ACKVECS];
76 u8 av_overflow:1; 75 u8 av_overflow:1;
77 struct list_head av_records; 76 struct list_head av_records;
78 u16 av_vec_len;
79}; 77};
80 78
81/** struct dccp_ackvec_record - Records information about sent Ack Vectors 79/** struct dccp_ackvec_record - Records information about sent Ack Vectors
@@ -101,24 +99,12 @@ struct dccp_ackvec_record {
101 u8 avr_ack_nonce:1; 99 u8 avr_ack_nonce:1;
102}; 100};
103 101
104struct sock;
105struct sk_buff;
106
107extern int dccp_ackvec_init(void); 102extern int dccp_ackvec_init(void);
108extern void dccp_ackvec_exit(void); 103extern void dccp_ackvec_exit(void);
109 104
110extern struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority); 105extern struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority);
111extern void dccp_ackvec_free(struct dccp_ackvec *av); 106extern void dccp_ackvec_free(struct dccp_ackvec *av);
112 107
113extern int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk,
114 const u64 ackno, const u8 state);
115
116extern void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av,
117 struct sock *sk, const u64 ackno);
118extern int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb,
119 u64 *ackno, const u8 opt,
120 const u8 *value, const u8 len);
121
122extern void dccp_ackvec_input(struct dccp_ackvec *av, struct sk_buff *skb); 108extern void dccp_ackvec_input(struct dccp_ackvec *av, struct sk_buff *skb);
123extern int dccp_ackvec_update_records(struct dccp_ackvec *av, u64 seq, u8 sum); 109extern int dccp_ackvec_update_records(struct dccp_ackvec *av, u64 seq, u8 sum);
124extern void dccp_ackvec_clear_state(struct dccp_ackvec *av, const u64 ackno); 110extern void dccp_ackvec_clear_state(struct dccp_ackvec *av, const u64 ackno);