Netdev List
 help / color / mirror / Atom feed
From: Adrian Moreno <amorenoz@redhat.com>
To: netdev@vger.kernel.org, dev@openvswitch.org
Cc: Adrian Moreno <amorenoz@redhat.com>,
	cmi@nvidia.com, yotam.gi@gmail.com, i.maximets@ovn.org,
	aconole@redhat.com, echaudro@redhat.com, horms@kernel.org
Subject: [RFC PATCH 2/4] openvswitch:trace: Add ovs_dp_monitor tracepoint.
Date: Thu,  7 Mar 2024 16:18:46 +0100	[thread overview]
Message-ID: <20240307151849.394962-3-amorenoz@redhat.com> (raw)
In-Reply-To: <20240307151849.394962-1-amorenoz@redhat.com>

The existing dp_upcall tracepoint was intented to provide visibility on
flow-misses (what we typically refer as upcalls). It's used to measure
things like upcall latency.

However, if a monitoring userspace action (such as IPFIX) is
multicasted, using the same tracepoint will only add confusion as
ovs-vswithcd will not receive this upcall.

In order to make things clearer, create a new tracepoint called
"ovs_dp_monitor" and use it instead of the existing one for multicasted
packets.

Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
---
 net/openvswitch/datapath.c          |  6 ++-
 net/openvswitch/openvswitch_trace.h | 71 +++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+), 1 deletion(-)

diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 15bad6f4b645..5a2c0b3b4112 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -316,12 +316,16 @@ int ovs_dp_upcall(struct datapath *dp, struct sk_buff *skb,
 		  const struct dp_upcall_info *upcall_info,
 		  uint32_t cutlen)
 {
+	const bool mcast = upcall_info->portid == MCAST_PID;
 	struct dp_stats_percpu *stats;
 	int err;
 
-	if (trace_ovs_dp_upcall_enabled())
+	if (!mcast && trace_ovs_dp_upcall_enabled())
 		trace_ovs_dp_upcall(dp, skb, key, upcall_info);
 
+	if (mcast && trace_ovs_dp_monitor_enabled())
+		trace_ovs_dp_monitor(dp, skb, key, upcall_info);
+
 	if (upcall_info->portid == 0) {
 		err = -ENOTCONN;
 		goto err;
diff --git a/net/openvswitch/openvswitch_trace.h b/net/openvswitch/openvswitch_trace.h
index 3eb35d9eb700..76e9612e3555 100644
--- a/net/openvswitch/openvswitch_trace.h
+++ b/net/openvswitch/openvswitch_trace.h
@@ -148,6 +148,77 @@ TRACE_EVENT(ovs_dp_upcall,
 		  __entry->upcall_mru)
 );
 
+TRACE_EVENT(ovs_dp_monitor,
+
+	TP_PROTO(struct datapath *dp, struct sk_buff *skb,
+		 const struct sw_flow_key *key,
+		 const struct dp_upcall_info *upcall_info),
+
+	TP_ARGS(dp, skb, key, upcall_info),
+
+	TP_STRUCT__entry(
+		__field(	void *,		dpaddr			)
+		__string(	dp_name,	ovs_dp_name(dp)		)
+		__string(	dev_name,	skb->dev->name		)
+		__field(	void *,		skbaddr			)
+		__field(	unsigned int,	len			)
+		__field(	unsigned int,	data_len		)
+		__field(	unsigned int,	truesize		)
+		__field(	u8,		nr_frags		)
+		__field(	u16,		gso_size		)
+		__field(	u16,		gso_type		)
+		__field(	u32,		ovs_flow_hash		)
+		__field(	u32,		recirc_id		)
+		__field(	const void *,	keyaddr			)
+		__field(	u16,		key_eth_type		)
+		__field(	u8,		key_ct_state		)
+		__field(	u8,		key_ct_orig_proto	)
+		__field(	u16,		key_ct_zone		)
+		__field(	unsigned int,	flow_key_valid		)
+		__field(	u32,		upcall_port		)
+		__field(	void *,		upcall_udata		)
+		__field(	u16,		upcall_ulen		)
+	),
+
+	TP_fast_assign(
+		__entry->dpaddr = dp;
+		__assign_str(dp_name, ovs_dp_name(dp));
+		__assign_str(dev_name, skb->dev->name);
+		__entry->skbaddr = skb;
+		__entry->len = skb->len;
+		__entry->data_len = skb->data_len;
+		__entry->truesize = skb->truesize;
+		__entry->nr_frags = skb_shinfo(skb)->nr_frags;
+		__entry->gso_size = skb_shinfo(skb)->gso_size;
+		__entry->gso_type = skb_shinfo(skb)->gso_type;
+		__entry->ovs_flow_hash = key->ovs_flow_hash;
+		__entry->recirc_id = key->recirc_id;
+		__entry->keyaddr = key;
+		__entry->key_eth_type = key->eth.type;
+		__entry->key_ct_state = key->ct_state;
+		__entry->key_ct_orig_proto = key->ct_orig_proto;
+		__entry->key_ct_zone = key->ct_zone;
+		__entry->flow_key_valid =  !(key->mac_proto & SW_FLOW_KEY_INVALID);
+		__entry->upcall_port = upcall_info->portid;
+		__entry->upcall_udata = upcall_info->userdata ?
+			nla_data(upcall_info->userdata): NULL;
+		__entry->upcall_ulen = upcall_info->userdata ?
+			nla_len(upcall_info->userdata): 0;
+	),
+
+	TP_printk("dpaddr=%p dp_name=%s dev=%s skbaddr=%p len=%u data_len=%u truesize=%u nr_frags=%d gso_size=%d gso_type=%#x ovs_flow_hash=0x%08x recirc_id=0x%08x keyaddr=%p eth_type=0x%04x ct_state=%02x ct_orig_proto=%02x ct_zone=%04x flow_key_valid=%d upcall_port=%u upcall_udata=%p upcall_ulen=%d",
+		  __entry->dpaddr, __get_str(dp_name), __get_str(dev_name),
+		  __entry->skbaddr, __entry->len, __entry->data_len,
+		  __entry->truesize, __entry->nr_frags, __entry->gso_size,
+		  __entry->gso_type, __entry->ovs_flow_hash,
+		  __entry->recirc_id, __entry->keyaddr, __entry->key_eth_type,
+		  __entry->key_ct_state, __entry->key_ct_orig_proto,
+		  __entry->key_ct_zone,
+		  __entry->flow_key_valid,
+		  __entry->upcall_port,
+		  __entry->upcall_udata, __entry->upcall_ulen)
+);
+
 #endif /* _TRACE_OPENVSWITCH_H */
 
 /* This part must be outside protection */
-- 
2.44.0


  parent reply	other threads:[~2024-03-07 15:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-07 15:18 [RFC PATCH 0/4] net: openvswitch: Add sample multicasting Adrian Moreno
2024-03-07 15:18 ` [RFC PATCH 1/4] net:openvswitch: Support multicasting userspace Adrian Moreno
2024-03-07 15:18 ` Adrian Moreno [this message]
2024-03-07 15:18 ` [RFC PATCH 3/4] net:openvswitch: Avoid extra copy if no listeners Adrian Moreno
2024-03-07 15:18 ` [RFC PATCH 4/4] net:openvswitch: Add multicasted packets to stats Adrian Moreno
2024-03-07 16:54 ` [RFC PATCH 0/4] net: openvswitch: Add sample multicasting Ilya Maximets
2024-03-07 20:59   ` Adrian Moreno
2024-03-07 21:29     ` Ilya Maximets
2024-03-08 14:24       ` Ilya Maximets
2024-03-13  8:28         ` Adrian Moreno

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240307151849.394962-3-amorenoz@redhat.com \
    --to=amorenoz@redhat.com \
    --cc=aconole@redhat.com \
    --cc=cmi@nvidia.com \
    --cc=dev@openvswitch.org \
    --cc=echaudro@redhat.com \
    --cc=horms@kernel.org \
    --cc=i.maximets@ovn.org \
    --cc=netdev@vger.kernel.org \
    --cc=yotam.gi@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox