aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/ccids
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:40 -0400
commit24b8d343215919c7a2ba18b9f89a0961e1459cad (patch)
tree2b97062dae6e80bb178a0cd0354aa71fe884ef30 /net/dccp/ccids
parent8b67ad12b04ef7bdf5d2b4de24fe5a609b26cf12 (diff)
dccp tfrc: Receiver history initialisation routine
This patch 1) separates history allocation and initialisation, to facilitate early loss detection (implemented by a subsequent patch); 2) removes duplication by using the existing tfrc_rx_hist_purge() if the allocation fails. This is now possible, since the initialisation routine 3) zeroes out the entire history before using it. Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Diffstat (limited to 'net/dccp/ccids')
-rw-r--r--net/dccp/ccids/ccid3.c2
-rw-r--r--net/dccp/ccids/lib/packet_history.c52
-rw-r--r--net/dccp/ccids/lib/packet_history.h2
3 files changed, 32 insertions, 24 deletions
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index 5470a978be02..36f4992f3c38 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -766,7 +766,7 @@ static int ccid3_hc_rx_init(struct ccid *ccid, struct sock *sk)
766 766
767 hcrx->state = TFRC_RSTATE_NO_DATA; 767 hcrx->state = TFRC_RSTATE_NO_DATA;
768 tfrc_lh_init(&hcrx->li_hist); 768 tfrc_lh_init(&hcrx->li_hist);
769 return tfrc_rx_hist_alloc(&hcrx->hist); 769 return tfrc_rx_hist_init(&hcrx->hist, sk);
770} 770}
771 771
772static void ccid3_hc_rx_exit(struct sock *sk) 772static void ccid3_hc_rx_exit(struct sock *sk)
diff --git a/net/dccp/ccids/lib/packet_history.c b/net/dccp/ccids/lib/packet_history.c
index 5c4450866904..5b4e1cf8439d 100644
--- a/net/dccp/ccids/lib/packet_history.c
+++ b/net/dccp/ccids/lib/packet_history.c
@@ -352,28 +352,6 @@ int tfrc_rx_handle_loss(struct tfrc_rx_hist *h,
352} 352}
353EXPORT_SYMBOL_GPL(tfrc_rx_handle_loss); 353EXPORT_SYMBOL_GPL(tfrc_rx_handle_loss);
354 354
355int tfrc_rx_hist_alloc(struct tfrc_rx_hist *h)
356{
357 int i;
358
359 for (i = 0; i <= TFRC_NDUPACK; i++) {
360 h->ring[i] = kmem_cache_alloc(tfrc_rx_hist_slab, GFP_ATOMIC);
361 if (h->ring[i] == NULL)
362 goto out_free;
363 }
364
365 h->loss_count = h->loss_start = 0;
366 return 0;
367
368out_free:
369 while (i-- != 0) {
370 kmem_cache_free(tfrc_rx_hist_slab, h->ring[i]);
371 h->ring[i] = NULL;
372 }
373 return -ENOBUFS;
374}
375EXPORT_SYMBOL_GPL(tfrc_rx_hist_alloc);
376
377void tfrc_rx_hist_purge(struct tfrc_rx_hist *h) 355void tfrc_rx_hist_purge(struct tfrc_rx_hist *h)
378{ 356{
379 int i; 357 int i;
@@ -386,6 +364,36 @@ void tfrc_rx_hist_purge(struct tfrc_rx_hist *h)
386} 364}
387EXPORT_SYMBOL_GPL(tfrc_rx_hist_purge); 365EXPORT_SYMBOL_GPL(tfrc_rx_hist_purge);
388 366
367static int tfrc_rx_hist_alloc(struct tfrc_rx_hist *h)
368{
369 int i;
370
371 memset(h, 0, sizeof(*h));
372
373 for (i = 0; i <= TFRC_NDUPACK; i++) {
374 h->ring[i] = kmem_cache_alloc(tfrc_rx_hist_slab, GFP_ATOMIC);
375 if (h->ring[i] == NULL) {
376 tfrc_rx_hist_purge(h);
377 return -ENOBUFS;
378 }
379 }
380 return 0;
381}
382
383int tfrc_rx_hist_init(struct tfrc_rx_hist *h, struct sock *sk)
384{
385 if (tfrc_rx_hist_alloc(h))
386 return -ENOBUFS;
387 /*
388 * Initialise first entry with GSR to start loss detection as early as
389 * possible. Code using this must not use any other fields. The entry
390 * will be overwritten once the CCID updates its received packets.
391 */
392 tfrc_rx_hist_loss_prev(h)->tfrchrx_seqno = dccp_sk(sk)->dccps_gsr;
393 return 0;
394}
395EXPORT_SYMBOL_GPL(tfrc_rx_hist_init);
396
389/** 397/**
390 * tfrc_rx_hist_rtt_last_s - reference entry to compute RTT samples against 398 * tfrc_rx_hist_rtt_last_s - reference entry to compute RTT samples against
391 */ 399 */
diff --git a/net/dccp/ccids/lib/packet_history.h b/net/dccp/ccids/lib/packet_history.h
index 221d8102da51..e9d8097947d5 100644
--- a/net/dccp/ccids/lib/packet_history.h
+++ b/net/dccp/ccids/lib/packet_history.h
@@ -153,7 +153,7 @@ extern int tfrc_rx_handle_loss(struct tfrc_rx_hist *h,
153 struct sock *sk); 153 struct sock *sk);
154extern u32 tfrc_rx_hist_sample_rtt(struct tfrc_rx_hist *h, 154extern u32 tfrc_rx_hist_sample_rtt(struct tfrc_rx_hist *h,
155 const struct sk_buff *skb); 155 const struct sk_buff *skb);
156extern int tfrc_rx_hist_alloc(struct tfrc_rx_hist *h); 156extern int tfrc_rx_hist_init(struct tfrc_rx_hist *h, struct sock *sk);
157extern void tfrc_rx_hist_purge(struct tfrc_rx_hist *h); 157extern void tfrc_rx_hist_purge(struct tfrc_rx_hist *h);
158 158
159#endif /* _DCCP_PKT_HIST_ */ 159#endif /* _DCCP_PKT_HIST_ */