summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/cdp/cdp.c14
-rw-r--r--src/plugins/cdp/cdp.h1
-rw-r--r--src/plugins/cdp/cdp_input.c3
-rw-r--r--src/plugins/cdp/cdp_node.c24
4 files changed, 20 insertions, 22 deletions
diff --git a/src/plugins/cdp/cdp.c b/src/plugins/cdp/cdp.c
index 45863a096a3..2c947a74d71 100644
--- a/src/plugins/cdp/cdp.c
+++ b/src/plugins/cdp/cdp.c
@@ -63,11 +63,17 @@ cdp_enable_disable (cdp_main_t * cm, int enable_disable)
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 ab2ab95e895..d3abb07fa01 100644
--- a/src/plugins/cdp/cdp.h
+++ b/src/plugins/cdp/cdp.h
@@ -143,6 +143,7 @@ void cdp_periodic (vlib_main_t * vm);
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 dbe179ad095..a6da0f67ac0 100644
--- a/src/plugins/cdp/cdp_input.c
+++ b/src/plugins/cdp/cdp_input.c
@@ -409,9 +409,6 @@ static clib_error_t *
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 740bb4105e8..f9ee251c022 100644
--- a/src/plugins/cdp/cdp_node.c
+++ b/src/plugins/cdp/cdp_node.c
@@ -129,9 +129,6 @@ cdp_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f)
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 @@ cdp_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f)
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 */ );
}
/*