Start the cdp period process on demand
Change-Id: I219b270f905dad5939ab38e933712845c314286d
Signed-off-by: Dave Barach <dave@barachs.net>
diff --git a/src/plugins/cdp/cdp.c b/src/plugins/cdp/cdp.c
index 45863a0..2c947a7 100644
--- a/src/plugins/cdp/cdp.c
+++ b/src/plugins/cdp/cdp.c
@@ -63,11 +63,17 @@
int rv = 0;
if (enable_disable)
- vlib_process_signal_event (cm->vlib_main, cdp_process_node.index,
- CDP_EVENT_ENABLE, 0);
+ {
+ vnet_cdp_create_periodic_process (cm);
+ vlib_process_signal_event (cm->vlib_main, cm->cdp_process_node_index,
+ CDP_EVENT_ENABLE, 0);
+ }
else
- vlib_process_signal_event (cm->vlib_main, cdp_process_node.index,
- CDP_EVENT_DISABLE, 0);
+ {
+ vnet_cdp_create_periodic_process (cm);
+ vlib_process_signal_event (cm->vlib_main, cm->cdp_process_node_index,
+ CDP_EVENT_DISABLE, 0);
+ }
cm->enabled = enable_disable;
return rv;
diff --git a/src/plugins/cdp/cdp.h b/src/plugins/cdp/cdp.h
index ab2ab95..d3abb07 100644
--- a/src/plugins/cdp/cdp.h
+++ b/src/plugins/cdp/cdp.h
@@ -143,6 +143,7 @@
void cdp_keepalive (cdp_main_t * cm, cdp_neighbor_t * n);
u16 cdp_checksum (void *p, int count);
u8 *cdp_input_format_trace (u8 * s, va_list * args);
+void vnet_cdp_create_periodic_process (cdp_main_t * cmp);
#endif /* __included_cdp_h__ */
diff --git a/src/plugins/cdp/cdp_input.c b/src/plugins/cdp/cdp_input.c
index dbe179a..a6da0f6 100644
--- a/src/plugins/cdp/cdp_input.c
+++ b/src/plugins/cdp/cdp_input.c
@@ -409,9 +409,6 @@
cdp_input_init (vlib_main_t * vm)
{
cdp_main_t *cm = &cdp_main;
- void vnet_cdp_node_reference (void);
-
- vnet_cdp_node_reference ();
cm->vlib_main = vm;
cm->vnet_main = vnet_get_main ();
diff --git a/src/plugins/cdp/cdp_node.c b/src/plugins/cdp/cdp_node.c
index 740bb41..f9ee251 100644
--- a/src/plugins/cdp/cdp_node.c
+++ b/src/plugins/cdp/cdp_node.c
@@ -129,9 +129,6 @@
f64 poll_time_remaining;
uword event_type, *event_data = 0;
- /* So we can send events to the cdp process */
- cm->cdp_process_node_index = cdp_process_node.index;
-
/* Start w/ cdp disabled */
poll_time_remaining = 86400.0;
@@ -200,20 +197,17 @@
return 0;
}
-/*
- * cdp periodic node declaration
- */
-/* *INDENT-OFF* */
-VLIB_REGISTER_NODE (cdp_process_node) = {
- .function = cdp_process,
- .type = VLIB_NODE_TYPE_PROCESS,
- .name = "cdp-process",
-};
-/* *INDENT-ON* */
-
void
-vnet_cdp_node_reference (void)
+vnet_cdp_create_periodic_process (cdp_main_t * cmp)
{
+ /* Already created the process node? */
+ if (cmp->cdp_process_node_index > 0)
+ return;
+
+ /* No, create it now and make a note of the node index */
+ cmp->cdp_process_node_index = vlib_process_create
+ (cmp->vlib_main, "cdp-process",
+ cdp_process, 16 /* log2_n_stack_bytes */ );
}
/*