diff mbox series

[net-next,v3,2/2] net: udp: add IP/port data to the tracepoint udp/udp_fail_queue_rcv_skb

Message ID 34a9c221a6d644f18c826a1beddba58af6b7a64c.1711361723.git.balazs.scheidler@axoflow.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v3,1/2] net: port TP_STORE_ADDR_PORTS_SKB macro to be tcp/udp independent | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 952 this patch: 952
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 11 of 11 maintainers
netdev/build_clang success Errors and warnings before: 956 this patch: 956
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 963 this patch: 963
netdev/checkpatch fail ERROR: code indent should use tabs where possible ERROR: trailing whitespace WARNING: From:/Signed-off-by: email address mismatch: 'From: Balazs Scheidler <bazsi77@gmail.com>' != 'Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>' WARNING: please, no spaces at the start of a line
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Balazs Scheidler March 25, 2024, 10:29 a.m. UTC
The udp_fail_queue_rcv_skb() tracepoint lacks any details on the source
and destination IP/port whereas this information can be critical in case
of UDP/syslog.

Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
---
 include/trace/events/udp.h | 29 ++++++++++++++++++++++++-----
 net/ipv4/udp.c             |  2 +-
 net/ipv6/udp.c             |  3 ++-
 3 files changed, 27 insertions(+), 7 deletions(-)

Comments

Jakub Kicinski March 26, 2024, 2:28 a.m. UTC | #1
On Mon, 25 Mar 2024 11:29:18 +0100 Balazs Scheidler wrote:
> +                memset(__entry->saddr, 0, sizeof(struct sockaddr_in6));
> +                memset(__entry->daddr, 0, sizeof(struct sockaddr_in6));

Indent with tabs please, checkpatch says:

ERROR: code indent should use tabs where possible
#59: FILE: include/trace/events/udp.h:38:
+                memset(__entry->saddr, 0, sizeof(struct sockaddr_in6));$

WARNING: please, no spaces at the start of a line
#59: FILE: include/trace/events/udp.h:38:
+                memset(__entry->saddr, 0, sizeof(struct sockaddr_in6));$

ERROR: code indent should use tabs where possible
#60: FILE: include/trace/events/udp.h:39:
+                memset(__entry->daddr, 0, sizeof(struct sockaddr_in6));$

WARNING: please, no spaces at the start of a line
#60: FILE: include/trace/events/udp.h:39:
+                memset(__entry->daddr, 0, sizeof(struct sockaddr_in6));$
Jason Xing March 26, 2024, 7:25 a.m. UTC | #2
On Tue, Mar 26, 2024 at 10:28 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Mon, 25 Mar 2024 11:29:18 +0100 Balazs Scheidler wrote:
> > +                memset(__entry->saddr, 0, sizeof(struct sockaddr_in6));
> > +                memset(__entry->daddr, 0, sizeof(struct sockaddr_in6));
>
> Indent with tabs please, checkpatch says:
>
> ERROR: code indent should use tabs where possible
> #59: FILE: include/trace/events/udp.h:38:
> +                memset(__entry->saddr, 0, sizeof(struct sockaddr_in6));$
>
> WARNING: please, no spaces at the start of a line
> #59: FILE: include/trace/events/udp.h:38:
> +                memset(__entry->saddr, 0, sizeof(struct sockaddr_in6));$
>
> ERROR: code indent should use tabs where possible
> #60: FILE: include/trace/events/udp.h:39:
> +                memset(__entry->daddr, 0, sizeof(struct sockaddr_in6));$
>
> WARNING: please, no spaces at the start of a line
> #60: FILE: include/trace/events/udp.h:39:
> +                memset(__entry->daddr, 0, sizeof(struct sockaddr_in6));$

More than this, it would be better to put "From Balazs Scheidler
<balazs.scheidler@axoflow.com>" in the first line of each patch to
eliminate the mismatched email address warning.

Link (Jakub referred to):
https://patchwork.kernel.org/project/netdevbpf/patch/34a9c221a6d644f18c826a1beddba58af6b7a64c.1711361723.git.balazs.scheidler@axoflow.com/
Detailed info: https://netdev.bots.linux.dev/static/nipa/837832/13601927/checkpatch/stdout

> --
> pw-bot: cr
diff mbox series

Patch

diff --git a/include/trace/events/udp.h b/include/trace/events/udp.h
index 336fe272889f..9c5abe23d0f5 100644
--- a/include/trace/events/udp.h
+++ b/include/trace/events/udp.h
@@ -7,24 +7,43 @@ 
 
 #include <linux/udp.h>
 #include <linux/tracepoint.h>
+#include <trace/events/net_probe_common.h>
 
 TRACE_EVENT(udp_fail_queue_rcv_skb,
 
-	TP_PROTO(int rc, struct sock *sk),
+	TP_PROTO(int rc, struct sock *sk, struct sk_buff *skb),
 
-	TP_ARGS(rc, sk),
+	TP_ARGS(rc, sk, skb),
 
 	TP_STRUCT__entry(
 		__field(int, rc)
-		__field(__u16, lport)
+
+		__field(__u16, sport)
+		__field(__u16, dport)
+		__field(__u16, family)
+		__array(__u8, saddr, sizeof(struct sockaddr_in6))
+		__array(__u8, daddr, sizeof(struct sockaddr_in6))
 	),
 
 	TP_fast_assign(
+		const struct udphdr *uh = (const struct udphdr *)udp_hdr(skb);
+
 		__entry->rc = rc;
-		__entry->lport = inet_sk(sk)->inet_num;
+		
+		/* for filtering use */
+		__entry->sport = ntohs(uh->source);
+		__entry->dport = ntohs(uh->dest);
+		__entry->family = sk->sk_family;
+
+                memset(__entry->saddr, 0, sizeof(struct sockaddr_in6));
+                memset(__entry->daddr, 0, sizeof(struct sockaddr_in6));
+
+		TP_STORE_ADDR_PORTS_SKB(__entry, skb, uh);
 	),
 
-	TP_printk("rc=%d port=%hu", __entry->rc, __entry->lport)
+	TP_printk("rc=%d family=%s src=%pISpc dest=%pISpc", __entry->rc,
+		  show_family_name(__entry->family),
+		  __entry->saddr, __entry->daddr)
 );
 
 #endif /* _TRACE_UDP_H */
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 661d0e0d273f..531882f321f2 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -2049,8 +2049,8 @@  static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
 			drop_reason = SKB_DROP_REASON_PROTO_MEM;
 		}
 		UDP_INC_STATS(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
+		trace_udp_fail_queue_rcv_skb(rc, sk, skb);
 		kfree_skb_reason(skb, drop_reason);
-		trace_udp_fail_queue_rcv_skb(rc, sk);
 		return -1;
 	}
 
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 7c1e6469d091..2e4dc5e6137b 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -34,6 +34,7 @@ 
 #include <linux/slab.h>
 #include <linux/uaccess.h>
 #include <linux/indirect_call_wrapper.h>
+#include <trace/events/udp.h>
 
 #include <net/addrconf.h>
 #include <net/ndisc.h>
@@ -658,8 +659,8 @@  static int __udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
 			drop_reason = SKB_DROP_REASON_PROTO_MEM;
 		}
 		UDP6_INC_STATS(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
+		trace_udp_fail_queue_rcv_skb(rc, sk, skb);
 		kfree_skb_reason(skb, drop_reason);
-		trace_udp_fail_queue_rcv_skb(rc, sk);
 		return -1;
 	}