Skip to contentSkip to conversation

add trace events

RFC In review Geliang Tang 3 participants 11 messages Jan 26, 2021 – Jan 30, 2021

Subsystems (3)
lore
Share & tools
lore

Geliang Tang

author
#0 lore raw

cover add trace events

This patchset addressed issues 131, replace some/most pr_debug with trace events.

Geliang Tang (6):
mptcp: add tracepoints for data operations
mptcp: add echo field in mptcp_out_options
mptcp: add tracepoints for options operations
mptcp: add mptcpi_local_addr_* in mptcp_info
mptcp: add tracepoints for PM operations
mptcp: add tracepoints for subflow operations

 include/net/mptcp.h          |   1 +
 include/trace/events/mptcp.h | 408 +++++++++++++++++++++++++++++++++++
 include/uapi/linux/mptcp.h   |   4 +-
 net/mptcp/mptcp_diag.c       |   4 +-
 net/mptcp/options.c          |  11 +-
 net/mptcp/pm.c               |   3 +
 net/mptcp/pm_netlink.c       |   6 +-
 net/mptcp/protocol.c         |   5 +
 net/mptcp/protocol.h         |   1 +
 net/mptcp/subflow.c          |   6 +
 10 files changed, 445 insertions(+), 4 deletions(-)
 create mode 100644 include/trace/events/mptcp.h
Signature · 1 line
2.29.2
author
#1 lore raw

RFC 1/6 mptcp: add tracepoints for data operations

Add tracepoints in MPTCP for tracing the data sending and receiving.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 include/trace/events/mptcp.h | 66 ++++++++++++++++++++++++++++++++++++
 net/mptcp/protocol.c         |  5 +++
 2 files changed, 71 insertions(+)
 create mode 100644 include/trace/events/mptcp.h
include/trace/events/mptcp.h new file +66 -0
new file mode 100644
index 000000000000..b56ece509dc5
@@ -0,0 +1,66 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM mptcp
+
+#if !defined(_TRACE_MPTCP_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_MPTCP_H
+
+#include <linux/mptcp.h>
+#include <linux/tracepoint.h>
+
+TRACE_EVENT(mptcp_sendmsg,
+
+	TP_PROTO(struct mptcp_data_frag *dfrag),
+
+	TP_ARGS(dfrag),
+
+	TP_STRUCT__entry(
+		__field(__u64, data_seq)
+		__field(__u16, data_len)
+		__field(__u16, offset)
+		__field(__u16, overhead)
+		__field(__u16, already_sent)
+	),
+
+	TP_fast_assign(
+		__entry->data_seq = dfrag->data_seq;
+		__entry->data_len = dfrag->data_len;
+		__entry->offset = dfrag->offset;
+		__entry->overhead = dfrag->overhead;
+		__entry->already_sent = dfrag->already_sent;
+	),
+
+	TP_printk("data_seq=%llx data_len=%d offset=%d overhead=%d already_sent=%d",
+		  __entry->data_seq, __entry->data_len,
+		  __entry->offset, __entry->overhead,
+		  __entry->already_sent)
+);
+
+TRACE_EVENT(mptcp_recvmsg,
+
+	TP_PROTO(struct sock *sk, int copied),
+
+	TP_ARGS(sk, copied),
+
+	TP_STRUCT__entry(
+		__field(int, data_ready)
+		__field(int, empty)
+		__field(int, copied)
+	),
+
+	TP_fast_assign(
+		struct mptcp_sock *msk = mptcp_sk(sk);
+
+		__entry->data_ready = test_bit(MPTCP_DATA_READY, &msk->flags);
+		__entry->empty = skb_queue_empty_lockless(&sk->sk_receive_queue);
+		__entry->copied = copied;
+	),
+
+	TP_printk("data_ready=%d rx queue empty=%d copied=%d",
+		  __entry->data_ready, __entry->empty, __entry->copied)
+);
+
+#endif /* _TRACE_MPTCP_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
net/mptcp/protocol.c +5 -0
index e9ad8cb5268b..f1d713834382 100644
@@ -25,6 +25,9 @@
 #include "protocol.h"
 #include "mib.h"
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/mptcp.h>
+
 #if IS_ENABLED(CONFIG_MPTCP_IPV6)
 struct mptcp6_sock {
 	struct mptcp_sock msk;
@@ -1674,6 +1677,7 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
 			if (!msk->first_pending)
 				WRITE_ONCE(msk->first_pending, dfrag);
 		}
+		trace_mptcp_sendmsg(dfrag);
 		pr_debug("msk=%p dfrag at seq=%lld len=%d sent=%d new=%d", msk,
 			 dfrag->data_seq, dfrag->data_len, dfrag->already_sent,
 			 !dfrag_collapsed);
@@ -2022,6 +2026,7 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
 		set_bit(MPTCP_DATA_READY, &msk->flags);
 	}
 out_err:
