Commit 4259cb25 authored by Linus Torvalds's avatar Linus Torvalds

Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6

* master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6: (32 commits)
  [NETPOLL]: Fix local_bh_enable() warning.
  [IPVS]: Make ip_vs_sync.c <= 80col wide.
  [IPVS]: Use msleep_interruptable() instead of ssleep() aka msleep()
  [HAMRADIO]: Fix baycom_epp.c compile failure.
  [DCCP]: Whitespace cleanups
  [DCCP] ccid3: Fixup some type conversions related to rtts
  [DCCP] ccid3: BUG-FIX - conversion errors
  [DCCP] ccid3: Reorder packet history source file
  [DCCP] ccid3: Reorder packet history header file
  [DCCP] ccid3: Make debug output consistent
  [DCCP] ccid3: Perform history operations only after packet has been sent
  [DCCP] ccid3: TX history - remove unused field
  [DCCP] ccid3: Shift window counter computation
  [DCCP] ccid3: Sanity-check RTT samples
  [DCCP] ccid3: Initialise RTT values
  [DCCP] ccid: Deprecate ccid_hc_tx_insert_options
  [DCCP]: Warn when discarding packet due to internal errors
  [DCCP]: Only deliver to the CCID rx side in charge
  [DCCP]: Simplify TFRC calculation
  [DCCP]: Debug timeval operations
  ...
