• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

OISF / suricata / 23374838686

21 Mar 2026 07:29AM UTC coverage: 59.341% (-20.0%) from 79.315%
23374838686

Pull #15075

github

web-flow
Merge 90b4e834f into 6587e363a
Pull Request #15075: Stack 8001 v16.4

38 of 70 new or added lines in 10 files covered. (54.29%)

34165 existing lines in 563 files now uncovered.

119621 of 201584 relevant lines covered (59.34%)

650666.92 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/util-dpdk.c
1
/* Copyright (C) 2021 Open Information Security Foundation
2
 *
3
 * You can copy, redistribute or modify this Program under the terms of
4
 * the GNU General Public License version 2 as published by the Free
5
 * Software Foundation.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 * GNU General Public License for more details.
11
 *
12
 * You should have received a copy of the GNU General Public License
13
 * version 2 along with this program; if not, write to the Free Software
14
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15
 * 02110-1301, USA.
16
 */
17

18
/**
19
 * \file
20
 *
21
 * \author Lukas Sismis <lukas.sismis@gmail.com>
22
 */
23

24
#include "suricata-common.h"
25
#include "suricata.h"
26
#include "util-dpdk.h"
27
#include "util-debug.h"
28
#include "util-device-private.h"
29

30
void DPDKCleanupEAL(void)
UNCOV
31
{
×
32
#ifdef HAVE_DPDK
33
    if (SCRunmodeGet() == RUNMODE_DPDK) {
34
        int retval = rte_eal_cleanup();
35
        if (retval != 0)
36
            SCLogError("EAL cleanup failed: %s", strerror(-retval));
37
    }
38
#endif
UNCOV
39
}
×
40

41
void DPDKCloseDevice(LiveDevice *ldev)
UNCOV
42
{
×
UNCOV
43
    (void)ldev; // avoid warnings of unused variable
×
44
#ifdef HAVE_DPDK
45
    if (SCRunmodeGet() == RUNMODE_DPDK) {
46
        uint16_t port_id;
47
        int retval = rte_eth_dev_get_port_by_name(ldev->dev, &port_id);
48
        if (retval < 0) {
49
            SCLogError("%s: failed get port id, error: %s", ldev->dev, rte_strerror(-retval));
50
            return;
51
        }
52

53
        SCLogPerf("%s: closing device", ldev->dev);
54
        rte_eth_dev_close(port_id);
55
    }
56
#endif
UNCOV
57
}
×
58

59
void DPDKFreeDevice(LiveDevice *ldev)
UNCOV
60
{
×
UNCOV
61
    (void)ldev; // avoid warnings of unused variable
×
62
#ifdef HAVE_DPDK
63
    if (SCRunmodeGet() == RUNMODE_DPDK) {
64
        SCLogDebug("%s: releasing packet mempools", ldev->dev);
65
        DPDKDeviceResourcesDeinit(&ldev->dpdk_vars);
66
    }
67
#endif
UNCOV
68
}
×
69

70
/**
71
 * \param port_id - queried port
72
 * \param socket_id - socket ID of the queried port
73
 * \return non-negative number on success, negative on failure (errno)
74
 */
75
int32_t DPDKDeviceSetSocketID(uint16_t port_id, int32_t *socket_id)
UNCOV
76
{
×
77
#ifdef HAVE_DPDK
78
    rte_errno = 0;
79
    int retval = rte_eth_dev_socket_id(port_id);
80
    *socket_id = retval;
81

82
#if RTE_VERSION >= RTE_VERSION_NUM(22, 11, 0, 0) // DPDK API changed since 22.11
83
    retval = -rte_errno;
84
#else
85
    if (retval == SOCKET_ID_ANY)
86
        retval = 0; // DPDK couldn't determine socket ID of a port
87
#endif
88

89
    return retval;
90
#endif /* HAVE_DPDK */
91
    return -ENOTSUP;
×
UNCOV
92
}
×
93

94
/**
95
 * \param iface_name - name of the queried interface
96
 * \param socket_id - socket ID of the queried port
97
 * \return non-negative number on success, negative on failure (errno)
98
 */
99
int32_t DPDKDeviceNameSetSocketID(char *iface_name, int32_t *socket_id)
100
{
×
101
#ifdef HAVE_DPDK
102
    uint16_t port_id = 0;
103
    int r = rte_eth_dev_get_port_by_name(iface_name, &port_id);
104
    if (r < 0) {
105
        SCLogError("%s: interface not found: %s", iface_name, rte_strerror(-r));
106
        SCReturnInt(r);
107
    }
108
    return DPDKDeviceSetSocketID(port_id, socket_id);
109
#endif /* HAVE_DPDK */
110
    return -ENOTSUP;
111
}
×
112

113
#ifdef HAVE_DPDK
114
/**
115
 * Retrieves name of the port from port id
116
 * Not thread-safe
117
 * @param pid
118
 * @return static dev_name on success
119
 */
120
const char *DPDKGetPortNameByPortID(uint16_t pid)
121
{
122
    static char dev_name[RTE_ETH_NAME_MAX_LEN];
123
    int32_t ret = rte_eth_dev_get_name_by_port(pid, dev_name);
124
    if (ret < 0) {
125
        FatalError("Port %d: Failed to obtain port name (err: %s)", pid, rte_strerror(-ret));
126
    }
127
    return dev_name;
128
}
129

130
#endif /* HAVE_DPDK */
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc