aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/interface.h
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2018-04-05 21:32:29 +0200
committerDave Barach <openvpp@barachs.net>2018-04-09 16:06:20 +0000
commit72d2c4f3718ba5293e9e0fa8726406ee7d9f3940 (patch)
tree799a61d776b35e640bf2542148bcca946b926dca /src/vnet/interface.h
parentf13a8787365300d757eca4624c8f8a6b7c49392b (diff)
plugins: unload plugin if early init fails
Change-Id: I32f68e2ee8f5d32962acdefb0193583f71d342b3 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vnet/interface.h')
-rw-r--r--src/vnet/interface.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/vnet/interface.h b/src/vnet/interface.h
index 00a7353d701..6a140d2059c 100644
--- a/src/vnet/interface.h
+++ b/src/vnet/interface.h
@@ -101,6 +101,31 @@ static void __vnet_interface_function_init_##tag##_##f (void) \
init_function.next_interface_function = vnm->tag##_functions[p]; \
vnm->tag##_functions[p] = &init_function; \
init_function.fp = (void *) &f; \
+} \
+static void __vnet_interface_function_deinit_##tag##_##f (void) \
+ __attribute__((__destructor__)) ; \
+ \
+static void __vnet_interface_function_deinit_##tag##_##f (void) \
+{ \
+ vnet_main_t * vnm = vnet_get_main(); \
+ _vnet_interface_function_list_elt_t *next; \
+ if (vnm->tag##_functions[p]->fp == (void *) &f) \
+ { \
+ vnm->tag##_functions[p] = \
+ vnm->tag##_functions[p]->next_interface_function; \
+ return; \
+ } \
+ next = vnm->tag##_functions[p]; \
+ while (next->next_interface_function) \
+ { \
+ if (next->next_interface_function->fp == (void *) &f) \
+ { \
+ next->next_interface_function = \
+ next->next_interface_function->next_interface_function; \
+ return; \
+ } \
+ next = next->next_interface_function; \
+ } \
}
#define _VNET_INTERFACE_FUNCTION_DECL(f,tag) \
@@ -200,6 +225,14 @@ static void __vnet_add_device_class_registration_##x (void) \
x.next_class_registration = vnm->device_class_registrations; \
vnm->device_class_registrations = &x; \
} \
+static void __vnet_rm_device_class_registration_##x (void) \
+ __attribute__((__destructor__)) ; \
+static void __vnet_rm_device_class_registration_##x (void) \
+{ \
+ vnet_main_t * vnm = vnet_get_main(); \
+ VLIB_REMOVE_FROM_LINKED_LIST (vnm->device_class_registrations, \
+ &x, next_class_registration); \
+} \
__VA_ARGS__ vnet_device_class_t x
#define VLIB_DEVICE_TX_FUNCTION_CLONE_TEMPLATE(arch, fn, tgt) \
@@ -368,6 +401,14 @@ static void __vnet_add_hw_interface_class_registration_##x (void) \
x.next_class_registration = vnm->hw_interface_class_registrations; \
vnm->hw_interface_class_registrations = &x; \
} \
+static void __vnet_rm_hw_interface_class_registration_##x (void) \
+ __attribute__((__destructor__)) ; \
+static void __vnet_rm_hw_interface_class_registration_##x (void) \
+{ \
+ vnet_main_t * vnm = vnet_get_main(); \
+ VLIB_REMOVE_FROM_LINKED_LIST (vnm->hw_interface_class_registrations,\
+ &x, next_class_registration); \
+} \
__VA_ARGS__ vnet_hw_interface_class_t x
/* Hardware-interface. This corresponds to a physical wire