+	trace_mptcp_recvmsg(sk, copied);
 	pr_debug("msk=%p data_ready=%d rx queue empty=%d copied=%d",
 		 msk, test_bit(MPTCP_DATA_READY, &msk->flags),
 		 skb_queue_empty_lockless(&sk->sk_receive_queue), copied);
Signature · 1 line
2.29.2
author
#2 lore raw

RFC 2/6 mptcp: add echo field in mptcp_out_options

This patch added a new field echo in mptcp_out_options, it will be used when using the trace event to dump the mptcp_out_options info.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 include/net/mptcp.h | 1 +
 net/mptcp/options.c | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
include/net/mptcp.h +1 -0
index 5694370be3d4..85b39d901150 100644
@@ -46,6 +46,7 @@ struct mptcp_out_options {
 #endif
 	};
 	u8 addr_id;
+	u8 echo;
 	u16 port;
 	u64 ahmac;
 	u8 rm_id;
net/mptcp/options.c +2 -1
index 331d460d82fa..465144afade8 100644
@@ -634,6 +634,7 @@ static bool mptcp_established_options_add_addr(struct sock *sk, struct sk_buff *
 	if (drop_other_suboptions)
 		*size -= opt_size;
 	opts->addr_id = saddr.id;
+	opts->echo = echo;
 	if (port)
 		opts->port = ntohs(saddr.port);
 	if (saddr.family == AF_INET) {
@@ -659,7 +660,7 @@ static bool mptcp_established_options_add_addr(struct sock *sk, struct sk_buff *
 	}
 #endif
 	pr_debug("addr_id=%d, ahmac=%llu, echo=%d, port=%d",
-		 opts->addr_id, opts->ahmac, echo, opts->port);
+		 opts->addr_id, opts->ahmac, opts->echo, opts->port);
 
 	return true;
 }
Signature · 1 line
2.29.2
author
#3 lore raw

RFC 3/6 mptcp: add tracepoints for options operations

Add tracepoints in MPTCP for tracing the options writing and getting.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 include/trace/events/mptcp.h | 161 +++++++++++++++++++++++++++++++++++
 net/mptcp/options.c          |   8 ++
 2 files changed, 169 insertions(+)
include/trace/events/mptcp.h +161 -0
index b56ece509dc5..498b116056c1 100644
@@ -60,6 +60,167 @@ TRACE_EVENT(mptcp_recvmsg,
 		  __entry->data_ready, __entry->empty, __entry->copied)
 );
 
