1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 #ifndef _LINUX_DROPREASON_CORE_H
4 #define _LINUX_DROPREASON_CORE_H
6 #define DEFINE_DROP_REASON(FN, FNe) \
18 FN(UNICAST_IN_L2_MULTICAST) \
25 FN(TCP_MD5UNEXPECTED) \
28 FN(TCP_AOUNEXPECTED) \
29 FN(TCP_AOKEYNOTFOUND) \
33 FN(TCP_ABORT_ON_DATA) \
38 FN(TCP_RFC7323_PAWS) \
39 FN(TCP_OLD_SEQUENCE) \
40 FN(TCP_INVALID_SEQUENCE) \
41 FN(TCP_INVALID_ACK_SEQUENCE) \
48 FN(TCP_ACK_UNSENT_DATA) \
49 FN(TCP_OFO_QUEUE_PRUNE) \
52 FN(BPF_CGROUP_EGRESS) \
54 FN(NEIGH_CREATEFAIL) \
80 FN(IP_INVALID_SOURCE) \
85 FN(FRAG_REASM_TIMEOUT) \
90 FN(IPV6_NDISC_HOP_LIMIT) \
91 FN(IPV6_NDISC_BAD_CODE) \
92 FN(IPV6_NDISC_BAD_OPTIONS) \
93 FN(IPV6_NDISC_NS_OTHERHOST) \
96 FN(PACKET_SOCK_ERROR) \
97 FN(TC_CHAIN_NOTFOUND) \
98 FN(TC_RECLASSIFY_LOOP) \
99 FN(VXLAN_INVALID_HDR) \
100 FN(VXLAN_VNI_NOT_FOUND) \
101 FN(MAC_INVALID_SOURCE) \
102 FN(VXLAN_ENTRY_EXISTS) \
103 FN(VXLAN_NO_REMOTE) \
107 FN(ARP_PVLAN_DISABLE) \
111 * enum skb_drop_reason - the reasons of skb drops
113 * The reason of skb drop, which is used in kfree_skb_reason().
115 enum skb_drop_reason
{
117 * @SKB_NOT_DROPPED_YET: skb is not dropped yet (used for no-drop case)
119 SKB_NOT_DROPPED_YET
= 0,
120 /** @SKB_CONSUMED: packet has been consumed */
122 /** @SKB_DROP_REASON_NOT_SPECIFIED: drop reason is not specified */
123 SKB_DROP_REASON_NOT_SPECIFIED
,
125 * @SKB_DROP_REASON_NO_SOCKET: no valid socket that can be used.
126 * Reason could be one of three cases:
127 * 1) no established/listening socket found during lookup process
128 * 2) no valid request socket during 3WHS process
129 * 3) no valid child socket during 3WHS process
131 SKB_DROP_REASON_NO_SOCKET
,
132 /** @SKB_DROP_REASON_PKT_TOO_SMALL: packet size is too small */
133 SKB_DROP_REASON_PKT_TOO_SMALL
,
134 /** @SKB_DROP_REASON_TCP_CSUM: TCP checksum error */
135 SKB_DROP_REASON_TCP_CSUM
,
136 /** @SKB_DROP_REASON_SOCKET_FILTER: dropped by socket filter */
137 SKB_DROP_REASON_SOCKET_FILTER
,
138 /** @SKB_DROP_REASON_UDP_CSUM: UDP checksum error */
139 SKB_DROP_REASON_UDP_CSUM
,
140 /** @SKB_DROP_REASON_NETFILTER_DROP: dropped by netfilter */
141 SKB_DROP_REASON_NETFILTER_DROP
,
143 * @SKB_DROP_REASON_OTHERHOST: packet don't belong to current host
144 * (interface is in promisc mode)
146 SKB_DROP_REASON_OTHERHOST
,
147 /** @SKB_DROP_REASON_IP_CSUM: IP checksum error */
148 SKB_DROP_REASON_IP_CSUM
,
150 * @SKB_DROP_REASON_IP_INHDR: there is something wrong with IP header (see
151 * IPSTATS_MIB_INHDRERRORS)
153 SKB_DROP_REASON_IP_INHDR
,
155 * @SKB_DROP_REASON_IP_RPFILTER: IP rpfilter validate failed. see the
156 * document for rp_filter in ip-sysctl.rst for more information
158 SKB_DROP_REASON_IP_RPFILTER
,
160 * @SKB_DROP_REASON_UNICAST_IN_L2_MULTICAST: destination address of L2 is
161 * multicast, but L3 is unicast.
163 SKB_DROP_REASON_UNICAST_IN_L2_MULTICAST
,
164 /** @SKB_DROP_REASON_XFRM_POLICY: xfrm policy check failed */
165 SKB_DROP_REASON_XFRM_POLICY
,
166 /** @SKB_DROP_REASON_IP_NOPROTO: no support for IP protocol */
167 SKB_DROP_REASON_IP_NOPROTO
,
168 /** @SKB_DROP_REASON_SOCKET_RCVBUFF: socket receive buff is full */
169 SKB_DROP_REASON_SOCKET_RCVBUFF
,
171 * @SKB_DROP_REASON_PROTO_MEM: proto memory limitation, such as
172 * udp packet drop out of udp_memory_allocated.
174 SKB_DROP_REASON_PROTO_MEM
,
176 * @SKB_DROP_REASON_TCP_AUTH_HDR: TCP-MD5 or TCP-AO hashes are met
177 * twice or set incorrectly.
179 SKB_DROP_REASON_TCP_AUTH_HDR
,
181 * @SKB_DROP_REASON_TCP_MD5NOTFOUND: no MD5 hash and one expected,
182 * corresponding to LINUX_MIB_TCPMD5NOTFOUND
184 SKB_DROP_REASON_TCP_MD5NOTFOUND
,
186 * @SKB_DROP_REASON_TCP_MD5UNEXPECTED: MD5 hash and we're not expecting
187 * one, corresponding to LINUX_MIB_TCPMD5UNEXPECTED
189 SKB_DROP_REASON_TCP_MD5UNEXPECTED
,
191 * @SKB_DROP_REASON_TCP_MD5FAILURE: MD5 hash and its wrong, corresponding
192 * to LINUX_MIB_TCPMD5FAILURE
194 SKB_DROP_REASON_TCP_MD5FAILURE
,
196 * @SKB_DROP_REASON_TCP_AONOTFOUND: no TCP-AO hash and one was expected,
197 * corresponding to LINUX_MIB_TCPAOREQUIRED
199 SKB_DROP_REASON_TCP_AONOTFOUND
,
201 * @SKB_DROP_REASON_TCP_AOUNEXPECTED: TCP-AO hash is present and it
202 * was not expected, corresponding to LINUX_MIB_TCPAOKEYNOTFOUND
204 SKB_DROP_REASON_TCP_AOUNEXPECTED
,
206 * @SKB_DROP_REASON_TCP_AOKEYNOTFOUND: TCP-AO key is unknown,
207 * corresponding to LINUX_MIB_TCPAOKEYNOTFOUND
209 SKB_DROP_REASON_TCP_AOKEYNOTFOUND
,
211 * @SKB_DROP_REASON_TCP_AOFAILURE: TCP-AO hash is wrong,
212 * corresponding to LINUX_MIB_TCPAOBAD
214 SKB_DROP_REASON_TCP_AOFAILURE
,
216 * @SKB_DROP_REASON_SOCKET_BACKLOG: failed to add skb to socket backlog (
217 * see LINUX_MIB_TCPBACKLOGDROP)
219 SKB_DROP_REASON_SOCKET_BACKLOG
,
220 /** @SKB_DROP_REASON_TCP_FLAGS: TCP flags invalid */
221 SKB_DROP_REASON_TCP_FLAGS
,
223 * @SKB_DROP_REASON_TCP_ABORT_ON_DATA: abort on data, corresponding to
224 * LINUX_MIB_TCPABORTONDATA
226 SKB_DROP_REASON_TCP_ABORT_ON_DATA
,
228 * @SKB_DROP_REASON_TCP_ZEROWINDOW: TCP receive window size is zero,
229 * see LINUX_MIB_TCPZEROWINDOWDROP
231 SKB_DROP_REASON_TCP_ZEROWINDOW
,
233 * @SKB_DROP_REASON_TCP_OLD_DATA: the TCP data received is already
234 * received before (spurious retrans may happened), see
235 * LINUX_MIB_DELAYEDACKLOST
237 SKB_DROP_REASON_TCP_OLD_DATA
,
239 * @SKB_DROP_REASON_TCP_OVERWINDOW: the TCP data is out of window,
240 * the seq of the first byte exceed the right edges of receive
243 SKB_DROP_REASON_TCP_OVERWINDOW
,
245 * @SKB_DROP_REASON_TCP_OFOMERGE: the data of skb is already in the ofo
246 * queue, corresponding to LINUX_MIB_TCPOFOMERGE
248 SKB_DROP_REASON_TCP_OFOMERGE
,
250 * @SKB_DROP_REASON_TCP_RFC7323_PAWS: PAWS check, corresponding to
251 * LINUX_MIB_PAWSESTABREJECTED, LINUX_MIB_PAWSACTIVEREJECTED
253 SKB_DROP_REASON_TCP_RFC7323_PAWS
,
254 /** @SKB_DROP_REASON_TCP_OLD_SEQUENCE: Old SEQ field (duplicate packet) */
255 SKB_DROP_REASON_TCP_OLD_SEQUENCE
,
256 /** @SKB_DROP_REASON_TCP_INVALID_SEQUENCE: Not acceptable SEQ field */
257 SKB_DROP_REASON_TCP_INVALID_SEQUENCE
,
259 * @SKB_DROP_REASON_TCP_INVALID_ACK_SEQUENCE: Not acceptable ACK SEQ
260 * field because ack sequence is not in the window between snd_una
263 SKB_DROP_REASON_TCP_INVALID_ACK_SEQUENCE
,
264 /** @SKB_DROP_REASON_TCP_RESET: Invalid RST packet */
265 SKB_DROP_REASON_TCP_RESET
,
267 * @SKB_DROP_REASON_TCP_INVALID_SYN: Incoming packet has unexpected
270 SKB_DROP_REASON_TCP_INVALID_SYN
,
271 /** @SKB_DROP_REASON_TCP_CLOSE: TCP socket in CLOSE state */
272 SKB_DROP_REASON_TCP_CLOSE
,
273 /** @SKB_DROP_REASON_TCP_FASTOPEN: dropped by FASTOPEN request socket */
274 SKB_DROP_REASON_TCP_FASTOPEN
,
275 /** @SKB_DROP_REASON_TCP_OLD_ACK: TCP ACK is old, but in window */
276 SKB_DROP_REASON_TCP_OLD_ACK
,
277 /** @SKB_DROP_REASON_TCP_TOO_OLD_ACK: TCP ACK is too old */
278 SKB_DROP_REASON_TCP_TOO_OLD_ACK
,
280 * @SKB_DROP_REASON_TCP_ACK_UNSENT_DATA: TCP ACK for data we haven't
283 SKB_DROP_REASON_TCP_ACK_UNSENT_DATA
,
284 /** @SKB_DROP_REASON_TCP_OFO_QUEUE_PRUNE: pruned from TCP OFO queue */
285 SKB_DROP_REASON_TCP_OFO_QUEUE_PRUNE
,
286 /** @SKB_DROP_REASON_TCP_OFO_DROP: data already in receive queue */
287 SKB_DROP_REASON_TCP_OFO_DROP
,
288 /** @SKB_DROP_REASON_IP_OUTNOROUTES: route lookup failed */
289 SKB_DROP_REASON_IP_OUTNOROUTES
,
291 * @SKB_DROP_REASON_BPF_CGROUP_EGRESS: dropped by BPF_PROG_TYPE_CGROUP_SKB
294 SKB_DROP_REASON_BPF_CGROUP_EGRESS
,
295 /** @SKB_DROP_REASON_IPV6DISABLED: IPv6 is disabled on the device */
296 SKB_DROP_REASON_IPV6DISABLED
,
297 /** @SKB_DROP_REASON_NEIGH_CREATEFAIL: failed to create neigh entry */
298 SKB_DROP_REASON_NEIGH_CREATEFAIL
,
299 /** @SKB_DROP_REASON_NEIGH_FAILED: neigh entry in failed state */
300 SKB_DROP_REASON_NEIGH_FAILED
,
301 /** @SKB_DROP_REASON_NEIGH_QUEUEFULL: arp_queue for neigh entry is full */
302 SKB_DROP_REASON_NEIGH_QUEUEFULL
,
303 /** @SKB_DROP_REASON_NEIGH_DEAD: neigh entry is dead */
304 SKB_DROP_REASON_NEIGH_DEAD
,
305 /** @SKB_DROP_REASON_TC_EGRESS: dropped in TC egress HOOK */
306 SKB_DROP_REASON_TC_EGRESS
,
307 /** @SKB_DROP_REASON_SECURITY_HOOK: dropped due to security HOOK */
308 SKB_DROP_REASON_SECURITY_HOOK
,
310 * @SKB_DROP_REASON_QDISC_DROP: dropped by qdisc when packet outputting (
311 * failed to enqueue to current qdisc)
313 SKB_DROP_REASON_QDISC_DROP
,
315 * @SKB_DROP_REASON_CPU_BACKLOG: failed to enqueue the skb to the per CPU
316 * backlog queue. This can be caused by backlog queue full (see
317 * netdev_max_backlog in net.rst) or RPS flow limit
319 SKB_DROP_REASON_CPU_BACKLOG
,
320 /** @SKB_DROP_REASON_XDP: dropped by XDP in input path */
322 /** @SKB_DROP_REASON_TC_INGRESS: dropped in TC ingress HOOK */
323 SKB_DROP_REASON_TC_INGRESS
,
324 /** @SKB_DROP_REASON_UNHANDLED_PROTO: protocol not implemented or not supported */
325 SKB_DROP_REASON_UNHANDLED_PROTO
,
326 /** @SKB_DROP_REASON_SKB_CSUM: sk_buff checksum computation error */
327 SKB_DROP_REASON_SKB_CSUM
,
328 /** @SKB_DROP_REASON_SKB_GSO_SEG: gso segmentation error */
329 SKB_DROP_REASON_SKB_GSO_SEG
,
331 * @SKB_DROP_REASON_SKB_UCOPY_FAULT: failed to copy data from user space,
332 * e.g., via zerocopy_sg_from_iter() or skb_orphan_frags_rx()
334 SKB_DROP_REASON_SKB_UCOPY_FAULT
,
335 /** @SKB_DROP_REASON_DEV_HDR: device driver specific header/metadata is invalid */
336 SKB_DROP_REASON_DEV_HDR
,
338 * @SKB_DROP_REASON_DEV_READY: the device is not ready to xmit/recv due to
339 * any of its data structure that is not up/ready/initialized,
340 * e.g., the IFF_UP is not set, or driver specific tun->tfiles[txq]
343 SKB_DROP_REASON_DEV_READY
,
344 /** @SKB_DROP_REASON_FULL_RING: ring buffer is full */
345 SKB_DROP_REASON_FULL_RING
,
346 /** @SKB_DROP_REASON_NOMEM: error due to OOM */
347 SKB_DROP_REASON_NOMEM
,
349 * @SKB_DROP_REASON_HDR_TRUNC: failed to trunc/extract the header from
350 * networking data, e.g., failed to pull the protocol header from
351 * frags via pskb_may_pull()
353 SKB_DROP_REASON_HDR_TRUNC
,
355 * @SKB_DROP_REASON_TAP_FILTER: dropped by (ebpf) filter directly attached
356 * to tun/tap, e.g., via TUNSETFILTEREBPF
358 SKB_DROP_REASON_TAP_FILTER
,
360 * @SKB_DROP_REASON_TAP_TXFILTER: dropped by tx filter implemented at
361 * tun/tap, e.g., check_filter()
363 SKB_DROP_REASON_TAP_TXFILTER
,
364 /** @SKB_DROP_REASON_ICMP_CSUM: ICMP checksum error */
365 SKB_DROP_REASON_ICMP_CSUM
,
367 * @SKB_DROP_REASON_INVALID_PROTO: the packet doesn't follow RFC 2211,
368 * such as a broadcasts ICMP_TIMESTAMP
370 SKB_DROP_REASON_INVALID_PROTO
,
372 * @SKB_DROP_REASON_IP_INADDRERRORS: host unreachable, corresponding to
373 * IPSTATS_MIB_INADDRERRORS
375 SKB_DROP_REASON_IP_INADDRERRORS
,
377 * @SKB_DROP_REASON_IP_INNOROUTES: network unreachable, corresponding to
378 * IPSTATS_MIB_INADDRERRORS
380 SKB_DROP_REASON_IP_INNOROUTES
,
381 /** @SKB_DROP_REASON_IP_LOCAL_SOURCE: the source ip is local */
382 SKB_DROP_REASON_IP_LOCAL_SOURCE
,
384 * @SKB_DROP_REASON_IP_INVALID_SOURCE: the source ip is invalid:
385 * 1) source ip is multicast or limited broadcast
386 * 2) source ip is zero and not IGMP
388 SKB_DROP_REASON_IP_INVALID_SOURCE
,
389 /** @SKB_DROP_REASON_IP_LOCALNET: source or dest ip is local net */
390 SKB_DROP_REASON_IP_LOCALNET
,
392 * @SKB_DROP_REASON_IP_INVALID_DEST: the dest ip is invalid:
395 SKB_DROP_REASON_IP_INVALID_DEST
,
397 * @SKB_DROP_REASON_PKT_TOO_BIG: packet size is too big (maybe exceed the
400 SKB_DROP_REASON_PKT_TOO_BIG
,
401 /** @SKB_DROP_REASON_DUP_FRAG: duplicate fragment */
402 SKB_DROP_REASON_DUP_FRAG
,
403 /** @SKB_DROP_REASON_FRAG_REASM_TIMEOUT: fragment reassembly timeout */
404 SKB_DROP_REASON_FRAG_REASM_TIMEOUT
,
406 * @SKB_DROP_REASON_FRAG_TOO_FAR: ipv4 fragment too far.
407 * (/proc/sys/net/ipv4/ipfrag_max_dist)
409 SKB_DROP_REASON_FRAG_TOO_FAR
,
411 * @SKB_DROP_REASON_TCP_MINTTL: ipv4 ttl or ipv6 hoplimit below
412 * the threshold (IP_MINTTL or IPV6_MINHOPCOUNT).
414 SKB_DROP_REASON_TCP_MINTTL
,
415 /** @SKB_DROP_REASON_IPV6_BAD_EXTHDR: Bad IPv6 extension header. */
416 SKB_DROP_REASON_IPV6_BAD_EXTHDR
,
417 /** @SKB_DROP_REASON_IPV6_NDISC_FRAG: invalid frag (suppress_frag_ndisc). */
418 SKB_DROP_REASON_IPV6_NDISC_FRAG
,
419 /** @SKB_DROP_REASON_IPV6_NDISC_HOP_LIMIT: invalid hop limit. */
420 SKB_DROP_REASON_IPV6_NDISC_HOP_LIMIT
,
421 /** @SKB_DROP_REASON_IPV6_NDISC_BAD_CODE: invalid NDISC icmp6 code. */
422 SKB_DROP_REASON_IPV6_NDISC_BAD_CODE
,
423 /** @SKB_DROP_REASON_IPV6_NDISC_BAD_OPTIONS: invalid NDISC options. */
424 SKB_DROP_REASON_IPV6_NDISC_BAD_OPTIONS
,
426 * @SKB_DROP_REASON_IPV6_NDISC_NS_OTHERHOST: NEIGHBOUR SOLICITATION
429 SKB_DROP_REASON_IPV6_NDISC_NS_OTHERHOST
,
430 /** @SKB_DROP_REASON_QUEUE_PURGE: bulk free. */
431 SKB_DROP_REASON_QUEUE_PURGE
,
433 * @SKB_DROP_REASON_TC_COOKIE_ERROR: An error occurred whilst
434 * processing a tc ext cookie.
436 SKB_DROP_REASON_TC_COOKIE_ERROR
,
438 * @SKB_DROP_REASON_PACKET_SOCK_ERROR: generic packet socket errors
439 * after its filter matches an incoming packet.
441 SKB_DROP_REASON_PACKET_SOCK_ERROR
,
442 /** @SKB_DROP_REASON_TC_CHAIN_NOTFOUND: tc chain lookup failed. */
443 SKB_DROP_REASON_TC_CHAIN_NOTFOUND
,
445 * @SKB_DROP_REASON_TC_RECLASSIFY_LOOP: tc exceeded max reclassify loop
448 SKB_DROP_REASON_TC_RECLASSIFY_LOOP
,
450 * @SKB_DROP_REASON_VXLAN_INVALID_HDR: VXLAN header is invalid. E.g.:
451 * 1) reserved fields are not zero
452 * 2) "I" flag is not set
454 SKB_DROP_REASON_VXLAN_INVALID_HDR
,
455 /** @SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND: no VXLAN device found for VNI */
456 SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND
,
457 /** @SKB_DROP_REASON_MAC_INVALID_SOURCE: source mac is invalid */
458 SKB_DROP_REASON_MAC_INVALID_SOURCE
,
460 * @SKB_DROP_REASON_VXLAN_ENTRY_EXISTS: trying to migrate a static
461 * entry or an entry pointing to a nexthop.
463 SKB_DROP_REASON_VXLAN_ENTRY_EXISTS
,
464 /** @SKB_DROP_REASON_VXLAN_NO_REMOTE: no remote found for xmit */
465 SKB_DROP_REASON_VXLAN_NO_REMOTE
,
467 * @SKB_DROP_REASON_IP_TUNNEL_ECN: skb is dropped according to
468 * RFC 6040 4.2, see __INET_ECN_decapsulate() for detail.
470 SKB_DROP_REASON_IP_TUNNEL_ECN
,
472 * @SKB_DROP_REASON_TUNNEL_TXINFO: packet without necessary metadata
473 * reached a device which is in "external" mode.
475 SKB_DROP_REASON_TUNNEL_TXINFO
,
477 * @SKB_DROP_REASON_LOCAL_MAC: the source MAC address is equal to
478 * the MAC address of the local netdev.
480 SKB_DROP_REASON_LOCAL_MAC
,
482 * @SKB_DROP_REASON_ARP_PVLAN_DISABLE: packet which is not IP is
483 * forwarded to the in_dev, and the proxy_arp_pvlan is not
486 SKB_DROP_REASON_ARP_PVLAN_DISABLE
,
488 * @SKB_DROP_REASON_MAX: the maximum of core drop reasons, which
489 * shouldn't be used as a real 'reason' - only for tracing code gen
494 * @SKB_DROP_REASON_SUBSYS_MASK: subsystem mask in drop reasons,
495 * see &enum skb_drop_reason_subsys
497 SKB_DROP_REASON_SUBSYS_MASK
= 0xffff0000,
500 #define SKB_DROP_REASON_SUBSYS_SHIFT 16
502 #define SKB_DR_INIT(name, reason) \
503 enum skb_drop_reason name = SKB_DROP_REASON_##reason
504 #define SKB_DR(name) \
505 SKB_DR_INIT(name, NOT_SPECIFIED)
506 #define SKB_DR_SET(name, reason) \
507 (name = SKB_DROP_REASON_##reason)
508 #define SKB_DR_OR(name, reason) \
510 if (name == SKB_DROP_REASON_NOT_SPECIFIED || \
511 name == SKB_NOT_DROPPED_YET) \
512 SKB_DR_SET(name, reason); \