Skip to contentSkip to conversation

ss: AF_XDP monitoring support

PATCH Superseded [email protected] 2 participants 5 messages Jan 25, 2019 – Jan 30, 2019

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover ss: AF_XDP monitoring support

From: Björn Töpel <[email protected]>

Hi!

This short series teaches ss about AF_XDP monitoring support using the sock_diag interface.

The AF_XDP monitoring support was merged to kernel in commit dbbd79ae166f ("Merge branch 'af-xdp-sock-diag'"), via the bpf-next tree.

Note libc has to know about AF_XDP for iproute2 to build properly after this series. For glibc, AF_XDP was added in commit 38b0593e9a86 ("Add PF_XDP, AF_XDP and SOL_XDP from Linux 4.18 to bits/socket.h.") and for musl AF_XDP was introduced in commit 0a9a5c20c7eb ("add AF_XDP to sys/socket.h from linux v4.18").

Thanks,
Björn

Björn Töpel (2):
uapi: add xdp_diag.h
ss: add AF_XDP support

 include/uapi/linux/xdp_diag.h |  72 +++++++++++++++
 man/man8/ss.8                 |   9 +-
 misc/ss.c                     | 168 +++++++++++++++++++++++++++++++++-
 3 files changed, 244 insertions(+), 5 deletions(-)
 create mode 100644 include/uapi/linux/xdp_diag.h
Signature · 1 line
2.19.1
#1 lore raw

PATCH 1/2 uapi: add xdp_diag.h

From: Björn Töpel <[email protected]>

Import xdp_diag.h that was introduced in Linux kernel commit a36b38aa2af6 ("xsk: add sock_diag interface for AF_XDP").

---
 include/uapi/linux/xdp_diag.h | 72 +++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)
 create mode 100644 include/uapi/linux/xdp_diag.h
include/uapi/linux/xdp_diag.h new file +72 -0
new file mode 100644
index 000000000000..78b2591a7782
@@ -0,0 +1,72 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * xdp_diag: interface for query/monitor XDP sockets
+ * Copyright(c) 2019 Intel Corporation.
+ */
+
+#ifndef _LINUX_XDP_DIAG_H
+#define _LINUX_XDP_DIAG_H
+
+#include <linux/types.h>
+
+struct xdp_diag_req {
+	__u8	sdiag_family;
+	__u8	sdiag_protocol;
+	__u16	pad;
+	__u32	xdiag_ino;
+	__u32	xdiag_show;
+	__u32	xdiag_cookie[2];
+};
+
+struct xdp_diag_msg {
+	__u8	xdiag_family;
+	__u8	xdiag_type;
+	__u16	pad;
+	__u32	xdiag_ino;
+	__u32	xdiag_cookie[2];
+};
+
+#define XDP_SHOW_INFO		(1 << 0) /* Basic information */
+#define XDP_SHOW_RING_CFG	(1 << 1)
+#define XDP_SHOW_UMEM		(1 << 2)
+#define XDP_SHOW_MEMINFO	(1 << 3)
+
+enum {
+	XDP_DIAG_NONE,
+	XDP_DIAG_INFO,
+	XDP_DIAG_UID,
+	XDP_DIAG_RX_RING,
+	XDP_DIAG_TX_RING,
+	XDP_DIAG_UMEM,
+	XDP_DIAG_UMEM_FILL_RING,
+	XDP_DIAG_UMEM_COMPLETION_RING,
+	XDP_DIAG_MEMINFO,
+	__XDP_DIAG_MAX,
+};
+
+#define XDP_DIAG_MAX (__XDP_DIAG_MAX - 1)
+
+struct xdp_diag_info {
+	__u32	ifindex;
+	__u32	queue_id;
+};
+
+struct xdp_diag_ring {
+	__u32	entries; /*num descs */
+};
+
+#define XDP_DU_F_ZEROCOPY (1 << 0)
+
+struct xdp_diag_umem {
+	__u64	size;
+	__u32	id;
+	__u32	num_pages;
+	__u32	chunk_size;
+	__u32	headroom;
+	__u32	ifindex;
+	__u32	queue_id;
+	__u32	flags;
+	__u32	refs;
+};
+
+#endif /* _LINUX_XDP_DIAG_H */
Signature · 1 line
2.19.1
#2 lore raw

PATCH 2/2 ss: add AF_XDP support

In reply to [email protected]

From: Björn Töpel <[email protected]>

AF_XDP is an address family that is optimized for high performance packet processing.

This patch adds AF_XDP support to ss(8) so that sockets can be queried and monitored.

---
 man/man8/ss.8 |   9 ++-
 misc/ss.c     | 168 +++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 172 insertions(+), 5 deletions(-)
man/man8/ss.8 +6 -3
index 553a6cf46f0e..bc120fd78716 100644
@@ -324,16 +324,19 @@ Display SCTP sockets.
 .B \-\-vsock
 Display vsock sockets (alias for -f vsock).
 .TP
+.B \-\-xdp
+Display XDP sockets (alias for -f xdp).
+.TP
 .B \-f FAMILY, \-\-family=FAMILY
 Display sockets of type FAMILY.
-Currently the following families are supported: unix, inet, inet6, link, netlink, vsock.
+Currently the following families are supported: unix, inet, inet6, link, netlink, vsock, xdp.
 .TP
 .B \-A QUERY, \-\-query=QUERY, \-\-socket=QUERY
 List of socket tables to dump, separated by commas. The following identifiers
 are understood: all, inet, tcp, udp, raw, unix, packet, netlink, unix_dgram,
 unix_stream, unix_seqpacket, packet_raw, packet_dgram, dccp, sctp,
-vsock_stream, vsock_dgram. Any item in the list may optionally be prefixed by
-an exclamation mark
+vsock_stream, vsock_dgram, xdp Any item in the list may optionally be
+prefixed by an exclamation mark
 .RB ( ! )
 to exclude that socket table from being dumped.
 .TP
misc/ss.c +166 -2

258 lines not on this page · raw message

Signature · 1 line
2.19.1
#3 lore raw

Re: [PATCH iproute2-next 2/2] ss: add AF_XDP support

Quoted 5 lines · On 1/25/19 12:18 AM, [email protected] wrote:

From: Björn Töpel <[email protected]>

AF_XDP is an address family that is optimized for high performance packet processing.

Quoted 9 lines

This patch adds AF_XDP support to ss(8) so that sockets can be queried and monitored.

---
 man/man8/ss.8 |   9 ++-
 misc/ss.c     | 168 +++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 172 insertions(+), 5 deletions(-)

AF_XDP is not currently defined for a number of distributions. Add a definition to include/utils.h similar to what is done for MPLS.

Also, please add example output to the commit log.

#4 lore raw

Re: [PATCH iproute2-next 2/2] ss: add AF_XDP support

Den ons 30 jan. 2019 kl 03:39 skrev David Ahern <[email protected]>:

Quoted 1 line

[...]

Quoted 5 lines

AF_XDP is not currently defined for a number of distributions. Add a definition to include/utils.h similar to what is done for MPLS.

Also, please add example output to the commit log.

Ok, I'll address AF_XDP/AF_MAX and fix the commit log in v2.

Thanks, David!
Björn