parents cd39301a a49f99ff
...@@ -19,7 +19,8 @@ for real time and multimedia traffic. ...@@ -19,7 +19,8 @@ for real time and multimedia traffic.
It has a base protocol and pluggable congestion control IDs (CCIDs). It has a base protocol and pluggable congestion control IDs (CCIDs).
It is at experimental RFC status and the homepage for DCCP as a protocol is at: It is at proposed standard RFC status and the homepage for DCCP as a protocol
is at:
http://www.read.cs.ucla.edu/dccp/ http://www.read.cs.ucla.edu/dccp/
Missing features Missing features
...@@ -34,9 +35,6 @@ The known bugs are at: ...@@ -34,9 +35,6 @@ The known bugs are at:
Socket options Socket options
============== ==============
DCCP_SOCKOPT_PACKET_SIZE is used for CCID3 to set default packet size for
calculations.
DCCP_SOCKOPT_SERVICE sets the service. The specification mandates use of DCCP_SOCKOPT_SERVICE sets the service. The specification mandates use of
service codes (RFC 4340, sec. 8.1.2); if this socket option is not set, service codes (RFC 4340, sec. 8.1.2); if this socket option is not set,
the socket will fall back to 0 (which means that no meaningful service code the socket will fall back to 0 (which means that no meaningful service code
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#define SHA384_DIGEST_SIZE 48 #define SHA384_DIGEST_SIZE 48
#define SHA512_DIGEST_SIZE 64 #define SHA512_DIGEST_SIZE 64
#define SHA384_HMAC_BLOCK_SIZE 96 #define SHA384_HMAC_BLOCK_SIZE 128
#define SHA512_HMAC_BLOCK_SIZE 128 #define SHA512_HMAC_BLOCK_SIZE 128
struct sha512_ctx { struct sha512_ctx {
......
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
fore200e_mkfirm fore200e_mkfirm
fore200e_pca_fw.c fore200e_pca_fw.c
pca200e.bin pca200e.bin
pca200e_ecd.bin2
...@@ -1177,7 +1177,7 @@ static void baycom_probe(struct net_device *dev) ...@@ -1177,7 +1177,7 @@ static void baycom_probe(struct net_device *dev)
dev->mtu = AX25_DEF_PACLEN; /* eth_mtu is the default */ dev->mtu = AX25_DEF_PACLEN; /* eth_mtu is the default */
dev->addr_len = AX25_ADDR_LEN; /* sizeof an ax.25 address */ dev->addr_len = AX25_ADDR_LEN; /* sizeof an ax.25 address */
memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN); memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN);
memcpy(dev->dev_addr, &ax25_nocall, AX25_ADDR_LEN); memcpy(dev->dev_addr, &null_ax25_address, AX25_ADDR_LEN);
dev->tx_queue_len = 16; dev->tx_queue_len = 16;
/* New style flags */ /* New style flags */
......
...@@ -382,7 +382,7 @@ config SDLA ...@@ -382,7 +382,7 @@ config SDLA
# Wan router core. # Wan router core.
config WAN_ROUTER_DRIVERS config WAN_ROUTER_DRIVERS
bool "WAN router drivers" tristate "WAN router drivers"
depends on WAN && WAN_ROUTER depends on WAN && WAN_ROUTER
---help--- ---help---
Connect LAN to WAN via Linux box. Connect LAN to WAN via Linux box.
...@@ -393,7 +393,8 @@ config WAN_ROUTER_DRIVERS ...@@ -393,7 +393,8 @@ config WAN_ROUTER_DRIVERS
<file:Documentation/networking/wan-router.txt>. <file:Documentation/networking/wan-router.txt>.
Note that the answer to this question won't directly affect the Note that the answer to this question won't directly affect the
kernel: saying N will just cause the configurator to skip all kernel except for how subordinate drivers may be built:
saying N will just cause the configurator to skip all
the questions about WAN router drivers. the questions about WAN router drivers.
If unsure, say N. If unsure, say N.
......
...@@ -176,7 +176,7 @@ enum { ...@@ -176,7 +176,7 @@ enum {
}; };
/* DCCP features (RFC 4340 section 6.4) */ /* DCCP features (RFC 4340 section 6.4) */
enum { enum {
DCCPF_RESERVED = 0, DCCPF_RESERVED = 0,
DCCPF_CCID = 1, DCCPF_CCID = 1,
DCCPF_SHORT_SEQNOS = 2, /* XXX: not yet implemented */ DCCPF_SHORT_SEQNOS = 2, /* XXX: not yet implemented */
......
...@@ -37,10 +37,14 @@ struct tfrc_rx_info { ...@@ -37,10 +37,14 @@ struct tfrc_rx_info {
* @tfrctx_p: current loss event rate (5.4) * @tfrctx_p: current loss event rate (5.4)
* @tfrctx_rto: estimate of RTO, equals 4*RTT (4.3) * @tfrctx_rto: estimate of RTO, equals 4*RTT (4.3)
* @tfrctx_ipi: inter-packet interval (4.6) * @tfrctx_ipi: inter-packet interval (4.6)
*
* Note: X and X_recv are both maintained in units of 64 * bytes/second. This
* enables a finer resolution of sending rates and avoids problems with
* integer arithmetic; u32 is not sufficient as scaling consumes 6 bits.
*/ */
struct tfrc_tx_info { struct tfrc_tx_info {
__u32 tfrctx_x; __u64 tfrctx_x;
__u32 tfrctx_x_recv; __u64 tfrctx_x_recv;
__u32 tfrctx_x_calc; __u32 tfrctx_x_calc;
__u32 tfrctx_rtt; __u32 tfrctx_rtt;
__u32 tfrctx_p; __u32 tfrctx_p;
......
...@@ -285,6 +285,8 @@ extern struct sock *ax25_make_new(struct sock *, struct ax25_dev *); ...@@ -285,6 +285,8 @@ extern struct sock *ax25_make_new(struct sock *, struct ax25_dev *);
extern const ax25_address ax25_bcast; extern const ax25_address ax25_bcast;
extern const ax25_address ax25_defaddr; extern const ax25_address ax25_defaddr;
extern const ax25_address null_ax25_address; extern const ax25_address null_ax25_address;
extern char *ax2asc(char *buf, const ax25_address *);
extern void asc2ax(ax25_address *addr, const char *callsign);
extern int ax25cmp(const ax25_address *, const ax25_address *); extern int ax25cmp(const ax25_address *, const ax25_address *);
extern int ax25digicmp(const ax25_digi *, const ax25_digi *); extern int ax25digicmp(const ax25_digi *, const ax25_digi *);
extern const unsigned char *ax25_addr_parse(const unsigned char *, int, extern const unsigned char *ax25_addr_parse(const unsigned char *, int,
......
...@@ -83,7 +83,7 @@ EXPORT_SYMBOL(ax2asc); ...@@ -83,7 +83,7 @@ EXPORT_SYMBOL(ax2asc);
*/ */
void asc2ax(ax25_address *addr, const char *callsign) void asc2ax(ax25_address *addr, const char *callsign)
{ {
char *s; const char *s;
int n; int n;
for (s = callsign, n = 0; n < 6; n++) { for (s = callsign, n = 0; n < 6; n++) {
......
...@@ -242,10 +242,14 @@ static void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb) ...@@ -242,10 +242,14 @@ static void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
/* don't get messages out of order, and no recursion */ /* don't get messages out of order, and no recursion */
if (skb_queue_len(&npinfo->txq) == 0 && if (skb_queue_len(&npinfo->txq) == 0 &&
npinfo->poll_owner != smp_processor_id() && npinfo->poll_owner != smp_processor_id()) {
netif_tx_trylock(dev)) { unsigned long flags;
local_irq_save(flags);
if (netif_tx_trylock(dev)) {
/* try until next clock tick */ /* try until next clock tick */
for (tries = jiffies_to_usecs(1)/USEC_PER_POLL; tries > 0; --tries) { for (tries = jiffies_to_usecs(1)/USEC_PER_POLL;
tries > 0; --tries) {
if (!netif_queue_stopped(dev)) if (!netif_queue_stopped(dev))
status = dev->hard_start_xmit(skb, dev); status = dev->hard_start_xmit(skb, dev);
...@@ -259,6 +263,8 @@ static void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb) ...@@ -259,6 +263,8 @@ static void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
} }
netif_tx_unlock(dev); netif_tx_unlock(dev);
} }
local_irq_restore(flags);
}
if (status != NETDEV_TX_OK) { if (status != NETDEV_TX_OK) {
skb_queue_tail(&npinfo->txq, skb); skb_queue_tail(&npinfo->txq, skb);
......
...@@ -43,8 +43,6 @@ struct ccid_operations { ...@@ -43,8 +43,6 @@ struct ccid_operations {
unsigned char* value); unsigned char* value);
int (*ccid_hc_rx_insert_options)(struct sock *sk, int (*ccid_hc_rx_insert_options)(struct sock *sk,
struct sk_buff *skb); struct sk_buff *skb);
int (*ccid_hc_tx_insert_options)(struct sock *sk,
struct sk_buff *skb);
void (*ccid_hc_tx_packet_recv)(struct sock *sk, void (*ccid_hc_tx_packet_recv)(struct sock *sk,
struct sk_buff *skb); struct sk_buff *skb);
int (*ccid_hc_tx_parse_options)(struct sock *sk, int (*ccid_hc_tx_parse_options)(struct sock *sk,
...@@ -146,14 +144,6 @@ static inline int ccid_hc_rx_parse_options(struct ccid *ccid, struct sock *sk, ...@@ -146,14 +144,6 @@ static inline int ccid_hc_rx_parse_options(struct ccid *ccid, struct sock *sk,
return rc; return rc;
} }
static inline int ccid_hc_tx_insert_options(struct ccid *ccid, struct sock *sk,
struct sk_buff *skb)
{
if (ccid->ccid_ops->ccid_hc_tx_insert_options != NULL)
return ccid->ccid_ops->ccid_hc_tx_insert_options(sk, skb);
return 0;
}
static inline int ccid_hc_rx_insert_options(struct ccid *ccid, struct sock *sk, static inline int ccid_hc_rx_insert_options(struct ccid *ccid, struct sock *sk,
struct sk_buff *skb) struct sk_buff *skb)
{ {
......
...@@ -41,27 +41,6 @@ ...@@ -41,27 +41,6 @@
#include "lib/tfrc.h" #include "lib/tfrc.h"
#include "ccid3.h" #include "ccid3.h"
/*
* Reason for maths here is to avoid 32 bit overflow when a is big.
* With this we get close to the limit.
*/
static u32 usecs_div(const u32 a, const u32 b)
{
const u32 div = a < (UINT_MAX / (USEC_PER_SEC / 10)) ? 10 :
a < (UINT_MAX / (USEC_PER_SEC / 50)) ? 50 :
a < (UINT_MAX / (USEC_PER_SEC / 100)) ? 100 :
a < (UINT_MAX / (USEC_PER_SEC / 500)) ? 500 :
a < (UINT_MAX / (USEC_PER_SEC / 1000)) ? 1000 :
a < (UINT_MAX / (USEC_PER_SEC / 5000)) ? 5000 :
a < (UINT_MAX / (USEC_PER_SEC / 10000)) ? 10000 :
a < (UINT_MAX / (USEC_PER_SEC / 50000)) ? 50000 :
100000;
const u32 tmp = a * (USEC_PER_SEC / div);
return (b >= 2 * div) ? tmp / (b / div) : tmp;
}
#ifdef CONFIG_IP_DCCP_CCID3_DEBUG #ifdef CONFIG_IP_DCCP_CCID3_DEBUG
static int ccid3_debug; static int ccid3_debug;
#define ccid3_pr_debug(format, a...) DCCP_PR_DEBUG(ccid3_debug, format, ##a) #define ccid3_pr_debug(format, a...) DCCP_PR_DEBUG(ccid3_debug, format, ##a)
...@@ -108,8 +87,9 @@ static inline void ccid3_update_send_time(struct ccid3_hc_tx_sock *hctx) ...@@ -108,8 +87,9 @@ static inline void ccid3_update_send_time(struct ccid3_hc_tx_sock *hctx)
{ {
timeval_sub_usecs(&hctx->ccid3hctx_t_nom, hctx->ccid3hctx_t_ipi); timeval_sub_usecs(&hctx->ccid3hctx_t_nom, hctx->ccid3hctx_t_ipi);
/* Calculate new t_ipi (inter packet interval) by t_ipi = s / X_inst */ /* Calculate new t_ipi = s / X_inst (X_inst is in 64 * bytes/second) */
hctx->ccid3hctx_t_ipi = usecs_div(hctx->ccid3hctx_s, hctx->ccid3hctx_x); hctx->ccid3hctx_t_ipi = scaled_div(hctx->ccid3hctx_s,
hctx->ccid3hctx_x >> 6);
/* Update nominal send time with regard to the new t_ipi */ /* Update nominal send time with regard to the new t_ipi */
timeval_add_usecs(&hctx->ccid3hctx_t_nom, hctx->ccid3hctx_t_ipi); timeval_add_usecs(&hctx->ccid3hctx_t_nom, hctx->ccid3hctx_t_ipi);
...@@ -128,6 +108,10 @@ static inline void ccid3_update_send_time(struct ccid3_hc_tx_sock *hctx) ...@@ -128,6 +108,10 @@ static inline void ccid3_update_send_time(struct ccid3_hc_tx_sock *hctx)
* X = max(min(2 * X, 2 * X_recv), s / R); * X = max(min(2 * X, 2 * X_recv), s / R);
* tld = now; * tld = now;
* *
* Note: X and X_recv are both stored in units of 64 * bytes/second, to support
* fine-grained resolution of sending rates. This requires scaling by 2^6
* throughout the code. Only X_calc is unscaled (in bytes/second).
*
* If X has changed, we also update the scheduled send time t_now, * If X has changed, we also update the scheduled send time t_now,
* the inter-packet interval t_ipi, and the delta value. * the inter-packet interval t_ipi, and the delta value.
*/ */
...@@ -135,25 +119,25 @@ static void ccid3_hc_tx_update_x(struct sock *sk, struct timeval *now) ...@@ -135,25 +119,25 @@ static void ccid3_hc_tx_update_x(struct sock *sk, struct timeval *now)
{ {
struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
const __u32 old_x = hctx->ccid3hctx_x; const __u64 old_x = hctx->ccid3hctx_x;
if (hctx->ccid3hctx_p > 0) { if (hctx->ccid3hctx_p > 0) {
hctx->ccid3hctx_x_calc = tfrc_calc_x(hctx->ccid3hctx_s,
hctx->ccid3hctx_rtt, hctx->ccid3hctx_x = min(((__u64)hctx->ccid3hctx_x_calc) << 6,
hctx->ccid3hctx_p); hctx->ccid3hctx_x_recv * 2);
hctx->ccid3hctx_x = max_t(u32, min(hctx->ccid3hctx_x_calc, hctx->ccid3hctx_x = max(hctx->ccid3hctx_x,
hctx->ccid3hctx_x_recv * 2), (((__u64)hctx->ccid3hctx_s) << 6) /
hctx->ccid3hctx_s / TFRC_T_MBI); TFRC_T_MBI);
} else if (timeval_delta(now, &hctx->ccid3hctx_t_ld) >= } else if (timeval_delta(now, &hctx->ccid3hctx_t_ld) -
hctx->ccid3hctx_rtt) { (suseconds_t)hctx->ccid3hctx_rtt >= 0) {
hctx->ccid3hctx_x = max(min(hctx->ccid3hctx_x_recv,
hctx->ccid3hctx_x ) * 2, hctx->ccid3hctx_x =
usecs_div(hctx->ccid3hctx_s, max(2 * min(hctx->ccid3hctx_x, hctx->ccid3hctx_x_recv),
hctx->ccid3hctx_rtt) ); scaled_div(((__u64)hctx->ccid3hctx_s) << 6,
hctx->ccid3hctx_rtt));
hctx->ccid3hctx_t_ld = *now; hctx->ccid3hctx_t_ld = *now;
} else }
ccid3_pr_debug("Not changing X\n");
if (hctx->ccid3hctx_x != old_x) if (hctx->ccid3hctx_x != old_x)
ccid3_update_send_time(hctx); ccid3_update_send_time(hctx);
...@@ -178,6 +162,33 @@ static inline void ccid3_hc_tx_update_s(struct ccid3_hc_tx_sock *hctx, int len) ...@@ -178,6 +162,33 @@ static inline void ccid3_hc_tx_update_s(struct ccid3_hc_tx_sock *hctx, int len)
*/ */
} }
/*
* Update Window Counter using the algorithm from [RFC 4342, 8.1].
* The algorithm is not applicable if RTT < 4 microseconds.
*/
static inline void ccid3_hc_tx_update_win_count(struct ccid3_hc_tx_sock *hctx,
struct timeval *now)
{
suseconds_t delta;
u32 quarter_rtts;
if (unlikely(hctx->ccid3hctx_rtt < 4)) /* avoid divide-by-zero */
return;
delta = timeval_delta(now, &hctx->ccid3hctx_t_last_win_count);
DCCP_BUG_ON(delta < 0);
quarter_rtts = (u32)delta / (hctx->ccid3hctx_rtt / 4);
if (quarter_rtts > 0) {
hctx->ccid3hctx_t_last_win_count = *now;
hctx->ccid3hctx_last_win_count += min_t(u32, quarter_rtts, 5);
hctx->ccid3hctx_last_win_count &= 0xF; /* mod 16 */
ccid3_pr_debug("now at %#X\n", hctx->ccid3hctx_last_win_count);
}
}
static void ccid3_hc_tx_no_feedback_timer(unsigned long data) static void ccid3_hc_tx_no_feedback_timer(unsigned long data)
{ {
struct sock *sk = (struct sock *)data; struct sock *sk = (struct sock *)data;
...@@ -191,20 +202,20 @@ static void ccid3_hc_tx_no_feedback_timer(unsigned long data) ...@@ -191,20 +202,20 @@ static void ccid3_hc_tx_no_feedback_timer(unsigned long data)
goto restart_timer; goto restart_timer;
} }
ccid3_pr_debug("%s, sk=%p, state=%s\n", dccp_role(sk), sk, ccid3_pr_debug("%s(%p, state=%s) - entry \n", dccp_role(sk), sk,
ccid3_tx_state_name(hctx->ccid3hctx_state)); ccid3_tx_state_name(hctx->ccid3hctx_state));
switch (hctx->ccid3hctx_state) { switch (hctx->ccid3hctx_state) {
case TFRC_SSTATE_NO_FBACK: case TFRC_SSTATE_NO_FBACK:
/* RFC 3448, 4.4: Halve send rate directly */ /* RFC 3448, 4.4: Halve send rate directly */
hctx->ccid3hctx_x = min_t(u32, hctx->ccid3hctx_x / 2, hctx->ccid3hctx_x = max(hctx->ccid3hctx_x / 2,
hctx->ccid3hctx_s / TFRC_T_MBI); (((__u64)hctx->ccid3hctx_s) << 6) /
TFRC_T_MBI);
ccid3_pr_debug("%s, sk=%p, state=%s, updated tx rate to %d " ccid3_pr_debug("%s(%p, state=%s), updated tx rate to %u "
"bytes/s\n", "bytes/s\n", dccp_role(sk), sk,
dccp_role(sk), sk,
ccid3_tx_state_name(hctx->ccid3hctx_state), ccid3_tx_state_name(hctx->ccid3hctx_state),
hctx->ccid3hctx_x); (unsigned)(hctx->ccid3hctx_x >> 6));
/* The value of R is still undefined and so we can not recompute /* The value of R is still undefined and so we can not recompute
* the timout value. Keep initial value as per [RFC 4342, 5]. */ * the timout value. Keep initial value as per [RFC 4342, 5]. */
t_nfb = TFRC_INITIAL_TIMEOUT; t_nfb = TFRC_INITIAL_TIMEOUT;
...@@ -213,34 +224,46 @@ static void ccid3_hc_tx_no_feedback_timer(unsigned long data) ...@@ -213,34 +224,46 @@ static void ccid3_hc_tx_no_feedback_timer(unsigned long data)
case TFRC_SSTATE_FBACK: case TFRC_SSTATE_FBACK:
/* /*
* Check if IDLE since last timeout and recv rate is less than * Check if IDLE since last timeout and recv rate is less than
* 4 packets per RTT * 4 packets (in units of 64*bytes/sec) per RTT
*/ */
if (!hctx->ccid3hctx_idle || if (!hctx->ccid3hctx_idle ||
(hctx->ccid3hctx_x_recv >= (hctx->ccid3hctx_x_recv >= 4 *
4 * usecs_div(hctx->ccid3hctx_s, hctx->ccid3hctx_rtt))) { scaled_div(((__u64)hctx->ccid3hctx_s) << 6,
hctx->ccid3hctx_rtt))) {
struct timeval now; struct timeval now;
ccid3_pr_debug("%s, sk=%p, state=%s, not idle\n", ccid3_pr_debug("%s(%p, state=%s), not idle\n",
dccp_role(sk), sk, dccp_role(sk), sk,
ccid3_tx_state_name(hctx->ccid3hctx_state)); ccid3_tx_state_name(hctx->ccid3hctx_state));
/* Halve sending rate */
/* If (p == 0 || X_calc > 2 * X_recv) /*
* Modify the cached value of X_recv [RFC 3448, 4.4]
*
* If (p == 0 || X_calc > 2 * X_recv)
* X_recv = max(X_recv / 2, s / (2 * t_mbi)); * X_recv = max(X_recv / 2, s / (2 * t_mbi));
* Else * Else
* X_recv = X_calc / 4; * X_recv = X_calc / 4;
*
* Note that X_recv is scaled by 2^6 while X_calc is not
*/ */
BUG_ON(hctx->ccid3hctx_p && !hctx->ccid3hctx_x_calc); BUG_ON(hctx->ccid3hctx_p && !hctx->ccid3hctx_x_calc);
if (hctx->ccid3hctx_p == 0 || if (hctx->ccid3hctx_p == 0 ||
hctx->ccid3hctx_x_calc > 2 * hctx->ccid3hctx_x_recv) (hctx->ccid3hctx_x_calc >
hctx->ccid3hctx_x_recv = max_t(u32, hctx->ccid3hctx_x_recv / 2, (hctx->ccid3hctx_x_recv >> 5))) {
hctx->ccid3hctx_s / (2 * TFRC_T_MBI));
else hctx->ccid3hctx_x_recv =
hctx->ccid3hctx_x_recv = hctx->ccid3hctx_x_calc / 4; max(hctx->ccid3hctx_x_recv / 2,
(((__u64)hctx->ccid3hctx_s) << 6) /
(2 * TFRC_T_MBI));
/* Update sending rate */ if (hctx->ccid3hctx_p == 0)
dccp_timestamp(sk, &now); dccp_timestamp(sk, &now);
} else {
hctx->ccid3hctx_x_recv = hctx->ccid3hctx_x_calc;
hctx->ccid3hctx_x_recv <<= 4;
}
/* Now recalculate X [RFC 3448, 4.3, step (4)] */
ccid3_hc_tx_update_x(sk, &now); ccid3_hc_tx_update_x(sk, &now);
} }
/* /*
...@@ -251,7 +274,7 @@ static void ccid3_hc_tx_no_feedback_timer(unsigned long data) ...@@ -251,7 +274,7 @@ static void ccid3_hc_tx_no_feedback_timer(unsigned long data)
t_nfb = max(hctx->ccid3hctx_t_rto, 2 * hctx->ccid3hctx_t_ipi); t_nfb = max(hctx->ccid3hctx_t_rto, 2 * hctx->ccid3hctx_t_ipi);
break; break;
case TFRC_SSTATE_NO_SENT: case TFRC_SSTATE_NO_SENT:
DCCP_BUG("Illegal %s state NO_SENT, sk=%p", dccp_role(sk), sk); DCCP_BUG("%s(%p) - Illegal state NO_SENT", dccp_role(sk), sk);
/* fall through */ /* fall through */
case TFRC_SSTATE_TERM: case TFRC_SSTATE_TERM:
goto out; goto out;
...@@ -277,9 +300,8 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb) ...@@ -277,9 +300,8 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb)
{ {
struct dccp_sock *dp = dccp_sk(sk); struct dccp_sock *dp = dccp_sk(sk);
struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
struct dccp_tx_hist_entry *new_packet;
struct timeval now; struct timeval now;
long delay; suseconds_t delay;
BUG_ON(hctx == NULL); BUG_ON(hctx == NULL);
...@@ -291,34 +313,21 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb) ...@@ -291,34 +313,21 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb)
if (unlikely(skb->len == 0)) if (unlikely(skb->len == 0))
return -EBADMSG; return -EBADMSG;
/* See if last packet allocated was not sent */
new_packet = dccp_tx_hist_head(&hctx->ccid3hctx_hist);
if (new_packet == NULL || new_packet->dccphtx_sent) {
new_packet = dccp_tx_hist_entry_new(ccid3_tx_hist,
GFP_ATOMIC);
if (unlikely(new_packet == NULL)) {
DCCP_WARN("%s, sk=%p, not enough mem to add to history,"
"send refused\n", dccp_role(sk), sk);
return -ENOBUFS;
}
dccp_tx_hist_add_entry(&hctx->ccid3hctx_hist, new_packet);
}
dccp_timestamp(sk, &now); dccp_timestamp(sk, &now);
switch (hctx->ccid3hctx_state) { switch (hctx->ccid3hctx_state) {
case TFRC_SSTATE_NO_SENT: case TFRC_SSTATE_NO_SENT:
sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer, sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer,
jiffies + usecs_to_jiffies(TFRC_INITIAL_TIMEOUT)); (jiffies +
usecs_to_jiffies(TFRC_INITIAL_TIMEOUT)));
hctx->ccid3hctx_last_win_count = 0; hctx->ccid3hctx_last_win_count = 0;
hctx->ccid3hctx_t_last_win_count = now; hctx->ccid3hctx_t_last_win_count = now;
ccid3_hc_tx_set_state(sk, TFRC_SSTATE_NO_FBACK); ccid3_hc_tx_set_state(sk, TFRC_SSTATE_NO_FBACK);
/* Set initial sending rate to 1 packet per second */ /* Set initial sending rate X/s to 1pps (X is scaled by 2^6) */
ccid3_hc_tx_update_s(hctx, skb->len); ccid3_hc_tx_update_s(hctx, skb->len);
hctx->ccid3hctx_x = hctx->ccid3hctx_s; hctx->ccid3hctx_x = hctx->ccid3hctx_s;
hctx->ccid3hctx_x <<= 6;
/* First timeout, according to [RFC 3448, 4.2], is 1 second */ /* First timeout, according to [RFC 3448, 4.2], is 1 second */
hctx->ccid3hctx_t_ipi = USEC_PER_SEC; hctx->ccid3hctx_t_ipi = USEC_PER_SEC;
...@@ -339,70 +348,50 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb) ...@@ -339,70 +348,50 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb)
* else * else
* // send the packet in (t_nom - t_now) milliseconds. * // send the packet in (t_nom - t_now) milliseconds.
*/ */
if (delay - (long)hctx->ccid3hctx_delta >= 0) if (delay - (suseconds_t)hctx->ccid3hctx_delta >= 0)
return delay / 1000L; return delay / 1000L;
ccid3_hc_tx_update_win_count(hctx, &now);
break; break;
case TFRC_SSTATE_TERM: case TFRC_SSTATE_TERM:
DCCP_BUG("Illegal %s state TERM, sk=%p", dccp_role(sk), sk); DCCP_BUG("%s(%p) - Illegal state TERM", dccp_role(sk), sk);
return -EINVAL; return -EINVAL;
} }
/* prepare to send now (add options etc.) */ /* prepare to send now (add options etc.) */
dp->dccps_hc_tx_insert_options = 1; dp->dccps_hc_tx_insert_options = 1;
new_packet->dccphtx_ccval = DCCP_SKB_CB(skb)->dccpd_ccval = DCCP_SKB_CB(skb)->dccpd_ccval = hctx->ccid3hctx_last_win_count;
hctx->ccid3hctx_last_win_count;
/* set the nominal send time for the next following packet */
timeval_add_usecs(&hctx->ccid3hctx_t_nom, hctx->ccid3hctx_t_ipi); timeval_add_usecs(&hctx->ccid3hctx_t_nom, hctx->ccid3hctx_t_ipi);
return 0; return 0;
} }
static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, unsigned int len) static void ccid3_hc_tx_packet_sent(struct sock *sk, int more,
unsigned int len)
{ {
const struct dccp_sock *dp = dccp_sk(sk);
struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
struct timeval now; struct timeval now;
unsigned long quarter_rtt;
struct dccp_tx_hist_entry *packet; struct dccp_tx_hist_entry *packet;
BUG_ON(hctx == NULL); BUG_ON(hctx == NULL);
dccp_timestamp(sk, &now);
ccid3_hc_tx_update_s(hctx, len); ccid3_hc_tx_update_s(hctx, len);
packet = dccp_tx_hist_head(&hctx->ccid3hctx_hist); packet = dccp_tx_hist_entry_new(ccid3_tx_hist, GFP_ATOMIC);
if (unlikely(packet == NULL)) { if (unlikely(packet == NULL)) {
DCCP_WARN("packet doesn't exist in history!\n"); DCCP_CRIT("packet history - out of memory!");
return;
}
if (unlikely(packet->dccphtx_sent)) {
DCCP_WARN("no unsent packet in history!\n");
return; return;
} }
packet->dccphtx_tstamp = now; dccp_tx_hist_add_entry(&hctx->ccid3hctx_hist, packet);
packet->dccphtx_seqno = dp->dccps_gss;
/*
* Check if win_count have changed
* Algorithm in "8.1. Window Counter Value" in RFC 4342.
*/
quarter_rtt = timeval_delta(&now, &hctx->ccid3hctx_t_last_win_count);
if (likely(hctx->ccid3hctx_rtt > 8))
quarter_rtt /= hctx->ccid3hctx_rtt / 4;
if (quarter_rtt > 0) {
hctx->ccid3hctx_t_last_win_count = now;
hctx->ccid3hctx_last_win_count = (hctx->ccid3hctx_last_win_count +
min_t(unsigned long, quarter_rtt, 5)) % 16;
ccid3_pr_debug("%s, sk=%p, window changed from "
"%u to %u!\n",
dccp_role(sk), sk,
packet->dccphtx_ccval,
hctx->ccid3hctx_last_win_count);
}
hctx->ccid3hctx_idle = 0; dccp_timestamp(sk, &now);
packet->dccphtx_tstamp = now;
packet->dccphtx_seqno = dccp_sk(sk)->dccps_gss;
packet->dccphtx_rtt = hctx->ccid3hctx_rtt; packet->dccphtx_rtt = hctx->ccid3hctx_rtt;
packet->dccphtx_sent = 1; packet->dccphtx_sent = 1;
hctx->ccid3hctx_idle = 0;
} }
static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
...@@ -414,7 +403,7 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) ...@@ -414,7 +403,7 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
struct timeval now; struct timeval now;
unsigned long t_nfb; unsigned long t_nfb;
u32 pinv; u32 pinv;
long r_sample, t_elapsed; suseconds_t r_sample, t_elapsed;
BUG_ON(hctx == NULL); BUG_ON(hctx == NULL);
...@@ -439,14 +428,15 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) ...@@ -439,14 +428,15 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
return; return;
} }
/* Update receive rate */ /* Update receive rate in units of 64 * bytes/second */
hctx->ccid3hctx_x_recv = opt_recv->ccid3or_receive_rate; hctx->ccid3hctx_x_recv = opt_recv->ccid3or_receive_rate;
hctx->ccid3hctx_x_recv <<= 6;
/* Update loss event rate */ /* Update loss event rate */
pinv = opt_recv->ccid3or_loss_event_rate; pinv = opt_recv->ccid3or_loss_event_rate;
if (pinv == ~0U || pinv == 0) if (pinv == ~0U || pinv == 0) /* see RFC 4342, 8.5 */
hctx->ccid3hctx_p = 0; hctx->ccid3hctx_p = 0;
else else /* can not exceed 100% */
hctx->ccid3hctx_p = 1000000 / pinv; hctx->ccid3hctx_p = 1000000 / pinv;
dccp_timestamp(sk, &now); dccp_timestamp(sk, &now);
...@@ -458,14 +448,13 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) ...@@ -458,14 +448,13 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
r_sample = timeval_delta(&now, &packet->dccphtx_tstamp); r_sample = timeval_delta(&now, &packet->dccphtx_tstamp);
t_elapsed = dp->dccps_options_received.dccpor_elapsed_time * 10; t_elapsed = dp->dccps_options_received.dccpor_elapsed_time * 10;
if (unlikely(r_sample <= 0)) { DCCP_BUG_ON(r_sample < 0);
DCCP_WARN("WARNING: R_sample (%ld) <= 0!\n", r_sample); if (unlikely(r_sample <= t_elapsed))
r_sample = 0; DCCP_WARN("WARNING: r_sample=%dus <= t_elapsed=%dus\n",
} else if (unlikely(r_sample <= t_elapsed)) (int)r_sample, (int)t_elapsed);
DCCP_WARN("WARNING: r_sample=%ldus <= t_elapsed=%ldus\n",
r_sample, t_elapsed);
else else
r_sample -= t_elapsed; r_sample -= t_elapsed;
CCID3_RTT_SANITY_CHECK(r_sample);
/* Update RTT estimate by /* Update RTT estimate by
* If (No feedback recv) * If (No feedback recv)
...@@ -476,34 +465,45 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) ...@@ -476,34 +465,45 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
* q is a constant, RFC 3448 recomments 0.9 * q is a constant, RFC 3448 recomments 0.9
*/ */
if (hctx->ccid3hctx_state == TFRC_SSTATE_NO_FBACK) { if (hctx->ccid3hctx_state == TFRC_SSTATE_NO_FBACK) {
/* Use Larger Initial Windows [RFC 4342, sec. 5] /*
* We deviate in that we use `s' instead of `MSS'. */ * Larger Initial Windows [RFC 4342, sec. 5]
u16 w_init = max( 4 * hctx->ccid3hctx_s, * We deviate in that we use `s' instead of `MSS'.
*/
__u64 w_init = min(4 * hctx->ccid3hctx_s,
max(2 * hctx->ccid3hctx_s, 4380)); max(2 * hctx->ccid3hctx_s, 4380));
hctx->ccid3hctx_rtt = r_sample; hctx->ccid3hctx_rtt = r_sample;
hctx->ccid3hctx_x = usecs_div(w_init, r_sample); hctx->ccid3hctx_x = scaled_div(w_init << 6, r_sample);
hctx->ccid3hctx_t_ld = now; hctx->ccid3hctx_t_ld = now;
ccid3_update_send_time(hctx); ccid3_update_send_time(hctx);
ccid3_pr_debug("%s(%p), s=%u, w_init=%u, " ccid3_pr_debug("%s(%p), s=%u, w_init=%llu, "
"R_sample=%ldus, X=%u\n", dccp_role(sk), "R_sample=%dus, X=%u\n", dccp_role(sk),
sk, hctx->ccid3hctx_s, w_init, r_sample, sk, hctx->ccid3hctx_s, w_init,
hctx->ccid3hctx_x); (int)r_sample,
(unsigned)(hctx->ccid3hctx_x >> 6));
ccid3_hc_tx_set_state(sk, TFRC_SSTATE_FBACK); ccid3_hc_tx_set_state(sk, TFRC_SSTATE_FBACK);
} else { } else {
hctx->ccid3hctx_rtt = (9 * hctx->ccid3hctx_rtt + hctx->ccid3hctx_rtt = (9 * hctx->ccid3hctx_rtt +
(u32)r_sample ) / 10; (u32)r_sample) / 10;
/* Update sending rate (step 4 of [RFC 3448, 4.3]) */
if (hctx->ccid3hctx_p > 0)
hctx->ccid3hctx_x_calc =
tfrc_calc_x(hctx->ccid3hctx_s,
hctx->ccid3hctx_rtt,
hctx->ccid3hctx_p);
ccid3_hc_tx_update_x(sk, &now); ccid3_hc_tx_update_x(sk, &now);
ccid3_pr_debug("%s(%p), RTT=%uus (sample=%ldus), s=%u, " ccid3_pr_debug("%s(%p), RTT=%uus (sample=%dus), s=%u, "
"p=%u, X_calc=%u, X=%u\n", dccp_role(sk), "p=%u, X_calc=%u, X_recv=%u, X=%u\n",
sk, hctx->ccid3hctx_rtt, r_sample, dccp_role(sk),
sk, hctx->ccid3hctx_rtt, (int)r_sample,
hctx->ccid3hctx_s, hctx->ccid3hctx_p, hctx->ccid3hctx_s, hctx->ccid3hctx_p,
hctx->ccid3hctx_x_calc, hctx->ccid3hctx_x_calc,
hctx->ccid3hctx_x); (unsigned)(hctx->ccid3hctx_x_recv >> 6),
(unsigned)(hctx->ccid3hctx_x >> 6));
} }
/* unschedule no feedback timer */ /* unschedule no feedback timer */
...@@ -513,30 +513,30 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) ...@@ -513,30 +513,30 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
dccp_tx_hist_purge_older(ccid3_tx_hist, dccp_tx_hist_purge_older(ccid3_tx_hist,
&hctx->ccid3hctx_hist, packet); &hctx->ccid3hctx_hist, packet);
/* /*
* As we have calculated new ipi, delta, t_nom it is possible that * As we have calculated new ipi, delta, t_nom it is possible
* we now can send a packet, so wake up dccp_wait_for_ccid * that we now can send a packet, so wake up dccp_wait_for_ccid
*/ */
sk->sk_write_space(sk); sk->sk_write_space(sk);
/* /*
* Update timeout interval for the nofeedback timer. * Update timeout interval for the nofeedback timer.
* We use a configuration option to increase the lower bound. * We use a configuration option to increase the lower bound.
* This can help avoid triggering the nofeedback timer too often * This can help avoid triggering the nofeedback timer too
* ('spinning') on LANs with small RTTs. * often ('spinning') on LANs with small RTTs.
*/ */
hctx->ccid3hctx_t_rto = max_t(u32, 4 * hctx->ccid3hctx_rtt, hctx->ccid3hctx_t_rto = max_t(u32, 4 * hctx->ccid3hctx_rtt,
CONFIG_IP_DCCP_CCID3_RTO * CONFIG_IP_DCCP_CCID3_RTO *
(USEC_PER_SEC/1000) ); (USEC_PER_SEC/1000));
/* /*
* Schedule no feedback timer to expire in * Schedule no feedback timer to expire in
* max(t_RTO, 2 * s/X) = max(t_RTO, 2 * t_ipi) * max(t_RTO, 2 * s/X) = max(t_RTO, 2 * t_ipi)
*/ */
t_nfb = max(hctx->ccid3hctx_t_rto, 2 * hctx->ccid3hctx_t_ipi); t_nfb = max(hctx->ccid3hctx_t_rto, 2 * hctx->ccid3hctx_t_ipi);
ccid3_pr_debug("%s, sk=%p, Scheduled no feedback timer to " ccid3_pr_debug("%s(%p), Scheduled no feedback timer to "
"expire in %lu jiffies (%luus)\n", "expire in %lu jiffies (%luus)\n",
dccp_role(sk), sk, dccp_role(sk),
usecs_to_jiffies(t_nfb), t_nfb); sk, usecs_to_jiffies(t_nfb), t_nfb);
sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer, sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer,
jiffies + usecs_to_jiffies(t_nfb)); jiffies + usecs_to_jiffies(t_nfb));
...@@ -545,7 +545,9 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) ...@@ -545,7 +545,9 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
hctx->ccid3hctx_idle = 1; hctx->ccid3hctx_idle = 1;
break; break;
case TFRC_SSTATE_NO_SENT: case TFRC_SSTATE_NO_SENT:
if (dccp_sk(sk)->dccps_role == DCCP_ROLE_CLIENT) /*
* XXX when implementing bidirectional rx/tx check this again
*/
DCCP_WARN("Illegal ACK received - no packet sent\n"); DCCP_WARN("Illegal ACK received - no packet sent\n");
/* fall through */ /* fall through */
case TFRC_SSTATE_TERM: /* ignore feedback when closing */ case TFRC_SSTATE_TERM: /* ignore feedback when closing */
...@@ -553,17 +555,6 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) ...@@ -553,17 +555,6 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
} }
} }
static int ccid3_hc_tx_insert_options(struct sock *sk, struct sk_buff *skb)
{
const struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
BUG_ON(hctx == NULL);
if (sk->sk_state == DCCP_OPEN || sk->sk_state == DCCP_PARTOPEN)
DCCP_SKB_CB(skb)->dccpd_ccval = hctx->ccid3hctx_last_win_count;
return 0;
}
static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option, static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option,
unsigned char len, u16 idx, unsigned char len, u16 idx,
unsigned char *value) unsigned char *value)
...@@ -588,13 +579,14 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option, ...@@ -588,13 +579,14 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option,
switch (option) { switch (option) {
case TFRC_OPT_LOSS_EVENT_RATE: case TFRC_OPT_LOSS_EVENT_RATE:
if (unlikely(len != 4)) { if (unlikely(len != 4)) {
DCCP_WARN("%s, sk=%p, invalid len %d " DCCP_WARN("%s(%p), invalid len %d "
"for TFRC_OPT_LOSS_EVENT_RATE\n", "for TFRC_OPT_LOSS_EVENT_RATE\n",
dccp_role(sk), sk, len); dccp_role(sk), sk, len);
rc = -EINVAL; rc = -EINVAL;
} else { } else {
opt_recv->ccid3or_loss_event_rate = ntohl(*(__be32 *)value); opt_recv->ccid3or_loss_event_rate =
ccid3_pr_debug("%s, sk=%p, LOSS_EVENT_RATE=%u\n", ntohl(*(__be32 *)value);
ccid3_pr_debug("%s(%p), LOSS_EVENT_RATE=%u\n",
dccp_role(sk), sk, dccp_role(sk), sk,
opt_recv->ccid3or_loss_event_rate); opt_recv->ccid3or_loss_event_rate);
} }
...@@ -602,20 +594,21 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option, ...@@ -602,20 +594,21 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option,
case TFRC_OPT_LOSS_INTERVALS: case TFRC_OPT_LOSS_INTERVALS:
opt_recv->ccid3or_loss_intervals_idx = idx; opt_recv->ccid3or_loss_intervals_idx = idx;
opt_recv->ccid3or_loss_intervals_len = len; opt_recv->ccid3or_loss_intervals_len = len;
ccid3_pr_debug("%s, sk=%p, LOSS_INTERVALS=(%u, %u)\n", ccid3_pr_debug("%s(%p), LOSS_INTERVALS=(%u, %u)\n",
dccp_role(sk), sk, dccp_role(sk), sk,
opt_recv->ccid3or_loss_intervals_idx, opt_recv->ccid3or_loss_intervals_idx,
opt_recv->ccid3or_loss_intervals_len); opt_recv->ccid3or_loss_intervals_len);
break; break;
case TFRC_OPT_RECEIVE_RATE: case TFRC_OPT_RECEIVE_RATE:
if (unlikely(len != 4)) { if (unlikely(len != 4)) {
DCCP_WARN("%s, sk=%p, invalid len %d " DCCP_WARN("%s(%p), invalid len %d "
"for TFRC_OPT_RECEIVE_RATE\n", "for TFRC_OPT_RECEIVE_RATE\n",
dccp_role(sk), sk, len); dccp_role(sk), sk, len);
rc = -EINVAL; rc = -EINVAL;
} else { } else {
opt_recv->ccid3or_receive_rate = ntohl(*(__be32 *)value); opt_recv->ccid3or_receive_rate =
ccid3_pr_debug("%s, sk=%p, RECEIVE_RATE=%u\n", ntohl(*(__be32 *)value);
ccid3_pr_debug("%s(%p), RECEIVE_RATE=%u\n",
dccp_role(sk), sk, dccp_role(sk), sk,
opt_recv->ccid3or_receive_rate); opt_recv->ccid3or_receive_rate);
} }
...@@ -630,10 +623,12 @@ static int ccid3_hc_tx_init(struct ccid *ccid, struct sock *sk) ...@@ -630,10 +623,12 @@ static int ccid3_hc_tx_init(struct ccid *ccid, struct sock *sk)
struct ccid3_hc_tx_sock *hctx = ccid_priv(ccid); struct ccid3_hc_tx_sock *hctx = ccid_priv(ccid);
hctx->ccid3hctx_s = 0; hctx->ccid3hctx_s = 0;
hctx->ccid3hctx_rtt = 0;
hctx->ccid3hctx_state = TFRC_SSTATE_NO_SENT; hctx->ccid3hctx_state = TFRC_SSTATE_NO_SENT;
INIT_LIST_HEAD(&hctx->ccid3hctx_hist); INIT_LIST_HEAD(&hctx->ccid3hctx_hist);
hctx->ccid3hctx_no_feedback_timer.function = ccid3_hc_tx_no_feedback_timer; hctx->ccid3hctx_no_feedback_timer.function =
ccid3_hc_tx_no_feedback_timer;
hctx->ccid3hctx_no_feedback_timer.data = (unsigned long)sk; hctx->ccid3hctx_no_feedback_timer.data = (unsigned long)sk;
init_timer(&hctx->ccid3hctx_no_feedback_timer); init_timer(&hctx->ccid3hctx_no_feedback_timer);
...@@ -698,8 +693,9 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk) ...@@ -698,8 +693,9 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk)
struct dccp_sock *dp = dccp_sk(sk); struct dccp_sock *dp = dccp_sk(sk);
struct dccp_rx_hist_entry *packet; struct dccp_rx_hist_entry *packet;
struct timeval now; struct timeval now;
suseconds_t delta;
ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); ccid3_pr_debug("%s(%p) - entry \n", dccp_role(sk), sk);
dccp_timestamp(sk, &now); dccp_timestamp(sk, &now);
...@@ -707,21 +703,21 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk) ...@@ -707,21 +703,21 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk)
case TFRC_RSTATE_NO_DATA: case TFRC_RSTATE_NO_DATA:
hcrx->ccid3hcrx_x_recv = 0; hcrx->ccid3hcrx_x_recv = 0;
break; break;
case TFRC_RSTATE_DATA: { case TFRC_RSTATE_DATA:
const u32 delta = timeval_delta(&now, delta = timeval_delta(&now,
&hcrx->ccid3hcrx_tstamp_last_feedback); &hcrx->ccid3hcrx_tstamp_last_feedback);
hcrx->ccid3hcrx_x_recv = usecs_div(hcrx->ccid3hcrx_bytes_recv, DCCP_BUG_ON(delta < 0);
delta); hcrx->ccid3hcrx_x_recv =
} scaled_div32(hcrx->ccid3hcrx_bytes_recv, delta);
break; break;
case TFRC_RSTATE_TERM: case TFRC_RSTATE_TERM:
DCCP_BUG("Illegal %s state TERM, sk=%p", dccp_role(sk), sk); DCCP_BUG("%s(%p) - Illegal state TERM", dccp_role(sk), sk);
return; return;
} }
packet = dccp_rx_hist_find_data_packet(&hcrx->ccid3hcrx_hist); packet = dccp_rx_hist_find_data_packet(&hcrx->ccid3hcrx_hist);
if (unlikely(packet == NULL)) { if (unlikely(packet == NULL)) {
DCCP_WARN("%s, sk=%p, no data packet in history!\n", DCCP_WARN("%s(%p), no data packet in history!\n",
dccp_role(sk), sk); dccp_role(sk), sk);
return; return;
} }
...@@ -730,13 +726,19 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk) ...@@ -730,13 +726,19 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk)
hcrx->ccid3hcrx_ccval_last_counter = packet->dccphrx_ccval; hcrx->ccid3hcrx_ccval_last_counter = packet->dccphrx_ccval;
hcrx->ccid3hcrx_bytes_recv = 0; hcrx->ccid3hcrx_bytes_recv = 0;
/* Convert to multiples of 10us */ /* Elapsed time information [RFC 4340, 13.2] in units of 10 * usecs */
hcrx->ccid3hcrx_elapsed_time = delta = timeval_delta(&now, &packet->dccphrx_tstamp);
timeval_delta(&now, &packet->dccphrx_tstamp) / 10; DCCP_BUG_ON(delta < 0);
hcrx->ccid3hcrx_elapsed_time = delta / 10;
if (hcrx->ccid3hcrx_p == 0) if (hcrx->ccid3hcrx_p == 0)
hcrx->ccid3hcrx_pinv = ~0; hcrx->ccid3hcrx_pinv = ~0U; /* see RFC 4342, 8.5 */
else 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; hcrx->ccid3hcrx_pinv = 1000000 / hcrx->ccid3hcrx_p;
dp->dccps_hc_rx_insert_options = 1; dp->dccps_hc_rx_insert_options = 1;
dccp_send_ack(sk); dccp_send_ack(sk);
} }
...@@ -780,12 +782,13 @@ static u32 ccid3_hc_rx_calc_first_li(struct sock *sk) ...@@ -780,12 +782,13 @@ static u32 ccid3_hc_rx_calc_first_li(struct sock *sk)
{ {
struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
struct dccp_rx_hist_entry *entry, *next, *tail = NULL; struct dccp_rx_hist_entry *entry, *next, *tail = NULL;
u32 rtt, delta, x_recv, fval, p, tmp2; u32 x_recv, p;
suseconds_t rtt, delta;
struct timeval tstamp = { 0, }; struct timeval tstamp = { 0, };
int interval = 0; int interval = 0;
int win_count = 0; int win_count = 0;
int step = 0; int step = 0;
u64 tmp1; u64 fval;
list_for_each_entry_safe(entry, next, &hcrx->ccid3hcrx_hist, list_for_each_entry_safe(entry, next, &hcrx->ccid3hcrx_hist,
dccphrx_node) { dccphrx_node) {
...@@ -810,13 +813,13 @@ static u32 ccid3_hc_rx_calc_first_li(struct sock *sk) ...@@ -810,13 +813,13 @@ static u32 ccid3_hc_rx_calc_first_li(struct sock *sk)
} }
if (unlikely(step == 0)) { if (unlikely(step == 0)) {
DCCP_WARN("%s, sk=%p, packet history has no data packets!\n", DCCP_WARN("%s(%p), packet history has no data packets!\n",
dccp_role(sk), sk); dccp_role(sk), sk);
return ~0; return ~0;
} }
if (unlikely(interval == 0)) { if (unlikely(interval == 0)) {
DCCP_WARN("%s, sk=%p, Could not find a win_count interval > 0." DCCP_WARN("%s(%p), Could not find a win_count interval > 0."
"Defaulting to 1\n", dccp_role(sk), sk); "Defaulting to 1\n", dccp_role(sk), sk);
interval = 1; interval = 1;
} }
...@@ -825,35 +828,45 @@ static u32 ccid3_hc_rx_calc_first_li(struct sock *sk) ...@@ -825,35 +828,45 @@ static u32 ccid3_hc_rx_calc_first_li(struct sock *sk)
DCCP_CRIT("tail is null\n"); DCCP_CRIT("tail is null\n");
return ~0; return ~0;
} }
rtt = timeval_delta(&tstamp, &tail->dccphrx_tstamp) * 4 / interval;
ccid3_pr_debug("%s, sk=%p, approximated RTT to %uus\n",
dccp_role(sk), sk, rtt);
if (rtt == 0) { delta = timeval_delta(&tstamp, &tail->dccphrx_tstamp);
DCCP_WARN("RTT==0, setting to 1\n"); DCCP_BUG_ON(delta < 0);
rtt = 1;
rtt = delta * 4 / interval;
ccid3_pr_debug("%s(%p), approximated RTT to %dus\n",
dccp_role(sk), sk, (int)rtt);
/*
* Determine the length of the first loss interval via inverse lookup.
* Assume that X_recv can be computed by the throughput equation
* s
* X_recv = --------
* R * fval
* Find some p such that f(p) = fval; return 1/p [RFC 3448, 6.3.1].
*/
if (rtt == 0) { /* would result in divide-by-zero */
DCCP_WARN("RTT==0, returning 1/p = 1\n");
return 1000000;
} }
dccp_timestamp(sk, &tstamp); dccp_timestamp(sk, &tstamp);
delta = timeval_delta(&tstamp, &hcrx->ccid3hcrx_tstamp_last_feedback); delta = timeval_delta(&tstamp, &hcrx->ccid3hcrx_tstamp_last_feedback);
x_recv = usecs_div(hcrx->ccid3hcrx_bytes_recv, delta); DCCP_BUG_ON(delta <= 0);
if (x_recv == 0) x_recv = scaled_div32(hcrx->ccid3hcrx_bytes_recv, delta);
x_recv = hcrx->ccid3hcrx_x_recv; if (x_recv == 0) { /* would also trigger divide-by-zero */
DCCP_WARN("X_recv==0\n");
tmp1 = (u64)x_recv * (u64)rtt; if ((x_recv = hcrx->ccid3hcrx_x_recv) == 0) {
do_div(tmp1,10000000); DCCP_BUG("stored value of X_recv is zero");
tmp2 = (u32)tmp1; return 1000000;
}
if (!tmp2) {
DCCP_CRIT("tmp2 = 0, x_recv = %u, rtt =%u\n", x_recv, rtt);
return ~0;
} }
fval = (hcrx->ccid3hcrx_s * 100000) / tmp2; fval = scaled_div(hcrx->ccid3hcrx_s, rtt);
/* do not alter order above or you will get overflow on 32 bit */ fval = scaled_div32(fval, x_recv);
p = tfrc_calc_x_reverse_lookup(fval); p = tfrc_calc_x_reverse_lookup(fval);
ccid3_pr_debug("%s, sk=%p, receive rate=%u bytes/s, implied "
ccid3_pr_debug("%s(%p), receive rate=%u bytes/s, implied "
"loss rate=%u\n", dccp_role(sk), sk, x_recv, p); "loss rate=%u\n", dccp_role(sk), sk, x_recv, p);
if (p == 0) if (p == 0)
...@@ -913,7 +926,8 @@ static int ccid3_hc_rx_detect_loss(struct sock *sk, ...@@ -913,7 +926,8 @@ static int ccid3_hc_rx_detect_loss(struct sock *sk,
struct dccp_rx_hist_entry *packet) struct dccp_rx_hist_entry *packet)
{ {
struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); 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); struct dccp_rx_hist_entry *rx_hist =
dccp_rx_hist_head(&hcrx->ccid3hcrx_hist);
u64 seqno = packet->dccphrx_seqno; u64 seqno = packet->dccphrx_seqno;
u64 tmp_seqno; u64 tmp_seqno;
int loss = 0; int loss = 0;
...@@ -967,7 +981,8 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) ...@@ -967,7 +981,8 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
const struct dccp_options_received *opt_recv; const struct dccp_options_received *opt_recv;
struct dccp_rx_hist_entry *packet; struct dccp_rx_hist_entry *packet;
struct timeval now; struct timeval now;
u32 p_prev, rtt_prev, r_sample, t_elapsed; u32 p_prev, rtt_prev;
suseconds_t r_sample, t_elapsed;
int loss, payload_size; int loss, payload_size;
BUG_ON(hcrx == NULL); BUG_ON(hcrx == NULL);
...@@ -987,11 +1002,13 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) ...@@ -987,11 +1002,13 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
r_sample = timeval_usecs(&now); r_sample = timeval_usecs(&now);
t_elapsed = opt_recv->dccpor_elapsed_time * 10; t_elapsed = opt_recv->dccpor_elapsed_time * 10;
DCCP_BUG_ON(r_sample < 0);
if (unlikely(r_sample <= t_elapsed)) if (unlikely(r_sample <= t_elapsed))
DCCP_WARN("r_sample=%uus, t_elapsed=%uus\n", DCCP_WARN("r_sample=%ldus, t_elapsed=%ldus\n",
r_sample, t_elapsed); r_sample, t_elapsed);
else else
r_sample -= t_elapsed; r_sample -= t_elapsed;
CCID3_RTT_SANITY_CHECK(r_sample);
if (hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA) if (hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA)
hcrx->ccid3hcrx_rtt = r_sample; hcrx->ccid3hcrx_rtt = r_sample;
...@@ -1000,8 +1017,8 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) ...@@ -1000,8 +1017,8 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
r_sample / 10; r_sample / 10;
if (rtt_prev != hcrx->ccid3hcrx_rtt) if (rtt_prev != hcrx->ccid3hcrx_rtt)
ccid3_pr_debug("%s, New RTT=%uus, elapsed time=%u\n", ccid3_pr_debug("%s(%p), New RTT=%uus, elapsed time=%u\n",
dccp_role(sk), hcrx->ccid3hcrx_rtt, dccp_role(sk), sk, hcrx->ccid3hcrx_rtt,
opt_recv->dccpor_elapsed_time); opt_recv->dccpor_elapsed_time);
break; break;
case DCCP_PKT_DATA: case DCCP_PKT_DATA:
...@@ -1013,7 +1030,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) ...@@ -1013,7 +1030,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
packet = dccp_rx_hist_entry_new(ccid3_rx_hist, sk, opt_recv->dccpor_ndp, packet = dccp_rx_hist_entry_new(ccid3_rx_hist, sk, opt_recv->dccpor_ndp,
skb, GFP_ATOMIC); skb, GFP_ATOMIC);
if (unlikely(packet == NULL)) { if (unlikely(packet == NULL)) {
DCCP_WARN("%s, sk=%p, Not enough mem to add rx packet " DCCP_WARN("%s(%p), Not enough mem to add rx packet "
"to history, consider it lost!\n", dccp_role(sk), sk); "to history, consider it lost!\n", dccp_role(sk), sk);
return; return;
} }
...@@ -1028,9 +1045,8 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) ...@@ -1028,9 +1045,8 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
switch (hcrx->ccid3hcrx_state) { switch (hcrx->ccid3hcrx_state) {
case TFRC_RSTATE_NO_DATA: case TFRC_RSTATE_NO_DATA:
ccid3_pr_debug("%s, sk=%p(%s), skb=%p, sending initial " ccid3_pr_debug("%s(%p, state=%s), skb=%p, sending initial "
"feedback\n", "feedback\n", dccp_role(sk), sk,
dccp_role(sk), sk,
dccp_state_name(sk->sk_state), skb); dccp_state_name(sk->sk_state), skb);
ccid3_hc_rx_send_feedback(sk); ccid3_hc_rx_send_feedback(sk);
ccid3_hc_rx_set_state(sk, TFRC_RSTATE_DATA); ccid3_hc_rx_set_state(sk, TFRC_RSTATE_DATA);
...@@ -1041,19 +1057,19 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) ...@@ -1041,19 +1057,19 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
break; break;
dccp_timestamp(sk, &now); dccp_timestamp(sk, &now);
if (timeval_delta(&now, &hcrx->ccid3hcrx_tstamp_last_ack) >= if ((timeval_delta(&now, &hcrx->ccid3hcrx_tstamp_last_ack) -
hcrx->ccid3hcrx_rtt) { (suseconds_t)hcrx->ccid3hcrx_rtt) >= 0) {
hcrx->ccid3hcrx_tstamp_last_ack = now; hcrx->ccid3hcrx_tstamp_last_ack = now;
ccid3_hc_rx_send_feedback(sk); ccid3_hc_rx_send_feedback(sk);
} }
return; return;
case TFRC_RSTATE_TERM: case TFRC_RSTATE_TERM:
DCCP_BUG("Illegal %s state TERM, sk=%p", dccp_role(sk), sk); DCCP_BUG("%s(%p) - Illegal state TERM", dccp_role(sk), sk);
return; return;
} }
/* Dealing with packet loss */ /* Dealing with packet loss */
ccid3_pr_debug("%s, sk=%p(%s), data loss! Reacting...\n", ccid3_pr_debug("%s(%p, state=%s), data loss! Reacting...\n",
dccp_role(sk), sk, dccp_state_name(sk->sk_state)); dccp_role(sk), sk, dccp_state_name(sk->sk_state));
p_prev = hcrx->ccid3hcrx_p; p_prev = hcrx->ccid3hcrx_p;
...@@ -1078,7 +1094,7 @@ static int ccid3_hc_rx_init(struct ccid *ccid, struct sock *sk) ...@@ -1078,7 +1094,7 @@ static int ccid3_hc_rx_init(struct ccid *ccid, struct sock *sk)
{ {
struct ccid3_hc_rx_sock *hcrx = ccid_priv(ccid); struct ccid3_hc_rx_sock *hcrx = ccid_priv(ccid);
ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); ccid3_pr_debug("entry\n");
hcrx->ccid3hcrx_state = TFRC_RSTATE_NO_DATA; hcrx->ccid3hcrx_state = TFRC_RSTATE_NO_DATA;
INIT_LIST_HEAD(&hcrx->ccid3hcrx_hist); INIT_LIST_HEAD(&hcrx->ccid3hcrx_hist);
...@@ -1086,7 +1102,7 @@ static int ccid3_hc_rx_init(struct ccid *ccid, struct sock *sk) ...@@ -1086,7 +1102,7 @@ static int ccid3_hc_rx_init(struct ccid *ccid, struct sock *sk)
dccp_timestamp(sk, &hcrx->ccid3hcrx_tstamp_last_ack); dccp_timestamp(sk, &hcrx->ccid3hcrx_tstamp_last_ack);
hcrx->ccid3hcrx_tstamp_last_feedback = hcrx->ccid3hcrx_tstamp_last_ack; hcrx->ccid3hcrx_tstamp_last_feedback = hcrx->ccid3hcrx_tstamp_last_ack;
hcrx->ccid3hcrx_s = 0; hcrx->ccid3hcrx_s = 0;
hcrx->ccid3hcrx_rtt = 5000; /* XXX 5ms for now... */ hcrx->ccid3hcrx_rtt = 0;
return 0; return 0;
} }
...@@ -1198,7 +1214,6 @@ static struct ccid_operations ccid3 = { ...@@ -1198,7 +1214,6 @@ static struct ccid_operations ccid3 = {
.ccid_hc_tx_send_packet = ccid3_hc_tx_send_packet, .ccid_hc_tx_send_packet = ccid3_hc_tx_send_packet,
.ccid_hc_tx_packet_sent = ccid3_hc_tx_packet_sent, .ccid_hc_tx_packet_sent = ccid3_hc_tx_packet_sent,
.ccid_hc_tx_packet_recv = ccid3_hc_tx_packet_recv, .ccid_hc_tx_packet_recv = ccid3_hc_tx_packet_recv,
.ccid_hc_tx_insert_options = ccid3_hc_tx_insert_options,
.ccid_hc_tx_parse_options = ccid3_hc_tx_parse_options, .ccid_hc_tx_parse_options = ccid3_hc_tx_parse_options,
.ccid_hc_rx_obj_size = sizeof(struct ccid3_hc_rx_sock), .ccid_hc_rx_obj_size = sizeof(struct ccid3_hc_rx_sock),
.ccid_hc_rx_init = ccid3_hc_rx_init, .ccid_hc_rx_init = ccid3_hc_rx_init,
......
...@@ -51,6 +51,16 @@ ...@@ -51,6 +51,16 @@
/* Parameter t_mbi from [RFC 3448, 4.3]: backoff interval in seconds */ /* Parameter t_mbi from [RFC 3448, 4.3]: backoff interval in seconds */
#define TFRC_T_MBI 64 #define TFRC_T_MBI 64
/* What we think is a reasonable upper limit on RTT values */
#define CCID3_SANE_RTT_MAX ((suseconds_t)(4 * USEC_PER_SEC))
#define CCID3_RTT_SANITY_CHECK(rtt) do { \
if (rtt > CCID3_SANE_RTT_MAX) { \
DCCP_CRIT("RTT (%d) too large, substituting %d", \
(int)rtt, (int)CCID3_SANE_RTT_MAX); \
rtt = CCID3_SANE_RTT_MAX; \
} } while (0)
enum ccid3_options { enum ccid3_options {
TFRC_OPT_LOSS_EVENT_RATE = 192, TFRC_OPT_LOSS_EVENT_RATE = 192,
TFRC_OPT_LOSS_INTERVALS = 193, TFRC_OPT_LOSS_INTERVALS = 193,
...@@ -75,14 +85,14 @@ enum ccid3_hc_tx_states { ...@@ -75,14 +85,14 @@ enum ccid3_hc_tx_states {
/** struct ccid3_hc_tx_sock - CCID3 sender half-connection socket /** struct ccid3_hc_tx_sock - CCID3 sender half-connection socket
* *
* @ccid3hctx_x - Current sending rate * @ccid3hctx_x - Current sending rate in 64 * bytes per second
* @ccid3hctx_x_recv - Receive rate * @ccid3hctx_x_recv - Receive rate in 64 * bytes per second
* @ccid3hctx_x_calc - Calculated send rate (RFC 3448, 3.1) * @ccid3hctx_x_calc - Calculated rate in bytes per second
* @ccid3hctx_rtt - Estimate of current round trip time in usecs * @ccid3hctx_rtt - Estimate of current round trip time in usecs
* @ccid3hctx_p - Current loss event rate (0-1) scaled by 1000000 * @ccid3hctx_p - Current loss event rate (0-1) scaled by 1000000
* @ccid3hctx_s - Packet size * @ccid3hctx_s - Packet size in bytes
* @ccid3hctx_t_rto - Retransmission Timeout (RFC 3448, 3.1) * @ccid3hctx_t_rto - Nofeedback Timer setting in usecs
* @ccid3hctx_t_ipi - Interpacket (send) interval (RFC 3448, 4.6) * @ccid3hctx_t_ipi - Interpacket (send) interval (RFC 3448, 4.6) in usecs
* @ccid3hctx_state - Sender state, one of %ccid3_hc_tx_states * @ccid3hctx_state - Sender state, one of %ccid3_hc_tx_states
* @ccid3hctx_last_win_count - Last window counter sent * @ccid3hctx_last_win_count - Last window counter sent
* @ccid3hctx_t_last_win_count - Timestamp of earliest packet * @ccid3hctx_t_last_win_count - Timestamp of earliest packet
...@@ -91,7 +101,7 @@ enum ccid3_hc_tx_states { ...@@ -91,7 +101,7 @@ enum ccid3_hc_tx_states {
* @ccid3hctx_idle - Flag indicating that sender is idling * @ccid3hctx_idle - Flag indicating that sender is idling
* @ccid3hctx_t_ld - Time last doubled during slow start * @ccid3hctx_t_ld - Time last doubled during slow start
* @ccid3hctx_t_nom - Nominal send time of next packet * @ccid3hctx_t_nom - Nominal send time of next packet
* @ccid3hctx_delta - Send timer delta * @ccid3hctx_delta - Send timer delta (RFC 3448, 4.6) in usecs
* @ccid3hctx_hist - Packet history * @ccid3hctx_hist - Packet history
* @ccid3hctx_options_received - Parsed set of retrieved options * @ccid3hctx_options_received - Parsed set of retrieved options
*/ */
......
...@@ -36,9 +36,100 @@ ...@@ -36,9 +36,100 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/string.h> #include <linux/string.h>
#include "packet_history.h" #include "packet_history.h"
/*
* Transmitter History Routines
*/
struct dccp_tx_hist *dccp_tx_hist_new(const char *name)
{
struct dccp_tx_hist *hist = kmalloc(sizeof(*hist), GFP_ATOMIC);
static const char dccp_tx_hist_mask[] = "tx_hist_%s";
char *slab_name;
if (hist == NULL)
goto out;
slab_name = kmalloc(strlen(name) + sizeof(dccp_tx_hist_mask) - 1,
GFP_ATOMIC);
if (slab_name == NULL)
goto out_free_hist;
sprintf(slab_name, dccp_tx_hist_mask, name);
hist->dccptxh_slab = kmem_cache_create(slab_name,
sizeof(struct dccp_tx_hist_entry),
0, SLAB_HWCACHE_ALIGN,
NULL, NULL);
if (hist->dccptxh_slab == NULL)
goto out_free_slab_name;
out:
return hist;
out_free_slab_name:
kfree(slab_name);
out_free_hist:
kfree(hist);
hist = NULL;
goto out;
}
EXPORT_SYMBOL_GPL(dccp_tx_hist_new);
void dccp_tx_hist_delete(struct dccp_tx_hist *hist)
{
const char* name = kmem_cache_name(hist->dccptxh_slab);
kmem_cache_destroy(hist->dccptxh_slab);
kfree(name);
kfree(hist);
}
EXPORT_SYMBOL_GPL(dccp_tx_hist_delete);
struct dccp_tx_hist_entry *
dccp_tx_hist_find_entry(const struct list_head *list, const u64 seq)
{
struct dccp_tx_hist_entry *packet = NULL, *entry;
list_for_each_entry(entry, list, dccphtx_node)
if (entry->dccphtx_seqno == seq) {
packet = entry;
break;
}
return packet;
}
EXPORT_SYMBOL_GPL(dccp_tx_hist_find_entry);
void dccp_tx_hist_purge(struct dccp_tx_hist *hist, struct list_head *list)
{
struct dccp_tx_hist_entry *entry, *next;
list_for_each_entry_safe(entry, next, list, dccphtx_node) {
list_del_init(&entry->dccphtx_node);
dccp_tx_hist_entry_delete(hist, entry);
}
}
EXPORT_SYMBOL_GPL(dccp_tx_hist_purge);
void dccp_tx_hist_purge_older(struct dccp_tx_hist *hist,
struct list_head *list,
struct dccp_tx_hist_entry *packet)
{
struct dccp_tx_hist_entry *next;
list_for_each_entry_safe_continue(packet, next, list, dccphtx_node) {
list_del_init(&packet->dccphtx_node);
dccp_tx_hist_entry_delete(hist, packet);
}
}
EXPORT_SYMBOL_GPL(dccp_tx_hist_purge_older);
/*
* Receiver History Routines
*/
struct dccp_rx_hist *dccp_rx_hist_new(const char *name) struct dccp_rx_hist *dccp_rx_hist_new(const char *name)
{ {
struct dccp_rx_hist *hist = kmalloc(sizeof(*hist), GFP_ATOMIC); struct dccp_rx_hist *hist = kmalloc(sizeof(*hist), GFP_ATOMIC);
...@@ -83,18 +174,24 @@ void dccp_rx_hist_delete(struct dccp_rx_hist *hist) ...@@ -83,18 +174,24 @@ void dccp_rx_hist_delete(struct dccp_rx_hist *hist)
EXPORT_SYMBOL_GPL(dccp_rx_hist_delete); EXPORT_SYMBOL_GPL(dccp_rx_hist_delete);
void dccp_rx_hist_purge(struct dccp_rx_hist *hist, struct list_head *list) int dccp_rx_hist_find_entry(const struct list_head *list, const u64 seq,
u8 *ccval)
{ {
struct dccp_rx_hist_entry *entry, *next; struct dccp_rx_hist_entry *packet = NULL, *entry;
list_for_each_entry_safe(entry, next, list, dccphrx_node) { list_for_each_entry(entry, list, dccphrx_node)
list_del_init(&entry->dccphrx_node); if (entry->dccphrx_seqno == seq) {
kmem_cache_free(hist->dccprxh_slab, entry); packet = entry;
break;
} }
}
EXPORT_SYMBOL_GPL(dccp_rx_hist_purge); if (packet)
*ccval = packet->dccphrx_ccval;
return packet != NULL;
}
EXPORT_SYMBOL_GPL(dccp_rx_hist_find_entry);
struct dccp_rx_hist_entry * struct dccp_rx_hist_entry *
dccp_rx_hist_find_data_packet(const struct list_head *list) dccp_rx_hist_find_data_packet(const struct list_head *list)
{ {
...@@ -184,110 +281,18 @@ void dccp_rx_hist_add_packet(struct dccp_rx_hist *hist, ...@@ -184,110 +281,18 @@ void dccp_rx_hist_add_packet(struct dccp_rx_hist *hist,
EXPORT_SYMBOL_GPL(dccp_rx_hist_add_packet); EXPORT_SYMBOL_GPL(dccp_rx_hist_add_packet);
struct dccp_tx_hist *dccp_tx_hist_new(const char *name) void dccp_rx_hist_purge(struct dccp_rx_hist *hist, struct list_head *list)
{
struct dccp_tx_hist *hist = kmalloc(sizeof(*hist), GFP_ATOMIC);
static const char dccp_tx_hist_mask[] = "tx_hist_%s";
char *slab_name;
if (hist == NULL)
goto out;
slab_name = kmalloc(strlen(name) + sizeof(dccp_tx_hist_mask) - 1,
GFP_ATOMIC);
if (slab_name == NULL)
goto out_free_hist;
sprintf(slab_name, dccp_tx_hist_mask, name);
hist->dccptxh_slab = kmem_cache_create(slab_name,
sizeof(struct dccp_tx_hist_entry),
0, SLAB_HWCACHE_ALIGN,
NULL, NULL);
if (hist->dccptxh_slab == NULL)
goto out_free_slab_name;
out:
return hist;
out_free_slab_name:
kfree(slab_name);
out_free_hist:
kfree(hist);
hist = NULL;
goto out;
}
EXPORT_SYMBOL_GPL(dccp_tx_hist_new);
void dccp_tx_hist_delete(struct dccp_tx_hist *hist)
{
const char* name = kmem_cache_name(hist->dccptxh_slab);
kmem_cache_destroy(hist->dccptxh_slab);
kfree(name);
kfree(hist);
}
EXPORT_SYMBOL_GPL(dccp_tx_hist_delete);
struct dccp_tx_hist_entry *
dccp_tx_hist_find_entry(const struct list_head *list, const u64 seq)
{
struct dccp_tx_hist_entry *packet = NULL, *entry;
list_for_each_entry(entry, list, dccphtx_node)
if (entry->dccphtx_seqno == seq) {
packet = entry;
break;
}
return packet;
}
EXPORT_SYMBOL_GPL(dccp_tx_hist_find_entry);
int dccp_rx_hist_find_entry(const struct list_head *list, const u64 seq,
u8 *ccval)
{
struct dccp_rx_hist_entry *packet = NULL, *entry;
list_for_each_entry(entry, list, dccphrx_node)
if (entry->dccphrx_seqno == seq) {
packet = entry;
break;
}
if (packet)
*ccval = packet->dccphrx_ccval;
return packet != NULL;
}
EXPORT_SYMBOL_GPL(dccp_rx_hist_find_entry);
void dccp_tx_hist_purge_older(struct dccp_tx_hist *hist,
struct list_head *list,
struct dccp_tx_hist_entry *packet)
{ {
struct dccp_tx_hist_entry *next; struct dccp_rx_hist_entry *entry, *next;
list_for_each_entry_safe_continue(packet, next, list, dccphtx_node) { list_for_each_entry_safe(entry, next, list, dccphrx_node) {
list_del_init(&packet->dccphtx_node); list_del_init(&entry->dccphrx_node);
dccp_tx_hist_entry_delete(hist, packet); kmem_cache_free(hist->dccprxh_slab, entry);
} }
} }
EXPORT_SYMBOL_GPL(dccp_tx_hist_purge_older); EXPORT_SYMBOL_GPL(dccp_rx_hist_purge);
void dccp_tx_hist_purge(struct dccp_tx_hist *hist, struct list_head *list)
{
struct dccp_tx_hist_entry *entry, *next;
list_for_each_entry_safe(entry, next, list, dccphtx_node) {
list_del_init(&entry->dccphtx_node);
dccp_tx_hist_entry_delete(hist, entry);
}
}
EXPORT_SYMBOL_GPL(dccp_tx_hist_purge);
MODULE_AUTHOR("Ian McDonald <ian.mcdonald@jandi.co.nz>, " MODULE_AUTHOR("Ian McDonald <ian.mcdonald@jandi.co.nz>, "
"Arnaldo Carvalho de Melo <acme@ghostprotocols.net>"); "Arnaldo Carvalho de Melo <acme@ghostprotocols.net>");
......
...@@ -49,24 +49,17 @@ ...@@ -49,24 +49,17 @@
#define TFRC_WIN_COUNT_PER_RTT 4 #define TFRC_WIN_COUNT_PER_RTT 4
#define TFRC_WIN_COUNT_LIMIT 16 #define TFRC_WIN_COUNT_LIMIT 16
/*
* Transmitter History data structures and declarations
*/
struct dccp_tx_hist_entry { struct dccp_tx_hist_entry {
struct list_head dccphtx_node; struct list_head dccphtx_node;
u64 dccphtx_seqno:48, u64 dccphtx_seqno:48,
dccphtx_ccval:4,
dccphtx_sent:1; dccphtx_sent:1;
u32 dccphtx_rtt; u32 dccphtx_rtt;
struct timeval dccphtx_tstamp; struct timeval dccphtx_tstamp;
}; };
struct dccp_rx_hist_entry {
struct list_head dccphrx_node;
u64 dccphrx_seqno:48,
dccphrx_ccval:4,
dccphrx_type:4;
u32 dccphrx_ndp; /* In fact it is from 8 to 24 bits */
struct timeval dccphrx_tstamp;
};
struct dccp_tx_hist { struct dccp_tx_hist {
struct kmem_cache *dccptxh_slab; struct kmem_cache *dccptxh_slab;
}; };
...@@ -74,15 +67,6 @@ struct dccp_tx_hist { ...@@ -74,15 +67,6 @@ struct dccp_tx_hist {
extern struct dccp_tx_hist *dccp_tx_hist_new(const char *name); extern struct dccp_tx_hist *dccp_tx_hist_new(const char *name);
extern void dccp_tx_hist_delete(struct dccp_tx_hist *hist); extern void dccp_tx_hist_delete(struct dccp_tx_hist *hist);
struct dccp_rx_hist {
struct kmem_cache *dccprxh_slab;
};
extern struct dccp_rx_hist *dccp_rx_hist_new(const char *name);
extern void dccp_rx_hist_delete(struct dccp_rx_hist *hist);
extern struct dccp_rx_hist_entry *
dccp_rx_hist_find_data_packet(const struct list_head *list);
static inline struct dccp_tx_hist_entry * static inline struct dccp_tx_hist_entry *
dccp_tx_hist_entry_new(struct dccp_tx_hist *hist, dccp_tx_hist_entry_new(struct dccp_tx_hist *hist,
const gfp_t prio) const gfp_t prio)
...@@ -96,18 +80,20 @@ static inline struct dccp_tx_hist_entry * ...@@ -96,18 +80,20 @@ static inline struct dccp_tx_hist_entry *
return entry; return entry;
} }
static inline void dccp_tx_hist_entry_delete(struct dccp_tx_hist *hist, static inline struct dccp_tx_hist_entry *
struct dccp_tx_hist_entry *entry) dccp_tx_hist_head(struct list_head *list)
{ {
if (entry != NULL) struct dccp_tx_hist_entry *head = NULL;
kmem_cache_free(hist->dccptxh_slab, entry);
if (!list_empty(list))
head = list_entry(list->next, struct dccp_tx_hist_entry,
dccphtx_node);
return head;
} }
extern struct dccp_tx_hist_entry * extern struct dccp_tx_hist_entry *
dccp_tx_hist_find_entry(const struct list_head *list, dccp_tx_hist_find_entry(const struct list_head *list,
const u64 seq); const u64 seq);
extern int dccp_rx_hist_find_entry(const struct list_head *list, const u64 seq,
u8 *ccval);
static inline void dccp_tx_hist_add_entry(struct list_head *list, static inline void dccp_tx_hist_add_entry(struct list_head *list,
struct dccp_tx_hist_entry *entry) struct dccp_tx_hist_entry *entry)
...@@ -115,23 +101,38 @@ static inline void dccp_tx_hist_add_entry(struct list_head *list, ...@@ -115,23 +101,38 @@ static inline void dccp_tx_hist_add_entry(struct list_head *list,
list_add(&entry->dccphtx_node, list); list_add(&entry->dccphtx_node, list);
} }
static inline void dccp_tx_hist_entry_delete(struct dccp_tx_hist *hist,
struct dccp_tx_hist_entry *entry)
{
if (entry != NULL)
kmem_cache_free(hist->dccptxh_slab, entry);
}
extern void dccp_tx_hist_purge(struct dccp_tx_hist *hist,
struct list_head *list);
extern void dccp_tx_hist_purge_older(struct dccp_tx_hist *hist, extern void dccp_tx_hist_purge_older(struct dccp_tx_hist *hist,
struct list_head *list, struct list_head *list,
struct dccp_tx_hist_entry *next); struct dccp_tx_hist_entry *next);
extern void dccp_tx_hist_purge(struct dccp_tx_hist *hist, /*
struct list_head *list); * Receiver History data structures and declarations
*/
struct dccp_rx_hist_entry {
struct list_head dccphrx_node;
u64 dccphrx_seqno:48,
dccphrx_ccval:4,
dccphrx_type:4;
u32 dccphrx_ndp; /* In fact it is from 8 to 24 bits */
struct timeval dccphrx_tstamp;
};
static inline struct dccp_tx_hist_entry * struct dccp_rx_hist {
dccp_tx_hist_head(struct list_head *list) struct kmem_cache *dccprxh_slab;
{ };
struct dccp_tx_hist_entry *head = NULL;
if (!list_empty(list)) extern struct dccp_rx_hist *dccp_rx_hist_new(const char *name);
head = list_entry(list->next, struct dccp_tx_hist_entry, extern void dccp_rx_hist_delete(struct dccp_rx_hist *hist);
dccphtx_node);
return head;
}
static inline struct dccp_rx_hist_entry * static inline struct dccp_rx_hist_entry *
dccp_rx_hist_entry_new(struct dccp_rx_hist *hist, dccp_rx_hist_entry_new(struct dccp_rx_hist *hist,
...@@ -156,16 +157,6 @@ static inline struct dccp_rx_hist_entry * ...@@ -156,16 +157,6 @@ static inline struct dccp_rx_hist_entry *
return entry; return entry;
} }
static inline void dccp_rx_hist_entry_delete(struct dccp_rx_hist *hist,
struct dccp_rx_hist_entry *entry)
{
if (entry != NULL)
kmem_cache_free(hist->dccprxh_slab, entry);
}
extern void dccp_rx_hist_purge(struct dccp_rx_hist *hist,
struct list_head *list);
static inline struct dccp_rx_hist_entry * static inline struct dccp_rx_hist_entry *
dccp_rx_hist_head(struct list_head *list) dccp_rx_hist_head(struct list_head *list)
{ {
...@@ -177,12 +168,10 @@ static inline struct dccp_rx_hist_entry * ...@@ -177,12 +168,10 @@ static inline struct dccp_rx_hist_entry *
return head; return head;
} }
static inline int extern int dccp_rx_hist_find_entry(const struct list_head *list, const u64 seq,
dccp_rx_hist_entry_data_packet(const struct dccp_rx_hist_entry *entry) u8 *ccval);
{ extern struct dccp_rx_hist_entry *
return entry->dccphrx_type == DCCP_PKT_DATA || dccp_rx_hist_find_data_packet(const struct list_head *list);
entry->dccphrx_type == DCCP_PKT_DATAACK;
}
extern void dccp_rx_hist_add_packet(struct dccp_rx_hist *hist, extern void dccp_rx_hist_add_packet(struct dccp_rx_hist *hist,
struct list_head *rx_list, struct list_head *rx_list,
...@@ -190,6 +179,23 @@ extern void dccp_rx_hist_add_packet(struct dccp_rx_hist *hist, ...@@ -190,6 +179,23 @@ extern void dccp_rx_hist_add_packet(struct dccp_rx_hist *hist,
struct dccp_rx_hist_entry *packet, struct dccp_rx_hist_entry *packet,
u64 nonloss_seqno); u64 nonloss_seqno);
static inline void dccp_rx_hist_entry_delete(struct dccp_rx_hist *hist,
struct dccp_rx_hist_entry *entry)
{
if (entry != NULL)
kmem_cache_free(hist->dccprxh_slab, entry);
}
extern void dccp_rx_hist_purge(struct dccp_rx_hist *hist,
struct list_head *list);
static inline int
dccp_rx_hist_entry_data_packet(const struct dccp_rx_hist_entry *entry)
{
return entry->dccphrx_type == DCCP_PKT_DATA ||
entry->dccphrx_type == DCCP_PKT_DATAACK;
}
extern u64 dccp_rx_hist_detect_loss(struct list_head *rx_list, extern u64 dccp_rx_hist_detect_loss(struct list_head *rx_list,
struct list_head *li_list, u8 *win_loss); struct list_head *li_list, u8 *win_loss);
......
...@@ -13,8 +13,29 @@ ...@@ -13,8 +13,29 @@
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
*/ */
#include <linux/types.h> #include <linux/types.h>
#include <asm/div64.h>
/* integer-arithmetic divisions of type (a * 1000000)/b */
static inline u64 scaled_div(u64 a, u32 b)
{
BUG_ON(b==0);
a *= 1000000;
do_div(a, b);
return a;
}
static inline u32 scaled_div32(u64 a, u32 b)
{
u64 result = scaled_div(a, b);
if (result > UINT_MAX) {
DCCP_CRIT("Overflow: a(%llu)/b(%u) > ~0U",
(unsigned long long)a, b);
return UINT_MAX;
}
return result;
}
extern u32 tfrc_calc_x(u16 s, u32 R, u32 p); extern u32 tfrc_calc_x(u16 s, u32 R, u32 p);
extern u32 tfrc_calc_x_reverse_lookup(u32 fvalue); extern u32 tfrc_calc_x_reverse_lookup(u32 fvalue);
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <asm/div64.h>
#include "../../dccp.h" #include "../../dccp.h"
#include "tfrc.h" #include "tfrc.h"
...@@ -616,15 +615,12 @@ static inline u32 tfrc_binsearch(u32 fval, u8 small) ...@@ -616,15 +615,12 @@ static inline u32 tfrc_binsearch(u32 fval, u8 small)
* @R: RTT scaled by 1000000 (i.e., microseconds) * @R: RTT scaled by 1000000 (i.e., microseconds)
* @p: loss ratio estimate scaled by 1000000 * @p: loss ratio estimate scaled by 1000000
* Returns X_calc in bytes per second (not scaled). * Returns X_calc in bytes per second (not scaled).
*
* Note: DO NOT alter this code unless you run test cases against it,
* as the code has been optimized to stop underflow/overflow.
*/ */
u32 tfrc_calc_x(u16 s, u32 R, u32 p) u32 tfrc_calc_x(u16 s, u32 R, u32 p)
{ {
int index; u16 index;
u32 f; u32 f;
u64 tmp1, tmp2; u64 result;
/* check against invalid parameters and divide-by-zero */ /* check against invalid parameters and divide-by-zero */
BUG_ON(p > 1000000); /* p must not exceed 100% */ BUG_ON(p > 1000000); /* p must not exceed 100% */
...@@ -650,15 +646,17 @@ u32 tfrc_calc_x(u16 s, u32 R, u32 p) ...@@ -650,15 +646,17 @@ u32 tfrc_calc_x(u16 s, u32 R, u32 p)
f = tfrc_calc_x_lookup[index][0]; f = tfrc_calc_x_lookup[index][0];
} }
/* The following computes X = s/(R*f(p)) in bytes per second. Since f(p) /*
* and R are both scaled by 1000000, we need to multiply by 1000000^2. * Compute X = s/(R*f(p)) in bytes per second.
* ==> DO NOT alter this unless you test against overflow on 32 bit */ * Since f(p) and R are both scaled by 1000000, we need to multiply by
tmp1 = ((u64)s * 100000000); * 1000000^2. To avoid overflow, the result is computed in two stages.
tmp2 = ((u64)R * (u64)f); * This works under almost all reasonable operational conditions, for a
do_div(tmp2, 10000); * wide range of parameters. Yet, should some strange combination of
do_div(tmp1, tmp2); * parameters result in overflow, the use of scaled_div32 will catch
* this and return UINT_MAX - which is a logically adequate consequence.
return (u32)tmp1; */
result = scaled_div(s, R);
return scaled_div32(result, f);
} }
EXPORT_SYMBOL_GPL(tfrc_calc_x); EXPORT_SYMBOL_GPL(tfrc_calc_x);
......
...@@ -80,8 +80,6 @@ extern void dccp_time_wait(struct sock *sk, int state, int timeo); ...@@ -80,8 +80,6 @@ extern void dccp_time_wait(struct sock *sk, int state, int timeo);
#define DCCP_RTO_MAX ((unsigned)(120 * HZ)) /* FIXME: using TCP value */ #define DCCP_RTO_MAX ((unsigned)(120 * HZ)) /* FIXME: using TCP value */
#define DCCP_XMIT_TIMEO 30000 /* Time/msecs for blocking transmit per packet */
/* sysctl variables for DCCP */ /* sysctl variables for DCCP */
extern int sysctl_dccp_request_retries; extern int sysctl_dccp_request_retries;
extern int sysctl_dccp_retries1; extern int sysctl_dccp_retries1;
...@@ -434,6 +432,7 @@ static inline void timeval_sub_usecs(struct timeval *tv, ...@@ -434,6 +432,7 @@ static inline void timeval_sub_usecs(struct timeval *tv,
tv->tv_sec--; tv->tv_sec--;
tv->tv_usec += USEC_PER_SEC; tv->tv_usec += USEC_PER_SEC;
} }
DCCP_BUG_ON(tv->tv_sec < 0);
} }
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
......
...@@ -248,7 +248,17 @@ int dccp_rcv_established(struct sock *sk, struct sk_buff *skb, ...@@ -248,7 +248,17 @@ int dccp_rcv_established(struct sock *sk, struct sk_buff *skb,
DCCP_ACKVEC_STATE_RECEIVED)) DCCP_ACKVEC_STATE_RECEIVED))
goto discard; goto discard;
/*
* Deliver to the CCID module in charge.
* FIXME: Currently DCCP operates one-directional only, i.e. a listening
* server is not at the same time a connecting client. There is
* not much sense in delivering to both rx/tx sides at the moment
* (only one is active at a time); when moving to bidirectional
* service, this needs to be revised.
*/
if (dccp_sk(sk)->dccps_role == DCCP_ROLE_SERVER)
ccid_hc_rx_packet_recv(dp->dccps_hc_rx_ccid, sk, skb); ccid_hc_rx_packet_recv(dp->dccps_hc_rx_ccid, sk, skb);
else
ccid_hc_tx_packet_recv(dp->dccps_hc_tx_ccid, sk, skb); ccid_hc_tx_packet_recv(dp->dccps_hc_tx_ccid, sk, skb);
return __dccp_rcv_established(sk, skb, dh, len); return __dccp_rcv_established(sk, skb, dh, len);
...@@ -484,7 +494,10 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb, ...@@ -484,7 +494,10 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
DCCP_ACKVEC_STATE_RECEIVED)) DCCP_ACKVEC_STATE_RECEIVED))
goto discard; goto discard;
/* XXX see the comments in dccp_rcv_established about this */
if (dccp_sk(sk)->dccps_role == DCCP_ROLE_SERVER)
ccid_hc_rx_packet_recv(dp->dccps_hc_rx_ccid, sk, skb); ccid_hc_rx_packet_recv(dp->dccps_hc_rx_ccid, sk, skb);
else
ccid_hc_tx_packet_recv(dp->dccps_hc_tx_ccid, sk, skb); ccid_hc_tx_packet_recv(dp->dccps_hc_tx_ccid, sk, skb);
} }
......
...@@ -557,11 +557,6 @@ int dccp_insert_options(struct sock *sk, struct sk_buff *skb) ...@@ -557,11 +557,6 @@ int dccp_insert_options(struct sock *sk, struct sk_buff *skb)
return -1; return -1;
dp->dccps_hc_rx_insert_options = 0; dp->dccps_hc_rx_insert_options = 0;
} }
if (dp->dccps_hc_tx_insert_options) {
if (ccid_hc_tx_insert_options(dp->dccps_hc_tx_ccid, sk, skb))
return -1;
dp->dccps_hc_tx_insert_options = 0;
}
/* Feature negotiation */ /* Feature negotiation */
/* Data packets can't do feat negotiation */ /* Data packets can't do feat negotiation */
......
...@@ -175,14 +175,12 @@ void dccp_write_space(struct sock *sk) ...@@ -175,14 +175,12 @@ void dccp_write_space(struct sock *sk)
/** /**
* dccp_wait_for_ccid - Wait for ccid to tell us we can send a packet * dccp_wait_for_ccid - Wait for ccid to tell us we can send a packet
* @sk: socket to wait for * @sk: socket to wait for
* @timeo: for how long
*/ */
static int dccp_wait_for_ccid(struct sock *sk, struct sk_buff *skb, static int dccp_wait_for_ccid(struct sock *sk, struct sk_buff *skb)
long *timeo)
{ {
struct dccp_sock *dp = dccp_sk(sk); struct dccp_sock *dp = dccp_sk(sk);
DEFINE_WAIT(wait); DEFINE_WAIT(wait);
long delay; unsigned long delay;
int rc; int rc;
while (1) { while (1) {
...@@ -190,8 +188,6 @@ static int dccp_wait_for_ccid(struct sock *sk, struct sk_buff *skb, ...@@ -190,8 +188,6 @@ static int dccp_wait_for_ccid(struct sock *sk, struct sk_buff *skb,
if (sk->sk_err) if (sk->sk_err)
goto do_error; goto do_error;
if (!*timeo)
goto do_nonblock;
if (signal_pending(current)) if (signal_pending(current))
goto do_interrupted; goto do_interrupted;
...@@ -199,12 +195,9 @@ static int dccp_wait_for_ccid(struct sock *sk, struct sk_buff *skb, ...@@ -199,12 +195,9 @@ static int dccp_wait_for_ccid(struct sock *sk, struct sk_buff *skb,
if (rc <= 0) if (rc <= 0)
break; break;
delay = msecs_to_jiffies(rc); delay = msecs_to_jiffies(rc);
if (delay > *timeo || delay < 0)
goto do_nonblock;
sk->sk_write_pending++; sk->sk_write_pending++;
release_sock(sk); release_sock(sk);
*timeo -= schedule_timeout(delay); schedule_timeout(delay);
lock_sock(sk); lock_sock(sk);
sk->sk_write_pending--; sk->sk_write_pending--;
} }
...@@ -215,11 +208,8 @@ static int dccp_wait_for_ccid(struct sock *sk, struct sk_buff *skb, ...@@ -215,11 +208,8 @@ static int dccp_wait_for_ccid(struct sock *sk, struct sk_buff *skb,
do_error: do_error:
rc = -EPIPE; rc = -EPIPE;
goto out; goto out;
do_nonblock:
rc = -EAGAIN;
goto out;
do_interrupted: do_interrupted:
rc = sock_intr_errno(*timeo); rc = -EINTR;
goto out; goto out;
} }
...@@ -240,8 +230,6 @@ void dccp_write_xmit(struct sock *sk, int block) ...@@ -240,8 +230,6 @@ void dccp_write_xmit(struct sock *sk, int block)
{ {
struct dccp_sock *dp = dccp_sk(sk); struct dccp_sock *dp = dccp_sk(sk);
struct sk_buff *skb; struct sk_buff *skb;
long timeo = DCCP_XMIT_TIMEO; /* If a packet is taking longer than
this we have other issues */
while ((skb = skb_peek(&sk->sk_write_queue))) { while ((skb = skb_peek(&sk->sk_write_queue))) {
int err = ccid_hc_tx_send_packet(dp->dccps_hc_tx_ccid, sk, skb); int err = ccid_hc_tx_send_packet(dp->dccps_hc_tx_ccid, sk, skb);
...@@ -251,11 +239,9 @@ void dccp_write_xmit(struct sock *sk, int block) ...@@ -251,11 +239,9 @@ void dccp_write_xmit(struct sock *sk, int block)
sk_reset_timer(sk, &dp->dccps_xmit_timer, sk_reset_timer(sk, &dp->dccps_xmit_timer,
msecs_to_jiffies(err)+jiffies); msecs_to_jiffies(err)+jiffies);
break; break;
} else { } else
err = dccp_wait_for_ccid(sk, skb, &timeo); err = dccp_wait_for_ccid(sk, skb);
timeo = DCCP_XMIT_TIMEO; if (err && err != -EINTR)
}
if (err)
DCCP_BUG("err=%d after dccp_wait_for_ccid", err); DCCP_BUG("err=%d after dccp_wait_for_ccid", err);
} }
...@@ -281,9 +267,11 @@ void dccp_write_xmit(struct sock *sk, int block) ...@@ -281,9 +267,11 @@ void dccp_write_xmit(struct sock *sk, int block)
if (err) if (err)
DCCP_BUG("err=%d after ccid_hc_tx_packet_sent", DCCP_BUG("err=%d after ccid_hc_tx_packet_sent",
err); err);
} else } else {
dccp_pr_debug("packet discarded\n");
kfree(skb); kfree(skb);
} }
}
} }
int dccp_retransmit_skb(struct sock *sk, struct sk_buff *skb) int dccp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
...@@ -350,7 +338,6 @@ EXPORT_SYMBOL_GPL(dccp_make_response); ...@@ -350,7 +338,6 @@ EXPORT_SYMBOL_GPL(dccp_make_response);
static struct sk_buff *dccp_make_reset(struct sock *sk, struct dst_entry *dst, static struct sk_buff *dccp_make_reset(struct sock *sk, struct dst_entry *dst,
const enum dccp_reset_codes code) const enum dccp_reset_codes code)
{ {
struct dccp_hdr *dh; struct dccp_hdr *dh;
struct dccp_sock *dp = dccp_sk(sk); struct dccp_sock *dp = dccp_sk(sk);
......
...@@ -657,7 +657,7 @@ static void sync_master_loop(void) ...@@ -657,7 +657,7 @@ static void sync_master_loop(void)
if (stop_master_sync) if (stop_master_sync)
break; break;
ssleep(1); msleep_interruptible(1000);
} }
/* clean up the sync_buff queue */ /* clean up the sync_buff queue */
...@@ -714,7 +714,7 @@ static void sync_backup_loop(void) ...@@ -714,7 +714,7 @@ static void sync_backup_loop(void)
if (stop_backup_sync) if (stop_backup_sync)
break; break;
ssleep(1); msleep_interruptible(1000);
} }
/* release the sending multicast socket */ /* release the sending multicast socket */
...@@ -826,7 +826,7 @@ static int fork_sync_thread(void *startup) ...@@ -826,7 +826,7 @@ static int fork_sync_thread(void *startup)
if ((pid = kernel_thread(sync_thread, startup, 0)) < 0) { if ((pid = kernel_thread(sync_thread, startup, 0)) < 0) {
IP_VS_ERR("could not create sync_thread due to %d... " IP_VS_ERR("could not create sync_thread due to %d... "
"retrying.\n", pid); "retrying.\n", pid);
ssleep(1); msleep_interruptible(1000);
goto repeat; goto repeat;
} }
...@@ -849,10 +849,12 @@ int start_sync_thread(int state, char *mcast_ifn, __u8 syncid) ...@@ -849,10 +849,12 @@ int start_sync_thread(int state, char *mcast_ifn, __u8 syncid)
ip_vs_sync_state |= state; ip_vs_sync_state |= state;
if (state == IP_VS_STATE_MASTER) { if (state == IP_VS_STATE_MASTER) {
strlcpy(ip_vs_master_mcast_ifn, mcast_ifn, sizeof(ip_vs_master_mcast_ifn)); strlcpy(ip_vs_master_mcast_ifn, mcast_ifn,
sizeof(ip_vs_master_mcast_ifn));
ip_vs_master_syncid = syncid; ip_vs_master_syncid = syncid;
} else { } else {
strlcpy(ip_vs_backup_mcast_ifn, mcast_ifn, sizeof(ip_vs_backup_mcast_ifn)); strlcpy(ip_vs_backup_mcast_ifn, mcast_ifn,
sizeof(ip_vs_backup_mcast_ifn));
ip_vs_backup_syncid = syncid; ip_vs_backup_syncid = syncid;
} }
...@@ -860,7 +862,7 @@ int start_sync_thread(int state, char *mcast_ifn, __u8 syncid) ...@@ -860,7 +862,7 @@ int start_sync_thread(int state, char *mcast_ifn, __u8 syncid)
if ((pid = kernel_thread(fork_sync_thread, &startup, 0)) < 0) { if ((pid = kernel_thread(fork_sync_thread, &startup, 0)) < 0) {
IP_VS_ERR("could not create fork_sync_thread due to %d... " IP_VS_ERR("could not create fork_sync_thread due to %d... "
"retrying.\n", pid); "retrying.\n", pid);
ssleep(1); msleep_interruptible(1000);
goto repeat; goto repeat;
} }
...@@ -880,7 +882,8 @@ int stop_sync_thread(int state) ...@@ -880,7 +882,8 @@ int stop_sync_thread(int state)
IP_VS_DBG(7, "%s: pid %d\n", __FUNCTION__, current->pid); IP_VS_DBG(7, "%s: pid %d\n", __FUNCTION__, current->pid);
IP_VS_INFO("stopping sync thread %d ...\n", IP_VS_INFO("stopping sync thread %d ...\n",
(state == IP_VS_STATE_MASTER) ? sync_master_pid : sync_backup_pid); (state == IP_VS_STATE_MASTER) ?
sync_master_pid : sync_backup_pid);
__set_current_state(TASK_UNINTERRUPTIBLE); __set_current_state(TASK_UNINTERRUPTIBLE);
add_wait_queue(&stop_sync_wait, &wait); add_wait_queue(&stop_sync_wait, &wait);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment