From 37ebb798813514bc29b60ea7d28b99ad1036c68d Mon Sep 17 00:00:00 2001
From: Dimitri Staessens <dimitri@ouroboros.rocks>
Date: Sat, 5 Dec 2020 15:58:15 +0100
Subject: ipcpd: Fix off-by-one in Multi-bit (F)ECN policy

Noticed an off-by-one in the packet counter because it was incremented
before and the byte counter after the flow update.

Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
---
 src/ipcpd/unicast/pol/ca-mb-ecn.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

(limited to 'src/ipcpd')

diff --git a/src/ipcpd/unicast/pol/ca-mb-ecn.c b/src/ipcpd/unicast/pol/ca-mb-ecn.c
index 0542e291..31a646b2 100644
--- a/src/ipcpd/unicast/pol/ca-mb-ecn.c
+++ b/src/ipcpd/unicast/pol/ca-mb-ecn.c
@@ -119,6 +119,7 @@ ca_wnd_t mb_ecn_ctx_update_snd(void * _ctx,
 
         ctx->tx_ctr++;
         ctx->tx_wpc++;
+        ctx->tx_wbc += len;
 
         if (ctx->tx_ctr > CA_WND)
                 ctx->tx_ece = 0;
@@ -153,8 +154,6 @@ ca_wnd_t mb_ecn_ctx_update_snd(void * _ctx,
                 ctx->tx_wpc = 0;
         }
 
-        ctx->tx_wbc += len;
-
         if (ctx->tx_wbc > ctx->tx_wbl)
                 wnd.wait = ((ctx->tx_slot + 1) << ctx->tx_mul) - ts_to_ns(now);
         else
-- 
cgit v1.2.3