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

This commit is contained in:
fengbojiang 2021-06-15 17:48:26 +08:00
parent 823b1d7cf4
commit a3702d0636
1 changed files with 12 additions and 1 deletions

View File

@ -23,6 +23,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_ethdev_driver.h> #include <rte_ethdev_driver.h>
#include <rte_bus_pci.h> #include <rte_bus_pci.h>
@ -1070,6 +1071,7 @@ mlx5_sysfs_check_switch_info(bool device_dir,
* @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)
{ {
@ -1088,7 +1090,16 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info)
bool device_dir = false; bool device_dir = false;
char c; char c;
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;
} }