aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Mazur <mkm@semihalf.com>2018-01-04 21:12:15 +0100
committerMichal Mazur <mkm@semihalf.com>2018-01-11 22:32:38 +0100
commit192a196b02b35d1f69d0679d138436bcac9d3034 (patch)
tree342acbdbf182d7b98ba6b26839f1d8e6168d0f64
parentfee373a0f71824aa3aceaacea3033864f555b9ca (diff)
plugins: odp: Fix error when all interfaces removed
Packet pool cannot be destroyed when last interface is deleted because it will not be reallocated on creation of a new interface. Change-Id: Iec7b03b4413fc6602a7a1493ffd706f4c4dd1309 Signed-off-by: Michal Mazur <mkm@semihalf.com>
-rwxr-xr-xsrc/plugins/odp/odp_packet.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/plugins/odp/odp_packet.c b/src/plugins/odp/odp_packet.c
index 2cf6ff90..e1b259fd 100755
--- a/src/plugins/odp/odp_packet.c
+++ b/src/plugins/odp/odp_packet.c
@@ -278,7 +278,6 @@ odp_packet_delete_if (vlib_main_t * vm, u8 * host_if_name)
odp_packet_main_t *om = odp_packet_main;
odp_packet_if_t *oif = 0;
uword *p;
- vlib_thread_main_t *tm = vlib_get_thread_main ();
p = mhash_get (&om->if_index_by_host_if_name, host_if_name);
@@ -306,13 +305,7 @@ odp_packet_delete_if (vlib_main_t * vm, u8 * host_if_name)
pool_put (om->interfaces, oif);
- if (tm->n_vlib_mains > 1 && pool_elts (om->interfaces) == 0)
- {
- odp_pool_destroy (om->pool);
- }
-
return 0;
-
}
static clib_error_t *
@@ -559,6 +552,26 @@ odp_packet_init (vlib_main_t * vm)
VLIB_INIT_FUNCTION (odp_packet_init);
+static clib_error_t *
+odp_packet_exit (vlib_main_t *vm)
+{
+ odp_packet_main_t *om = odp_packet_main;
+ odp_packet_if_t *port;
+
+ pool_foreach (port, om->interfaces,
+ ({
+ odp_packet_delete_if (vm, port->host_if_name);
+ }));
+
+ odp_pool_destroy (om->pool);
+ odp_shm_free (odp_shm_lookup("odp_packet_main"));
+ odp_packet_main = 0x0;
+
+ return 0;
+}
+
+VLIB_MAIN_LOOP_EXIT_FUNCTION (odp_packet_exit);
+
/* *INDENT-OFF* */
VLIB_PLUGIN_REGISTER () = {
.version = VPP_BUILD_VER,