]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
dpdk: check rte_eth_link_get_nowait return value
authorMatwey V. Kornilov <matwey.kornilov@gmail.com>
Sun, 26 Oct 2025 15:51:34 +0000 (18:51 +0300)
committerMatthias Runge <mrunge@matthias-runge.de>
Tue, 28 Oct 2025 09:55:51 +0000 (10:55 +0100)
Update link status only if rte_eth_link_get_nowait return success
otherwise link may not be filled properly.

This also fixes the following build issue with up-to-date gcc version:

src/dpdkevents.c: In function 'dpdk_helper_link_status_get':
src/dpdkevents.c:439:7: error: ignoring return value of 'rte_eth_link_get_nowait' declared with attribute 'warn_unused_result' [-Werror=unused-result]
  439 |       rte_eth_link_get_nowait(i, &link);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

src/dpdkevents.c

index 4c8196aed48e7a4df708a1dbb2a719eb19260cb4..e12128dcf86c964ab287b761e1281d76b8912c72 100644 (file)
@@ -418,6 +418,7 @@ static int dpdk_events_config(oconfig_item_t *ci) {
 
 static int dpdk_helper_link_status_get(dpdk_helper_ctx_t *phc) {
   dpdk_events_ctx_t *ec = DPDK_EVENTS_CTX_GET(phc);
+  int ret = 0;
 
 /* get Link Status values from DPDK */
 #if RTE_VERSION < RTE_VERSION_NUM(18, 05, 0, 0)
@@ -436,9 +437,13 @@ static int dpdk_helper_link_status_get(dpdk_helper_ctx_t *phc) {
     if (ec->config.link_status.enabled_port_mask & (1 << i)) {
       struct rte_eth_link link;
       ec->link_info[i].read_time = cdtime();
+#if RTE_VERSION >= RTE_VERSION_NUM(19, 11, 0, 0)
+      ret = rte_eth_link_get_nowait(i, &link);
+#else
       rte_eth_link_get_nowait(i, &link);
-      if ((link.link_status == ETH_LINK_NA) ||
-          (link.link_status != ec->link_info[i].link_status)) {
+#endif
+      if (ret == 0 && ((link.link_status == ETH_LINK_NA) ||
+                       (link.link_status != ec->link_info[i].link_status))) {
         ec->link_info[i].link_status = link.link_status;
         ec->link_info[i].status_updated = 1;
         DPDK_CHILD_LOG(" === PORT %d Link Status: %s\n", i,