Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit acfbf3ca authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'tcp-sctp-dccp-Replace-jprobe-usage-with-trace-events'

Masami Hiramatsu says:

====================
net: tcp: sctp: dccp: Replace jprobe usage with trace events

This series is v7 of the replacement of jprobe usage with trace
events. This version fixes net/dccp/trace.h to avoid sparse
warning. Since the TP_STORE_ADDR_PORTS macro can be shared
with trace/events/tcp.h, it also introduce a new common header
file and move the definition of that macro.

Previous version is here;
 https://lkml.org/lkml/2017/12/28/7



Changes from v6:
  [5/6]: Avoid preprocessor directives in tracepoint macro args
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 4e3b95f1 a56c1470
Loading
Loading
Loading
Loading
+44 −0
Original line number Original line Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */

#if !defined(_TRACE_NET_PROBE_COMMON_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_NET_PROBE_COMMON_H

#define TP_STORE_ADDR_PORTS_V4(__entry, inet, sk)			\
	do {								\
		struct sockaddr_in *v4 = (void *)__entry->saddr;	\
									\
		v4->sin_family = AF_INET;				\
		v4->sin_port = inet->inet_sport;			\
		v4->sin_addr.s_addr = inet->inet_saddr;			\
		v4 = (void *)__entry->daddr;				\
		v4->sin_family = AF_INET;				\
		v4->sin_port = inet->inet_dport;			\
		v4->sin_addr.s_addr = inet->inet_daddr;			\
	} while (0)

#if IS_ENABLED(CONFIG_IPV6)

#define TP_STORE_ADDR_PORTS(__entry, inet, sk)				\
	do {								\
		if (sk->sk_family == AF_INET6) {			\
			struct sockaddr_in6 *v6 = (void *)__entry->saddr; \
									\
			v6->sin6_family = AF_INET6;			\
			v6->sin6_port = inet->inet_sport;		\
			v6->sin6_addr = inet6_sk(sk)->saddr;		\
			v6 = (void *)__entry->daddr;			\
			v6->sin6_family = AF_INET6;			\
			v6->sin6_port = inet->inet_dport;		\
			v6->sin6_addr = sk->sk_v6_daddr;		\
		} else							\
			TP_STORE_ADDR_PORTS_V4(__entry, inet, sk);	\
	} while (0)

#else

#define TP_STORE_ADDR_PORTS(__entry, inet, sk)		\
	TP_STORE_ADDR_PORTS_V4(__entry, inet, sk);

#endif

#endif
+99 −0
Original line number Original line Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM sctp

#if !defined(_TRACE_SCTP_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_SCTP_H

#include <net/sctp/structs.h>
#include <linux/tracepoint.h>

TRACE_EVENT(sctp_probe_path,

	TP_PROTO(struct sctp_transport *sp,
		 const struct sctp_association *asoc),

	TP_ARGS(sp, asoc),

	TP_STRUCT__entry(
		__field(__u64, asoc)
		__field(__u32, primary)
		__array(__u8, ipaddr, sizeof(union sctp_addr))
		__field(__u32, state)
		__field(__u32, cwnd)
		__field(__u32, ssthresh)
		__field(__u32, flight_size)
		__field(__u32, partial_bytes_acked)
		__field(__u32, pathmtu)
	),

	TP_fast_assign(
		__entry->asoc = (unsigned long)asoc;
		__entry->primary = (sp == asoc->peer.primary_path);
		memcpy(__entry->ipaddr, &sp->ipaddr, sizeof(union sctp_addr));
		__entry->state = sp->state;
		__entry->cwnd = sp->cwnd;
		__entry->ssthresh = sp->ssthresh;
		__entry->flight_size = sp->flight_size;
		__entry->partial_bytes_acked = sp->partial_bytes_acked;
		__entry->pathmtu = sp->pathmtu;
	),

	TP_printk("asoc=%#llx%s ipaddr=%pISpc state=%u cwnd=%u ssthresh=%u "
		  "flight_size=%u partial_bytes_acked=%u pathmtu=%u",
		  __entry->asoc, __entry->primary ? "(*)" : "",
		  __entry->ipaddr, __entry->state, __entry->cwnd,
		  __entry->ssthresh, __entry->flight_size,
		  __entry->partial_bytes_acked, __entry->pathmtu)
);

TRACE_EVENT(sctp_probe,

	TP_PROTO(const struct sctp_endpoint *ep,
		 const struct sctp_association *asoc,
		 struct sctp_chunk *chunk),

	TP_ARGS(ep, asoc, chunk),

	TP_STRUCT__entry(
		__field(__u64, asoc)
		__field(__u32, mark)
		__field(__u16, bind_port)
		__field(__u16, peer_port)
		__field(__u32, pathmtu)
		__field(__u32, rwnd)
		__field(__u16, unack_data)
	),

	TP_fast_assign(
		struct sk_buff *skb = chunk->skb;

		__entry->asoc = (unsigned long)asoc;
		__entry->mark = skb->mark;
		__entry->bind_port = ep->base.bind_addr.port;
		__entry->peer_port = asoc->peer.port;
		__entry->pathmtu = asoc->pathmtu;
		__entry->rwnd = asoc->peer.rwnd;
		__entry->unack_data = asoc->unack_data;

		if (trace_sctp_probe_path_enabled()) {
			struct sctp_transport *sp;

			list_for_each_entry(sp, &asoc->peer.transport_addr_list,
					    transports) {
				trace_sctp_probe_path(sp, asoc);
			}
		}
	),

	TP_printk("asoc=%#llx mark=%#x bind_port=%d peer_port=%d pathmtu=%d "
		  "rwnd=%u unack_data=%d",
		  __entry->asoc, __entry->mark, __entry->bind_port,
		  __entry->peer_port, __entry->pathmtu, __entry->rwnd,
		  __entry->unack_data)
);

