Commit a38bc45a authored by Kleber Sacilotto de Souza's avatar Kleber Sacilotto de Souza Committed by Daniel Borkmann

selftests/net: Fix reuseport_bpf_numa by skipping unavailable nodes

In some platforms the numa node numbers are not necessarily consecutive,
meaning that not all nodes from 0 to the value returned by numa_max_node()
are available on the system. Using node numbers which are not available
results on errors from libnuma such as:

  ---- IPv4 UDP ----
  send node 0, receive socket 0
  libnuma: Warning: Cannot read node cpumask from sysfs
  ./reuseport_bpf_numa: failed to pin to node: No such file or directory

Fix it by checking if the node number bit is set on numa_nodes_ptr, which
is defined on libnuma as "Set with all nodes the kernel has exposed to
userspace".
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20211101145317.286118-1-kleber.souza@canonical.com
parent c08455de
...@@ -211,12 +211,16 @@ static void test(int *rcv_fd, int len, int family, int proto) ...@@ -211,12 +211,16 @@ static void test(int *rcv_fd, int len, int family, int proto)
/* Forward iterate */ /* Forward iterate */
for (node = 0; node < len; ++node) { for (node = 0; node < len; ++node) {
if (!numa_bitmask_isbitset(numa_nodes_ptr, node))
continue;
send_from_node(node, family, proto); send_from_node(node, family, proto);
receive_on_node(rcv_fd, len, epfd, node, proto); receive_on_node(rcv_fd, len, epfd, node, proto);
} }
/* Reverse iterate */ /* Reverse iterate */
for (node = len - 1; node >= 0; --node) { for (node = len - 1; node >= 0; --node) {
if (!numa_bitmask_isbitset(numa_nodes_ptr, node))
continue;
send_from_node(node, family, proto); send_from_node(node, family, proto);
receive_on_node(rcv_fd, len, epfd, node, proto); receive_on_node(rcv_fd, len, epfd, node, proto);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment