From e5fdcfb3cfee29385c44bf487638ac5a535ee5d6 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sun, 6 Dec 2020 14:24:51 +0100 Subject: ipcpd: Fix slow start in multi-bit (F)ECN policy There is a check not to rapidly double the window to astronomical sizes when there is no congestion experienced for long periods of time, but the if-else logic was botched and it still grew to astronomical sizes (albeit linear instead of exponential). I also lowered the ECN threshold a bit. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/ipcpd/unicast/pol/ca-mb-ecn.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/ipcpd/unicast/pol/ca-mb-ecn.c b/src/ipcpd/unicast/pol/ca-mb-ecn.c index 31a646b2..1baaca7a 100644 --- a/src/ipcpd/unicast/pol/ca-mb-ecn.c +++ b/src/ipcpd/unicast/pol/ca-mb-ecn.c @@ -46,7 +46,7 @@ #define CA_IWL 1 << 16 /* Initial limit ~4MiB/s */ #define CA_MINPS 8 /* Mimimum pkts / slot */ #define CA_MAXPS 64 /* Maximum pkts / slot */ -#define ECN_Q_SHFT 5 +#define ECN_Q_SHFT 4 #define ts_to_ns(ts) (ts.tv_sec * BILLION + ts.tv_nsec) struct mb_ecn_ctx { @@ -127,13 +127,16 @@ ca_wnd_t mb_ecn_ctx_update_snd(void * _ctx, if (slot > ctx->tx_slot) { ctx->tx_slot = slot; - if (!ctx->tx_cav && ctx->tx_wbc > ctx->tx_wbl) /* Slow start */ - ctx->tx_wbl <<= 1; - else if (ctx->tx_ece) /* Multiplicative Decrease */ - ctx->tx_wbl -= (ctx->tx_wbl * ctx->tx_ece) - >> (CA_SHFT + 8); - else /* Additive Increase */ - ctx->tx_wbl = ctx->tx_wbl + ctx->tx_inc; + if (!ctx->tx_cav) { /* Slow start */ + if (ctx->tx_wbc > ctx->tx_wbl) + ctx->tx_wbl <<= 1; + } else { + if (ctx->tx_ece) /* Mult. Decrease */ + ctx->tx_wbl -= (ctx->tx_wbl * ctx->tx_ece) + >> (CA_SHFT + 8); + else if (ctx->tx_wbc > ctx->tx_wbl) /* Add. Increase */ + ctx->tx_wbl = ctx->tx_wbl + ctx->tx_inc; + } /* Window scaling */ if (ctx->tx_wpc < CA_MINPS) { -- cgit v1.2.3