: DCCP patches for 2.6.25
Subsystems (2)
cover : DCCP patches for 2.6.25
Hi David,
Please consider pulling from:
master.kernel.org:/pub/scm/linux/kernel/git/acme/net-2.6.25
Best Regards,
- Arnaldo
b/net/dccp/ccids/Kconfig | 13 b/net/dccp/ccids/ccid3.c | 35 -- b/net/dccp/ccids/ccid3.h | 14 b/net/dccp/ccids/lib/Makefile | 2 b/net/dccp/ccids/lib/loss_interval.c | 14 b/net/dccp/ccids/lib/packet_history.c | 27 - b/net/dccp/ccids/lib/packet_history.h | 3 b/net/dccp/ccids/lib/tfrc.c | 48 +++ b/net/dccp/ccids/lib/tfrc.h | 18 - b/net/dccp/dccp.h | 13 net/dccp/ccids/ccid3.c | 322 ++++++++-------------- net/dccp/ccids/lib/loss_interval.c | 13 net/dccp/ccids/lib/packet_history.c | 496 +++++++++++++++++++--------------- net/dccp/ccids/lib/packet_history.h | 177 ++++-------- 14 files changed, 579 insertions(+), 616 deletions(-)
PATCH 1/7 : Provide central source file and debug facility
From: Gerrit Renker <[email protected]>
This patch changes the tfrc_lib module in the following manner:
(1) a dedicated tfrc source file to call the packet history & loss interval init/exit functions.
(2) a dedicated tfrc_pr_debug macro with toggle switch `tfrc_debug'.
Commiter note: renamed tfrc_module.c to tfrc.c, and made CONFIG_IP_DCCP_CCID3 select IP_DCCP_TFRC_LIB.
--- net/dccp/ccids/Kconfig | 13 ++++++--- net/dccp/ccids/lib/Makefile | 2 +- net/dccp/ccids/lib/packet_history.c | 27 ++----------------- net/dccp/ccids/lib/packet_history.h | 3 +- net/dccp/ccids/lib/tfrc.c | 48 +++++++++++++++++++++++++++++++++++ net/dccp/ccids/lib/tfrc.h | 17 +++++++++--- 6 files changed, 75 insertions(+), 35 deletions(-) create mode 100644 net/dccp/ccids/lib/tfrc.c
net/dccp/ccids/Kconfig +9 -4
@@ -38,6 +38,7 @@ config IP_DCCP_CCID2_DEBUG config IP_DCCP_CCID3 tristate "CCID3 (TCP-Friendly) (EXPERIMENTAL)" def_tristate IP_DCCP + select IP_DCCP_TFRC_LIB ---help--- CCID 3 denotes TCP-Friendly Rate Control (TFRC), an equation-based rate-controlled congestion control mechanism. TFRC is designed to
@@ -63,10 +64,6 @@ config IP_DCCP_CCID3 If in doubt, say M. -config IP_DCCP_TFRC_LIB - depends on IP_DCCP_CCID3 - def_tristate IP_DCCP_CCID3 - config IP_DCCP_CCID3_DEBUG bool "CCID3 debugging messages" depends on IP_DCCP_CCID3
@@ -110,5 +107,13 @@ config IP_DCCP_CCID3_RTO is serious network congestion: experimenting with larger values should therefore not be performed on WANs. +config IP_DCCP_TFRC_LIB + tristate + default n + +config IP_DCCP_TFRC_DEBUG + bool + depends on IP_DCCP_TFRC_LIB + default y if IP_DCCP_CCID3_DEBUG endmenu
net/dccp/ccids/lib/Makefile +1 -1
@@ -1,3 +1,3 @@ obj-$(CONFIG_IP_DCCP_TFRC_LIB) += dccp_tfrc_lib.o -dccp_tfrc_lib-y := loss_interval.o packet_history.o tfrc_equation.o +dccp_tfrc_lib-y := tfrc.o tfrc_equation.o packet_history.o loss_interval.o
net/dccp/ccids/lib/packet_history.c +3 -24
@@ -35,7 +35,6 @@* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <linux/module.h> #include <linux/string.h> #include "packet_history.h"
@@ -277,39 +276,19 @@ void dccp_rx_hist_purge(struct dccp_rx_hist *hist, struct list_head *list)EXPORT_SYMBOL_GPL (dccp_rx_hist_purge); -extern int __init dccp_li_init (void ); -extern void dccp_li_exit (void ); - -static __init int packet_history_init (void ) +__init int packet_history_init (void ) { -if (dccp_li_init () !=0 ) - goto out; - tfrc_tx_hist =kmem_cache_create ("tfrc_tx_hist" ,sizeof (struct tfrc_tx_hist_entry ),0 ,SLAB_HWCACHE_ALIGN ,NULL ); -if (tfrc_tx_hist =NULL ) - goto out_li_exit; -return 0 ; -out_li_exit: -dccp_li_exit (); -out: -return -ENOBUFS ; +return tfrc_tx_hist =NULL ? -ENOBUFS :0 ; } -module_init (packet_history_init); -static __exit void packet_history_exit(void) +void packet_history_exit (void ) {if (tfrc_tx_hist !=NULL ) {kmem_cache_destroy (tfrc_tx_hist); tfrc_tx_hist =NULL ; } -dccp_li_exit (); } -module_exit (packet_history_exit); - -MODULE_AUTHOR ("Ian McDonald <[email protected]>, " -"Arnaldo Carvalho de Melo <[email protected]>" ); -MODULE_DESCRIPTION ("DCCP TFRC library" ); -MODULE_LICENSE ("GPL" );
net/dccp/ccids/lib/packet_history.h +1 -2
@@ -39,8 +39,7 @@#include <linux/ktime.h> #include <linux/list.h> #include <linux/slab.h> - -#include "../../dccp.h" +#include "tfrc.h" /* Number of later packets received before one is considered lost */ #define TFRC_RECV_NUM_LATE_LOSS 3
net/dccp/ccids/lib/tfrc.c new file +48 -0
48 lines not on this page · raw message
net/dccp/ccids/lib/tfrc.h +13 -4
@@ -3,10 +3,11 @@/* * net/dccp/ccids/lib/tfrc.h * -* Copyright (c) 2005 The University of Waikato, Hamilton, New Zealand. -* Copyright (c) 2005 Ian McDonald <[email protected]> -* Copyright (c) 2005 Arnaldo Carvalho de Melo <[email protected]> -* Copyright (c) 2003 Nils-Erik Mattsson, Joacim Haggmark, Magnus Erixzon +* Copyright (c) 2007 The University of Aberdeen, Scotland, UK +* Copyright (c) 2005-6 The University of Waikato, Hamilton, New Zealand. +* Copyright (c) 2005-6 Ian McDonald <[email protected]> +* Copyright (c) 2005 Arnaldo Carvalho de Melo <[email protected]> +* Copyright (c) 2003 Nils-Erik Mattsson, Joacim Haggmark, Magnus Erixzon * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
@@ -15,6 +16,14 @@*/ #include <linux/types.h> #include <asm/div64.h> +#include "../../dccp.h" + +#ifdef CONFIG_IP_DCCP_TFRC_DEBUG +extern int tfrc_debug; +#define tfrc_pr_debug(format, a...) DCCP_PR_DEBUG(tfrc_debug, format, ##a) +#else +#define tfrc_pr_debug(format, a...) +#endif /* integer-arithmetic divisions of type (a * 1000000)/b */ static inline u64 scaled_div (u64 a,u32 b)
Signature · 1 line
1.5.3.4
PATCH 2/7 : Introduce generic function to test for `data packets'
From: Gerrit Renker <[email protected]>
as per RFC 4340, sec. 7.7.
--- net/dccp/dccp.h | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
net/dccp/dccp.h +12 -0
@@ -334,6 +334,7 @@ struct dccp_skb_cb {#define DCCP_SKB_CB (__skb) ((struct dccp_skb_cb *)&((__skb)->cb[0])) +/* RFC 4340, sec. 7.7 */ static inline int dccp_non_data_packet (const struct sk_buff *skb) {const __u8 type =DCCP_SKB_CB (skb)->dccpd_type;
@@ -346,6 +347,17 @@ static inline int dccp_non_data_packet(const struct sk_buff *skb) type =DCCP_PKT_SYNCACK ; } +/* RFC 4340, sec. 7.7 */ +static inline int dccp_data_packet (const struct sk_buff *skb) +{ +const __u8 type =DCCP_SKB_CB (skb)->dccpd_type; + +return type =DCCP_PKT_DATA || + type =DCCP_PKT_DATAACK || + type =DCCP_PKT_REQUEST || + type =DCCP_PKT_RESPONSE ; +} +static inline int dccp_packet_without_ack (const struct sk_buff *skb) {const __u8 type =DCCP_SKB_CB (skb)->dccpd_type;
Signature · 1 line
1.5.3.4
PATCH 3/7 : Rename tfrc_tx_hist to tfrc_tx_hist_slab, for consistency
--- net/dccp/ccids/lib/packet_history.c | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-)
net/dccp/ccids/lib/packet_history.c +10 -10
@@ -53,7 +53,7 @@ struct tfrc_tx_hist_entry {/* * Transmitter History Routines */ -static struct kmem_cache *tfrc_tx_hist; +static struct kmem_cache *tfrc_tx_hist_slab;static struct tfrc_tx_hist_entry *tfrc_tx_hist_find_entry (struct tfrc_tx_hist_entry *head,u64 seqno)
@@ -66,7 +66,7 @@ static struct tfrc_tx_hist_entry *int tfrc_tx_hist_add (struct tfrc_tx_hist_entry **headp,u64 seqno) { -struct tfrc_tx_hist_entry *entry =kmem_cache_alloc (tfrc_tx_hist,gfp_any ()); +struct tfrc_tx_hist_entry *entry =kmem_cache_alloc (tfrc_tx_hist_slab,gfp_any ());if (entry =NULL )return -ENOBUFS ;
@@ -85,7 +85,7 @@ void tfrc_tx_hist_purge(struct tfrc_tx_hist_entry **headp)while (head !=NULL ) {struct tfrc_tx_hist_entry *next = head->next; -kmem_cache_free (tfrc_tx_hist, head); +kmem_cache_free (tfrc_tx_hist_slab, head); head = next; }
@@ -278,17 +278,17 @@ EXPORT_SYMBOL_GPL(dccp_rx_hist_purge);__init int packet_history_init (void ) { - tfrc_tx_hist =kmem_cache_create ("tfrc_tx_hist" , -sizeof (struct tfrc_tx_hist_entry ),0 , -SLAB_HWCACHE_ALIGN ,NULL ); + tfrc_tx_hist_slab =kmem_cache_create ("tfrc_tx_hist" , +sizeof (struct tfrc_tx_hist_entry ),0 , +SLAB_HWCACHE_ALIGN ,NULL ); -return tfrc_tx_hist =NULL ? -ENOBUFS :0 ; +return tfrc_tx_hist_slab =NULL ? -ENOBUFS :0 ; }void packet_history_exit (void ) { -if (tfrc_tx_hist !=NULL ) { -kmem_cache_destroy (tfrc_tx_hist); - tfrc_tx_hist =NULL ; +if (tfrc_tx_hist_slab !=NULL ) { +kmem_cache_destroy (tfrc_tx_hist_slab); + tfrc_tx_hist_slab =NULL ; } }
Signature · 1 line
1.5.3.4
PATCH 4/7 : Make the rx history slab be global
This is in preparation for merging the new rx history code written by Gerrit Renker.
--- net/dccp/ccids/ccid3.c | 35 ++----------- net/dccp/ccids/lib/packet_history.c | 95 ++++++++++++++++++----------------- net/dccp/ccids/lib/packet_history.h | 43 ++-------------- 3 files changed, 60 insertions(+), 113 deletions(-)
net/dccp/ccids/ccid3.c +6 -29
@@ -49,8 +49,6 @@ static int ccid3_debug; #define ccid3_pr_debug(format, a...)#endif -static struct dccp_rx_hist *ccid3_rx_hist; -/* * Transmitter Half-Connection Routines */
@@ -807,9 +805,9 @@ static int ccid3_hc_rx_detect_loss(struct sock *sk, } detect_out: -dccp_rx_hist_add_packet (ccid3_rx_hist, &hcrx->ccid3hcrx_hist, - &hcrx->ccid3hcrx_li_hist, packet, - hcrx->ccid3hcrx_seqno_nonloss); +dccp_rx_hist_add_packet (&hcrx->ccid3hcrx_hist, + &hcrx->ccid3hcrx_li_hist, packet, + hcrx->ccid3hcrx_seqno_nonloss);return loss; }
@@ -852,8 +850,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)return ; } - packet =dccp_rx_hist_entry_new (ccid3_rx_hist, opt_recv->dccpor_ndp, - skb,GFP_ATOMIC ); + packet =dccp_rx_hist_entry_new (opt_recv->dccpor_ndp, skb,GFP_ATOMIC );if (unlikely (packet =NULL )) {DCCP_WARN ("%s(%p), Not enough mem to add rx packet " "to history, consider it lost!\n" ,dccp_role (sk), sk);
@@ -936,7 +933,7 @@ static void ccid3_hc_rx_exit(struct sock *sk)ccid3_hc_rx_set_state (sk,TFRC_RSTATE_TERM );/* Empty packet history */ -dccp_rx_hist_purge (ccid3_rx_hist, &hcrx->ccid3hcrx_hist); +dccp_rx_hist_purge (&hcrx->ccid3hcrx_hist);/* Empty loss interval history */ dccp_li_hist_purge (&hcrx->ccid3hcrx_li_hist);
@@ -1013,33 +1010,13 @@ MODULE_PARM_DESC(ccid3_debug, "Enable debug messages");static __init int ccid3_module_init (void ) { -int rc = -ENOBUFS ; - - ccid3_rx_hist =dccp_rx_hist_new ("ccid3" ); -if (ccid3_rx_hist =NULL ) - goto out; - - rc =ccid_register (&ccid3); -if (rc !=0 ) - goto out_free_rx; -out: -return rc; - -out_free_rx: -dccp_rx_hist_delete (ccid3_rx_hist); - ccid3_rx_hist =NULL ; - goto out; +return ccid_register (&ccid3); }module_init (ccid3_module_init); static __exit void ccid3_module_exit(void) {ccid_unregister (&ccid3); - -if (ccid3_rx_hist !=NULL ) { -dccp_rx_hist_delete (ccid3_rx_hist); - ccid3_rx_hist =NULL ; - } }module_exit (ccid3_module_exit);
net/dccp/ccids/lib/packet_history.c +49 -46
147 lines not on this page · raw message
net/dccp/ccids/lib/packet_history.h +5 -38
60 lines not on this page · raw message
Signature · 1 line
1.5.3.4
PATCH 5/7 : Rename dccp_rx_ to tfrc_rx_
This is in preparation for merging the new rx history code written by Gerrit Renker.
--- net/dccp/ccids/ccid3.c | 32 ++++++------ net/dccp/ccids/lib/loss_interval.c | 14 +++--- net/dccp/ccids/lib/packet_history.c | 90 +++++++++++++++++----------------- net/dccp/ccids/lib/packet_history.h | 48 +++++++++--------- 4 files changed, 92 insertions(+), 92 deletions(-)
net/dccp/ccids/ccid3.c +15 -15
@@ -677,7 +677,7 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk) {struct ccid3_hc_rx_sock *hcrx =ccid3_hc_rx_sk (sk);struct dccp_sock *dp =dccp_sk (sk); -struct dccp_rx_hist_entry *packet; +struct tfrc_rx_hist_entry *packet;ktime_t now;suseconds_t delta;
@@ -701,7 +701,7 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk)return ; } - packet =dccp_rx_hist_find_data_packet (&hcrx->ccid3hcrx_hist); + packet =tfrc_rx_hist_find_data_packet (&hcrx->ccid3hcrx_hist);if (unlikely (packet =NULL )) {DCCP_WARN ("%s(%p), no data packet in history!\n" ,dccp_role (sk), sk);
@@ -709,7 +709,7 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk) } hcrx->ccid3hcrx_tstamp_last_feedback = now; - hcrx->ccid3hcrx_ccval_last_counter = packet->dccphrx_ccval; + hcrx->ccid3hcrx_ccval_last_counter = packet->tfrchrx_ccval; hcrx->ccid3hcrx_bytes_recv =0 ;if (hcrx->ccid3hcrx_p =0 )
@@ -752,12 +752,12 @@ static int ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb) }static int ccid3_hc_rx_detect_loss (struct sock *sk, -struct dccp_rx_hist_entry *packet) +struct tfrc_rx_hist_entry *packet) {struct ccid3_hc_rx_sock *hcrx =ccid3_hc_rx_sk (sk); - struct dccp_rx_hist_entry *rx_hist - dccp_rx_hist_head(&hcrx->ccid3hcrx_hist); -u64 seqno = packet->dccphrx_seqno; + struct tfrc_rx_hist_entry *rx_hist + tfrc_rx_hist_head(&hcrx->ccid3hcrx_hist); +u64 seqno = packet->tfrchrx_seqno;u64 tmp_seqno;int loss =0 ;u8 ccval;
@@ -766,9 +766,9 @@ static int ccid3_hc_rx_detect_loss(struct sock *sk, tmp_seqno = hcrx->ccid3hcrx_seqno_nonloss;if (!rx_hist || -follows48 (packet->dccphrx_seqno, hcrx->ccid3hcrx_seqno_nonloss)) { +follows48 (packet->tfrchrx_seqno, hcrx->ccid3hcrx_seqno_nonloss)) { hcrx->ccid3hcrx_seqno_nonloss = seqno; - hcrx->ccid3hcrx_ccval_nonloss = packet->dccphrx_ccval; + hcrx->ccid3hcrx_ccval_nonloss = packet->tfrchrx_ccval; goto detect_out; }
@@ -789,7 +789,7 @@ static int ccid3_hc_rx_detect_loss(struct sock *sk,dccp_inc_seqno (&tmp_seqno); hcrx->ccid3hcrx_seqno_nonloss = tmp_seqno;dccp_inc_seqno (&tmp_seqno); -while (dccp_rx_hist_find_entry (&hcrx->ccid3hcrx_hist, +while (tfrc_rx_hist_find_entry (&hcrx->ccid3hcrx_hist, tmp_seqno, &ccval)) { hcrx->ccid3hcrx_seqno_nonloss = tmp_seqno; hcrx->ccid3hcrx_ccval_nonloss = ccval;
@@ -799,13 +799,13 @@ static int ccid3_hc_rx_detect_loss(struct sock *sk,/* FIXME - this code could be simplified with above while */ /* but works at moment */ -if (follows48 (packet->dccphrx_seqno, hcrx->ccid3hcrx_seqno_nonloss)) { +if (follows48 (packet->tfrchrx_seqno, hcrx->ccid3hcrx_seqno_nonloss)) { hcrx->ccid3hcrx_seqno_nonloss = seqno; - hcrx->ccid3hcrx_ccval_nonloss = packet->dccphrx_ccval; + hcrx->ccid3hcrx_ccval_nonloss = packet->tfrchrx_ccval; } detect_out: -dccp_rx_hist_add_packet (&hcrx->ccid3hcrx_hist, +tfrc_rx_hist_add_packet (&hcrx->ccid3hcrx_hist, &hcrx->ccid3hcrx_li_hist, packet, hcrx->ccid3hcrx_seqno_nonloss);return loss;
@@ -815,7 +815,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) {struct ccid3_hc_rx_sock *hcrx =ccid3_hc_rx_sk (sk);const struct dccp_options_received *opt_recv; -struct dccp_rx_hist_entry *packet; +struct tfrc_rx_hist_entry *packet;u32 p_prev, r_sample, rtt_prev;int loss, payload_size;ktime_t now;
@@ -850,7 +850,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)return ; } - packet =dccp_rx_hist_entry_new (opt_recv->dccpor_ndp, skb,GFP_ATOMIC ); + packet =tfrc_rx_hist_entry_new (opt_recv->dccpor_ndp, skb,GFP_ATOMIC );if (unlikely (packet =NULL )) {DCCP_WARN ("%s(%p), Not enough mem to add rx packet " "to history, consider it lost!\n" ,dccp_role (sk), sk);
@@ -933,7 +933,7 @@ static void ccid3_hc_rx_exit(struct sock *sk)ccid3_hc_rx_set_state (sk,TFRC_RSTATE_TERM );/* Empty packet history */ -dccp_rx_hist_purge (&hcrx->ccid3hcrx_hist); +tfrc_rx_hist_purge (&hcrx->ccid3hcrx_hist);/* Empty loss interval history */ dccp_li_hist_purge (&hcrx->ccid3hcrx_li_hist);
net/dccp/ccids/lib/loss_interval.c +7 -7
@@ -129,7 +129,7 @@ static u32 dccp_li_calc_first_li(struct sock *sk, u16 s, u32 bytes_recv, u32 previous_x_recv) { - struct dccp_rx_hist_entry *entry, *next, *tail = NULL; + struct tfrc_rx_hist_entry *entry, *next, *tail = NULL;u32 x_recv, p;suseconds_t rtt, delta;ktime_t tstamp =ktime_set (0 ,0 );
@@ -138,18 +138,18 @@ static u32 dccp_li_calc_first_li(struct sock *sk,int step =0 ;u64 fval; -list_for_each_entry_safe (entry, next, hist_list, dccphrx_node) { -if (dccp_rx_hist_entry_data_packet (entry)) { +list_for_each_entry_safe (entry, next, hist_list, tfrchrx_node) { +if (tfrc_rx_hist_entry_data_packet (entry)) { tail = entry;switch (step) {case 0 : - tstamp = entry->dccphrx_tstamp; - win_count = entry->dccphrx_ccval; + tstamp = entry->tfrchrx_tstamp; + win_count = entry->tfrchrx_ccval; step =1 ;break ;case 1 : - interval = win_count - entry->dccphrx_ccval; + interval = win_count - entry->tfrchrx_ccval;if (interval <0 ) interval +=TFRC_WIN_COUNT_LIMIT ;if (interval >4 )
@@ -176,7 +176,7 @@ found:return ~0 ; } - delta =ktime_us_delta (tstamp, tail->dccphrx_tstamp); + delta =ktime_us_delta (tstamp, tail->tfrchrx_tstamp);DCCP_BUG_ON (delta <0 ); rtt = delta *4 / interval;
net/dccp/ccids/lib/packet_history.c +45 -45
185 lines not on this page · raw message
net/dccp/ccids/lib/packet_history.h +24 -24
75 lines not on this page · raw message
Signature · 1 line
1.5.3.4
PATCH 6/7 : The receiver of a half-connection does not set window counter values
From: Gerrit Renker <[email protected]>
Only the sender sets window counters [RFC 4342, sections 5 and 8.1].
--- net/dccp/ccids/ccid3.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
net/dccp/ccids/ccid3.c +0 -1
@@ -733,7 +733,6 @@ static int ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb)return 0 ; hcrx =ccid3_hc_rx_sk (sk); -DCCP_SKB_CB (skb)->dccpd_ccval = hcrx->ccid3hcrx_ccval_last_counter;if (dccp_packet_without_ack (skb))return 0 ;
Signature · 1 line
1.5.3.4
PATCH 7/7 : New rx history code
Credit here goes to Gerrit Renker, that provided the initial implementation for this new codebase.
I modified it just to try to make it closer to the existing API, renaming some functions, add namespacing and fix one bug where the tfrc_rx_hist_alloc was not freeing the allocated ring entries on the error path.
Original changeset comment from Gerrit:
-----------
This provides a new, self-contained and generic RX history service for TFRC based protocols.
Details:
* new data structure, initialisation and cleanup routines;
* allocation of dccp_rx_hist entries local to packet_history.c, as a service exported by the dccp_tfrc_lib module.
* interface to automatically track highest-received seqno;
* receiver-based RTT estimation (needed for instance by RFC 3448, 6.3.1);
* a generic function to test for `data packets' as per RFC 4340, sec. 7.7.
--- net/dccp/ccids/ccid3.c | 288 ++++++++++++---------------------- net/dccp/ccids/ccid3.h | 14 +- net/dccp/ccids/lib/loss_interval.c | 13 ++- net/dccp/ccids/lib/packet_history.c | 290 +++++++++++++++++++++-------------- net/dccp/ccids/lib/packet_history.h | 83 +++++------ 5 files changed, 330 insertions(+), 358 deletions(-)
net/dccp/ccids/ccid3.c +101 -183
@@ -641,6 +641,15 @@ static int ccid3_hc_tx_getsockopt(struct sock *sk, const int optname, int len,/* * Receiver Half-Connection Routines */ + +/* CCID3 feedback types */ +enum ccid3_fback_type { +CCID3_FBACK_NONE =0 , +CCID3_FBACK_INITIAL , +CCID3_FBACK_PERIODIC , +CCID3_FBACK_PARAM_CHANGE +}; +#ifdef CONFIG_IP_DCCP_CCID3_DEBUG static const char *ccid3_rx_state_name (enum ccid3_hc_rx_states state) {
@@ -667,59 +676,60 @@ static void ccid3_hc_rx_set_state(struct sock *sk, hcrx->ccid3hcrx_state = state; } -static inline void ccid3_hc_rx_update_s (struct ccid3_hc_rx_sock *hcrx,int len) -{ -if (likely (len >0 ))/* don't update on empty packets (e.g. ACKs) */ - hcrx->ccid3hcrx_s =tfrc_ewma (hcrx->ccid3hcrx_s, len,9 ); -} - -static void ccid3_hc_rx_send_feedback (struct sock *sk) +static void ccid3_hc_rx_send_feedback (struct sock *sk, +const struct sk_buff *skb, +enum ccid3_fback_type fbtype) {struct ccid3_hc_rx_sock *hcrx =ccid3_hc_rx_sk (sk);struct dccp_sock *dp =dccp_sk (sk); -struct tfrc_rx_hist_entry *packet;ktime_t now; -suseconds_t delta; +s64 delta =0 ;ccid3_pr_debug ("%s(%p) - entry \n" ,dccp_role (sk), sk); +if (unlikely (hcrx->ccid3hcrx_state =TFRC_RSTATE_TERM )) +return ; + now =ktime_get_real (); -switch (hcrx->ccid3hcrx_state) { -case TFRC_RSTATE_NO_DATA : +switch (fbtype) { +case CCID3_FBACK_INITIAL : hcrx->ccid3hcrx_x_recv =0 ; + hcrx->ccid3hcrx_pinv = ~0U ;/* see RFC 4342, 8.5 */ break ; -case TFRC_RSTATE_DATA : - delta =ktime_us_delta (now, - hcrx->ccid3hcrx_tstamp_last_feedback); -DCCP_BUG_ON (delta <0 ); - hcrx->ccid3hcrx_x_recv -scaled_div32 (hcrx->ccid3hcrx_bytes_recv, delta); +case CCID3_FBACK_PARAM_CHANGE : +/* +* When parameters change (new loss or p > p_prev), we do not +* have a reliable estimate for R_m of [RFC 3448, 6.2] and so +* need to reuse the previous value of X_recv. However, when +* X_recv was 0 (due to early loss), this would kill X down to +* s/t_mbi (i.e. one packet in 64 seconds). +* To avoid such drastic reduction, we approximate X_recv as +* the number of bytes since last feedback. +* This is a safe fallback, since X is bounded above by X_calc. +*/ +if (hcrx->ccid3hcrx_x_recv >0 ) +break ; +/* fall through */ +case CCID3_FBACK_PERIODIC : + delta =ktime_us_delta (now, hcrx->ccid3hcrx_tstamp_last_feedback); +if (delta <=0 ) +DCCP_BUG ("delta (%ld) <= 0" , (long )delta); +else + hcrx->ccid3hcrx_x_recv +scaled_div32 (hcrx->ccid3hcrx_bytes_recv, delta);break ; -case TFRC_RSTATE_TERM : -DCCP_BUG ("%s(%p) - Illegal state TERM" ,dccp_role (sk), sk); +default :return ; } - packet =tfrc_rx_hist_find_data_packet (&hcrx->ccid3hcrx_hist); -if (unlikely (packet =NULL )) { -DCCP_WARN ("%s(%p), no data packet in history!\n" , -dccp_role (sk), sk); -return ; - } +ccid3_pr_debug ("Interval %ldusec, X_recv=%u, 1/p=%u\n" , (long )delta, + hcrx->ccid3hcrx_x_recv, hcrx->ccid3hcrx_pinv); hcrx->ccid3hcrx_tstamp_last_feedback = now; - hcrx->ccid3hcrx_ccval_last_counter = packet->tfrchrx_ccval; + hcrx->ccid3hcrx_last_counter =dccp_hdr (skb)->dccph_ccval; hcrx->ccid3hcrx_bytes_recv =0 ; -if (hcrx->ccid3hcrx_p =0 ) - hcrx->ccid3hcrx_pinv = ~0U ;/* see RFC 4342, 8.5 */ -else if (hcrx->ccid3hcrx_p >1000000 ) { -DCCP_WARN ("p (%u) > 100%%\n" , hcrx->ccid3hcrx_p); - hcrx->ccid3hcrx_pinv =1 ;/* use 100% in this case */ - }else - hcrx->ccid3hcrx_pinv =1000000 / hcrx->ccid3hcrx_p; - dp->dccps_hc_rx_insert_options =1 ;dccp_send_ack (sk); }
@@ -750,165 +760,74 @@ static int ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb)return 0 ; } -static int ccid3_hc_rx_detect_loss (struct sock *sk, -struct tfrc_rx_hist_entry *packet) -{ -struct ccid3_hc_rx_sock *hcrx =ccid3_hc_rx_sk (sk); - struct tfrc_rx_hist_entry *rx_hist - tfrc_rx_hist_head(&hcrx->ccid3hcrx_hist); -u64 seqno = packet->tfrchrx_seqno; -u64 tmp_seqno; -int loss =0 ; -u8 ccval; - - - tmp_seqno = hcrx->ccid3hcrx_seqno_nonloss; - -if (!rx_hist || -follows48 (packet->tfrchrx_seqno, hcrx->ccid3hcrx_seqno_nonloss)) { - hcrx->ccid3hcrx_seqno_nonloss = seqno; - hcrx->ccid3hcrx_ccval_nonloss = packet->tfrchrx_ccval; - goto detect_out; - } - - -while (dccp_delta_seqno (hcrx->ccid3hcrx_seqno_nonloss, seqno) - >TFRC_RECV_NUM_LATE_LOSS ) { - loss =1 ; -dccp_li_update_li (sk, - &hcrx->ccid3hcrx_li_hist, - &hcrx->ccid3hcrx_hist, - hcrx->ccid3hcrx_tstamp_last_feedback, - hcrx->ccid3hcrx_s, - hcrx->ccid3hcrx_bytes_recv, - hcrx->ccid3hcrx_x_recv, - hcrx->ccid3hcrx_seqno_nonloss, - hcrx->ccid3hcrx_ccval_nonloss); - tmp_seqno = hcrx->ccid3hcrx_seqno_nonloss; -dccp_inc_seqno (&tmp_seqno); - hcrx->ccid3hcrx_seqno_nonloss = tmp_seqno; -dccp_inc_seqno (&tmp_seqno); -while (tfrc_rx_hist_find_entry (&hcrx->ccid3hcrx_hist, - tmp_seqno, &ccval)) { - hcrx->ccid3hcrx_seqno_nonloss = tmp_seqno; - hcrx->ccid3hcrx_ccval_nonloss = ccval; -dccp_inc_seqno (&tmp_seqno); - } - } - -/* FIXME - this code could be simplified with above while */ -/* but works at moment */ -if (follows48 (packet->tfrchrx_seqno, hcrx->ccid3hcrx_seqno_nonloss)) { - hcrx->ccid3hcrx_seqno_nonloss = seqno; - hcrx->ccid3hcrx_ccval_nonloss = packet->tfrchrx_ccval; - } - -detect_out: -tfrc_rx_hist_add_packet (&hcrx->ccid3hcrx_hist, - &hcrx->ccid3hcrx_li_hist, packet, - hcrx->ccid3hcrx_seqno_nonloss); -return loss; -} -static void ccid3_hc_rx_packet_recv (struct sock *sk,struct sk_buff *skb) {struct ccid3_hc_rx_sock *hcrx =ccid3_hc_rx_sk (sk); -const struct dccp_options_received *opt_recv; -struct tfrc_rx_hist_entry *packet; -u32 p_prev, r_sample, rtt_prev; -int loss, payload_size; -ktime_t now; - - opt_recv = &dccp_sk (sk)->dccps_options_received; - -switch (DCCP_SKB_CB (skb)->dccpd_type) { -case DCCP_PKT_ACK : -if (hcrx->ccid3hcrx_state =TFRC_RSTATE_NO_DATA ) -return ; -case DCCP_PKT_DATAACK : -if (opt_recv->dccpor_timestamp_echo =0 ) -break ; - r_sample =dccp_timestamp () - opt_recv->dccpor_timestamp_echo; - rtt_prev = hcrx->ccid3hcrx_rtt; - r_sample =dccp_sample_rtt (sk,10 * r_sample); - -if (hcrx->ccid3hcrx_state =TFRC_RSTATE_NO_DATA ) - hcrx->ccid3hcrx_rtt = r_sample; -else - hcrx->ccid3hcrx_rtt = (hcrx->ccid3hcrx_rtt *9 ) /10 + - r_sample /10 ; - -if (rtt_prev != hcrx->ccid3hcrx_rtt) -ccid3_pr_debug ("%s(%p), New RTT=%uus, elapsed time=%u\n" , -dccp_role (sk), sk, hcrx->ccid3hcrx_rtt, - opt_recv->dccpor_elapsed_time); -break ; -case DCCP_PKT_DATA : -break ; -default :/* We're not interested in other packet types, move along */ -return ; - } - - packet =tfrc_rx_hist_entry_new (opt_recv->dccpor_ndp, skb,GFP_ATOMIC ); -if (unlikely (packet =NULL )) { -DCCP_WARN ("%s(%p), Not enough mem to add rx packet " -"to history, consider it lost!\n" ,dccp_role (sk), sk); -return ; - } - - loss =ccid3_hc_rx_detect_loss (sk, packet); +enum ccid3_fback_type do_feedback =CCID3_FBACK_NONE ; +const u32 ndp =dccp_sk (sk)->dccps_options_received.dccpor_ndp; +const bool is_data_packet =dccp_data_packet (skb); + +if (unlikely (hcrx->ccid3hcrx_state =TFRC_RSTATE_NO_DATA )) { +if (is_data_packet) { +const u32 payload = skb->len -dccp_hdr (skb)->dccph_doff *4 ; + do_feedback =CCID3_FBACK_INITIAL ; +ccid3_hc_rx_set_state (sk,TFRC_RSTATE_DATA ); + hcrx->ccid3hcrx_s = payload; +/* +* Not necessary to update ccid3hcrx_bytes_recv here, +* since X_recv = 0 for the first feedback packet (cf. +* RFC 3448, 6.3) -- gerrit +*/ + } + goto update_records; + } -if (DCCP_SKB_CB (skb)->dccpd_type =DCCP_PKT_ACK ) -return ; +if (tfrc_rx_hist_duplicate (&hcrx->ccid3hcrx_hist, skb)) +return ;/* done receiving */ - payload_size = skb->len -dccp_hdr (skb)->dccph_doff *4 ; -ccid3_hc_rx_update_s (hcrx, payload_size); +if (is_data_packet) { +const u32 payload = skb->len -dccp_hdr (skb)->dccph_doff *4 ; +/* +* Update moving-average of s and the sum of received payload bytes +*/ + hcrx->ccid3hcrx_s =tfrc_ewma (hcrx->ccid3hcrx_s, payload,9 ); + hcrx->ccid3hcrx_bytes_recv += payload; + } -switch (hcrx->ccid3hcrx_state) { -case TFRC_RSTATE_NO_DATA : -ccid3_pr_debug ("%s(%p, state=%s), skb=%p, sending initial " -"feedback\n" ,dccp_role (sk), sk, -dccp_state_name (sk->sk_state), skb); -ccid3_hc_rx_send_feedback (sk); -ccid3_hc_rx_set_state (sk,TFRC_RSTATE_DATA ); -return ; -case TFRC_RSTATE_DATA : - hcrx->ccid3hcrx_bytes_recv += payload_size; -if (loss) -break ; +/* +* Handle pending losses and otherwise check for new loss +*/ +if (tfrc_rx_hist_new_loss_indicated (&hcrx->ccid3hcrx_hist, skb, ndp)) + goto update_records; - now =ktime_get_real (); -if ((ktime_us_delta (now, hcrx->ccid3hcrx_tstamp_last_ack) - - (s64 )hcrx->ccid3hcrx_rtt) >=0 ) { - hcrx->ccid3hcrx_tstamp_last_ack = now; -ccid3_hc_rx_send_feedback (sk); - } -return ; -case TFRC_RSTATE_TERM : -DCCP_BUG ("%s(%p) - Illegal state TERM" ,dccp_role (sk), sk); -return ; +/* +* Handle data packets: RTT sampling and monitoring p +*/ +if (unlikely (!is_data_packet)) + goto update_records; + +if (list_empty (&hcrx->ccid3hcrx_li_hist)) {/* no loss so far: p = 0 */ +const u32 sample =tfrc_rx_hist_sample_rtt (&hcrx->ccid3hcrx_hist, skb); +/* +* Empty loss history: no loss so far, hence p stays 0. +* Sample RTT values, since an RTT estimate is required for the +* computation of p when the first loss occurs; RFC 3448, 6.3.1. +*/ +if (sample !=0 ) + hcrx->ccid3hcrx_rtt =tfrc_ewma (hcrx->ccid3hcrx_rtt, sample,9 ); } -/* Dealing with packet loss */ -ccid3_pr_debug ("%s(%p, state=%s), data loss! Reacting...\n" , -dccp_role (sk), sk,dccp_state_name (sk->sk_state)); - - p_prev = hcrx->ccid3hcrx_p; - -/* Calculate loss event rate */ -if (!list_empty (&hcrx->ccid3hcrx_li_hist)) { -u32 i_mean =dccp_li_hist_calc_i_mean (&hcrx->ccid3hcrx_li_hist); +/* +* Check if the periodic once-per-RTT feedback is due; RFC 4342, 10.3 +*/ +if (SUB16 (dccp_hdr (skb)->dccph_ccval, hcrx->ccid3hcrx_last_counter) >3 ) + do_feedback =CCID3_FBACK_PERIODIC ; -/* Scaling up by 1000000 as fixed decimal */ -if (i_mean !=0 ) - hcrx->ccid3hcrx_p =1000000 / i_mean; - }else -DCCP_BUG ("empty loss history" ); +update_records: +tfrc_rx_hist_add_packet (&hcrx->ccid3hcrx_hist, skb, ndp); -if (hcrx->ccid3hcrx_p > p_prev) { -ccid3_hc_rx_send_feedback (sk); -return ; - } +if (do_feedback) +ccid3_hc_rx_send_feedback (sk, skb, do_feedback); }static int ccid3_hc_rx_init (struct ccid *ccid,struct sock *sk)
@@ -918,11 +837,8 @@ static int ccid3_hc_rx_init(struct ccid *ccid, struct sock *sk)ccid3_pr_debug ("entry\n" ); hcrx->ccid3hcrx_state =TFRC_RSTATE_NO_DATA ; -INIT_LIST_HEAD (&hcrx->ccid3hcrx_hist);INIT_LIST_HEAD (&hcrx->ccid3hcrx_li_hist); - hcrx->ccid3hcrx_tstamp_last_feedback - hcrx->ccid3hcrx_tstamp_last_ack =ktime_get_real (); -return 0 ; +return tfrc_rx_hist_alloc (&hcrx->ccid3hcrx_hist); }static void ccid3_hc_rx_exit (struct sock *sk)
net/dccp/ccids/ccid3.h +5 -9
@@ -1,7 +1,8 @@/* * net/dccp/ccids/ccid3.h * -* Copyright (c) 2005-6 The University of Waikato, Hamilton, New Zealand. +* Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand. +* Copyright (c) 2007 The University of Aberdeen, Scotland, UK * * An implementation of the DCCP protocol *
@@ -135,9 +136,7 @@ enum ccid3_hc_rx_states {* @ccid3hcrx_x_recv - Receiver estimate of send rate (RFC 3448 4.3) * @ccid3hcrx_rtt - Receiver estimate of rtt (non-standard) * @ccid3hcrx_p - current loss event rate (RFC 3448 5.4) -* @ccid3hcrx_seqno_nonloss - Last received non-loss sequence number -* @ccid3hcrx_ccval_nonloss - Last received non-loss Window CCVal -* @ccid3hcrx_ccval_last_counter - Tracks window counter (RFC 4342, 8.1) +* @ccid3hcrx_last_counter - Tracks window counter (RFC 4342, 8.1) * @ccid3hcrx_state - receiver state, one of %ccid3_hc_rx_states * @ccid3hcrx_bytes_recv - Total sum of DCCP payload bytes * @ccid3hcrx_tstamp_last_feedback - Time at which last feedback was sent
@@ -152,14 +151,11 @@ struct ccid3_hc_rx_sock {#define ccid3hcrx_x_recv ccid3hcrx_tfrc.tfrcrx_x_recv#define ccid3hcrx_rtt ccid3hcrx_tfrc.tfrcrx_rtt#define ccid3hcrx_p ccid3hcrx_tfrc.tfrcrx_p - u64 ccid3hcrx_seqno_nonloss:48, - ccid3hcrx_ccval_nonloss:4, - ccid3hcrx_ccval_last_counter:4; + u8 ccid3hcrx_last_counter:4; enum ccid3_hc_rx_states ccid3hcrx_state:8;u32 ccid3hcrx_bytes_recv;ktime_t ccid3hcrx_tstamp_last_feedback; -ktime_t ccid3hcrx_tstamp_last_ack; -struct list_head ccid3hcrx_hist; +struct tfrc_rx_hist ccid3hcrx_hist;struct list_head ccid3hcrx_li_hist;u16 ccid3hcrx_s;u32 ccid3hcrx_pinv;
net/dccp/ccids/lib/loss_interval.c +10 -3
@@ -129,6 +129,13 @@ static u32 dccp_li_calc_first_li(struct sock *sk, u16 s, u32 bytes_recv, u32 previous_x_recv) { +/* +* FIXME: +* Will be rewritten in the upcoming new loss intervals code. +* Has to be commented ou because it relies on the old rx history +* data structures +*/ +#if 0 struct tfrc_rx_hist_entry *entry, *next, *tail =NULL ;u32 x_recv, p;suseconds_t rtt, delta;
@@ -216,10 +223,10 @@ found:dccp_pr_debug ("%s(%p), receive rate=%u bytes/s, implied " "loss rate=%u\n" ,dccp_role (sk), sk, x_recv, p); -if (p =0 ) -return ~0 ; -else +if (p !=0 )return 1000000 / p; +#endif +return ~0 ; } void dccp_li_update_li(struct sock *sk,
net/dccp/ccids/lib/packet_history.c +176 -114
337 lines not on this page · raw message
net/dccp/ccids/lib/packet_history.h +37 -46
105 lines not on this page · raw message
Signature · 1 line
1.5.3.4
David Miller
maintainerFrom: Arnaldo Carvalho de Melo <[email protected]>
Date: Thu, 6 Dec 2007 19:02:47 -0200
Quoted 3 lines
Please consider pulling from:
master.kernel.org:/pub/scm/linux/kernel/git/acme/net-2.6.25
Pulled and pushed out to net-2.6.25, thanks!