summaryrefslogtreecommitdiffstats
path: root/src/plugins/ikev2/ikev2.c
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2020-03-31 05:59:41 +0000
committerNeale Ranns <nranns@cisco.com>2020-04-07 12:29:09 +0000
commit59fea5a6a3fafe0a5a0d2f543db53af790013e3a (patch)
tree270cef072f0fcb11bb29c02a4119bed43a6f157e /src/plugins/ikev2/ikev2.c
parent483a3d819abf13a95b5ded65c3efa360e9b4fdf0 (diff)
ikev2: make liveness params configurable
Introduce new cli for setting liveness check period and max retries for a peer to consider its partner dead. ikev2 set liveness <period-in-seconds> <max-retires> Type: improvement Change-Id: Iadae1de245d34fe3ee85e09b570f9df8c401772b Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
Diffstat (limited to 'src/plugins/ikev2/ikev2.c')
-rw-r--r--src/plugins/ikev2/ikev2.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/plugins/ikev2/ikev2.c b/src/plugins/ikev2/ikev2.c
index 892f57cd1d6..45da023f104 100644
--- a/src/plugins/ikev2/ikev2.c
+++ b/src/plugins/ikev2/ikev2.c
@@ -29,7 +29,7 @@
#include <plugins/ikev2/ikev2_priv.h>
#include <openssl/sha.h>
-#define IKEV2_LIVENESS_RETRIES 2
+#define IKEV2_LIVENESS_RETRIES 3
#define IKEV2_LIVENESS_PERIOD_CHECK 30
ikev2_main_t ikev2_main;
@@ -2309,7 +2309,7 @@ ikev2_init_sa (ikev2_sa_t * sa)
{
ikev2_main_t *km = &ikev2_main;
sa->liveness_period_check =
- vlib_time_now (km->vlib_main) + IKEV2_LIVENESS_PERIOD_CHECK;
+ vlib_time_now (km->vlib_main) + km->liveness_period;
}
static uword
@@ -3710,6 +3710,8 @@ ikev2_init (vlib_main_t * vm)
km->vnet_main = vnet_get_main ();
km->vlib_main = vm;
+ km->liveness_period = IKEV2_LIVENESS_PERIOD_CHECK;
+ km->liveness_max_retries = IKEV2_LIVENESS_RETRIES;
ikev2_crypto_init (km);
mhash_init_vec_string (&km->profile_index_by_name, sizeof (uword));
@@ -3847,6 +3849,19 @@ ikev2_set_log_level (ikev2_log_level_t log_level)
return 0;
}
+clib_error_t *
+ikev2_set_liveness_params (u32 period, u32 max_retries)
+{
+ ikev2_main_t *km = &ikev2_main;
+
+ if (period == 0 || max_retries == 0)
+ return clib_error_return (0, "invalid args");
+
+ km->liveness_period = period;
+ km->liveness_max_retries = max_retries;
+ return 0;
+}
+
static void
ikev2_mngr_process_ipsec_sa (ipsec_sa_t * ipsec_sa)
{
@@ -3963,7 +3978,7 @@ ikev2_mngr_process_responder_sas (ikev2_sa_t * sa)
if (!sa->sk_ai || !sa->sk_ar)
return 0;
- if (sa->liveness_retries > IKEV2_LIVENESS_RETRIES)
+ if (sa->liveness_retries >= km->liveness_max_retries)
return 1;
f64 now = vlib_time_now (vm);
@@ -3971,7 +3986,7 @@ ikev2_mngr_process_responder_sas (ikev2_sa_t * sa)
if (sa->liveness_period_check < now)
{
sa->liveness_retries++;
- sa->liveness_period_check = now + IKEV2_LIVENESS_PERIOD_CHECK;
+ sa->liveness_period_check = now + km->liveness_period;
ikev2_send_informational_request (sa);
}
return 0;