[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250919213153.103606-7-daniel@iogearbox.net>
Date: Fri, 19 Sep 2025 23:31:39 +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 06/20] net, ynl: Add peer info to queue-get response
From: David Wei <dw@...idwei.uk>
Add a nested peer field to the queue-get response that returns the
peered ifindex and queue id. If the queried queue is a mapped queue
in a virtual netdev, the nested fields for dmabuf/io-uring/xsk will
be filled in, too.
Example:
# ip netns exec foo ./pyynl/cli.py \
--spec ~/netlink/specs/netdev.yaml \
--do queue-get \
--json '{"ifindex": 3, "id": 1, "type": "rx"}'
{'id': 1, 'ifindex': 3, 'peer': {'id': 15, 'ifindex': 4}, 'io-uring': {}, 'type': 'rx'}
Signed-off-by: David Wei <dw@...idwei.uk>
Co-developed-by: Daniel Borkmann <daniel@...earbox.net>
Signed-off-by: Daniel Borkmann <daniel@...earbox.net>
---
Documentation/netlink/specs/netdev.yaml | 17 +++++++++++++++++
include/uapi/linux/netdev.h | 9 +++++++++
net/core/netdev-genl.c | 23 ++++++++++++++++++++++-
tools/include/uapi/linux/netdev.h | 9 +++++++++
4 files changed, 57 insertions(+), 1 deletion(-)
diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlink/specs/netdev.yaml
index 99a430ea8a9a..1467c36f6b5f 100644
--- a/Documentation/netlink/specs/netdev.yaml
+++ b/Documentation/netlink/specs/netdev.yaml
@@ -297,6 +297,17 @@ attribute-sets:
-
name: xsk-info
attributes: []
+ -
+ name: peer-info
+ attributes:
+ -
+ name: id
+ doc: Queue index of the netdevice to which the peer queue belongs.
+ type: u32
+ -
+ name: ifindex
+ doc: ifindex of the netdevice to which the peer queue belongs.
+ type: u32
-
name: queue
attributes:
@@ -338,6 +349,11 @@ attribute-sets:
doc: XSK information for this queue, if any.
type: nest
nested-attributes: xsk-info
+ -
+ name: peer
+ doc: Whether this queue was bound to another peer queue.
+ type: nest
+ nested-attributes: peer-info
-
name: qstats
doc: |
@@ -706,6 +722,7 @@ operations:
- dmabuf
- io-uring
- xsk
+ - peer
dump:
request:
attributes:
diff --git a/include/uapi/linux/netdev.h b/include/uapi/linux/netdev.h
index 05e17765a39d..73d1590e4696 100644
--- a/include/uapi/linux/netdev.h
+++ b/include/uapi/linux/netdev.h
@@ -150,6 +150,14 @@ enum {
NETDEV_A_XSK_INFO_MAX = (__NETDEV_A_XSK_INFO_MAX - 1)
};
+enum {
+ NETDEV_A_PEER_INFO_ID = 1,
+ NETDEV_A_PEER_INFO_IFINDEX,
+
+ __NETDEV_A_PEER_INFO_MAX,
+ NETDEV_A_PEER_INFO_MAX = (__NETDEV_A_PEER_INFO_MAX - 1)
+};
+
enum {
NETDEV_A_QUEUE_ID = 1,
NETDEV_A_QUEUE_IFINDEX,
@@ -158,6 +166,7 @@ enum {
NETDEV_A_QUEUE_DMABUF,
NETDEV_A_QUEUE_IO_URING,
NETDEV_A_QUEUE_XSK,
+ NETDEV_A_QUEUE_PEER,
__NETDEV_A_QUEUE_MAX,
NETDEV_A_QUEUE_MAX = (__NETDEV_A_QUEUE_MAX - 1)
diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c
index ed0ce3dbfc6f..c20922539216 100644
--- a/net/core/netdev-genl.c
+++ b/net/core/netdev-genl.c
@@ -393,6 +393,7 @@ netdev_nl_queue_fill_one(struct sk_buff *rsp, struct net_device *netdev,
struct pp_memory_provider_params *params;
struct netdev_rx_queue *rxq;
struct netdev_queue *txq;
+ struct nlattr *nest;
void *hdr;
hdr = genlmsg_iput(rsp, info);
@@ -410,6 +411,27 @@ netdev_nl_queue_fill_one(struct sk_buff *rsp, struct net_device *netdev,
if (nla_put_napi_id(rsp, rxq->napi))
goto nla_put_failure;
+ if (netdev_rx_queue_peered(netdev, q_idx)) {
+ struct netdev_rx_queue *p_rxq;
+ struct net_device *p_netdev = netdev;
+ u32 p_q_idx = q_idx;
+
+ nest = nla_nest_start(rsp, NETDEV_A_QUEUE_PEER);
+ if (!nest)
+ goto nla_put_failure;
+ p_rxq = __netif_get_rx_queue_peer(&p_netdev, &p_q_idx);
+ if (nla_put_u32(rsp, NETDEV_A_PEER_INFO_ID, p_q_idx) ||
+ nla_put_u32(rsp, NETDEV_A_PEER_INFO_IFINDEX, p_netdev->ifindex))
+ goto nla_put_failure;
+ nla_nest_end(rsp, nest);
+
+ if (!netdev->dev.parent) {
+ netdev = p_netdev;
+ q_idx = p_q_idx;
+ rxq = p_rxq;
+ }
+ }
+
params = &rxq->mp_params;
if (params->mp_ops &&
params->mp_ops->nl_fill(params->mp_priv, rsp, rxq))
@@ -419,7 +441,6 @@ netdev_nl_queue_fill_one(struct sk_buff *rsp, struct net_device *netdev,
if (nla_put_empty_nest(rsp, NETDEV_A_QUEUE_XSK))
goto nla_put_failure;
#endif
-
break;
case NETDEV_QUEUE_TYPE_TX:
txq = netdev_get_tx_queue(netdev, q_idx);
diff --git a/tools/include/uapi/linux/netdev.h b/tools/include/uapi/linux/netdev.h
index 05e17765a39d..73d1590e4696 100644
--- a/tools/include/uapi/linux/netdev.h
+++ b/tools/include/uapi/linux/netdev.h
@@ -150,6 +150,14 @@ enum {
NETDEV_A_XSK_INFO_MAX = (__NETDEV_A_XSK_INFO_MAX - 1)
};
+enum {
+ NETDEV_A_PEER_INFO_ID = 1,
+ NETDEV_A_PEER_INFO_IFINDEX,
+
+ __NETDEV_A_PEER_INFO_MAX,
+ NETDEV_A_PEER_INFO_MAX = (__NETDEV_A_PEER_INFO_MAX - 1)
+};
+
enum {
NETDEV_A_QUEUE_ID = 1,
NETDEV_A_QUEUE_IFINDEX,
@@ -158,6 +166,7 @@ enum {
NETDEV_A_QUEUE_DMABUF,
NETDEV_A_QUEUE_IO_URING,
NETDEV_A_QUEUE_XSK,
+ NETDEV_A_QUEUE_PEER,
__NETDEV_A_QUEUE_MAX,
NETDEV_A_QUEUE_MAX = (__NETDEV_A_QUEUE_MAX - 1)
--
2.43.0
Powered by blists - more mailing lists