aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-03-26 14:05:38 -0700
committerDamjan Marion <dmarion@me.com>2019-03-27 12:37:36 +0000
commitfbf278adc2fa5ffd1671fb9f91eb03d6d0dc5a9e (patch)
tree800143900cd83703b77a5779b13f9c165c02fe20
parent9c1f824366bdde7d2b5aafd31ab788bb2135a859 (diff)
tcp: add cc algo lookup table
Change-Id: Ie7be0136c182cdc35193e47dd3249153c2f8d65e Signed-off-by: Florin Coras <fcoras@cisco.com>
-rw-r--r--src/vnet/tcp/tcp.c21
-rw-r--r--src/vnet/tcp/tcp.h3
2 files changed, 17 insertions, 7 deletions
diff --git a/src/vnet/tcp/tcp.c b/src/vnet/tcp/tcp.c
index 32abe2df210..e262513687f 100644
--- a/src/vnet/tcp/tcp.c
+++ b/src/vnet/tcp/tcp.c
@@ -545,6 +545,7 @@ tcp_cc_algo_register (tcp_cc_algorithm_type_e type,
vec_validate (tm->cc_algos, type);
tm->cc_algos[type] = *vft;
+ hash_set_mem (tm->cc_algo_by_name, vft->name, type);
}
tcp_cc_algorithm_t *
@@ -1533,6 +1534,7 @@ tcp_init (vlib_main_t * vm)
FIB_PROTOCOL_IP6, tcp6_output_node.index);
tcp_api_reference ();
+ tm->cc_algo_by_name = hash_create_string (0, sizeof (uword));
tm->tx_pacing = 1;
tm->cc_algo = TCP_CC_NEWRENO;
tm->default_mtu = 1460;
@@ -1545,15 +1547,20 @@ uword
unformat_tcp_cc_algo (unformat_input_t * input, va_list * va)
{
uword *result = va_arg (*va, uword *);
+ tcp_main_t *tm = &tcp_main;
+ char *cc_algo_name;
+ u8 found = 0;
+ uword *p;
- if (unformat (input, "newreno"))
- *result = TCP_CC_NEWRENO;
- else if (unformat (input, "cubic"))
- *result = TCP_CC_CUBIC;
- else
- return 0;
+ if (unformat (input, "%s", &cc_algo_name)
+ && ((p = hash_get_mem (tm->cc_algo_by_name, cc_algo_name))))
+ {
+ *result = *p;
+ found = 1;
+ }
- return 1;
+ vec_free (cc_algo_name);
+ return found;
}
uword
diff --git a/src/vnet/tcp/tcp.h b/src/vnet/tcp/tcp.h
index 66f1aed1510..d15a36dc774 100644
--- a/src/vnet/tcp/tcp.h
+++ b/src/vnet/tcp/tcp.h
@@ -475,6 +475,9 @@ typedef struct _tcp_main
/* Seed used to generate random iss */
tcp_iss_seed_t iss_seed;
+ /** Hash table of cc algorithms by name */
+ uword *cc_algo_by_name;
+
/*
* Configuration
*/