+TRACE_EVENT_CONDITION(mptcp_write_options,
+
+	TP_PROTO(struct mptcp_out_options *opts),
+
+	TP_ARGS(opts),
+
+	TP_CONDITION(opts->suboptions || opts->ext_copy.use_ack || opts->ext_copy.use_map),
+
+	TP_STRUCT__entry(
+		__array(char, str, 128)
+	),
+
+	TP_fast_assign(
+		memset(__entry->str, 0, 128);
+
+		if (OPTION_MPTCP_MPC_SYN & opts->suboptions)
+			sprintf(__entry->str, "mp_capable syn");
+		if (OPTION_MPTCP_MPC_SYNACK & opts->suboptions) {
+			sprintf(__entry->str,
+				"mp_capable synack sndr_key=%llu", opts->sndr_key);
+		}
+		if (OPTION_MPTCP_MPC_ACK & opts->suboptions) {
+			sprintf(__entry->str,
+				"mp_capable ack sndr_key=%llu rcvr_key=%llu data_len=%d",
+				opts->sndr_key, opts->rcvr_key, opts->ext_copy.data_len);
+		}
+		if ((OPTION_MPTCP_ADD_ADDR
+#if IS_ENABLED(CONFIG_MPTCP_IPV6)
+		     | OPTION_MPTCP_ADD_ADDR6
+#endif
+		    ) & opts->suboptions) {
+			sprintf(__entry->str, "add_addr addr_id=%d, ahmac=%llu, echo=%d, port=%d",
+				opts->addr_id, opts->ahmac, opts->echo, opts->port);
+		}
+		if (OPTION_MPTCP_RM_ADDR & opts->suboptions)
+			sprintf(__entry->str, "rm_addr rm_id=%d", opts->rm_id);
+		if (OPTION_MPTCP_PRIO & opts->suboptions)
+			sprintf(__entry->str, "mp_prio prio=%d", opts->backup);
+		if (OPTION_MPTCP_MPJ_SYN & opts->suboptions) {
+			sprintf(__entry->str,
+				"mp_join syn join_id=%u token=%u nonce=%u backup=%u",
+				opts->join_id, opts->token, opts->nonce, opts->backup);
+		}
+		if (OPTION_MPTCP_MPJ_SYNACK & opts->suboptions) {
+			sprintf(__entry->str,
+				"mp_join synack backup=%u join_id=%u thmac=%llu nonce=%u",
+				opts->backup, opts->join_id, opts->thmac, opts->nonce);
+		}
+		if (OPTION_MPTCP_MPJ_ACK & opts->suboptions)
+			sprintf(__entry->str, "mp_join ack");
+
+		if (opts->ext_copy.use_ack || opts->ext_copy.use_map) {
+			sprintf(__entry->str, "dss");
+
+			if (opts->ext_copy.use_map) {
+				sprintf(__entry->str + strlen(__entry->str),
+					" use_map dsn64=%d", opts->ext_copy.dsn64);
+			}
+			if (opts->ext_copy.data_fin)
+				sprintf(__entry->str + strlen(__entry->str), " data_fin");
+			if (opts->ext_copy.use_ack) {
+				sprintf(__entry->str + strlen(__entry->str),
+					" use_ack ack64=%d", opts->ext_copy.ack64);
+			}
+		}
+	),
+
+	TP_printk("%s", __entry->str)
+);
+
+TRACE_EVENT(mptcp_get_options,
+
+	TP_PROTO(struct mptcp_options_received *opts),
+
+	TP_ARGS(opts),
+
+	TP_STRUCT__entry(
+		__array(char, str, 128)
+	),
+
+	TP_fast_assign(
+		memset(__entry->str, 0, 128);
+
+		if (opts->mp_capable) {
+			sprintf(__entry->str, "MP_CAPABLE: ");
+
+			if (!opts->sndr_key && !opts->rcvr_key)
+				sprintf(__entry->str + strlen(__entry->str), "syn");
+			if (opts->sndr_key && !opts->rcvr_key) {
+				sprintf(__entry->str + strlen(__entry->str),
+					"synack sndr_key=%llu", opts->sndr_key);
+			}
+			if (opts->sndr_key && opts->rcvr_key) {
+				sprintf(__entry->str + strlen(__entry->str),
+					"ack sndr_key=%llu rcvr_key=%llu data_len=%d",
+					opts->sndr_key, opts->rcvr_key, opts->data_len);
+			}
+		}
+		if (opts->mp_join) {
+			u8 i, hmac = 0;
+
+			for (i = 0; i < MPTCPOPT_HMAC_LEN; i++) {
+				if (opts->hmac[i]) {
+					hmac = 1;
+					break;
+				}
+			}
+
+			sprintf(__entry->str, "MP_JOIN: ");
+
+			if (!opts->thmac && !hmac) {
+				sprintf(__entry->str + strlen(__entry->str),
+					"syn backup=%u join_id=%u token=%u nonce=%u",
+					opts->backup, opts->join_id, opts->token, opts->nonce);
+			}
+			if (opts->thmac && !hmac) {
+				sprintf(__entry->str + strlen(__entry->str),
+					"synack backup=%u join_id=%u thmac=%llu nonce=%u",
+					opts->backup, opts->join_id, opts->thmac, opts->nonce);
+			}
+			if (!opts->thmac && hmac)
+				sprintf(__entry->str + strlen(__entry->str), "ack");
+		}
+		if (opts->dss) {
+			sprintf(__entry->str, "DSS:");
+
+			if (opts->use_map) {
+				sprintf(__entry->str + strlen(__entry->str),
+					" dsn64=%d data_seq=%llu subflow_seq=%u data_len=%u",
+					opts->dsn64, opts->data_seq,
+					opts->subflow_seq, opts->data_len);
+			}
+			if (opts->data_fin)
+				sprintf(__entry->str + strlen(__entry->str), " data_fin");
+			if (opts->use_ack) {
+				sprintf(__entry->str + strlen(__entry->str),
+					" ack64=%d data_ack=%llu",
+					opts->ack64, opts->data_ack);
+			}
+		}
+		if (opts->add_addr) {
+			sprintf(__entry->str, "ADD_ADDR");
+
+			if (opts->family == MPTCP_ADDR_IPVERSION_6)
+				sprintf(__entry->str + strlen(__entry->str), "6");
+
+			sprintf(__entry->str + strlen(__entry->str),
+				": addr_id=%d ahmac=%llu echo=%d port=%d",
+				opts->addr_id, opts->ahmac, opts->echo, opts->port);
+		}
+		if (opts->rm_addr)
+			sprintf(__entry->str, "RM_ADDR: id=%d", opts->rm_id);
+		if (opts->mp_prio)
+			sprintf(__entry->str, "MP_PRIO: prio=%d", opts->backup);
+		if (opts->fastclose)
+			sprintf(__entry->str, "MP_FASTCLOSE: rcvr_key=%llu", opts->rcvr_key);
+	),
+
+	TP_printk("%s", __entry->str)
+);
+
 #endif /* _TRACE_MPTCP_H */
 
 /* This part must be outside protection */
