summaryrefslogtreecommitdiffstats
path: root/src/plugins/gbp
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2019-03-05 04:22:08 -0800
committerNeale Ranns <nranns@cisco.com>2019-03-05 13:51:32 +0000
commit32f6d8e0ca39483f706dc3a1c28223e9fe028f06 (patch)
tree4d36a736e12268ca5f4cb937260b3ac037e743c2 /src/plugins/gbp
parent0fce11f23d64eae2f374435b31a77b872d552298 (diff)
GBP: per-group EP retention policy
Change-Id: I3ed4e2e92f74f15b07fcd3e7fbc3fa8718d5249d Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/plugins/gbp')
-rw-r--r--src/plugins/gbp/gbp.api18
-rw-r--r--src/plugins/gbp/gbp_api.c31
-rw-r--r--src/plugins/gbp/gbp_endpoint.c35
-rw-r--r--src/plugins/gbp/gbp_endpoint.h1
-rw-r--r--src/plugins/gbp/gbp_endpoint_group.c9
-rw-r--r--src/plugins/gbp/gbp_endpoint_group.h18
-rw-r--r--src/plugins/gbp/gbp_learn.h2
-rw-r--r--src/plugins/gbp/gbp_scanner.c7
8 files changed, 55 insertions, 66 deletions
diff --git a/src/plugins/gbp/gbp.api b/src/plugins/gbp/gbp.api
index a7a9a7e8dc8..347855197d7 100644
--- a/src/plugins/gbp/gbp.api
+++ b/src/plugins/gbp/gbp.api
@@ -157,6 +157,11 @@ define gbp_endpoint_details
vl_api_gbp_endpoint_t endpoint;
};
+typedef gbp_endpoint_retention
+{
+ u32 remote_ep_timeout;
+};
+
typeonly define gbp_endpoint_group
{
u16 epg_id;
@@ -164,6 +169,7 @@ typeonly define gbp_endpoint_group
u32 bd_id;
u32 rd_id;
u32 uplink_sw_if_index;
+ vl_api_gbp_endpoint_retention_t retention;
};
autoreply define gbp_endpoint_group_add
@@ -322,18 +328,6 @@ define gbp_contract_details
};
/**
- * @brief Set the time throeshold after which an endpoint is
- considered inative and is aged/reaped by the scanner
- * @param threshold In seconds
- */
-autoreply define gbp_endpoint_learn_set_inactive_threshold
-{
- u32 client_index;
- u32 context;
- u32 threshold;
-};
-
-/**
* @brief Configure a 'base' tunnel from which learned tunnels
* are permitted to derive
* A base tunnel consists only of the VNI, any src,dst IP
diff --git a/src/plugins/gbp/gbp_api.c b/src/plugins/gbp/gbp_api.c
index 665d97ea0b1..7c36da6829a 100644
--- a/src/plugins/gbp/gbp_api.c
+++ b/src/plugins/gbp/gbp_api.c
@@ -80,9 +80,8 @@
_(GBP_EXT_ITF_DUMP, gbp_ext_itf_dump) \
_(GBP_CONTRACT_ADD_DEL, gbp_contract_add_del) \
_(GBP_CONTRACT_DUMP, gbp_contract_dump) \
- _(GBP_ENDPOINT_LEARN_SET_INACTIVE_THRESHOLD, gbp_endpoint_learn_set_inactive_threshold) \
- _(GBP_VXLAN_TUNNEL_ADD, gbp_vxlan_tunnel_add) \
- _(GBP_VXLAN_TUNNEL_DEL, gbp_vxlan_tunnel_del) \
+ _(GBP_VXLAN_TUNNEL_ADD, gbp_vxlan_tunnel_add) \
+ _(GBP_VXLAN_TUNNEL_DEL, gbp_vxlan_tunnel_del) \
_(GBP_VXLAN_TUNNEL_DUMP, gbp_vxlan_tunnel_dump)
gbp_main_t gbp_main;
@@ -199,19 +198,6 @@ vl_api_gbp_endpoint_del_t_handler (vl_api_gbp_endpoint_del_t * mp)
REPLY_MACRO (VL_API_GBP_ENDPOINT_DEL_REPLY + GBP_MSG_BASE);
}
-static void
- vl_api_gbp_endpoint_learn_set_inactive_threshold_t_handler
- (vl_api_gbp_endpoint_learn_set_inactive_threshold_t * mp)
-{
- vl_api_gbp_endpoint_learn_set_inactive_threshold_reply_t *rmp;
- int rv = 0;
-
- gbp_learn_set_inactive_threshold (ntohl (mp->threshold));
-
- REPLY_MACRO (VL_API_GBP_ENDPOINT_LEARN_SET_INACTIVE_THRESHOLD_REPLY +
- GBP_MSG_BASE);
-}
-
typedef struct gbp_walk_ctx_t_
{
vl_api_registration_t *reg;
@@ -291,17 +277,28 @@ vl_api_gbp_endpoint_dump_t_handler (vl_api_gbp_endpoint_dump_t * mp)
}
static void
+gbp_retention_decode (const vl_api_gbp_endpoint_retention_t * in,
+ gbp_endpoint_retention_t * out)
+{
+ out->remote_ep_timeout = ntohl (in->remote_ep_timeout);
+}
+
+static void
vl_api_gbp_endpoint_group_add_t_handler
(vl_api_gbp_endpoint_group_add_t * mp)
{
vl_api_gbp_endpoint_group_add_reply_t *rmp;
+ gbp_endpoint_retention_t retention;
int rv = 0;
+ gbp_retention_decode (&mp->epg.retention, &retention);
+
rv = gbp_endpoint_group_add_and_lock (ntohs (mp->epg.epg_id),
ntohs (mp->epg.sclass),
ntohl (mp->epg.bd_id),
ntohl (mp->epg.rd_id),
- ntohl (mp->epg.uplink_sw_if_index));
+ ntohl (mp->epg.uplink_sw_if_index),
+ &retention);
REPLY_MACRO (VL_API_GBP_ENDPOINT_GROUP_ADD_REPLY + GBP_MSG_BASE);
}
diff --git a/src/plugins/gbp/gbp_endpoint.c b/src/plugins/gbp/gbp_endpoint.c
index f32a8820238..9cae2ab9421 100644
--- a/src/plugins/gbp/gbp_endpoint.c
+++ b/src/plugins/gbp/gbp_endpoint.c
@@ -51,13 +51,6 @@ vlib_log_class_t gbp_ep_logger;
vlib_log_notice (gbp_ep_logger, __VA_ARGS__);
/**
- * GBP Endpoint inactive timeout (in seconds)
- * If a dynamically learned Endpoint has not been heard from in this
- * amount of time it is considered inactive and discarded
- */
-static u32 GBP_ENDPOINT_INACTIVE_TIME = 30;
-
-/**
* Pool of GBP endpoints
*/
gbp_endpoint_t *gbp_endpoint_pool;
@@ -1340,16 +1333,22 @@ VLIB_CLI_COMMAND (gbp_endpoint_show_node, static) = {
static void
gbp_endpoint_check (index_t gei, f64 start_time)
{
+ gbp_endpoint_group_t *gg;
gbp_endpoint_loc_t *gel;
gbp_endpoint_t *ge;
ge = gbp_endpoint_get (gei);
gel = gbp_endpoint_loc_find (ge, GBP_ENDPOINT_SRC_DP);
- if ((NULL != gel) &&
- ((start_time - ge->ge_last_time) > GBP_ENDPOINT_INACTIVE_TIME))
+ if (NULL != gel)
{
- gbp_endpoint_unlock (GBP_ENDPOINT_SRC_DP, gei);
+ gg = gbp_endpoint_group_get (gel->gel_epg);
+
+ if ((start_time - ge->ge_last_time) >
+ gg->gg_retention.remote_ep_timeout)
+ {
+ gbp_endpoint_unlock (GBP_ENDPOINT_SRC_DP, gei);
+ }
}
}
@@ -1464,22 +1463,6 @@ gbp_endpoint_scan (vlib_main_t * vm)
gbp_endpoint_scan_l3 (vm);
}
-void
-gbp_learn_set_inactive_threshold (u32 threshold)
-{
- GBP_ENDPOINT_INACTIVE_TIME = threshold;
-
- vlib_process_signal_event (vlib_get_main (),
- gbp_scanner_node.index,
- GBP_ENDPOINT_SCAN_SET_TIME, 0);
-}
-
-f64
-gbp_endpoint_scan_threshold (void)
-{
- return (GBP_ENDPOINT_INACTIVE_TIME);
-}
-
static fib_node_t *
gbp_endpoint_get_node (fib_node_index_t index)
{
diff --git a/src/plugins/gbp/gbp_endpoint.h b/src/plugins/gbp/gbp_endpoint.h
index 4b4c2e0b627..e399ff4f671 100644
--- a/src/plugins/gbp/gbp_endpoint.h
+++ b/src/plugins/gbp/gbp_endpoint.h
@@ -236,7 +236,6 @@ extern void gbp_endpoint_child_remove (index_t gei, u32 sibling);
typedef walk_rc_t (*gbp_endpoint_cb_t) (index_t gbpei, void *ctx);
extern void gbp_endpoint_walk (gbp_endpoint_cb_t cb, void *ctx);
extern void gbp_endpoint_scan (vlib_main_t * vm);
-extern f64 gbp_endpoint_scan_threshold (void);
extern int gbp_endpoint_is_remote (const gbp_endpoint_t * ge);
extern int gbp_endpoint_is_local (const gbp_endpoint_t * ge);
extern int gbp_endpoint_is_external (const gbp_endpoint_t * ge);
diff --git a/src/plugins/gbp/gbp_endpoint_group.c b/src/plugins/gbp/gbp_endpoint_group.c
index a2922716e42..dc4440743c7 100644
--- a/src/plugins/gbp/gbp_endpoint_group.c
+++ b/src/plugins/gbp/gbp_endpoint_group.c
@@ -75,7 +75,10 @@ gbp_endpoint_group_find (epg_id_t epg_id)
int
gbp_endpoint_group_add_and_lock (epg_id_t epg_id,
u16 sclass,
- u32 bd_id, u32 rd_id, u32 uplink_sw_if_index)
+ u32 bd_id,
+ u32 rd_id,
+ u32 uplink_sw_if_index,
+ const gbp_endpoint_retention_t * retention)
{
gbp_endpoint_group_t *gg;
index_t ggi;
@@ -113,6 +116,7 @@ gbp_endpoint_group_add_and_lock (epg_id_t epg_id,
gg->gg_uplink_sw_if_index = uplink_sw_if_index;
gg->gg_locks = 1;
gg->gg_sclass = sclass;
+ gg->gg_retention = *retention;
if (SCLASS_INVALID != gg->gg_sclass)
hash_set (gbp_epg_sclass_db, gg->gg_sclass, gg->gg_id);
@@ -256,6 +260,7 @@ static clib_error_t *
gbp_endpoint_group_cli (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
+ gbp_endpoint_retention_t retention = { 0 };
epg_id_t epg_id = EPG_INVALID, sclass;
vnet_main_t *vnm = vnet_get_main ();
u32 uplink_sw_if_index = ~0;
@@ -297,7 +302,7 @@ gbp_endpoint_group_cli (vlib_main_t * vm,
return clib_error_return (0, "route-domain must be specified");
gbp_endpoint_group_add_and_lock (epg_id, sclass, bd_id, rd_id,
- uplink_sw_if_index);
+ uplink_sw_if_index, &retention);
}
else
gbp_endpoint_group_delete (epg_id);
diff --git a/src/plugins/gbp/gbp_endpoint_group.h b/src/plugins/gbp/gbp_endpoint_group.h
index 123954f63ea..08e3a5c874c 100644
--- a/src/plugins/gbp/gbp_endpoint_group.h
+++ b/src/plugins/gbp/gbp_endpoint_group.h
@@ -21,6 +21,15 @@
#include <vnet/fib/fib_types.h>
/**
+ * Endpoint Retnetion Policy
+ */
+typedef struct gbp_endpoint_retention_t_
+{
+ /** Aging timeout for remote endpoints */
+ u32 remote_ep_timeout;
+} gbp_endpoint_retention_t;
+
+/**
* An Endpoint Group representation
*/
typedef struct gpb_endpoint_group_t_
@@ -65,6 +74,11 @@ typedef struct gpb_endpoint_group_t_
* Locks/references to this EPG
*/
u32 gg_locks;
+
+ /**
+ * EP retention policy
+ */
+ gbp_endpoint_retention_t gg_retention;
} gbp_endpoint_group_t;
/**
@@ -79,7 +93,9 @@ extern int gbp_endpoint_group_add_and_lock (epg_id_t epg_id,
u16 sclass,
u32 bd_id,
u32 rd_id,
- u32 uplink_sw_if_index);
+ u32 uplink_sw_if_index,
+ const gbp_endpoint_retention_t *
+ retention);
extern index_t gbp_endpoint_group_find (epg_id_t epg_id);
extern int gbp_endpoint_group_delete (epg_id_t epg_id);
extern void gbp_endpoint_group_unlock (index_t index);
diff --git a/src/plugins/gbp/gbp_learn.h b/src/plugins/gbp/gbp_learn.h
index c40196ef259..15a9fecaddd 100644
--- a/src/plugins/gbp/gbp_learn.h
+++ b/src/plugins/gbp/gbp_learn.h
@@ -56,8 +56,6 @@ extern gbp_learn_main_t gbp_learn_main;
extern void gbp_learn_enable (u32 sw_if_index, gbb_learn_mode_t mode);
extern void gbp_learn_disable (u32 sw_if_index, gbb_learn_mode_t mode);
-extern void gbp_learn_set_inactive_threshold (u32 max_age);
-
#endif
/*
diff --git a/src/plugins/gbp/gbp_scanner.c b/src/plugins/gbp/gbp_scanner.c
index 90507a60568..9ae962b7449 100644
--- a/src/plugins/gbp/gbp_scanner.c
+++ b/src/plugins/gbp/gbp_scanner.c
@@ -45,9 +45,7 @@ gbp_scanner (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f)
if (gs_enabled)
{
/* scan every 'inactive threshold' seconds */
- vlib_process_wait_for_event_or_clock (vm,
- gbp_endpoint_scan_threshold
- ());
+ vlib_process_wait_for_event_or_clock (vm, 2);
}
else
vlib_process_wait_for_event (vm);
@@ -99,8 +97,7 @@ static clib_error_t *
gbp_scanner_cli (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
- vlib_cli_output (vm, "GBP-scanner: enabled:%d interval:%f",
- gs_enabled, gbp_endpoint_scan_threshold ());
+ vlib_cli_output (vm, "GBP-scanner: enabled:%d interval:2", gs_enabled);
return (NULL);
}