dpdk: release mempool after the device is closed

Ticket: #5936
pull/8861/head
Lukas Sismis 3 years ago committed by Victor Julien
parent 15a61f02a0
commit b6f7693e86

@ -1362,6 +1362,13 @@ static void *ParseDpdkConfigAndConfigureDevice(const char *iface)
// This counter is increased by worker threads that individually pick queue IDs.
SC_ATOMIC_RESET(iconf->queue_id);
SC_ATOMIC_RESET(iconf->inconsitent_numa_cnt);
// initialize LiveDev DPDK values
LiveDevice *ldev_instance = LiveGetDevice(iface);
if (ldev_instance == NULL) {
FatalError("Device %s is not registered as a live device", iface);
}
ldev_instance->dpdk_vars.pkt_mp = iconf->pkt_mempool;
return iconf;
}

@ -646,10 +646,7 @@ static TmEcode ReceiveDPDKThreadDeinit(ThreadVars *tv, void *data)
rte_eth_dev_stop(ptv->out_port_id);
}
if (ptv->queue_id == 0 && ptv->pkt_mempool != NULL) {
rte_mempool_free(ptv->pkt_mempool);
ptv->pkt_mempool = NULL;
}
ptv->pkt_mempool = NULL; // MP is released when device is closed
SCFree(ptv);
SCReturnInt(TM_ECODE_OK);

@ -18,6 +18,10 @@
#ifndef __UTIL_DEVICE_H__
#define __UTIL_DEVICE_H__
#ifdef HAVE_DPDK
#include <rte_mempool.h>
#endif /* HAVE_DPDK */
#include "queue.h"
#define OFFLOAD_FLAG_SG (1<<0)
@ -35,6 +39,12 @@ int LiveGetOffload(void);
#define MAX_DEVNAME 10
#ifdef HAVE_DPDK
typedef struct {
struct rte_mempool *pkt_mp;
} DPDKDeviceResources;
#endif /* HAVE_DPDK */
/** storage for live device names */
typedef struct LiveDevice_ {
char *dev; /**< the device (e.g. "eth0") */
@ -51,6 +61,10 @@ typedef struct LiveDevice_ {
uint32_t tenant_id; /**< tenant id in multi-tenancy */
uint32_t offload_orig; /**< original offload settings to restore @exit */
#ifdef HAVE_DPDK
// DPDK resources that needs to be cleaned after workers are stopped and devices closed
DPDKDeviceResources dpdk_vars;
#endif
} LiveDevice;
typedef struct LiveDeviceName_ {

@ -51,6 +51,9 @@ void DPDKCloseDevice(LiveDevice *ldev)
SCLogInfo("%s: closing device", ldev->dev);
rte_eth_dev_close(port_id);
SCLogInfo("%s: releasing packet mempool", ldev->dev);
rte_mempool_free(ldev->dpdk_vars.pkt_mp);
}
#endif
}

Loading…
Cancel
Save