MLX5: modify if_indextoname syscall to support F-Stack tools.

This commit is contained in:
fengbojiang 2021-09-10 15:40:25 +08:00
parent 908bfc2b6a
commit 16f94e1fa3
1 changed files with 12 additions and 1 deletions
dpdk/drivers/net/mlx5

View File

@ -24,6 +24,7 @@
#include <stdalign.h> #include <stdalign.h>
#include <sys/un.h> #include <sys/un.h>
#include <time.h> #include <time.h>
#include <dlfcn.h>
#include <rte_atomic.h> #include <rte_atomic.h>
#include <rte_ethdev_driver.h> #include <rte_ethdev_driver.h>
@ -1640,6 +1641,7 @@ mlx5_dev_to_eswitch_info(struct rte_eth_dev *dev)
* @return * @return
* 0 on success, a negative errno value otherwise and rte_errno is set. * 0 on success, a negative errno value otherwise and rte_errno is set.
*/ */
static int (*real_if_indextoname)(unsigned int, char *);
int int
mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info) mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info)
{ {
@ -1659,7 +1661,16 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info)
char c; char c;
int ret; int ret;
if (!if_indextoname(ifindex, ifname)) { // for ff tools
if (!real_if_indextoname) {
real_if_indextoname = dlsym(RTLD_NEXT, "if_indextoname");
if (!real_if_indextoname) {
rte_errno = errno;
return -rte_errno;
}
}
if (!real_if_indextoname(ifindex, ifname)) {
rte_errno = errno; rte_errno = errno;
return -rte_errno; return -rte_errno;
} }