Commit e14a8f93 authored by Leonardo Lai's avatar Leonardo Lai

cleanup memory

parent ef89d0c5
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
extern const void *list_t_alloc; extern const void *list_t_alloc;
extern const void *list_node_t_alloc; extern const void *list_node_t_alloc;
extern const void *list_iterator_t_alloc; extern const void *list_iterator_t_alloc;
extern const void *bind_info_alloc;
void udpdk_list_init(void) void udpdk_list_init(void)
{ {
...@@ -27,10 +26,6 @@ int udpdk_list_reinit(void) ...@@ -27,10 +26,6 @@ int udpdk_list_reinit(void)
if (list_iterator_t_alloc == NULL) { if (list_iterator_t_alloc == NULL) {
return -1; return -1;
} }
bind_info_alloc = udpdk_retrieve_allocator("bind_info_alloc");
if (bind_info_alloc == NULL) {
return -1;
}
return 0; return 0;
} }
......
...@@ -151,3 +151,9 @@ void btable_del_binding(int s, int port) { ...@@ -151,3 +151,9 @@ void btable_del_binding(int s, int port) {
list_t *btable_get_bindings(int port) { list_t *btable_get_bindings(int port) {
return sock_bind_table[port]; return sock_bind_table[port];
} }
/* Destroy the bindings table */
void btable_destroy(void)
{
udpdk_destroy_allocator(bind_info_alloc);
}
...@@ -253,6 +253,17 @@ static int init_udp_bind_table(void) ...@@ -253,6 +253,17 @@ static int init_udp_bind_table(void)
return 0; return 0;
} }
/* Destroy table for UDP port switching */
static int destroy_udp_bind_table(void)
{
const struct rte_memzone *mz;
btable_destroy();
mz = rte_memzone_lookup(UDP_BIND_TABLE_NAME);
return rte_memzone_free(mz);
}
/* Initialize slots to exchange packets between the application and the poller */ /* Initialize slots to exchange packets between the application and the poller */
static int init_exchange_slots(void) static int init_exchange_slots(void)
{ {
...@@ -369,6 +380,16 @@ void udpdk_interrupt(int signum) ...@@ -369,6 +380,16 @@ void udpdk_interrupt(int signum)
interrupted = 1; interrupted = 1;
} }
static void udpdk_close_all_sockets(void)
{
for (int s = 0; s < NUM_SOCKETS_MAX; s++) {
if (exch_zone_desc->slots[s].bound) {
RTE_LOG(INFO, CLOSE, "Closing socket %d that was left open\n", s);
udpdk_close(s);
}
}
}
void udpdk_cleanup(void) void udpdk_cleanup(void)
{ {
uint16_t port_id; uint16_t port_id;
...@@ -390,5 +411,12 @@ void udpdk_cleanup(void) ...@@ -390,5 +411,12 @@ void udpdk_cleanup(void)
rte_eth_dev_close(port_id); rte_eth_dev_close(port_id);
} }
// Close all open sockets
udpdk_close_all_sockets();
// Free the bindings table
destroy_udp_bind_table();
// Release linked-list memory allocators
udpdk_list_deinit(); udpdk_list_deinit();
} }
...@@ -38,6 +38,7 @@ static volatile int poller_alive = 1; ...@@ -38,6 +38,7 @@ static volatile int poller_alive = 1;
extern struct exch_zone_info *exch_zone_desc; extern struct exch_zone_info *exch_zone_desc;
extern struct exch_slot *exch_slots; extern struct exch_slot *exch_slots;
extern list_t **sock_bind_table; extern list_t **sock_bind_table;
extern const void *bind_info_alloc;
/* Descriptor of a RX queue */ /* Descriptor of a RX queue */
struct rx_queue { struct rx_queue {
...@@ -86,8 +87,14 @@ static inline const char * get_exch_ring_name(unsigned id, enum exch_ring_func f ...@@ -86,8 +87,14 @@ static inline const char * get_exch_ring_name(unsigned id, enum exch_ring_func f
/* Initialize the allocators */ /* Initialize the allocators */
static int setup_allocators(void) static int setup_allocators(void)
{ {
bind_info_alloc = udpdk_retrieve_allocator("bind_info_alloc");
if (bind_info_alloc == NULL) {
RTE_LOG(ERR, POLLINIT, "Cannot retrieve bind_info shmem allocator\n");
return -1;
}
if (udpdk_list_reinit() < 0) { if (udpdk_list_reinit() < 0) {
RTE_LOG(ERR, POLLINIT, "Cannot retrieve shmem allocators\n"); RTE_LOG(ERR, POLLINIT, "Cannot retrieve list shmem allocators\n");
return -1; return -1;
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment