@@ -9,9 +9,12 @@
#include <linux/tracepoint.h>
TRACE_DEFINE_ENUM(VIRTIO_VSOCK_TYPE_STREAM);
+TRACE_DEFINE_ENUM(VIRTIO_VSOCK_TYPE_SEQPACKET);
#define show_type(val) \
- __print_symbolic(val, { VIRTIO_VSOCK_TYPE_STREAM, "STREAM" })
+ __print_symbolic(val, \
+ { VIRTIO_VSOCK_TYPE_STREAM, "STREAM" }, \
+ { VIRTIO_VSOCK_TYPE_SEQPACKET, "SEQPACKET" })
TRACE_DEFINE_ENUM(VIRTIO_VSOCK_OP_INVALID);
TRACE_DEFINE_ENUM(VIRTIO_VSOCK_OP_REQUEST);
@@ -21,6 +24,8 @@ TRACE_DEFINE_ENUM(VIRTIO_VSOCK_OP_SHUTDOWN);
TRACE_DEFINE_ENUM(VIRTIO_VSOCK_OP_RW);
TRACE_DEFINE_ENUM(VIRTIO_VSOCK_OP_CREDIT_UPDATE);
TRACE_DEFINE_ENUM(VIRTIO_VSOCK_OP_CREDIT_REQUEST);
+TRACE_DEFINE_ENUM(VIRTIO_VSOCK_OP_SEQ_BEGIN);
+TRACE_DEFINE_ENUM(VIRTIO_VSOCK_OP_SEQ_END);
#define show_op(val) \
__print_symbolic(val, \
@@ -31,7 +36,9 @@ TRACE_DEFINE_ENUM(VIRTIO_VSOCK_OP_CREDIT_REQUEST);
{ VIRTIO_VSOCK_OP_SHUTDOWN, "SHUTDOWN" }, \
{ VIRTIO_VSOCK_OP_RW, "RW" }, \
{ VIRTIO_VSOCK_OP_CREDIT_UPDATE, "CREDIT_UPDATE" }, \
- { VIRTIO_VSOCK_OP_CREDIT_REQUEST, "CREDIT_REQUEST" })
+ { VIRTIO_VSOCK_OP_CREDIT_REQUEST, "CREDIT_REQUEST" }, \
+ { VIRTIO_VSOCK_OP_SEQ_BEGIN, "SEQ_BEGIN" }, \
+ { VIRTIO_VSOCK_OP_SEQ_END, "SEQ_END" })
TRACE_EVENT(virtio_transport_alloc_pkt,
TP_PROTO(
@@ -40,7 +47,9 @@ TRACE_EVENT(virtio_transport_alloc_pkt,
__u32 len,
__u16 type,
__u16 op,
- __u32 flags
+ __u32 flags,
+ __u32 msg_len,
+ __u32 msg_cnt
),
TP_ARGS(
src_cid, src_port,
@@ -48,7 +57,9 @@ TRACE_EVENT(virtio_transport_alloc_pkt,
len,
type,
op,
- flags
+ flags,
+ msg_len,
+ msg_cnt
),
TP_STRUCT__entry(
__field(__u32, src_cid)
@@ -59,6 +70,8 @@ TRACE_EVENT(virtio_transport_alloc_pkt,
__field(__u16, type)
__field(__u16, op)
__field(__u32, flags)
+ __field(__u32, msg_len)
+ __field(__u32, msg_cnt)
),
TP_fast_assign(
__entry->src_cid = src_cid;
@@ -69,14 +82,19 @@ TRACE_EVENT(virtio_transport_alloc_pkt,
__entry->type = type;
__entry->op = op;
__entry->flags = flags;
+ __entry->msg_len = msg_len;
+ __entry->msg_cnt = msg_cnt;
),
- TP_printk("%u:%u -> %u:%u len=%u type=%s op=%s flags=%#x",
+ TP_printk("%u:%u -> %u:%u len=%u type=%s op=%s flags=%#x "
+ "msg_len=%u msg_cnt=%u",
__entry->src_cid, __entry->src_port,
__entry->dst_cid, __entry->dst_port,
__entry->len,
show_type(__entry->type),
show_op(__entry->op),
- __entry->flags)
+ __entry->flags,
+ __entry->msg_len,
+ __entry->msg_cnt)
);
TRACE_EVENT(virtio_transport_recv_pkt,
@@ -88,7 +106,9 @@ TRACE_EVENT(virtio_transport_recv_pkt,
__u16 op,
__u32 flags,
__u32 buf_alloc,
- __u32 fwd_cnt
+ __u32 fwd_cnt,
+ __u32 msg_len,
+ __u32 msg_cnt
),
TP_ARGS(
src_cid, src_port,
@@ -98,7 +118,9 @@ TRACE_EVENT(virtio_transport_recv_pkt,
op,
flags,
buf_alloc,
- fwd_cnt
+ fwd_cnt,
+ msg_len,
+ msg_cnt
),
TP_STRUCT__entry(
__field(__u32, src_cid)
@@ -111,6 +133,8 @@ TRACE_EVENT(virtio_transport_recv_pkt,
__field(__u32, flags)
__field(__u32, buf_alloc)
__field(__u32, fwd_cnt)
+ __field(__u32, msg_len)
+ __field(__u32, msg_cnt)
),
TP_fast_assign(
__entry->src_cid = src_cid;
@@ -123,9 +147,11 @@ TRACE_EVENT(virtio_transport_recv_pkt,
__entry->flags = flags;
__entry->buf_alloc = buf_alloc;
__entry->fwd_cnt = fwd_cnt;
+ __entry->msg_len = msg_len;
+ __entry->msg_cnt = msg_cnt;
),
TP_printk("%u:%u -> %u:%u len=%u type=%s op=%s flags=%#x "
- "buf_alloc=%u fwd_cnt=%u",
+ "buf_alloc=%u fwd_cnt=%u msg_len=%u msg_cnt=%u",
__entry->src_cid, __entry->src_port,
__entry->dst_cid, __entry->dst_port,
__entry->len,
@@ -133,7 +159,9 @@ TRACE_EVENT(virtio_transport_recv_pkt,
show_op(__entry->op),
__entry->flags,
__entry->buf_alloc,
- __entry->fwd_cnt)
+ __entry->fwd_cnt,
+ __entry->msg_len,
+ __entry->msg_cnt)
);
#endif /* _TRACE_VSOCK_VIRTIO_TRANSPORT_COMMON_H */
@@ -47,6 +47,8 @@ virtio_transport_alloc_pkt(struct virtio_vsock_pkt_info *info,
{
struct virtio_vsock_pkt *pkt;
int err;
+ u32 msg_len = 0;
+ u32 msg_cnt = 0;
pkt = kzalloc(sizeof(*pkt), GFP_KERNEL);
if (!pkt)
@@ -74,6 +76,14 @@ virtio_transport_alloc_pkt(struct virtio_vsock_pkt_info *info,
err = memcpy_from_msg(pkt->buf, info->msg, len);
if (err)
goto out;
+
+ if (info->op == VIRTIO_VSOCK_OP_SEQ_BEGIN ||
+ info->op == VIRTIO_VSOCK_OP_SEQ_END) {
+ struct virtio_vsock_seq_hdr *seq_hdr = pkt->buf;
+
+ msg_len = le32_to_cpu(seq_hdr->msg_len);
+ msg_cnt = le32_to_cpu(seq_hdr->msg_cnt);
+ }
}
trace_virtio_transport_alloc_pkt(src_cid, src_port,
@@ -81,7 +91,7 @@ virtio_transport_alloc_pkt(struct virtio_vsock_pkt_info *info,
len,
info->type,
info->op,
- info->flags);
+ info->flags, msg_len, msg_cnt);
return pkt;
@@ -1336,12 +1346,22 @@ void virtio_transport_recv_pkt(struct virtio_transport *t,
struct vsock_sock *vsk;
struct sock *sk;
bool space_available;
+ u32 msg_len = 0;
+ u32 msg_cnt = 0;
vsock_addr_init(&src, le64_to_cpu(pkt->hdr.src_cid),
le32_to_cpu(pkt->hdr.src_port));
vsock_addr_init(&dst, le64_to_cpu(pkt->hdr.dst_cid),
le32_to_cpu(pkt->hdr.dst_port));
+ if (le16_to_cpu(pkt->hdr.op) == VIRTIO_VSOCK_OP_SEQ_BEGIN ||
+ le16_to_cpu(pkt->hdr.op) == VIRTIO_VSOCK_OP_SEQ_END) {
+ struct virtio_vsock_seq_hdr *seq_hdr = pkt->buf;
+
+ msg_len = le32_to_cpu(seq_hdr->msg_len);
+ msg_cnt = le32_to_cpu(seq_hdr->msg_cnt);
+ }
+
trace_virtio_transport_recv_pkt(src.svm_cid, src.svm_port,
dst.svm_cid, dst.svm_port,
le32_to_cpu(pkt->hdr.len),
@@ -1349,7 +1369,8 @@ void virtio_transport_recv_pkt(struct virtio_transport *t,
le16_to_cpu(pkt->hdr.op),
le32_to_cpu(pkt->hdr.flags),
le32_to_cpu(pkt->hdr.buf_alloc),
- le32_to_cpu(pkt->hdr.fwd_cnt));
+ le32_to_cpu(pkt->hdr.fwd_cnt),
+ msg_len, msg_cnt);
if (!virtio_transport_valid_type(le16_to_cpu(pkt->hdr.type))) {
(void)virtio_transport_reset_no_sock(t, pkt);
This updates current implementation for trace event of virtio vsock: SEQPACKET socket's type, SEQPACKET specific ops and SEQPACKET 'msg_len' and 'msg_cnt' fields are added. Signed-off-by: Arseny Krasnov <arseny.krasnov@kaspersky.com> --- .../events/vsock_virtio_transport_common.h | 48 +++++++++++++++---- net/vmw_vsock/virtio_transport_common.c | 25 +++++++++- 2 files changed, 61 insertions(+), 12 deletions(-)