This patch adds the unlinking/unmapping of shared host memory
on termination of l2fwd-keepalive. Previously it was only
cleaned on re-running of the example application.
Fixes:
e64833f2273a ("examples/l2fwd-keepalive: add sample application")
Signed-off-by: Remy Horton <remy.horton@intel.com>
Tested-by: Roman Korynkevych <romanx.korynkevych@intel.com>
unsigned lcore_id, rx_lcore_id;
unsigned nb_ports_in_mask = 0;
struct sigaction signal_handler;
+ struct rte_keepalive_shm *ka_shm;
memset(&signal_handler, 0, sizeof(signal_handler));
terminate_signal_received = 0;
rte_timer_subsystem_init();
rte_timer_init(&stats_timer);
+ ka_shm = NULL;
if (check_period > 0) {
- struct rte_keepalive_shm *ka_shm;
-
ka_shm = rte_keepalive_shm_create();
if (ka_shm == NULL)
rte_exit(EXIT_FAILURE,
return -1;
}
+ if (ka_shm != NULL)
+ rte_keepalive_shm_cleanup(ka_shm);
return 0;
}
strerror(errno));
}
}
+
+void rte_keepalive_shm_cleanup(struct rte_keepalive_shm *ka_shm)
+{
+ if (shm_unlink(RTE_KEEPALIVE_SHM_NAME) == -1 && errno != ENOENT)
+ printf("Warning: Error unlinking %s (%s)\n",
+ RTE_KEEPALIVE_SHM_NAME, strerror(errno));
+
+ if (ka_shm && munmap(ka_shm, sizeof(struct rte_keepalive_shm)) != 0)
+ printf("Warning: munmap() failed\n");
+}
void rte_keepalive_relayed_state(struct rte_keepalive_shm *shm,
const int id_core, const enum rte_keepalive_state core_state,
uint64_t last_alive);
+
+/** Shutdown cleanup of shared host memory keepalive object.
+ * @param *shm
+ * Pointer to SHM keepalive structure. May be NULL.
+ *
+ * If *shm is NULL, this function will only attempt to remove the
+ * shared host memory handle and not unmap the underlying memory.
+ */
+void rte_keepalive_shm_cleanup(struct rte_keepalive_shm *ka_shm);