aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorXiaoming Jiang <jiangxiaoming@outlook.com>2023-03-08 06:49:19 +0000
committerDamjan Marion <dmarion@0xa5.net>2023-05-16 09:30:12 +0000
commit5b55526da489def814a239a3ae6599fcb30dbb6e (patch)
tree2ba829119d73291cc081b1c3ae5b3ddc7b0e6f64 /src
parente10c5242067b6ad6a9de73ad3b00bfd215202f64 (diff)
dpdk: fix format rx/tx burst function name failed
Type: fix Signed-off-by: Xiaoming Jiang <jiangxiaoming@outlook.com> Change-Id: I9971e69135e0652a36e4b4754774a43ea1d92e8b
Diffstat (limited to 'src')
-rw-r--r--src/plugins/dpdk/device/format.c17
-rw-r--r--src/vppinfra/elf_clib.c25
-rw-r--r--src/vppinfra/elf_clib.h2
3 files changed, 30 insertions, 14 deletions
diff --git a/src/plugins/dpdk/device/format.c b/src/plugins/dpdk/device/format.c
index d3234d16f00..11435343cc8 100644
--- a/src/plugins/dpdk/device/format.c
+++ b/src/plugins/dpdk/device/format.c
@@ -17,9 +17,6 @@
#include <vppinfra/format.h>
#include <assert.h>
-#define __USE_GNU
-#include <dlfcn.h>
-
#include <vnet/ethernet/ethernet.h>
#include <vnet/ethernet/sfp.h>
#include <dpdk/device/dpdk.h>
@@ -347,7 +344,7 @@ format_dpdk_burst_fn (u8 *s, va_list *args)
dpdk_device_t *xd = va_arg (*args, dpdk_device_t *);
vlib_rx_or_tx_t dir = va_arg (*args, vlib_rx_or_tx_t);
void *p;
- Dl_info info = { 0 };
+ clib_elf_symbol_t sym;
#if RTE_VERSION < RTE_VERSION_NUM(21, 11, 0, 0)
#define rte_eth_fp_ops rte_eth_devices
@@ -356,10 +353,14 @@ format_dpdk_burst_fn (u8 *s, va_list *args)
p = (dir == VLIB_TX) ? rte_eth_fp_ops[xd->port_id].tx_pkt_burst :
rte_eth_fp_ops[xd->port_id].rx_pkt_burst;
- if (dladdr (p, &info) == 0 || info.dli_sname == 0)
- return format (s, "(not available)");
-
- return format (s, "%s", info.dli_sname);
+ if (clib_elf_symbol_by_address (pointer_to_uword (p), &sym))
+ {
+ return format (s, "%s", clib_elf_symbol_name (&sym));
+ }
+ else
+ {
+ return format (s, "(not available)");
+ }
}
static u8 *
diff --git a/src/vppinfra/elf_clib.c b/src/vppinfra/elf_clib.c
index d2865f800e3..d4d511e0fba 100644
--- a/src/vppinfra/elf_clib.c
+++ b/src/vppinfra/elf_clib.c
@@ -319,20 +319,33 @@ symbol_by_address_or_name (char *by_name,
return 0;
}
-uword
-clib_elf_symbol_by_name (char *by_name, clib_elf_symbol_t * s)
+__clib_export uword
+clib_elf_symbol_by_name (char *by_name, clib_elf_symbol_t *s)
{
return symbol_by_address_or_name (by_name, /* by_address */ 0, s);
}
-uword
-clib_elf_symbol_by_address (uword by_address, clib_elf_symbol_t * s)
+__clib_export uword
+clib_elf_symbol_by_address (uword by_address, clib_elf_symbol_t *s)
{
return symbol_by_address_or_name ( /* by_name */ 0, by_address, s);
}
-u8 *
-format_clib_elf_symbol (u8 * s, va_list * args)
+__clib_export const char *
+clib_elf_symbol_name (clib_elf_symbol_t *s)
+{
+ clib_elf_main_t *cem = &clib_elf_main;
+ elf_main_t *em;
+ elf_symbol_table_t *t;
+
+ em = vec_elt_at_index (cem->elf_mains, s->elf_main_index);
+ t = vec_elt_at_index (em->symbol_tables, s->symbol_table_index);
+
+ return (const char *) elf_symbol_name (t, &s->symbol);
+}
+
+__clib_export u8 *
+format_clib_elf_symbol (u8 *s, va_list *args)
{
clib_elf_main_t *cem = &clib_elf_main;
clib_elf_symbol_t *sym = va_arg (*args, clib_elf_symbol_t *);
diff --git a/src/vppinfra/elf_clib.h b/src/vppinfra/elf_clib.h
index 25b928c22a5..4e5d4d72165 100644
--- a/src/vppinfra/elf_clib.h
+++ b/src/vppinfra/elf_clib.h
@@ -131,6 +131,8 @@ typedef struct
uword clib_elf_symbol_by_name (char *name, clib_elf_symbol_t * result);
uword clib_elf_symbol_by_address (uword address, clib_elf_symbol_t * result);
+const char *clib_elf_symbol_name (clib_elf_symbol_t *result);
+
format_function_t format_clib_elf_symbol, format_clib_elf_symbol_with_address;
#endif /* included_clib_elf_self_h */