aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorGerrit Renker <gerrit@erg.abdn.ac.uk>2008-09-04 01:30:19 -0400
committerGerrit Renker <gerrit@erg.abdn.ac.uk>2008-09-04 01:45:37 -0400
commit5a577b488f687f339dea62e7bb4f4c5793ad523f (patch)
tree7be4c34a22de21e66f33d5b4bdfc2eb547f67091 /net
parentc2f42077bd06f300ae959204f3c007f820f5e769 (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; * conditional debugging code (CONFIG_IP_DCCP_ACKVEC). The reason for removing the conditional debugging code is that Ack Vectors are an almost inevitable necessity - RFC 4341 says that for CCID-2, Ack Vectors must be used. Furthermore, the code would be only interesting for coding - after some extensive testing with this patch set, having the debug code around is no longer of real help. Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Diffstat (limited to 'net')
-rw-r--r--net/dccp/Kconfig3
-rw-r--r--net/dccp/Makefile5
-rw-r--r--net/dccp/ackvec.c251
-rw-r--r--net/dccp/ackvec.h79
-rw-r--r--net/dccp/ccids/Kconfig1
5 files changed, 3 insertions, 336 deletions
diff --git a/net/dccp/Kconfig b/net/dccp/Kconfig
index 7aa2a7acc7ec..206c16ad9c3c 100644
--- a/net/dccp/Kconfig
+++ b/net/dccp/Kconfig
@@ -25,9 +25,6 @@ config INET_DCCP_DIAG
25 def_tristate y if (IP_DCCP = y && INET_DIAG = y) 25 def_tristate y if (IP_DCCP = y && INET_DIAG = y)
26 def_tristate m 26 def_tristate m
27 27
28config IP_DCCP_ACKVEC
29 bool
30
31source "net/dccp/ccids/Kconfig" 28source "net/dccp/ccids/Kconfig"
32 29
33menu "DCCP Kernel Hacking" 30menu "DCCP Kernel Hacking"
diff --git a/net/dccp/Makefile b/net/dccp/Makefile
index f4f8793aafff..b68440bd7fa2 100644
--- a/net/dccp/Makefile
+++ b/net/dccp/Makefile
@@ -1,6 +1,7 @@
1obj-$(CONFIG_IP_DCCP) += dccp.o dccp_ipv4.o 1obj-$(CONFIG_IP_DCCP) += dccp.o dccp_ipv4.o
2 2
3dccp-y := ccid.o feat.o input.o minisocks.o options.o output.o proto.o timer.o 3dccp-y := ccid.o feat.o input.o minisocks.o options.o \
4 output.o proto.o timer.o ackvec.o
4 5
5dccp_ipv4-y := ipv4.o 6dccp_ipv4-y := ipv4.o
6 7
@@ -8,8 +9,6 @@ dccp_ipv4-y := ipv4.o
8obj-$(subst y,$(CONFIG_IP_DCCP),$(CONFIG_IPV6)) += dccp_ipv6.o 9obj-$(subst y,$(CONFIG_IP_DCCP),$(CONFIG_IPV6)) += dccp_ipv6.o
9dccp_ipv6-y := ipv6.o 10dccp_ipv6-y := ipv6.o
10 11
11dccp-$(CONFIG_IP_DCCP_ACKVEC) += ackvec.o
12
13obj-$(CONFIG_INET_DCCP_DIAG) += dccp_diag.o 12obj-$(CONFIG_INET_DCCP_DIAG) += dccp_diag.o
14obj-$(CONFIG_NET_DCCPPROBE) += dccp_probe.o 13obj-$(CONFIG_NET_DCCPPROBE) += dccp_probe.o
15 14
diff --git a/net/dccp/ackvec.c b/net/dccp/ackvec.c
index bf9cb7d7549d..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 unsigned int 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 36ca2e9e5c84..db447503b636 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,25 +99,12 @@ struct dccp_ackvec_record {
101 u8 avr_ack_nonce:1; 99 u8 avr_ack_nonce:1;
102}; 100};
103 101
104struct sock; 102extern int dccp_ackvec_init(void);
105struct sk_buff;
106
107#ifdef CONFIG_IP_DCCP_ACKVEC
108extern int dccp_ackvec_init(void);
109extern void dccp_ackvec_exit(void); 103extern void dccp_ackvec_exit(void);
110 104
111extern struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority); 105extern struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority);
112extern void dccp_ackvec_free(struct dccp_ackvec *av); 106extern void dccp_ackvec_free(struct dccp_ackvec *av);
113 107
114extern int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk,
115 const u64 ackno, const u8 state);
116
117extern void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av,
118 struct sock *sk, const u64 ackno);
119extern int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb,
120 u64 *ackno, const u8 opt,
121 const u8 *value, const u8 len);
122
123extern 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);
124extern 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);
125extern 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);
@@ -129,66 +114,4 @@ static inline bool dccp_ackvec_is_empty(const struct dccp_ackvec *av)
129{ 114{
130 return av->av_overflow == 0 && av->av_buf_head == av->av_buf_tail; 115 return av->av_overflow == 0 && av->av_buf_head == av->av_buf_tail;
131} 116}
132#else /* CONFIG_IP_DCCP_ACKVEC */
133static inline int dccp_ackvec_init(void)
134{
135 return 0;
136}
137
138static inline void dccp_ackvec_exit(void)
139{
140}
141
142static inline struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority)
143{
144 return NULL;
145}
146
147static inline void dccp_ackvec_free(struct dccp_ackvec *av)
148{
149}
150
151static inline void dccp_ackvec_input(struct dccp_ackvec *av, struct sk_buff *skb)
152{
153
154}
155
156static inline int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk,
157 const u64 ackno, const u8 state)
158{
159 return -1;
160}
161
162static inline void dccp_ackvec_clear_state(struct dccp_ackvec *av,
163 const u64 ackno)
164{
165}
166
167static inline void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av,
168 struct sock *sk, const u64 ackno)
169{
170}
171
172static inline int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb,
173 const u64 *ackno, const u8 opt,
174 const u8 *value, const u8 len)
175{
176 return -1;
177}
178
179static inline int dccp_ackvec_update_records(struct dccp_ackvec *av, u64 seq, u8 nonce)
180{
181 return -1;
182}
183
184static inline u16 dccp_ackvec_buflen(const struct dccp_ackvec *av)
185{
186 return 0;
187}
188
189static inline bool dccp_ackvec_is_empty(const struct dccp_ackvec *av)
190{
191 return true;
192}
193#endif /* CONFIG_IP_DCCP_ACKVEC */
194#endif /* _ACKVEC_H */ 117#endif /* _ACKVEC_H */
diff --git a/net/dccp/ccids/Kconfig b/net/dccp/ccids/Kconfig
index 12275943eab8..44c7e90248fa 100644
--- a/net/dccp/ccids/Kconfig
+++ b/net/dccp/ccids/Kconfig
@@ -4,7 +4,6 @@ menu "DCCP CCIDs Configuration (EXPERIMENTAL)"
4config IP_DCCP_CCID2 4config IP_DCCP_CCID2
5 tristate "CCID2 (TCP-Like) (EXPERIMENTAL)" 5 tristate "CCID2 (TCP-Like) (EXPERIMENTAL)"
6 def_tristate IP_DCCP 6 def_tristate IP_DCCP
7 select IP_DCCP_ACKVEC
8 ---help--- 7 ---help---
9 CCID 2, TCP-like Congestion Control, denotes Additive Increase, 8 CCID 2, TCP-like Congestion Control, denotes Additive Increase,
10 Multiplicative Decrease (AIMD) congestion control with behavior 9 Multiplicative Decrease (AIMD) congestion control with behavior