diff options
author | Benoît Ganne <bganne@cisco.com> | 2020-10-19 09:49:09 +0200 |
---|---|---|
committer | Andrew Yourtchenko <ayourtch@gmail.com> | 2020-11-12 12:33:28 +0000 |
commit | 087d81dafad8ff52e3704357e1ee2d87b0aed694 (patch) | |
tree | 761c5bc06b0ad09aca9a853f48c4e45a1791ae99 /src/plugins/af_xdp/device.c | |
parent | 73a347660205b96693d50cbd754be8d838dd5ae6 (diff) |
af_xdp: fix NUMA node parsing
Non-NUMA systems might report -1 as NUMA node.
Type: fix
Change-Id: I092c817ea670009d6f530cc70ad13d45e15fd363
Signed-off-by: Benoît Ganne <bganne@cisco.com>
(cherry picked from commit 4317b8efb1c4a4163b2585b9abd71ec38cd0862c)
Diffstat (limited to 'src/plugins/af_xdp/device.c')
-rw-r--r-- | src/plugins/af_xdp/device.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/plugins/af_xdp/device.c b/src/plugins/af_xdp/device.c index 35e39b79fbd..5090d3a649a 100644 --- a/src/plugins/af_xdp/device.c +++ b/src/plugins/af_xdp/device.c @@ -22,6 +22,7 @@ #include <vlib/vlib.h> #include <vlib/unix/unix.h> #include <vlib/pci/pci.h> +#include <vppinfra/linux/sysfs.h> #include <vppinfra/unix.h> #include <vnet/ethernet/ethernet.h> #include "af_xdp.h" @@ -273,21 +274,18 @@ err0: static int af_xdp_get_numa (const char *ifname) { - FILE *fptr; + char *path; + clib_error_t *err; int numa; - char *s; - s = (char *) format (0, "/sys/class/net/%s/device/numa_node%c", ifname, 0); - fptr = fopen (s, "rb"); - vec_free (s); - - if (!fptr) - return 0; - - if (fscanf (fptr, "%d\n", &numa) != 1) + path = + (char *) format (0, "/sys/class/net/%s/device/numa_node%c", ifname, 0); + err = clib_sysfs_read (path, "%d", &numa); + if (err || numa < 0) numa = 0; - fclose (fptr); + clib_error_free (err); + vec_free (path); return numa; } |