lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 04 Oct 2018 09:30:41 +0100
From:   David Howells <dhowells@...hat.com>
To:     netdev@...r.kernel.org
Cc:     dhowells@...hat.com, linux-afs@...ts.infradead.org,
        linux-kernel@...r.kernel.org
Subject: [PATCH net-next] udp: Add tracepoints to monitor skbs going in and
 out of a UDP socket

Add three tracepoints to the UDP/UDP6 code to trace three aspects of
sk_buff handling:

 (1) UDP packets that are about to be handed off to the IP layer to be
     transmitted.

 (2) UDP packets that have just arrived at the socket.

 (3) UDP packets that are about to be queued on the UDP socket's receive
     queue, and displaying the sk_rmem_alloc counter.

Signed-off-by: David Howells <dhowells@...hat.com>
---

 include/trace/events/udp.h |   53 ++++++++++++++++++++++++++++++++++++++++++++
 net/ipv4/udp.c             |    3 ++
 net/ipv6/udp.c             |    3 ++
 3 files changed, 59 insertions(+)

diff --git a/include/trace/events/udp.h b/include/trace/events/udp.h
index 336fe272889f..ff6b3ab5a65e 100644
--- a/include/trace/events/udp.h
+++ b/include/trace/events/udp.h
@@ -27,6 +27,59 @@ TRACE_EVENT(udp_fail_queue_rcv_skb,
 	TP_printk("rc=%d port=%hu", __entry->rc, __entry->lport)
 );
 
+TRACE_EVENT(udp_tx,
+
+	TP_PROTO(struct sk_buff *skb),
+
+	TP_ARGS(skb),
+
+	TP_STRUCT__entry(
+		__field(struct sk_buff *, skb)
+	),
+
+	TP_fast_assign(
+		__entry->skb = skb;
+	),
+
+	TP_printk("skb=%p", __entry->skb)
+);
+
+TRACE_EVENT(udp_rcv,
+
+	TP_PROTO(struct sk_buff *skb),
+
+	TP_ARGS(skb),
+
+	TP_STRUCT__entry(
+		__field(struct sk_buff *, skb)
+	),
+
+	TP_fast_assign(
+		__entry->skb = skb;
+	),
+
+	TP_printk("skb=%p", __entry->skb)
+);
+
+TRACE_EVENT(udp_enqueue,
+
+	    TP_PROTO(struct sk_buff *skb, int rmem),
+
+	    TP_ARGS(skb, rmem),
+
+	    TP_STRUCT__entry(
+		    __field(struct sk_buff *, skb)
+		    __field(int, rmem)
+			     ),
+
+	    TP_fast_assign(
+		    __entry->skb = skb;
+		    __entry->rmem = rmem;
+			   ),
+
+	    TP_printk("skb=%p rm=%d", __entry->skb, __entry->rmem)
+	    );
+
 #endif /* _TRACE_UDP_H */
 
 /* This part must be outside protection */
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index f93bc444f631..67afbd0ac0a7 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -826,6 +826,7 @@ static int udp_send_skb(struct sk_buff *skb, struct flowi4 *fl4,
 		uh->check = CSUM_MANGLED_0;
 
 send:
+	trace_udp_tx(skb);
 	err = ip_send_skb(sock_net(sk), skb);
 	if (err) {
 		if (err == -ENOBUFS && !inet->recverr) {
@@ -1363,6 +1364,7 @@ static int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)
 	rmem = atomic_read(&sk->sk_rmem_alloc);
 	if (rmem > sk->sk_rcvbuf)
 		goto drop;
+	trace_udp_enqueue(skb, rmem);
 
 	/* Under mem pressure, it might be helpful to help udp_recvmsg()
 	 * having linear skbs :
@@ -2395,6 +2397,7 @@ int udp_v4_early_demux(struct sk_buff *skb)
 
 int udp_rcv(struct sk_buff *skb)
 {
+	trace_udp_rcv(skb);
 	return __udp4_lib_rcv(skb, &udp_table, IPPROTO_UDP);
 }
 
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 4421fbf0a7a4..baec8abc1409 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -54,6 +54,7 @@
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <trace/events/skb.h>
+#include <trace/events/udp.h>
 #include "udp_impl.h"
 
 static bool udp6_lib_exact_dif_match(struct net *net, struct sk_buff *skb)
@@ -950,6 +951,7 @@ static void udp_v6_early_demux(struct sk_buff *skb)
 
 static __inline__ int udpv6_rcv(struct sk_buff *skb)
 {
+	trace_udp_rcv(skb);
 	return __udp6_lib_rcv(skb, &udp_table, IPPROTO_UDP);
 }
 
@@ -1093,6 +1095,7 @@ static int udp_v6_send_skb(struct sk_buff *skb, struct flowi6 *fl6,
 		uh->check = CSUM_MANGLED_0;
 
 send:
+	trace_udp_tx(skb);
 	err = ip6_send_skb(skb);
 	if (err) {
 		if (err == -ENOBUFS && !inet6_sk(sk)->recverr) {

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