Skip to contentSkip to conversation

ss: add AF_XDP support

PATCH Applied [email protected] 2 participants 2 messages Jan 30, 2019 – Jan 31, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ss: add AF_XDP support

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.

Example:

$ sudo ss --xdp -e -p -m
Recv-Q      Send-Q           Local Address:Port             Peer Address:Port

0 0 enp134s0f0:q20 *
users:(("xdpsock",pid=17787,fd=3)) ino:39424 sk:4

        rx(entries:2048)
        tx(entries:2048)
        umem(id:1,size:8388608,num_pages:2048,chunk_size:2048,headroom:0,ifindex:7,
qid:20,zc:0,refs:1)
        fr(entries:2048)
        cr(entries:2048) skmem:(r0,rb212992,t0,tb212992,f0,w0,o0,bl0,d0)
0           0                    enp24s0f0:q0                           *
 users:(("xdpsock",pid=17780,fd=3)) ino:37384 sk:5
        rx(entries:2048)
        tx(entries:2048)
        umem(id:0,size:8388608,num_pages:2048,chunk_size:2048,headroom:0,ifindex:6,
qid:0,zc:1,refs:1)
        fr(entries:2048)
        cr(entries:2048) skmem:(r0,rb212992,t0,tb212992,f0,w0,o0,bl0,d0)

---
v1->v2:
* Define/redefine AF_XDP/AF_MAX if missing. (David)
* Add example to the commit log. (David)

---
 include/utils.h |   8 +++
 man/man8/ss.8   |   9 ++-
 misc/ss.c       | 168 +++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 180 insertions(+), 5 deletions(-)
include/utils.h +8 -0
index 92bbe82d3366..8a9c302082b2 100644
@@ -127,6 +127,14 @@ struct dn_naddr
 # define CLOCK_TAI 11
 #endif
 
+#ifndef AF_XDP
+# define AF_XDP 44
+# if AF_MAX < 45
+#  undef AF_MAX
+#  define AF_MAX 45
+# endif
+#endif
+
 __u32 get_addr32(const char *name);
 int get_addr_1(inet_prefix *dst, const char *arg, int family);
 int get_prefix_1(inet_prefix *dst, char *arg, int family);
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
Applied
#1 lore raw
Quoted 34 lines · On 1/29/19 11:57 PM, [email protected] wrote:

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.

Example:

$ sudo ss --xdp -e -p -m
Recv-Q      Send-Q           Local Address:Port             Peer Address:Port

0 0 enp134s0f0:q20 *
users:(("xdpsock",pid=17787,fd=3)) ino:39424 sk:4

        rx(entries:2048)
        tx(entries:2048)
        umem(id:1,size:8388608,num_pages:2048,chunk_size:2048,headroom:0,ifindex:7,
qid:20,zc:0,refs:1)
        fr(entries:2048)
        cr(entries:2048) skmem:(r0,rb212992,t0,tb212992,f0,w0,o0,bl0,d0)
0           0                    enp24s0f0:q0                           *
 users:(("xdpsock",pid=17780,fd=3)) ino:37384 sk:5
        rx(entries:2048)
        tx(entries:2048)
        umem(id:0,size:8388608,num_pages:2048,chunk_size:2048,headroom:0,ifindex:6,
qid:0,zc:1,refs:1)
        fr(entries:2048)
        cr(entries:2048) skmem:(r0,rb212992,t0,tb212992,f0,w0,o0,bl0,d0)

---
v1->v2:
* Define/redefine AF_XDP/AF_MAX if missing. (David)
* Add example to the commit log. (David)

Quoted 6 lines
---
 include/utils.h |   8 +++
 man/man8/ss.8   |   9 ++-
 misc/ss.c       | 168 +++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 180 insertions(+), 5 deletions(-)

applied to iproute2-next. Thanks