Thread (6 messages) flat view 6 messages, 3 authors, 2021-02-03

Re: [PATCH RESEND net-next] netlink: add tracepoint at NL_SET_ERR_MSG

From: Jakub Kicinski <kuba@kernel.org>
Date: 2021-02-03 22:32:02

On Mon,  1 Feb 2021 15:12:19 -0300 Marcelo Ricardo Leitner wrote:
Often userspace won't request the extack information, or they don't log it
because of log level or so, and even when they do, sometimes it's not
enough to know exactly what caused the error.

Netlink extack is the standard way of reporting erros with descriptive
error messages. With a trace point on it, we then can know exactly where
the error happened, regardless of userspace app. Also, we can even see if
the err msg was overwritten.

The wrapper do_trace_netlink_extack() is because trace points shouldn't be
called from .h files, as trace points are not that small, and the function
call to do_trace_netlink_extack() on the macros is not protected by
tracepoint_enabled() because the macros are called from modules, and this
would require exporting some trace structs. As this is error path, it's
better to export just the wrapper instead.

Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
quoted hunk ↗ jump to hunk
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -6,11 +6,15 @@
 #include <linux/capability.h>
 #include <linux/skbuff.h>
 #include <linux/export.h>
+#include <linux/tracepoint.h>
Do we need the include...
 #include <net/scm.h>
 #include <uapi/linux/netlink.h>
 
 struct net;
 
+DECLARE_TRACEPOINT(netlink_extack);
... and the declaration? Seems to be a leftover.
quoted hunk ↗ jump to hunk
+void do_trace_netlink_extack(const char *msg);
+
 static inline struct nlmsghdr *nlmsg_hdr(const struct sk_buff *skb)
 {
 	return (struct nlmsghdr *)skb->data;
@@ -90,6 +94,8 @@ struct netlink_ext_ack {
 	static const char __msg[] = msg;		\
 	struct netlink_ext_ack *__extack = (extack);	\
 							\
+	do_trace_netlink_extack(__msg);			\
+							\
 	if (__extack)					\
 		__extack->_msg = __msg;			\
 } while (0)
@@ -110,6 +116,8 @@ struct netlink_ext_ack {
 	static const char __msg[] = msg;			\
 	struct netlink_ext_ack *__extack = (extack);		\
 								\
+	do_trace_netlink_extack(__msg);				\
+								\
 	if (__extack) {						\
 		__extack->_msg = __msg;				\
 		__extack->bad_attr = (attr);			\
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help