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_TCP_OFO_DROP, TCP_OFO_DROP)		\
41 	EM(SKB_DROP_REASON_TCP_RFC7323_PAWS, TCP_RFC7323_PAWS)	\
42 	EM(SKB_DROP_REASON_TCP_INVALID_SEQUENCE,		\
43 	   TCP_INVALID_SEQUENCE)				\
44 	EM(SKB_DROP_REASON_TCP_RESET, TCP_RESET)		\
45 	EM(SKB_DROP_REASON_TCP_INVALID_SYN, TCP_INVALID_SYN)	\
46 	EM(SKB_DROP_REASON_TCP_CLOSE, TCP_CLOSE)		\
47 	EM(SKB_DROP_REASON_TCP_FASTOPEN, TCP_FASTOPEN)		\
48 	EM(SKB_DROP_REASON_TCP_OLD_ACK, TCP_OLD_ACK)		\
49 	EM(SKB_DROP_REASON_TCP_TOO_OLD_ACK, TCP_TOO_OLD_ACK)	\
50 	EM(SKB_DROP_REASON_TCP_ACK_UNSENT_DATA,			\
51 	   TCP_ACK_UNSENT_DATA)					\
52 	EM(SKB_DROP_REASON_TCP_OFO_QUEUE_PRUNE,			\
53 	  TCP_OFO_QUEUE_PRUNE)					\
54 	EM(SKB_DROP_REASON_IP_OUTNOROUTES, IP_OUTNOROUTES)	\
55 	EM(SKB_DROP_REASON_BPF_CGROUP_EGRESS,			\
56 	   BPF_CGROUP_EGRESS)					\
57 	EM(SKB_DROP_REASON_IPV6DISABLED, IPV6DISABLED)		\
58 	EM(SKB_DROP_REASON_NEIGH_CREATEFAIL, NEIGH_CREATEFAIL)	\
59 	EM(SKB_DROP_REASON_NEIGH_FAILED, NEIGH_FAILED)		\
60 	EM(SKB_DROP_REASON_NEIGH_QUEUEFULL, NEIGH_QUEUEFULL)	\
61 	EM(SKB_DROP_REASON_NEIGH_DEAD, NEIGH_DEAD)		\
62 	EM(SKB_DROP_REASON_TC_EGRESS, TC_EGRESS)		\
63 	EM(SKB_DROP_REASON_QDISC_DROP, QDISC_DROP)		\
64 	EM(SKB_DROP_REASON_CPU_BACKLOG, CPU_BACKLOG)		\
65 	EM(SKB_DROP_REASON_XDP, XDP)				\
66 	EM(SKB_DROP_REASON_TC_INGRESS, TC_INGRESS)		\
67 	EM(SKB_DROP_REASON_UNHANDLED_PROTO, UNHANDLED_PROTO)	\
68 	EM(SKB_DROP_REASON_SKB_CSUM, SKB_CSUM)			\
69 	EM(SKB_DROP_REASON_SKB_GSO_SEG, SKB_GSO_SEG)		\
70 	EM(SKB_DROP_REASON_SKB_UCOPY_FAULT, SKB_UCOPY_FAULT)	\
71 	EM(SKB_DROP_REASON_DEV_HDR, DEV_HDR)			\
72 	EM(SKB_DROP_REASON_DEV_READY, DEV_READY)		\
73 	EM(SKB_DROP_REASON_FULL_RING, FULL_RING)		\
74 	EM(SKB_DROP_REASON_NOMEM, NOMEM)			\
75 	EM(SKB_DROP_REASON_HDR_TRUNC, HDR_TRUNC)		\
76 	EM(SKB_DROP_REASON_TAP_FILTER, TAP_FILTER)		\
77 	EM(SKB_DROP_REASON_TAP_TXFILTER, TAP_TXFILTER)		\
78 	EM(SKB_DROP_REASON_ICMP_CSUM, ICMP_CSUM)		\
79 	EM(SKB_DROP_REASON_INVALID_PROTO, INVALID_PROTO)	\
80 	EM(SKB_DROP_REASON_IP_INADDRERRORS, IP_INADDRERRORS)	\
81 	EM(SKB_DROP_REASON_IP_INNOROUTES, IP_INNOROUTES)	\
82 	EM(SKB_DROP_REASON_PKT_TOO_BIG, PKT_TOO_BIG)		\
83 	EMe(SKB_DROP_REASON_MAX, MAX)
84 
85 #undef EM
86 #undef EMe
87 
88 #define EM(a, b)	TRACE_DEFINE_ENUM(a);
89 #define EMe(a, b)	TRACE_DEFINE_ENUM(a);
90 
91 TRACE_SKB_DROP_REASON
92 
93 #undef EM
94 #undef EMe
95 #define EM(a, b)	{ a, #b },
96 #define EMe(a, b)	{ a, #b }
97 
98 /*
99  * Tracepoint for free an sk_buff:
100  */
101 TRACE_EVENT(kfree_skb,
102 
103 	TP_PROTO(struct sk_buff *skb, void *location,
104 		 enum skb_drop_reason reason),
105 
106 	TP_ARGS(skb, location, reason),
107 
108 	TP_STRUCT__entry(
109 		__field(void *,		skbaddr)
110 		__field(void *,		location)
111 		__field(unsigned short,	protocol)
112 		__field(enum skb_drop_reason,	reason)
113 	),
114 
115 	TP_fast_assign(
116 		__entry->skbaddr = skb;
117 		__entry->location = location;
118 		__entry->protocol = ntohs(skb->protocol);
119 		__entry->reason = reason;
120 	),
121 
122 	TP_printk("skbaddr=%p protocol=%u location=%p reason: %s",
123 		  __entry->skbaddr, __entry->protocol, __entry->location,
124 		  __print_symbolic(__entry->reason,
125 				   TRACE_SKB_DROP_REASON))
126 );
127 
128 TRACE_EVENT(consume_skb,
129 
130 	TP_PROTO(struct sk_buff *skb),
131 
132 	TP_ARGS(skb),
133 
134 	TP_STRUCT__entry(
135 		__field(	void *,	skbaddr	)
136 	),
137 
138 	TP_fast_assign(
139 		__entry->skbaddr = skb;
140 	),
141 
142 	TP_printk("skbaddr=%p", __entry->skbaddr)
143 );
144 
145 TRACE_EVENT(skb_copy_datagram_iovec,
146 
147 	TP_PROTO(const struct sk_buff *skb, int len),
148 
149 	TP_ARGS(skb, len),
150 
151 	TP_STRUCT__entry(
152 		__field(	const void *,		skbaddr		)
153 		__field(	int,			len		)
154 	),
155 
156 	TP_fast_assign(
157 		__entry->skbaddr = skb;
158 		__entry->len = len;
159 	),
160 
161 	TP_printk("skbaddr=%p len=%d", __entry->skbaddr, __entry->len)
162 );
163 
164 #endif /* _TRACE_SKB_H */
165 
166 /* This part must be outside protection */
167 #include <trace/define_trace.h>
168