lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250919213153.103606-21-daniel@iogearbox.net>
Date: Fri, 19 Sep 2025 23:31:53 +0200
From: Daniel Borkmann <daniel@...earbox.net>
To: netdev@...r.kernel.org
Cc: bpf@...r.kernel.org,
	kuba@...nel.org,
	davem@...emloft.net,
	razor@...ckwall.org,
	pabeni@...hat.com,
	willemb@...gle.com,
	sdf@...ichev.me,
	john.fastabend@...il.com,
	martin.lau@...nel.org,
	jordan@...fe.io,
	maciej.fijalkowski@...el.com,
	magnus.karlsson@...el.com,
	David Wei <dw@...idwei.uk>
Subject: [PATCH net-next 20/20] tools, ynl: Add queue binding ynl sample application

From: David Wei <dw@...idwei.uk>

Add a ynl sample application that calls bind-queue to bind a real rxq
to a mapped rxq in a virtual netdev.

  # ethtool -X eth0 start 0 equal 15
  # ethtool -X eth0 start 15 equal 1 context new
  # ethtool --config-ntuple eth0 flow-type [...] action 15
  # ip link add numrxqueues 2 nk type netkit single
  # ethtool -l nk
  Channel parameters for nk:
  Pre-set maximums:
  RX:           2
  TX:           1
  Other:        n/a
  Combined:     1
  Current hardware settings:
  RX:           1
  TX:           1
  Other:        n/a
  Combined:     0
  # ip a
  4: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
      link/ether e8:eb:d3:a3:43:f6 brd ff:ff:ff:ff:ff:ff
  [...]
  8: nk@...E: <BROADCAST,MULTICAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 1000
      link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
  # ynl-bind eth0 15 nk
  bound eth0, queue 15 to nk, queue 1
  # ethtool -l nk
  [...]
  Current hardware settings:
  RX:           2
  TX:           1
  Other:        n/a
  Combined:     0

Signed-off-by: David Wei <dw@...idwei.uk>
Co-developed-by: Daniel Borkmann <daniel@...earbox.net>
Signed-off-by: Daniel Borkmann <daniel@...earbox.net>
---
 tools/net/ynl/samples/bind.c | 56 ++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
 create mode 100644 tools/net/ynl/samples/bind.c

diff --git a/tools/net/ynl/samples/bind.c b/tools/net/ynl/samples/bind.c
new file mode 100644
index 000000000000..a6426121cbd4
--- /dev/null
+++ b/tools/net/ynl/samples/bind.c
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include <ynl.h>
+#include <net/if.h>
+
+#include "netdev-user.h"
+
+int main(int argc, char **argv)
+{
+	struct netdev_bind_queue_req *req;
+	struct netdev_bind_queue_rsp *rsp;
+	char if_src[IF_NAMESIZE] = {};
+	char if_dst[IF_NAMESIZE] = {};
+	struct ynl_sock *ys;
+	struct ynl_error yerr;
+	int src_ifindex = 0, dst_ifindex = 0;
+	int src_queue_id = 0;
+
+	if (argc > 1)
+		src_ifindex = if_nametoindex(argv[1]);
+	if (argc > 2)
+		src_queue_id = strtol(argv[2], NULL, 0);
+	if (argc > 3)
+		dst_ifindex = if_nametoindex(argv[3]);
+
+	ys = ynl_sock_create(&ynl_netdev_family, &yerr);
+	if (!ys) {
+		fprintf(stderr, "YNL: %s\n", yerr.msg);
+		return 1;
+	}
+
+	req = netdev_bind_queue_req_alloc();
+	netdev_bind_queue_req_set_src_ifindex(req, src_ifindex);
+	netdev_bind_queue_req_set_src_queue_id(req, src_queue_id);
+	netdev_bind_queue_req_set_dst_ifindex(req, dst_ifindex);
+
+	rsp = netdev_bind_queue(ys, req);
+	netdev_bind_queue_req_free(req);
+	if (!rsp)
+		goto err;
+
+	assert(rsp->_present.dst_queue_id);
+	printf("bound %s, queue %d to %s, queue %d\n",
+	       if_indextoname(src_ifindex, if_src), src_queue_id,
+	       if_indextoname(dst_ifindex, if_dst), rsp->dst_queue_id);
+
+	netdev_bind_queue_rsp_free(rsp);
+	ynl_sock_destroy(ys);
+	return 0;
+err:
+	fprintf(stderr, "YNL: %s\n", ys->err.msg);
+	ynl_sock_destroy(ys);
+	return 2;
+}
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