]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
dpdk: fix DPDK API change on NUMA/socket retrieval
authorLukas Sismis <lsismis@oisf.net>
Tue, 21 Mar 2023 09:22:33 +0000 (10:22 +0100)
committerVictor Julien <vjulien@oisf.net>
Wed, 10 May 2023 13:59:01 +0000 (15:59 +0200)
Ticket: #5923

src/runmode-dpdk.c
src/source-dpdk.c
src/source-dpdk.h

index d2ca7207c5614bf22c09bb39637f06749e7bbe51..c738cf61842a3a29a5b6e8e4fdf0b6a26b0078f6 100644 (file)
@@ -954,6 +954,24 @@ static void DeviceSetMTU(struct rte_eth_conf *port_conf, uint16_t mtu)
 #endif
 }
 
+/**
+ * \param port_id - queried port
+ * \param socket_id - socket ID of the queried port
+ * \return positive number on success, negative on failure (errno)
+ */
+static int32_t DeviceSetSocketID(uint16_t port_id, int32_t *socket_id)
+{
+    rte_errno = 0;
+    int retval = rte_eth_dev_socket_id(port_id);
+    *socket_id = retval;
+
+#if RTE_VER_YEAR > 22 || RTE_VER_YEAR == 22 && RTE_VER_MONTH == 11 // DPDK API changed since 22.11
+    retval = -rte_errno;
+#endif
+
+    return retval;
+}
+
 static void DeviceInitPortConf(const DPDKIfaceConfig *iconf,
         const struct rte_eth_dev_info *dev_info, struct rte_eth_conf *port_conf)
 {
@@ -1150,7 +1168,14 @@ static int DeviceConfigureIPS(DPDKIfaceConfig *iconf)
             SCReturnInt(retval);
         }
 
-        if (rte_eth_dev_socket_id(iconf->port_id) != rte_eth_dev_socket_id(iconf->out_port_id)) {
+        int32_t out_port_socket_id;
+        retval = DeviceSetSocketID(iconf->port_id, &out_port_socket_id);
+        if (retval < 0) {
+            SCLogError("%s: invalid socket id (err=%d)", iconf->out_iface, retval);
+            SCReturnInt(retval);
+        }
+
+        if (iconf->socket_id != out_port_socket_id) {
             SCLogWarning("%s: out iface %s is not on the same NUMA node", iconf->iface,
                     iconf->out_iface);
         }
@@ -1190,12 +1215,11 @@ static int DeviceConfigure(DPDKIfaceConfig *iconf)
         SCReturnInt(retval);
     }
 
-    retval = rte_eth_dev_socket_id(iconf->port_id);
+    retval = DeviceSetSocketID(iconf->port_id, &iconf->socket_id);
     if (retval < 0) {
         SCLogError("%s: invalid socket id (err=%d)", iconf->iface, retval);
         SCReturnInt(retval);
     }
-    iconf->socket_id = retval;
 
     retval = rte_eth_dev_info_get(iconf->port_id, &dev_info);
     if (retval != 0) {
index 3537f7b8cea93051a60dae70e06faa309ec3a732..60828c0b76ff60cfcfe07297fe710af94360d067 100644 (file)
@@ -121,6 +121,7 @@ typedef struct DPDKThreadVars_ {
     uint64_t dropped;
     uint16_t port_id;
     uint16_t queue_id;
+    int32_t port_socket_id;
     struct rte_mempool *pkt_mempool;
     struct rte_mbuf *received_mbufs[BURST_SIZE];
 } DPDKThreadVars;
@@ -473,15 +474,16 @@ static TmEcode ReceiveDPDKThreadInit(ThreadVars *tv, const void *initdata, void
     ptv->threads = dpdk_config->threads;
     ptv->port_id = dpdk_config->port_id;
     ptv->out_port_id = dpdk_config->out_port_id;
+    ptv->port_socket_id = dpdk_config->socket_id;
     // pass the pointer to the mempool and then forget about it. Mempool is freed in thread deinit.
     ptv->pkt_mempool = dpdk_config->pkt_mempool;
     dpdk_config->pkt_mempool = NULL;
 
     thread_numa = GetNumaNode();
-    if (thread_numa >= 0 && thread_numa != rte_eth_dev_socket_id(ptv->port_id)) {
+    if (thread_numa >= 0 && thread_numa != ptv->port_socket_id) {
         SC_ATOMIC_ADD(dpdk_config->inconsitent_numa_cnt, 1);
         SCLogPerf("%s: NIC is on NUMA %d, thread on NUMA %d", dpdk_config->iface,
-                rte_eth_dev_socket_id(ptv->port_id), thread_numa);
+                ptv->port_socket_id, thread_numa);
     }
 
     uint16_t queue_id = SC_ATOMIC_ADD(dpdk_config->queue_id, 1);
index 9a7d6500e4c7e8ef188ce845160bd0628f3b6721..3fdb63cb35d97e39043e742a59355e65af643fe5 100644 (file)
@@ -46,7 +46,7 @@ typedef struct DPDKIfaceConfig_ {
 #ifdef HAVE_DPDK
     char iface[RTE_ETH_NAME_MAX_LEN];
     uint16_t port_id;
-    uint16_t socket_id;
+    int32_t socket_id;
     /* number of threads - zero means all available */
     int threads;
     /* IPS mode */