aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/tcp/tcp_debug.h
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2017-11-27 04:34:14 -0500
committerDave Barach <openvpp@barachs.net>2017-11-28 13:21:26 +0000
commitf988e696149f42828444c69762c036d9684b6bb0 (patch)
tree8e62fbd53a713e64be7c0441f0399aa023a949d8 /src/vnet/tcp/tcp_debug.h
parentaf6f93a4eb4740ac13b1d65eb44da442976fa809 (diff)
tcp: fix retransmissions under buffer shortage
- add debugging scaffolding for simulating buffer shortage Change-Id: Ice519d74f9c4e4094c4586c548185135b7bb5f2d Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet/tcp/tcp_debug.h')
-rwxr-xr-xsrc/vnet/tcp/tcp_debug.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/vnet/tcp/tcp_debug.h b/src/vnet/tcp/tcp_debug.h
index eb318cde4b9..5d4f7d6879d 100755
--- a/src/vnet/tcp/tcp_debug.h
+++ b/src/vnet/tcp/tcp_debug.h
@@ -22,6 +22,7 @@
#define TCP_DEBUG_SM (0)
#define TCP_DEBUG_CC (0)
#define TCP_DEBUG_CC_STAT (1)
+#define TCP_DEBUG_BUFFER_ALLOCATION (0)
#define foreach_tcp_dbg_evt \
_(INIT, "") \
@@ -747,6 +748,39 @@ if (_tc->c_cc_stat_tstamp + STATS_INTERVAL < tcp_time_now()) \
} \
}
+/*
+ * Buffer allocation
+ */
+#if TCP_DEBUG_BUFFER_ALLOCATION
+
+#define TCP_DBG_BUFFER_ALLOC_MAYBE_FAIL(thread_index) \
+{ \
+ static u32 *buffer_fail_counters; \
+ if (PREDICT_FALSE (buffer_fail_counters == 0)) \
+ { \
+ u32 num_threads; \
+ vlib_thread_main_t *vtm = vlib_get_thread_main (); \
+ num_threads = 1 /* main thread */ + vtm->n_threads; \
+ vec_validate (buffer_fail_counters, num_threads - 1); \
+ } \
+ if (PREDICT_FALSE (tcp_main.buffer_fail_fraction != 0.0)) \
+ { \
+ if (PREDICT_TRUE (buffer_fail_counters[thread_index] > 0)) \
+ { \
+ if ((1.0 / (f32) (buffer_fail_counters[thread_index])) \
+ < tcp_main.buffer_fail_fraction) \
+ { \
+ buffer_fail_counters[thread_index] = 0.0000001; \
+ return -1; \
+ } \
+ } \
+ buffer_fail_counters[thread_index] ++; \
+ } \
+}
+#else
+#define TCP_DBG_BUFFER_ALLOC_MAYBE_FAIL(thread_index)
+#endif
+
#else
#define TCP_EVT_CC_STAT_HANDLER(_tc, ...)
#endif