summaryrefslogtreecommitdiffstats
path: root/src/vnet/session
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-09-15 16:28:45 -0700
committerAndrew Yourtchenko <ayourtch@gmail.com>2019-09-30 15:26:18 +0000
commit079895d95f40a0f32e2bafcaf16f167f60633edf (patch)
treeb4775480656c912d853efc15bd1e2ba94ae6d42e /src/vnet/session
parent3d7e4723098d10d4e64e07de2f5d5c1ac930e734 (diff)
session: limit pacer bucket size
Type: feature Change-Id: I3ca27b09670716eba463d7b16771f765a1bd6dcd Signed-off-by: Florin Coras <fcoras@cisco.com> (cherry picked from commit 7c8f828ba353472e27369a77574bca532147e458)
Diffstat (limited to 'src/vnet/session')
-rw-r--r--src/vnet/session/transport.c5
-rw-r--r--src/vnet/session/transport_types.h1
2 files changed, 4 insertions, 2 deletions
diff --git a/src/vnet/session/transport.c b/src/vnet/session/transport.c
index 6caa4d38cd7..effd5891e0b 100644
--- a/src/vnet/session/transport.c
+++ b/src/vnet/session/transport.c
@@ -581,7 +581,7 @@ spacer_max_burst (spacer_t * pacer, u64 norm_time_now)
if (n_periods > 0 && (inc = n_periods * pacer->tokens_per_period) > 10)
{
pacer->last_update = norm_time_now;
- pacer->bucket += inc;
+ pacer->bucket = clib_min (pacer->bucket + inc, pacer->bytes_per_sec);
}
return clib_min (pacer->bucket, TRANSPORT_PACER_MAX_BURST);
@@ -598,13 +598,14 @@ static inline void
spacer_set_pace_rate (spacer_t * pacer, u64 rate_bytes_per_sec)
{
ASSERT (rate_bytes_per_sec != 0);
+ pacer->bytes_per_sec = rate_bytes_per_sec;
pacer->tokens_per_period = rate_bytes_per_sec / transport_pacer_period;
}
static inline u64
spacer_pace_rate (spacer_t * pacer)
{
- return pacer->tokens_per_period * transport_pacer_period;
+ return pacer->bytes_per_sec;
}
void
diff --git a/src/vnet/session/transport_types.h b/src/vnet/session/transport_types.h
index ac2177c77b0..b6e01b54345 100644
--- a/src/vnet/session/transport_types.h
+++ b/src/vnet/session/transport_types.h
@@ -49,6 +49,7 @@ typedef enum transport_connection_flags_
typedef struct _spacer
{
+ u64 bytes_per_sec;
u64 bucket;
u64 last_update;
f32 tokens_per_period;