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: <20250923210026.3870-3-mehdi.benhadjkhelifa@gmail.com>
Date: Tue, 23 Sep 2025 22:00:13 +0100
From: Mehdi Ben Hadj Khelifa <mehdi.benhadjkhelifa@...il.com>
To: davem@...emloft.net,
	edumazet@...gle.com,
	kuba@...nel.org,
	pabeni@...hat.com,
	donald.hunter@...il.com,
	andrew+netdev@...n.ch,
	ast@...nel.org,
	daniel@...earbox.net,
	hawk@...nel.org,
	john.fastabend@...il.com,
	matttbe@...nel.org,
	chuck.lever@...cle.com,
	jdamato@...tly.com,
	skhawaja@...gle.com,
	dw@...idwei.uk,
	mkarsten@...terloo.ca,
	yoong.siang.song@...el.com,
	david.hunter.linux@...il.com,
	skhan@...uxfoundation.org
Cc: horms@...nel.org,
	sdf@...ichev.me,
	netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	bpf@...r.kernel.org,
	linux-kernel-mentees@...ts.linuxfoundation.org,
	Mehdi Ben Hadj Khelifa <mehdi.benhadjkhelifa@...il.com>
Subject: [PATCH RFC 2/4] net: xdp: Add xmo_rx_queue_index callback

Introduce xmo_rx_queue_index netdev callback in order allow the eBPF
program bounded to the device to retrieve the RX queue index from the
hw NIC.

Signed-off-by: Mehdi Ben Hadj Khelifa <mehdi.benhadjkhelifa@...il.com>
---
 include/net/xdp.h |  5 +++++
 net/core/xdp.c    | 15 +++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/include/net/xdp.h b/include/net/xdp.h
index b40f1f96cb11..edbf66c31f83 100644
--- a/include/net/xdp.h
+++ b/include/net/xdp.h
@@ -547,6 +547,10 @@ void xdp_attachment_setup(struct xdp_attachment_info *info,
 			   NETDEV_XDP_RX_METADATA_VLAN_TAG, \
 			   bpf_xdp_metadata_rx_vlan_tag, \
 			   xmo_rx_vlan_tag) \
+	XDP_METADATA_KFUNC(XDP_METADATA_KFUNC_RX_QUEUE_INDEX, \
+			   NETDEV_XDP_RX_METADATA_QUEUE_INDEX, \
+			   bpf_xdp_metadata_rx_queue_index, \
+			   xmo_rx_queue_index) \
 
 enum xdp_rx_metadata {
 #define XDP_METADATA_KFUNC(name, _, __, ___) name,
@@ -610,6 +614,7 @@ struct xdp_metadata_ops {
 			       enum xdp_rss_hash_type *rss_type);
 	int	(*xmo_rx_vlan_tag)(const struct xdp_md *ctx, __be16 *vlan_proto,
 				   u16 *vlan_tci);
+	int	(*xmo_rx_queue_index)(const struct xdp_md *ctx, u32 *queue_index);
 };
 
 #ifdef CONFIG_NET
diff --git a/net/core/xdp.c b/net/core/xdp.c
index 491334b9b8be..78c0c63e343c 100644
--- a/net/core/xdp.c
+++ b/net/core/xdp.c
@@ -962,6 +962,21 @@ __bpf_kfunc int bpf_xdp_metadata_rx_vlan_tag(const struct xdp_md *ctx,
 	return -EOPNOTSUPP;
 }
 
+/**
+ * bpf_xdp_metadata_rx_queue_index - Read XDP frame RX queue index.
+ * @ctx: XDP context pointer.
+ * @queue_index: Return value pointer.
+ *
+ * Return:
+ * * Returns 0 on success or ``-errno`` on error.
+ * * ``-EOPNOTSUPP`` : means device driver does not implement kfunc
+ * * ``-ENODATA``    : means no RX queue index available for this frame
+ */
+__bpf_kfunc int bpf_xdp_metadata_rx_queue_index(const struct xdp_md *ctx, u32 *queue_index)
+{
+	return -EOPNOTSUPP;
+}
+
 __bpf_kfunc_end_defs();
 
 BTF_KFUNCS_START(xdp_metadata_kfunc_ids)
-- 
2.51.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