xref: /linux/include/trace/events/skb.h (revision 06b9cce42634a50f2840777a66553b02320db5ef)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM skb
4 
5 #if !defined(_TRACE_SKB_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_SKB_H
7 
8 #include <linux/skbuff.h>
9 #include <linux/netdevice.h>
10 #include <linux/tracepoint.h>
11 
12 #define TRACE_SKB_DROP_REASON					\
13 	EM(SKB_DROP_REASON_NOT_SPECIFIED, NOT_SPECIFIED)	\
14 	EM(SKB_DROP_REASON_NO_SOCKET, NO_SOCKET)		\
15 	EM(SKB_DROP_REASON_PKT_TOO_SMALL, PKT_TOO_SMALL)	\
16 	EM(SKB_DROP_REASON_TCP_CSUM, TCP_CSUM)			\
17 	EM(SKB_DROP_REASON_SOCKET_FILTER, SOCKET_FILTER)	\
18 	EM(SKB_DROP_REASON_UDP_CSUM, UDP_CSUM)			\
19 	EM(SKB_DROP_REASON_NETFILTER_DROP, NETFILTER_DROP)	\
20 	EM(SKB_DROP_REASON_OTHERHOST, OTHERHOST)		\
21 	EM(SKB_DROP_REASON_IP_CSUM, IP_CSUM)			\
22 	EM(SKB_DROP_REASON_IP_INHDR, IP_INHDR)			\
23 	EM(SKB_DROP_REASON_IP_RPFILTER, IP_RPFILTER)		\
24 	EM(SKB_DROP_REASON_UNICAST_IN_L2_MULTICAST,		\
25 	   UNICAST_IN_L2_MULTICAST)				\
26 	EM(SKB_DROP_REASON_XFRM_POLICY, XFRM_POLICY)		\
27 	EM(SKB_DROP_REASON_IP_NOPROTO, IP_NOPROTO)		\
28 	EM(SKB_DROP_REASON_SOCKET_RCVBUFF, SOCKET_RCVBUFF)	\
29 	EM(SKB_DROP_REASON_PROTO_MEM, PROTO_MEM)		\
30 	EM(SKB_DROP_REASON_TCP_MD5NOTFOUND, TCP_MD5NOTFOUND)	\
31 	EM(SKB_DROP_REASON_TCP_MD5UNEXPECTED,			\
32 	   TCP_MD5UNEXPECTED)					\
33 	EM(SKB_DROP_REASON_TCP_MD5FAILURE, TCP_MD5FAILURE)	\
34 	EM(SKB_DROP_REASON_SOCKET_BACKLOG, SOCKET_BACKLOG)	\
35 	EM(SKB_DROP_REASON_TCP_FLAGS, TCP_FLAGS)		\
36 	EM(SKB_DROP_REASON_TCP_ZEROWINDOW, TCP_ZEROWINDOW)	\
37 	EM(SKB_DROP_REASON_TCP_OLD_DATA, TCP_OLD_DATA)		\
38 	EM(SKB_DROP_REASON_TCP_OVERWINDOW, TCP_OVERWINDOW)	\
39 	EM(SKB_DROP_REASON_TCP_OFOMERGE, TCP_OFOMERGE)		\
40 	EM(SKB_DROP_REASON_IP_OUTNOROUTES, IP_OUTNOROUTES)	\
41 	EM(SKB_DROP_REASON_BPF_CGROUP_EGRESS,			\
42 	   BPF_CGROUP_EGRESS)					\
43 	EM(SKB_DROP_REASON_IPV6DISABLED, IPV6DISABLED)		\
44 	EM(SKB_DROP_REASON_NEIGH_CREATEFAIL, NEIGH_CREATEFAIL)	\
45 	EM(SKB_DROP_REASON_NEIGH_FAILED, NEIGH_FAILED)		\
46 	EM(SKB_DROP_REASON_NEIGH_QUEUEFULL, NEIGH_QUEUEFULL)	\
47 	EM(SKB_DROP_REASON_NEIGH_DEAD, NEIGH_DEAD)		\
48 	EMe(SKB_DROP_REASON_MAX, MAX)
49 
50 #undef EM
51 #undef EMe
52 
53 #define EM(a, b)	TRACE_DEFINE_ENUM(a);
54 #define EMe(a, b)	TRACE_DEFINE_ENUM(a);
55 
56 TRACE_SKB_DROP_REASON
57 
58 #undef EM
59 #undef EMe
60 #define EM(a, b)	{ a, #b },
61 #define EMe(a, b)	{ a, #b }
62 
63 /*
64  * Tracepoint for free an sk_buff:
65  */
66 TRACE_EVENT(kfree_skb,
67 
68 	TP_PROTO(struct sk_buff *skb, void *location,
69 		 enum skb_drop_reason reason),
70 
71 	TP_ARGS(skb, location, reason),
72 
73 	TP_STRUCT__entry(
74 		__field(void *,		skbaddr)
75 		__field(void *,		location)
76 		__field(unsigned short,	protocol)
77 		__field(enum skb_drop_reason,	reason)
78 	),
79 
80 	TP_fast_assign(
81 		__entry->skbaddr = skb;
82 		__entry->location = location;
83 		__entry->protocol = ntohs(skb->protocol);
84 		__entry->reason = reason;
85 	),
86 
87 	TP_printk("skbaddr=%p protocol=%u location=%p reason: %s",
88 		  __entry->skbaddr, __entry->protocol, __entry->location,
89 		  __print_symbolic(__entry->reason,
90 				   TRACE_SKB_DROP_REASON))
91 );
92 
93 TRACE_EVENT(consume_skb,
94 
95 	TP_PROTO(struct sk_buff *skb),
96 
97 	TP_ARGS(skb),
98 
99 	TP_STRUCT__entry(
100 		__field(	void *,	skbaddr	)
101 	),
102 
103 	TP_fast_assign(
104 		__entry->skbaddr = skb;
105 	),
106 
107 	TP_printk("skbaddr=%p", __entry->skbaddr)
108 );
109 
110 TRACE_EVENT(skb_copy_datagram_iovec,
111 
112 	TP_PROTO(const struct sk_buff *skb, int len),
113 
114 	TP_ARGS(skb, len),
115 
116 	TP_STRUCT__entry(
117 		__field(	const void *,		skbaddr		)
118 		__field(	int,			len		)
119 	),
120 
121 	TP_fast_assign(
122 		__entry->skbaddr = skb;
123 		__entry->len = len;
124 	),
125 
126 	TP_printk("skbaddr=%p len=%d", __entry->skbaddr, __entry->len)
127 );
128 
129 #endif /* _TRACE_SKB_H */
130 
131 /* This part must be outside protection */
132 #include <trace/define_trace.h>
133