net/mptcp/options.c +8 -0
index 465144afade8..57adebec2d42 100644
@@ -13,6 +13,8 @@
 #include "protocol.h"
 #include "mib.h"
 
+#include <trace/events/mptcp.h>
+
 static bool mptcp_cap_flag_sha256(u8 flags)
 {
 	return (flags & MPTCP_CAP_FLAG_MASK) == MPTCP_CAP_HMAC_SHA256;
@@ -323,6 +325,9 @@ void mptcp_get_options(const struct sk_buff *skb,
 	mp_opt->rm_addr = 0;
 	mp_opt->dss = 0;
 	mp_opt->mp_prio = 0;
+	mp_opt->sndr_key = 0;
+	mp_opt->rcvr_key = 0;
+	memset(mp_opt->hmac, 0, MPTCPOPT_HMAC_LEN);
 
 	length = (th->doff * 4) - sizeof(struct tcphdr);
 	ptr = (const unsigned char *)(th + 1);
@@ -349,6 +354,7 @@ void mptcp_get_options(const struct sk_buff *skb,
 			length -= opsize;
 		}
 	}
+	trace_mptcp_get_options(mp_opt);
 }
 
 bool mptcp_syn_options(struct sock *sk, const struct sk_buff *skb,
@@ -1114,6 +1120,8 @@ static void mptcp_set_rwin(const struct tcp_sock *tp)
 void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp,
 			 struct mptcp_out_options *opts)
 {
+	trace_mptcp_write_options(opts);
+
 	if ((OPTION_MPTCP_MPC_SYN | OPTION_MPTCP_MPC_SYNACK |
 	     OPTION_MPTCP_MPC_ACK) & opts->suboptions) {
 		u8 len;
Signature · 1 line
2.29.2
author
#4 lore raw

RFC 4/6 mptcp: add mptcpi_local_addr_* in mptcp_info

Add mptcpi_local_addr_used and mptcpi_local_addr_max in struct mptcp_info, and rename mptcpi_add_addr_signal to mptcpi_add_addr_signaled.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 include/uapi/linux/mptcp.h | 4 +++-
 net/mptcp/mptcp_diag.c     | 4 +++-
 net/mptcp/pm_netlink.c     | 3 ++-
 net/mptcp/protocol.h       | 1 +
 4 files changed, 9 insertions(+), 3 deletions(-)
include/uapi/linux/mptcp.h +3 -1
index 3674a451a18c..43b674458747 100644
@@ -92,11 +92,13 @@ enum {
 
 struct mptcp_info {
 	__u8	mptcpi_subflows;
-	__u8	mptcpi_add_addr_signal;
+	__u8	mptcpi_add_addr_signaled;
 	__u8	mptcpi_add_addr_accepted;
+	__u8	mptcpi_local_addr_used;
 	__u8	mptcpi_subflows_max;
 	__u8	mptcpi_add_addr_signal_max;
 	__u8	mptcpi_add_addr_accepted_max;
+	__u8	mptcpi_local_addr_max;
 	__u32	mptcpi_flags;
 	__u32	mptcpi_token;
 	__u64	mptcpi_write_seq;
net/mptcp/mptcp_diag.c +3 -1
index 00ed742f48a4..195113e51c31 100644
@@ -126,13 +126,15 @@ static void mptcp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,
 
 	slow = lock_sock_fast(sk);
 	info->mptcpi_subflows = READ_ONCE(msk->pm.subflows);
-	info->mptcpi_add_addr_signal = READ_ONCE(msk->pm.add_addr_signaled);
+	info->mptcpi_add_addr_signaled = READ_ONCE(msk->pm.add_addr_signaled);
 	info->mptcpi_add_addr_accepted = READ_ONCE(msk->pm.add_addr_accepted);
+	info->mptcpi_local_addr_used = READ_ONCE(msk->pm.local_addr_used);
 	info->mptcpi_subflows_max = mptcp_pm_get_subflows_max(msk);
 	val = mptcp_pm_get_add_addr_signal_max(msk);
 	info->mptcpi_add_addr_signal_max = val;
 	val = mptcp_pm_get_add_addr_accept_max(msk);
 	info->mptcpi_add_addr_accepted_max = val;
+	info->mptcpi_local_addr_max = mptcp_pm_get_local_addr_max(msk);
 	if (test_bit(MPTCP_FALLBACK_DONE, &msk->flags))
 		flags |= MPTCP_INFO_FLAG_FALLBACK;
 	if (READ_ONCE(msk->can_ack))
net/mptcp/pm_netlink.c +2 -1
index bb0d4456d855..b6ee53623005 100644
@@ -228,13 +228,14 @@ unsigned int mptcp_pm_get_subflows_max(struct mptcp_sock *msk)
 }
 EXPORT_SYMBOL_GPL(mptcp_pm_get_subflows_max);
 
-static unsigned int mptcp_pm_get_local_addr_max(struct mptcp_sock *msk)
+unsigned int mptcp_pm_get_local_addr_max(struct mptcp_sock *msk)
 {
 	struct pm_nl_pernet *pernet;
 
 	pernet = net_generic(sock_net((struct sock *)msk), pm_nl_pernet_id);
 	return READ_ONCE(pernet->local_addr_max);
 }
+EXPORT_SYMBOL_GPL(mptcp_pm_get_local_addr_max);
 
 static void check_work_pending(struct mptcp_sock *msk)
 {
net/mptcp/protocol.h +1 -0
index 98b0169ab531..cdd110de8fa5 100644
@@ -718,6 +718,7 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct sock_common *skc);
 unsigned int mptcp_pm_get_add_addr_signal_max(struct mptcp_sock *msk);
 unsigned int mptcp_pm_get_add_addr_accept_max(struct mptcp_sock *msk);
 unsigned int mptcp_pm_get_subflows_max(struct mptcp_sock *msk);
+unsigned int mptcp_pm_get_local_addr_max(struct mptcp_sock *msk);
 
 static inline struct mptcp_ext *mptcp_get_ext(struct sk_buff *skb)
 {
Signature · 1 line
2.29.2
author
#5 lore raw

RFC 5/6 mptcp: add tracepoints for PM operations

Add tracepoints in MPTCP for tracing the path management operations.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 include/trace/events/mptcp.h | 73 ++++++++++++++++++++++++++++++++++++
 net/mptcp/pm.c               |  3 ++
 net/mptcp/pm_netlink.c       |  3 ++
 3 files changed, 79 insertions(+)
include/trace/events/mptcp.h +73 -0
index 498b116056c1..2d607cecdfa8 100644
@@ -221,6 +221,79 @@ TRACE_EVENT(mptcp_get_options,
 	TP_printk("%s", __entry->str)
 );
 
+TRACE_EVENT(mptcp_pm_announce_addr,
+
+	TP_PROTO(struct mptcp_sock *msk, const struct mptcp_addr_info *addr),
+
+	TP_ARGS(msk, addr),
+
+	TP_STRUCT__entry(
+		__array(char, str, 100)
+	),
+
+	TP_fast_assign(
+		memset(__entry->str, 0, 100);
+
+		sprintf(__entry->str, "family=%u port=%u id=%u flags=%u",
+			addr->family, ntohs(addr->port), addr->id, addr->flags);
+		if (addr->family == AF_INET) {
+			sprintf(__entry->str + strlen(__entry->str),
+				" addr=%pI4", &addr->addr);
+		}
+#if IS_ENABLED(CONFIG_MPTCP_IPV6)
+		if (addr->family == AF_INET6) {
+			sprintf(__entry->str + strlen(__entry->str),
+				" addr6=%pI6", &addr->addr6);
+		}
+#endif
+	),
+
+	TP_printk("%s", __entry->str)
+);
+
+TRACE_EVENT(mptcp_pm_create_subflow_or_signal_addr,
+
+	TP_PROTO(struct mptcp_sock *msk),
+
+	TP_ARGS(msk),
+
+	TP_STRUCT__entry(
+		__field_struct(struct mptcp_info, info)
+	),
+
+	TP_fast_assign(
+		u32 flags = 0;
+
+		__entry->info.mptcpi_subflows = READ_ONCE(msk->pm.subflows);
+		__entry->info.mptcpi_add_addr_signaled = READ_ONCE(msk->pm.add_addr_signaled);
+		__entry->info.mptcpi_add_addr_accepted = READ_ONCE(msk->pm.add_addr_accepted);
+		__entry->info.mptcpi_local_addr_used = READ_ONCE(msk->pm.local_addr_used);
+		__entry->info.mptcpi_subflows_max = mptcp_pm_get_subflows_max(msk);
+		__entry->info.mptcpi_add_addr_signal_max = mptcp_pm_get_add_addr_signal_max(msk);
+		__entry->info.mptcpi_add_addr_accepted_max = mptcp_pm_get_add_addr_accept_max(msk);
+		__entry->info.mptcpi_local_addr_max = mptcp_pm_get_local_addr_max(msk);
+		if (test_bit(MPTCP_FALLBACK_DONE, &msk->flags))
+			flags |= MPTCP_INFO_FLAG_FALLBACK;
+		if (READ_ONCE(msk->can_ack))
+			flags |= MPTCP_INFO_FLAG_REMOTE_KEY_RECEIVED;
+		__entry->info.mptcpi_flags = flags;
+		__entry->info.mptcpi_token = READ_ONCE(msk->token);
+		__entry->info.mptcpi_write_seq = READ_ONCE(msk->write_seq);
+		__entry->info.mptcpi_snd_una = READ_ONCE(msk->snd_una);
+		__entry->info.mptcpi_rcv_nxt = READ_ONCE(msk->ack_seq);
+	),
+
+	TP_printk("local %d:%d signal %d:%d subflows %d:%d accept %d:%d",
+		  __entry->info.mptcpi_local_addr_used,
+		  __entry->info.mptcpi_local_addr_max,
+		  __entry->info.mptcpi_add_addr_signaled,
+		  __entry->info.mptcpi_add_addr_signal_max,
+		  __entry->info.mptcpi_subflows,
+		  __entry->info.mptcpi_subflows_max,
+		  __entry->info.mptcpi_add_addr_accepted,
+		  __entry->info.mptcpi_add_addr_accepted_max)
+);
+
 #endif /* _TRACE_MPTCP_H */
 
 /* This part must be outside protection */
net/mptcp/pm.c +3 -0
index 1a25003fd8e3..eef85c3a97d1 100644
@@ -10,6 +10,8 @@
 #include <net/mptcp.h>
 #include "protocol.h"
 
+#include <trace/events/mptcp.h>
+
 /* path manager command handlers */
 
 int mptcp_pm_announce_addr(struct mptcp_sock *msk,
@@ -18,6 +20,7 @@ int mptcp_pm_announce_addr(struct mptcp_sock *msk,
 {
 	u8 add_addr = READ_ONCE(msk->pm.addr_signal);
 
+	trace_mptcp_pm_announce_addr(msk, addr);
 	pr_debug("msk=%p, local_id=%d", msk, addr->id);
 
 	lockdep_assert_held(&msk->pm.lock);
net/mptcp/pm_netlink.c +3 -0
index b6ee53623005..af7ff6b83483 100644
@@ -17,6 +17,8 @@
 #include "protocol.h"
 #include "mib.h"
 
+#include <trace/events/mptcp.h>
+
 /* forward declaration */
 static struct genl_family mptcp_genl_family;
 
@@ -404,6 +406,7 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
 	local_addr_max = mptcp_pm_get_local_addr_max(msk);
 	subflows_max = mptcp_pm_get_subflows_max(msk);
 
+	trace_mptcp_pm_create_subflow_or_signal_addr(msk);
 	pr_debug("local %d:%d signal %d:%d subflows %d:%d\n",
 		 msk->pm.local_addr_used, local_addr_max,
 		 msk->pm.add_addr_signaled, add_addr_signal_max,
Signature · 1 line
2.29.2
author
#6 lore raw

RFC 6/6 mptcp: add tracepoints for subflow operations

Add tracepoints in MPTCP for tracing the subflow operations.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 include/trace/events/mptcp.h | 108 +++++++++++++++++++++++++++++++++++
 net/mptcp/subflow.c          |   6 ++
 2 files changed, 114 insertions(+)
include/trace/events/mptcp.h +108 -0
index 2d607cecdfa8..bdcf46e4e28e 100644
@@ -294,6 +294,114 @@ TRACE_EVENT(mptcp_pm_create_subflow_or_signal_addr,
 		  __entry->info.mptcpi_add_addr_accepted_max)
 );
 
+/*
+ * mptcp event with arguments subflow_req
+ *
+ * Note: this class requires a valid subflow_req pointer.
+ */
+DECLARE_EVENT_CLASS(mptcp_event_subflow_req,
+
+	TP_PROTO(struct mptcp_subflow_request_sock *subflow_req),
+
+	TP_ARGS(subflow_req),
+
+	TP_STRUCT__entry(
+		__array(char, str, 128)
+	),
+
+	TP_fast_assign(
+		memset(__entry->str, 0, 128);
+
+		if (subflow_req->mp_capable)
+			sprintf(__entry->str, "subflow_req mp_capable");
+
+		if (subflow_req->mp_join)
+			sprintf(__entry->str, "subflow_req mp_join, token=%u remote_nonce=%u",
+				subflow_req->token, subflow_req->remote_nonce);
+	),
+
+	TP_printk("%s", __entry->str)
+);
+
+DEFINE_EVENT(mptcp_event_subflow_req, subflow_init_req,
+
+	TP_PROTO(struct mptcp_subflow_request_sock *subflow_req),
+
+	TP_ARGS(subflow_req)
+);
+
+DEFINE_EVENT(mptcp_event_subflow_req, subflow_syn_recv_sock,
+
+	TP_PROTO(struct mptcp_subflow_request_sock *subflow_req),
+
+	TP_ARGS(subflow_req)
+);
+
+/*
+ * mptcp event with arguments subflow
+ *
+ * Note: this class requires a valid subflow pointer.
+ */
+DECLARE_EVENT_CLASS(mptcp_event_subflow,
+
+	TP_PROTO(struct mptcp_subflow_context *subflow),
+
+	TP_ARGS(subflow),
+
+	TP_STRUCT__entry(
+		__array(char, str, 128)
+	),
+
+	TP_fast_assign(
+		memset(__entry->str, 0, 128);
+
+		if (subflow->mp_capable)
+			sprintf(__entry->str, "remote_key=%llu", subflow->remote_key);
+
+		if (subflow->mp_join) {
+			sprintf(__entry->str, "thmac=%llu, remote_nonce=%u",
+				subflow->thmac, subflow->remote_nonce);
+		}
+	),
+
+	TP_printk("%s", __entry->str)
+);
+
+DEFINE_EVENT(mptcp_event_subflow, subflow_finish_connect,
+
+	TP_PROTO(struct mptcp_subflow_context *subflow),
+
+	TP_ARGS(subflow)
+);
+
+TRACE_EVENT(get_mapping_status,
+
+	TP_PROTO(struct mptcp_ext *mpext),
+
+	TP_ARGS(mpext),
+
+	TP_STRUCT__entry(
+		__field(__u64, data_seq)
+		__field(__u32, subflow_seq)
+		__field(__u16, data_len)
+		__field(__u8, dsn64)
+		__field(__u8, data_fin)
+	),
+
+	TP_fast_assign(
+		__entry->data_seq = mpext->data_seq;
+		__entry->subflow_seq = mpext->subflow_seq;
+		__entry->data_len = mpext->data_len;
+		__entry->dsn64 = mpext->dsn64;
+		__entry->data_fin = mpext->data_fin;
+	),
+
+	TP_printk("data_seq=%llu subflow_seq=%u data_len=%u dsn64=%d data_fin=%d",
+		  __entry->data_seq, __entry->subflow_seq,
+		  __entry->data_len, __entry->dsn64,
+		  __entry->data_fin)
+);
+
 #endif /* _TRACE_MPTCP_H */
 
 /* This part must be outside protection */
net/mptcp/subflow.c +6 -0
index 280da418d60b..668a1b1bf049 100644
@@ -27,6 +27,8 @@
 
 static void mptcp_subflow_ops_undo_override(struct sock *ssk);
 
+#include <trace/events/mptcp.h>
+
 static void SUBFLOW_REQ_INC_STATS(struct request_sock *req,
 				  enum linux_mptcp_mib_field field)
 {
@@ -223,6 +225,7 @@ static int subflow_init_req(struct request_sock *req,
 		pr_debug("token=%u, remote_nonce=%u msk=%p", subflow_req->token,
 			 subflow_req->remote_nonce, subflow_req->msk);
 	}
+	trace_subflow_init_req(subflow_req);
 
 	return 0;
 }
@@ -439,6 +442,7 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb)
 fallback:
 		mptcp_rcv_space_init(mptcp_sk(parent), sk);
 	}
+	trace_subflow_finish_connect(subflow);
 	return;
 
 do_reset:
@@ -610,6 +614,7 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,
 	if (fallback)
 		goto create_child;
 
+	trace_subflow_syn_recv_sock(subflow_req);
 	/* if the sk is MP_CAPABLE, we try to fetch the client key */
 	if (subflow_req->mp_capable) {
 		if (TCP_SKB_CB(skb)->seq != subflow_req->ssn_offset + 1) {
@@ -836,6 +841,7 @@ static enum mapping_status get_mapping_status(struct sock *ssk,
 		goto validate_seq;
 	}
 
+	trace_get_mapping_status(mpext);
 	pr_debug("seq=%llu is64=%d ssn=%u data_len=%u data_fin=%d",
 		 mpext->data_seq, mpext->dsn64, mpext->subflow_seq,
 		 mpext->data_len, mpext->data_fin);
Signature · 1 line
2.29.2
#7 lore raw

[MPTCP] Re: [MPTCP][RFC mptcp-next 4/6] mptcp: add mptcpi_local_addr_* in mptcp_info

In reply to Geliang Tang
Quoted 4 lines · Geliang Tang

Add mptcpi_local_addr_used and mptcpi_local_addr_max in struct mptcp_info, and rename mptcpi_add_addr_signal to mptcpi_add_addr_signaled.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>

This patch could possibly live by its own merit, independently from the tracepoint patches.

Quoted 16 lines
---
 include/uapi/linux/mptcp.h | 4 +++-
 net/mptcp/mptcp_diag.c     | 4 +++-
 net/mptcp/pm_netlink.c     | 3 ++-
 net/mptcp/protocol.h       | 1 +
 4 files changed, 9 insertions(+), 3 deletions(-)
include/uapi/linux/mptcp.h +0 -1
index 3674a451a18c..43b674458747 100644
@@ -92,11 +92,13 @@ enum {
 
 struct mptcp_info {
 	__u8	mptcpi_subflows;
-	__u8	mptcpi_add_addr_signal;

include/uapi/linux/mptcp.h enum { · line 104

Quoted 10 lines
include/uapi/linux/mptcp.h +3 -0
+	__u8	mptcpi_add_addr_signaled;
 	__u8	mptcpi_add_addr_accepted;
+	__u8	mptcpi_local_addr_used;
 	__u8	mptcpi_subflows_max;
 	__u8	mptcpi_add_addr_signal_max;
 	__u8	mptcpi_add_addr_accepted_max;
+	__u8	mptcpi_local_addr_max;
 	__u32	mptcpi_flags;
 	__u32	mptcpi_token;
 	__u64	mptcpi_write_seq;

Beware: new fields of uapi exposed struct must be appended, or user space tools (e.g. iproute) reading the struct will mis-interpret the fields when running on top of kernels with/without this patch.

/P

#8 lore raw

[MPTCP] Re: [MPTCP][RFC mptcp-next 2/6] mptcp: add echo field in mptcp_out_options

In reply to Geliang Tang
Quoted 14 lines · Geliang Tang

This patch added a new field echo in mptcp_out_options, it will be used when using the trace event to dump the mptcp_out_options info.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 include/net/mptcp.h | 1 +
 net/mptcp/options.c | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
include/net/mptcp.h +0 -0
index 5694370be3d4..85b39d901150 100644

include/net/mptcp.h struct mptcp_out_options { · line 52

Quoted 7 lines
include/net/mptcp.h +1 -0
@@ -46,6 +46,7 @@ struct mptcp_out_options {
 #endif
 	};
 	u8 addr_id;
+	u8 echo;
 	u16 port;
 	u64 ahmac;
 	u8 rm_id;

This data structure is quite critical for performances, we should avoid adding more fields there (note: there is a pending ticket to shrink it using union).

I suggest avoiding touching this at all for tracepoint's sake

Quoted 21 lines
net/mptcp/options.c +2 -1
index 331d460d82fa..465144afade8 100644
@@ -634,6 +634,7 @@ static bool mptcp_established_options_add_addr(struct sock *sk, struct sk_buff *
 	if (drop_other_suboptions)
 		*size -= opt_size;
 	opts->addr_id = saddr.id;
+	opts->echo = echo;
 	if (port)
 		opts->port = ntohs(saddr.port);
 	if (saddr.family == AF_INET) {
@@ -659,7 +660,7 @@ static bool mptcp_established_options_add_addr(struct sock *sk, struct sk_buff *
 	}
 #endif
 	pr_debug("addr_id=%d, ahmac=%llu, echo=%d, port=%d",
-		 opts->addr_id, opts->ahmac, echo, opts->port);
+		 opts->addr_id, opts->ahmac, opts->echo, opts->port);
 
 	return true;
 }
#9 lore raw
In reply to Geliang Tang

Hello,

Quoted 5 lines · Geliang Tang

This patchset addressed issues 131, replace some/most pr_debug with trace events.

Quoted 7 lines

Geliang Tang (6):
mptcp: add tracepoints for data operations
mptcp: add echo field in mptcp_out_options
mptcp: add tracepoints for options operations
mptcp: add mptcpi_local_addr_* in mptcp_info
mptcp: add tracepoints for PM operations
mptcp: add tracepoints for subflow operations

I'm sorry for the late feedback.

I think we should first agree on which functions we want to instrument/where we want to add the tracepoint.

I suggest avoiding functions invoked not frequently (pr_debug would probably suffice there) and avoiding exposing data accessible elsewhere e.g. packet capture.

I think it would be nice to instrument the packet scheduler and the mapping status. I would not add much more tracepoints than that.

Additionally, I suggest dropping the pr_debug() from places where tracepoints are added.

I'd love to ear others opinions, too!

Cheers,

Paolo

#10 lore raw
Quoted 21 lines · Paolo Abeni

Hello,

Quoted 5 lines · Geliang Tang

This patchset addressed issues 131, replace some/most pr_debug with trace events.

Quoted 7 lines

Geliang Tang (6):
mptcp: add tracepoints for data operations
mptcp: add echo field in mptcp_out_options
mptcp: add tracepoints for options operations
mptcp: add mptcpi_local_addr_* in mptcp_info
mptcp: add tracepoints for PM operations
mptcp: add tracepoints for subflow operations

I'm sorry for the late feedback.

I think we should first agree on which functions we want to instrument/where we want to add the tracepoint.

Quoted 7 lines

I suggest avoiding functions invoked not frequently (pr_debug would probably suffice there) and avoiding exposing data accessible elsewhere e.g. packet capture.

I think it would be nice to instrument the packet scheduler and the mapping status. I would not add much more tracepoints than that.

Yes, these seem like good places to focus first as the main high-frequency tracepoints that will be helpful.

Quoted 5 lines

Additionally, I suggest dropping the pr_debug() from places where tracepoints are added.

I'd love to ear others opinions, too!

Agree with Paolo on all the above!

Thanks for the patches Geliang, and thanks for the review Paolo.

--
Mat Martineau
Intel