#endif /* _TRACE_SCTP_H */

/* This part must be outside protection */
#include <trace/define_trace.h>
+60 −0
Original line number Original line Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
#undef TRACE_SYSTEM
#undef TRACE_SYSTEM
#define TRACE_SYSTEM tcp
#define TRACE_SYSTEM tcp


@@ -8,6 +9,7 @@
#include <linux/tcp.h>
#include <linux/tcp.h>
#include <linux/tracepoint.h>
#include <linux/tracepoint.h>
#include <net/ipv6.h>
#include <net/ipv6.h>
#include <net/tcp.h>


#define TP_STORE_V4MAPPED(__entry, saddr, daddr)		\
#define TP_STORE_V4MAPPED(__entry, saddr, daddr)		\
	do {							\
	do {							\
@@ -254,6 +256,64 @@ TRACE_EVENT(tcp_retransmit_synack,
		  __entry->saddr_v6, __entry->daddr_v6)
		  __entry->saddr_v6, __entry->daddr_v6)
);
);


#include <trace/events/net_probe_common.h>

TRACE_EVENT(tcp_probe,

	TP_PROTO(struct sock *sk, struct sk_buff *skb),

	TP_ARGS(sk, skb),

	TP_STRUCT__entry(
		/* sockaddr_in6 is always bigger than sockaddr_in */
		__array(__u8, saddr, sizeof(struct sockaddr_in6))
		__array(__u8, daddr, sizeof(struct sockaddr_in6))
		__field(__u16, sport)
		__field(__u16, dport)
		__field(__u32, mark)
		__field(__u16, length)
		__field(__u32, snd_nxt)
		__field(__u32, snd_una)
		__field(__u32, snd_cwnd)
		__field(__u32, ssthresh)
		__field(__u32, snd_wnd)
		__field(__u32, srtt)
		__field(__u32, rcv_wnd)
	),

	TP_fast_assign(
		const struct tcp_sock *tp = tcp_sk(sk);
		const struct inet_sock *inet = inet_sk(sk);

		memset(__entry->saddr, 0, sizeof(struct sockaddr_in6));
		memset(__entry->daddr, 0, sizeof(struct sockaddr_in6));

		TP_STORE_ADDR_PORTS(__entry, inet, sk);

		/* For filtering use */
		__entry->sport = ntohs(inet->inet_sport);
		__entry->dport = ntohs(inet->inet_dport);
		__entry->mark = skb->mark;

		__entry->length = skb->len;
		__entry->snd_nxt = tp->snd_nxt;
		__entry->snd_una = tp->snd_una;
		__entry->snd_cwnd = tp->snd_cwnd;
		__entry->snd_wnd = tp->snd_wnd;
		__entry->rcv_wnd = tp->rcv_wnd;
		__entry->ssthresh = tcp_current_ssthresh(sk);
		__entry->srtt = tp->srtt_us >> 3;
	),

	TP_printk("src=%pISpc dest=%pISpc mark=%#x length=%d snd_nxt=%#x "
		  "snd_una=%#x snd_cwnd=%u ssthresh=%u snd_wnd=%u srtt=%u "
		  "rcv_wnd=%u",
		  __entry->saddr, __entry->daddr, __entry->mark,
		  __entry->length, __entry->snd_nxt, __entry->snd_una,
		  __entry->snd_cwnd, __entry->ssthresh, __entry->snd_wnd,
		  __entry->srtt, __entry->rcv_wnd)
);

#endif /* _TRACE_TCP_H */
#endif /* _TRACE_TCP_H */


/* This part must be outside protection */
/* This part must be outside protection */
+0 −17
Original line number Original line Diff line number Diff line
@@ -336,23 +336,6 @@ config NET_PKTGEN
	  To compile this code as a module, choose M here: the
	  To compile this code as a module, choose M here: the
	  module will be called pktgen.
	  module will be called pktgen.


config NET_TCPPROBE
	tristate "TCP connection probing"
	depends on INET && PROC_FS && KPROBES
	---help---
	This module allows for capturing the changes to TCP connection
	state in response to incoming packets. It is used for debugging
	TCP congestion avoidance modules. If you don't understand
	what was just said, you don't need it: say N.

	Documentation on how to use TCP connection probing can be found
	at:
	
	  http://www.linuxfoundation.org/collaborate/workgroups/networking/tcpprobe

	To compile this code as a module, choose M here: the
	module will be called tcp_probe.

config NET_DROP_MONITOR
config NET_DROP_MONITOR
	tristate "Network packet drop alerting service"
	tristate "Network packet drop alerting service"
	depends on INET && TRACEPOINTS
	depends on INET && TRACEPOINTS
+0 −17
Original line number Original line Diff line number Diff line
@@ -39,23 +39,6 @@ config IP_DCCP_DEBUG


	  Just say N.
	  Just say N.


config NET_DCCPPROBE
	tristate "DCCP connection probing"
	depends on PROC_FS && KPROBES
	---help---
	This module allows for capturing the changes to DCCP connection
	state in response to incoming packets. It is used for debugging
	DCCP congestion avoidance modules. If you don't understand
	what was just said, you don't need it: say N.

	Documentation on how to use DCCP connection probing can be found
	at:
	
	  http://www.linuxfoundation.org/collaborate/workgroups/networking/dccpprobe

	To compile this code as a module, choose M here: the
	module will be called dccp_probe.



endmenu
endmenu


Loading