summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2020-11-09 17:11:57 -0500
committerNeale Ranns <nranns@cisco.com>2020-11-10 08:49:23 +0000
commit5f09efe70cc872a97c9db4c3a53455712548cad7 (patch)
treeb20356cc4c8c1eb5a0dff3d450ed2f918d187c0b /src
parent9ed4866440f4a20c04c86ecfc7f8b2cc380b2b09 (diff)
ip6-nd: fix memory leaks
Quite a noticeable amount of memory. Recoded ra event tx and rx fns in the usual manner, which terminated the leaks. Type: fix Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: I486d348456b465ad3940a280d4cf489e8dd655a5
Diffstat (limited to 'src')
-rw-r--r--src/vlib/unix/cli.c1
-rw-r--r--src/vnet/ip6-nd/ip6_ra.c34
2 files changed, 24 insertions, 11 deletions
diff --git a/src/vlib/unix/cli.c b/src/vlib/unix/cli.c
index 07ce414f616..9d26e6e7e34 100644
--- a/src/vlib/unix/cli.c
+++ b/src/vlib/unix/cli.c
@@ -2708,6 +2708,7 @@ unix_cli_kill (unix_cli_main_t * cm, uword cli_file_index)
vec_free (cf->command_history[i]);
vec_free (cf->command_history);
+ vec_free (cf->input_vector);
clib_file_del (fm, uf);
diff --git a/src/vnet/ip6-nd/ip6_ra.c b/src/vnet/ip6-nd/ip6_ra.c
index af82a06eb2b..5605939c092 100644
--- a/src/vnet/ip6-nd/ip6_ra.c
+++ b/src/vnet/ip6-nd/ip6_ra.c
@@ -1601,19 +1601,23 @@ ip6_ra_process_timer_event (vlib_main_t * vm,
}
static void
-ip6_ra_handle_report (const ip6_ra_report_t * rap)
+ip6_ra_handle_report (ip6_ra_report_t * rap)
{
u32 ii;
vec_foreach_index (ii, ip6_ra_listeners) ip6_ra_listeners[ii] (rap);
+ vec_free (rap->prefixes);
+ clib_mem_free (rap);
}
static uword
ip6_ra_event_process (vlib_main_t * vm,
vlib_node_runtime_t * node, vlib_frame_t * frame)
{
- ip6_ra_report_t *r, *rs;
+ ip6_ra_report_t *r;
uword event_type;
+ uword *event_data = 0;
+ int i;
/* init code here */
@@ -1621,9 +1625,9 @@ ip6_ra_event_process (vlib_main_t * vm,
{
vlib_process_wait_for_event_or_clock (vm, 1. /* seconds */ );
- rs = vlib_process_get_event_data (vm, &event_type);
+ event_type = vlib_process_get_events (vm, &event_data);
- if (NULL == rs)
+ if (event_type == ~0)
{
/* No events found: timer expired. */
/* process interface list and send RAs as appropriate, update timer info */
@@ -1631,17 +1635,25 @@ ip6_ra_event_process (vlib_main_t * vm,
}
else
{
- vec_foreach (r, rs) ip6_ra_handle_report (r);
- vec_reset_length (rs);
+ for (i = 0; i < vec_len (event_data); i++)
+ {
+ r = (void *) (event_data[i]);
+ ip6_ra_handle_report (r);
+ }
+ vec_reset_length (event_data);
}
}
return frame->n_vectors;
}
+/* *INDENT-OFF* */
VLIB_REGISTER_NODE (ip6_ra_process_node) =
{
-.function = ip6_ra_event_process,.name = "ip6-ra-process",.type =
- VLIB_NODE_TYPE_PROCESS,};
+ .function = ip6_ra_event_process,
+ .name = "ip6-ra-process",
+ .type = VLIB_NODE_TYPE_PROCESS,
+};
+/* *INDENT-ON* */
static void
ip6_ra_signal_report (ip6_ra_report_t * r)
@@ -1652,10 +1664,10 @@ ip6_ra_signal_report (ip6_ra_report_t * r)
if (!vec_len (ip6_ra_listeners))
return;
- q = vlib_process_signal_event_data (vm,
- ip6_ra_process_node.index,
- 0, 1, sizeof *q);
+ q = clib_mem_alloc (sizeof (*q));
*q = *r;
+
+ vlib_process_signal_event (vm, ip6_ra_process_node.index, 0, (uword) q);
}
static int