xref: /openbmc/linux/include/net/dropreason.h (revision 0df499ea)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #ifndef _LINUX_DROPREASON_H
4 #define _LINUX_DROPREASON_H
5 
6 /**
7  * enum skb_drop_reason - the reasons of skb drops
8  *
9  * The reason of skb drop, which is used in kfree_skb_reason().
10  */
11 enum skb_drop_reason {
12 	/**
13 	 * @SKB_NOT_DROPPED_YET: skb is not dropped yet (used for no-drop case)
14 	 */
15 	SKB_NOT_DROPPED_YET = 0,
16 	/** @SKB_DROP_REASON_NOT_SPECIFIED: drop reason is not specified */
17 	SKB_DROP_REASON_NOT_SPECIFIED,
18 	/** @SKB_DROP_REASON_NO_SOCKET: socket not found */
19 	SKB_DROP_REASON_NO_SOCKET,
20 	/** @SKB_DROP_REASON_PKT_TOO_SMALL: packet size is too small */
21 	SKB_DROP_REASON_PKT_TOO_SMALL,
22 	/** @SKB_DROP_REASON_TCP_CSUM: TCP checksum error */
23 	SKB_DROP_REASON_TCP_CSUM,
24 	/** @SKB_DROP_REASON_SOCKET_FILTER: dropped by socket filter */
25 	SKB_DROP_REASON_SOCKET_FILTER,
26 	/** @SKB_DROP_REASON_UDP_CSUM: UDP checksum error */
27 	SKB_DROP_REASON_UDP_CSUM,
28 	/** @SKB_DROP_REASON_NETFILTER_DROP: dropped by netfilter */
29 	SKB_DROP_REASON_NETFILTER_DROP,
30 	/**
31 	 * @SKB_DROP_REASON_OTHERHOST: packet don't belong to current host
32 	 * (interface is in promisc mode)
33 	 */
34 	SKB_DROP_REASON_OTHERHOST,
35 	/** @SKB_DROP_REASON_IP_CSUM: IP checksum error */
36 	SKB_DROP_REASON_IP_CSUM,
37 	/**
38 	 * @SKB_DROP_REASON_IP_INHDR: there is something wrong with IP header (see
39 	 * IPSTATS_MIB_INHDRERRORS)
40 	 */
41 	SKB_DROP_REASON_IP_INHDR,
42 	/**
43 	 * @SKB_DROP_REASON_IP_RPFILTER: IP rpfilter validate failed. see the
44 	 * document for rp_filter in ip-sysctl.rst for more information
45 	 */
46 	SKB_DROP_REASON_IP_RPFILTER,
47 	/**
48 	 * @SKB_DROP_REASON_UNICAST_IN_L2_MULTICAST: destination address of L2 is
49 	 * multicast, but L3 is unicast.
50 	 */
51 	SKB_DROP_REASON_UNICAST_IN_L2_MULTICAST,
52 	/** @SKB_DROP_REASON_XFRM_POLICY: xfrm policy check failed */
53 	SKB_DROP_REASON_XFRM_POLICY,
54 	/** @SKB_DROP_REASON_IP_NOPROTO: no support for IP protocol */
55 	SKB_DROP_REASON_IP_NOPROTO,
56 	/** @SKB_DROP_REASON_SOCKET_RCVBUFF: socket receive buff is full */
57 	SKB_DROP_REASON_SOCKET_RCVBUFF,
58 	/**
59 	 * @SKB_DROP_REASON_PROTO_MEM: proto memory limition, such as udp packet
60 	 * drop out of udp_memory_allocated.
61 	 */
62 	SKB_DROP_REASON_PROTO_MEM,
63 	/**
64 	 * @SKB_DROP_REASON_TCP_MD5NOTFOUND: no MD5 hash and one expected,
65 	 * corresponding to LINUX_MIB_TCPMD5NOTFOUND
66 	 */
67 	SKB_DROP_REASON_TCP_MD5NOTFOUND,
68 	/**
69 	 * @SKB_DROP_REASON_TCP_MD5UNEXPECTED: MD5 hash and we're not expecting
70 	 * one, corresponding to LINUX_MIB_TCPMD5UNEXPECTED
71 	 */
72 	SKB_DROP_REASON_TCP_MD5UNEXPECTED,
73 	/**
74 	 * @SKB_DROP_REASON_TCP_MD5FAILURE: MD5 hash and its wrong, corresponding
75 	 * to LINUX_MIB_TCPMD5FAILURE
76 	 */
77 	SKB_DROP_REASON_TCP_MD5FAILURE,
78 	/**
79 	 * @SKB_DROP_REASON_SOCKET_BACKLOG: failed to add skb to socket backlog (
80 	 * see LINUX_MIB_TCPBACKLOGDROP)
81 	 */
82 	SKB_DROP_REASON_SOCKET_BACKLOG,
83 	/** @SKB_DROP_REASON_TCP_FLAGS: TCP flags invalid */
84 	SKB_DROP_REASON_TCP_FLAGS,
85 	/**
86 	 * @SKB_DROP_REASON_TCP_ZEROWINDOW: TCP receive window size is zero,
87 	 * see LINUX_MIB_TCPZEROWINDOWDROP
88 	 */
89 	SKB_DROP_REASON_TCP_ZEROWINDOW,
90 	/**
91 	 * @SKB_DROP_REASON_TCP_OLD_DATA: the TCP data reveived is already
92 	 * received before (spurious retrans may happened), see
93 	 * LINUX_MIB_DELAYEDACKLOST
94 	 */
95 	SKB_DROP_REASON_TCP_OLD_DATA,
96 	/**
97 	 * @SKB_DROP_REASON_TCP_OVERWINDOW: the TCP data is out of window,
98 	 * the seq of the first byte exceed the right edges of receive
99 	 * window
100 	 */
101 	SKB_DROP_REASON_TCP_OVERWINDOW,
102 	/**
103 	 * @SKB_DROP_REASON_TCP_OFOMERGE: the data of skb is already in the ofo
104 	 * queue, corresponding to LINUX_MIB_TCPOFOMERGE
105 	 */
106 	SKB_DROP_REASON_TCP_OFOMERGE,
107 	/**
108 	 * @SKB_DROP_REASON_TCP_RFC7323_PAWS: PAWS check, corresponding to
109 	 * LINUX_MIB_PAWSESTABREJECTED
110 	 */
111 	SKB_DROP_REASON_TCP_RFC7323_PAWS,
112 	/** @SKB_DROP_REASON_TCP_INVALID_SEQUENCE: Not acceptable SEQ field */
113 	SKB_DROP_REASON_TCP_INVALID_SEQUENCE,
114 	/** @SKB_DROP_REASON_TCP_RESET: Invalid RST packet */
115 	SKB_DROP_REASON_TCP_RESET,
116 	/**
117 	 * @SKB_DROP_REASON_TCP_INVALID_SYN: Incoming packet has unexpected
118 	 * SYN flag
119 	 */
120 	SKB_DROP_REASON_TCP_INVALID_SYN,
121 	/** @SKB_DROP_REASON_TCP_CLOSE: TCP socket in CLOSE state */
122 	SKB_DROP_REASON_TCP_CLOSE,
123 	/** @SKB_DROP_REASON_TCP_FASTOPEN: dropped by FASTOPEN request socket */
124 	SKB_DROP_REASON_TCP_FASTOPEN,
125 	/** @SKB_DROP_REASON_TCP_OLD_ACK: TCP ACK is old, but in window */
126 	SKB_DROP_REASON_TCP_OLD_ACK,
127 	/** @SKB_DROP_REASON_TCP_TOO_OLD_ACK: TCP ACK is too old */
128 	SKB_DROP_REASON_TCP_TOO_OLD_ACK,
129 	/**
130 	 * @SKB_DROP_REASON_TCP_ACK_UNSENT_DATA: TCP ACK for data we haven't
131 	 * sent yet
132 	 */
133 	SKB_DROP_REASON_TCP_ACK_UNSENT_DATA,
134 	/** @SKB_DROP_REASON_TCP_OFO_QUEUE_PRUNE: pruned from TCP OFO queue */
135 	SKB_DROP_REASON_TCP_OFO_QUEUE_PRUNE,
136 	/** @SKB_DROP_REASON_TCP_OFO_DROP: data already in receive queue */
137 	SKB_DROP_REASON_TCP_OFO_DROP,
138 	/** @SKB_DROP_REASON_IP_OUTNOROUTES: route lookup failed */
139 	SKB_DROP_REASON_IP_OUTNOROUTES,
140 	/**
141 	 * @SKB_DROP_REASON_BPF_CGROUP_EGRESS: dropped by BPF_PROG_TYPE_CGROUP_SKB
142 	 * eBPF program
143 	 */
144 	SKB_DROP_REASON_BPF_CGROUP_EGRESS,
145 	/** @SKB_DROP_REASON_IPV6DISABLED: IPv6 is disabled on the device */
146 	SKB_DROP_REASON_IPV6DISABLED,
147 	/** @SKB_DROP_REASON_NEIGH_CREATEFAIL: failed to create neigh entry */
148 	SKB_DROP_REASON_NEIGH_CREATEFAIL,
149 	/** @SKB_DROP_REASON_NEIGH_FAILED: neigh entry in failed state */
150 	SKB_DROP_REASON_NEIGH_FAILED,
151 	/** @SKB_DROP_REASON_NEIGH_QUEUEFULL: arp_queue for neigh entry is full */
152 	SKB_DROP_REASON_NEIGH_QUEUEFULL,
153 	/** @SKB_DROP_REASON_NEIGH_DEAD: neigh entry is dead */
154 	SKB_DROP_REASON_NEIGH_DEAD,
155 	/** @SKB_DROP_REASON_TC_EGRESS: dropped in TC egress HOOK */
156 	SKB_DROP_REASON_TC_EGRESS,
157 	/**
158 	 * @SKB_DROP_REASON_QDISC_DROP: dropped by qdisc when packet outputting (
159 	 * failed to enqueue to current qdisc)
160 	 */
161 	SKB_DROP_REASON_QDISC_DROP,
162 	/**
163 	 * @SKB_DROP_REASON_CPU_BACKLOG: failed to enqueue the skb to the per CPU
164 	 * backlog queue. This can be caused by backlog queue full (see
165 	 * netdev_max_backlog in net.rst) or RPS flow limit
166 	 */
167 	SKB_DROP_REASON_CPU_BACKLOG,
168 	/** @SKB_DROP_REASON_XDP: dropped by XDP in input path */
169 	SKB_DROP_REASON_XDP,
170 	/** @SKB_DROP_REASON_TC_INGRESS: dropped in TC ingress HOOK */
171 	SKB_DROP_REASON_TC_INGRESS,
172 	/** @SKB_DROP_REASON_UNHANDLED_PROTO: protocol not implemented or not supported */
173 	SKB_DROP_REASON_UNHANDLED_PROTO,
174 	/** @SKB_DROP_REASON_SKB_CSUM: sk_buff checksum computation error */
175 	SKB_DROP_REASON_SKB_CSUM,
176 	/** @SKB_DROP_REASON_SKB_GSO_SEG: gso segmentation error */
177 	SKB_DROP_REASON_SKB_GSO_SEG,
178 	/**
179 	 * @SKB_DROP_REASON_SKB_UCOPY_FAULT: failed to copy data from user space,
180 	 * e.g., via zerocopy_sg_from_iter() or skb_orphan_frags_rx()
181 	 */
182 	SKB_DROP_REASON_SKB_UCOPY_FAULT,
183 	/** @SKB_DROP_REASON_DEV_HDR: device driver specific header/metadata is invalid */
184 	SKB_DROP_REASON_DEV_HDR,
185 	/**
186 	 * @SKB_DROP_REASON_DEV_READY: the device is not ready to xmit/recv due to
187 	 * any of its data structure that is not up/ready/initialized,
188 	 * e.g., the IFF_UP is not set, or driver specific tun->tfiles[txq]
189 	 * is not initialized
190 	 */
191 	SKB_DROP_REASON_DEV_READY,
192 	/** @SKB_DROP_REASON_FULL_RING: ring buffer is full */
193 	SKB_DROP_REASON_FULL_RING,
194 	/** @SKB_DROP_REASON_NOMEM: error due to OOM */
195 	SKB_DROP_REASON_NOMEM,
196 	/**
197 	 * @SKB_DROP_REASON_HDR_TRUNC: failed to trunc/extract the header from
198 	 * networking data, e.g., failed to pull the protocol header from
199 	 * frags via pskb_may_pull()
200 	 */
201 	SKB_DROP_REASON_HDR_TRUNC,
202 	/**
203 	 * @SKB_DROP_REASON_TAP_FILTER: dropped by (ebpf) filter directly attached
204 	 * to tun/tap, e.g., via TUNSETFILTEREBPF
205 	 */
206 	SKB_DROP_REASON_TAP_FILTER,
207 	/**
208 	 * @SKB_DROP_REASON_TAP_TXFILTER: dropped by tx filter implemented at
209 	 * tun/tap, e.g., check_filter()
210 	 */
211 	SKB_DROP_REASON_TAP_TXFILTER,
212 	/** @SKB_DROP_REASON_ICMP_CSUM: ICMP checksum error */
213 	SKB_DROP_REASON_ICMP_CSUM,
214 	/**
215 	 * @SKB_DROP_REASON_INVALID_PROTO: the packet doesn't follow RFC 2211,
216 	 * such as a broadcasts ICMP_TIMESTAMP
217 	 */
218 	SKB_DROP_REASON_INVALID_PROTO,
219 	/**
220 	 * @SKB_DROP_REASON_IP_INADDRERRORS: host unreachable, corresponding to
221 	 * IPSTATS_MIB_INADDRERRORS
222 	 */
223 	SKB_DROP_REASON_IP_INADDRERRORS,
224 	/**
225 	 * @SKB_DROP_REASON_IP_INNOROUTES: network unreachable, corresponding to
226 	 * IPSTATS_MIB_INADDRERRORS
227 	 */
228 	SKB_DROP_REASON_IP_INNOROUTES,
229 	/**
230 	 * @SKB_DROP_REASON_PKT_TOO_BIG: packet size is too big (maybe exceed the
231 	 * MTU)
232 	 */
233 	SKB_DROP_REASON_PKT_TOO_BIG,
234 	/**
235 	 * @SKB_DROP_REASON_MAX: the maximum of drop reason, which shouldn't be
236 	 * used as a real 'reason'
237 	 */
238 	SKB_DROP_REASON_MAX,
239 };
240 
241 #define SKB_DR_INIT(name, reason)				\
242 	enum skb_drop_reason name = SKB_DROP_REASON_##reason
243 #define SKB_DR(name)						\
244 	SKB_DR_INIT(name, NOT_SPECIFIED)
245 #define SKB_DR_SET(name, reason)				\
246 	(name = SKB_DROP_REASON_##reason)
247 #define SKB_DR_OR(name, reason)					\
248 	do {							\
249 		if (name == SKB_DROP_REASON_NOT_SPECIFIED ||	\
250 		    name == SKB_NOT_DROPPED_YET)		\
251 			SKB_DR_SET(name, reason);		\
252 	} while (0)
253 
254 extern const char * const drop_reasons[];
255 
256 #endif
257