netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thiago Rafael Becker <trbecker@gmail.com>
To: netdev@vger.kernel.org
Cc: Jakub Kicinski <kuba@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Ingo Molnar <mingo@redhat.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	dhowells@redhat.com, Thiago Rafael Becker <trbecker@gmail.com>
Subject: [PATCH] dns_resolver: Add dns_query tracing
Date: Mon, 14 Feb 2022 15:53:04 -0300	[thread overview]
Message-ID: <20220214185304.3146173-1-trbecker@gmail.com> (raw)

Signed-off-by: Thiago Rafael Becker <trbecker@gmail.com>
---
 include/trace/events/dns_resolver.h | 39 +++++++++++++++++++++++++++++
 net/dns_resolver/dns_query.c        |  5 ++++
 2 files changed, 44 insertions(+)
 create mode 100644 include/trace/events/dns_resolver.h

diff --git a/include/trace/events/dns_resolver.h b/include/trace/events/dns_resolver.h
new file mode 100644
index 000000000000..c733e61ccd1e
--- /dev/null
+++ b/include/trace/events/dns_resolver.h
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM dns_resolver
+
+#if !defined(_TRACE_DNS_RESOLVER_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_DNS_RESOLVER_H
+
+#include <linux/tracepoint.h>
+
+TRACE_EVENT(dns_query,
+	TP_PROTO(
+		const char *type,
+		const char *name,
+		size_t namelen,
+		const char *options
+	),
+
+	TP_ARGS(type, name, namelen, options),
+
+	TP_STRUCT__entry(
+		__string(type, type)
+		__string_len(name, name, namelen)
+		__string(options, options)
+	),
+
+	TP_fast_assign(
+		__assign_str(type, type);
+		__assign_str_len(name, name, namelen);
+		__assign_str(options, options);
+	),
+
+	TP_printk("t=%s n=%s o=%s",
+		__get_str(type), __get_str(name), __get_str(options))
+);
+
+#endif /* _TRACE_DNS_RESOLVER_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/net/dns_resolver/dns_query.c b/net/dns_resolver/dns_query.c
index 82b084cc1cc6..610938dfbf6b 100644
--- a/net/dns_resolver/dns_query.c
+++ b/net/dns_resolver/dns_query.c
@@ -47,6 +47,9 @@
 
 #include "internal.h"
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/dns_resolver.h>
+
 /**
  * dns_query - Query the DNS
  * @net: The network namespace to operate in.
@@ -86,6 +89,8 @@ int dns_query(struct net *net,
 	kenter("%s,%*.*s,%zu,%s",
 	       type, (int)namelen, (int)namelen, name, namelen, options);
 
+	trace_dns_query(type, name, namelen, options);
+
 	if (!name || namelen == 0)
 		return -EINVAL;
 
-- 
2.31.1


                 reply	other threads:[~2022-02-14 20:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220214185304.3146173-1-trbecker@gmail.com \
    --to=trbecker@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=kuba@kernel.org \
    --cc=mingo@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /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;
as well as URLs for NNTP newsgroup(s).