1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 3 #ifndef _LINUX_DROPREASON_CORE_H 4 #define _LINUX_DROPREASON_CORE_H 5 6 #define DEFINE_DROP_REASON(FN, FNe) \ 7 FN(NOT_SPECIFIED) \ 8 FN(NO_SOCKET) \ 9 FN(PKT_TOO_SMALL) \ 10 FN(TCP_CSUM) \ 11 FN(SOCKET_FILTER) \ 12 FN(UDP_CSUM) \ 13 FN(NETFILTER_DROP) \ 14 FN(OTHERHOST) \ 15 FN(IP_CSUM) \ 16 FN(IP_INHDR) \ 17 FN(IP_RPFILTER) \ 18 FN(UNICAST_IN_L2_MULTICAST) \ 19 FN(XFRM_POLICY) \ 20 FN(IP_NOPROTO) \ 21 FN(SOCKET_RCVBUFF) \ 22 FN(PROTO_MEM) \ 23 FN(TCP_AUTH_HDR) \ 24 FN(TCP_MD5NOTFOUND) \ 25 FN(TCP_MD5UNEXPECTED) \ 26 FN(TCP_MD5FAILURE) \ 27 FN(TCP_AONOTFOUND) \ 28 FN(TCP_AOUNEXPECTED) \ 29 FN(TCP_AOKEYNOTFOUND) \ 30 FN(TCP_AOFAILURE) \ 31 FN(SOCKET_BACKLOG) \ 32 FN(TCP_FLAGS) \ 33 FN(TCP_ZEROWINDOW) \ 34 FN(TCP_OLD_DATA) \ 35 FN(TCP_OVERWINDOW) \ 36 FN(TCP_OFOMERGE) \ 37 FN(TCP_RFC7323_PAWS) \ 38 FN(TCP_OLD_SEQUENCE) \ 39 FN(TCP_INVALID_SEQUENCE) \ 40 FN(TCP_RESET) \ 41 FN(TCP_INVALID_SYN) \ 42 FN(TCP_CLOSE) \ 43 FN(TCP_FASTOPEN) \ 44 FN(TCP_OLD_ACK) \ 45 FN(TCP_TOO_OLD_ACK) \ 46 FN(TCP_ACK_UNSENT_DATA) \ 47 FN(TCP_OFO_QUEUE_PRUNE) \ 48 FN(TCP_OFO_DROP) \ 49 FN(IP_OUTNOROUTES) \ 50 FN(BPF_CGROUP_EGRESS) \ 51 FN(IPV6DISABLED) \ 52 FN(NEIGH_CREATEFAIL) \ 53 FN(NEIGH_FAILED) \ 54 FN(NEIGH_QUEUEFULL) \ 55 FN(NEIGH_DEAD) \ 56 FN(TC_EGRESS) \ 57 FN(QDISC_DROP) \ 58 FN(CPU_BACKLOG) \ 59 FN(XDP) \ 60 FN(TC_INGRESS) \ 61 FN(UNHANDLED_PROTO) \ 62 FN(SKB_CSUM) \ 63 FN(SKB_GSO_SEG) \ 64 FN(SKB_UCOPY_FAULT) \ 65 FN(DEV_HDR) \ 66 FN(DEV_READY) \ 67 FN(FULL_RING) \ 68 FN(NOMEM) \ 69 FN(HDR_TRUNC) \ 70 FN(TAP_FILTER) \ 71 FN(TAP_TXFILTER) \ 72 FN(ICMP_CSUM) \ 73 FN(INVALID_PROTO) \ 74 FN(IP_INADDRERRORS) \ 75 FN(IP_INNOROUTES) \ 76 FN(PKT_TOO_BIG) \ 77 FN(DUP_FRAG) \ 78 FN(FRAG_REASM_TIMEOUT) \ 79 FN(FRAG_TOO_FAR) \ 80 FN(TCP_MINTTL) \ 81 FN(IPV6_BAD_EXTHDR) \ 82 FN(IPV6_NDISC_FRAG) \ 83 FN(IPV6_NDISC_HOP_LIMIT) \ 84 FN(IPV6_NDISC_BAD_CODE) \ 85 FN(IPV6_NDISC_BAD_OPTIONS) \ 86 FN(IPV6_NDISC_NS_OTHERHOST) \ 87 FN(QUEUE_PURGE) \ 88 FN(TC_COOKIE_ERROR) \ 89 FN(PACKET_SOCK_ERROR) \ 90 FN(TC_CHAIN_NOTFOUND) \ 91 FN(TC_RECLASSIFY_LOOP) \ 92 FNe(MAX) 93 94 /** 95 * enum skb_drop_reason - the reasons of skb drops 96 * 97 * The reason of skb drop, which is used in kfree_skb_reason(). 98 */ 99 enum skb_drop_reason { 100 /** 101 * @SKB_NOT_DROPPED_YET: skb is not dropped yet (used for no-drop case) 102 */ 103 SKB_NOT_DROPPED_YET = 0, 104 /** @SKB_CONSUMED: packet has been consumed */ 105 SKB_CONSUMED, 106 /** @SKB_DROP_REASON_NOT_SPECIFIED: drop reason is not specified */ 107 SKB_DROP_REASON_NOT_SPECIFIED, 108 /** @SKB_DROP_REASON_NO_SOCKET: socket not found */ 109 SKB_DROP_REASON_NO_SOCKET, 110 /** @SKB_DROP_REASON_PKT_TOO_SMALL: packet size is too small */ 111 SKB_DROP_REASON_PKT_TOO_SMALL, 112 /** @SKB_DROP_REASON_TCP_CSUM: TCP checksum error */ 113 SKB_DROP_REASON_TCP_CSUM, 114 /** @SKB_DROP_REASON_SOCKET_FILTER: dropped by socket filter */ 115 SKB_DROP_REASON_SOCKET_FILTER, 116 /** @SKB_DROP_REASON_UDP_CSUM: UDP checksum error */ 117 SKB_DROP_REASON_UDP_CSUM, 118 /** @SKB_DROP_REASON_NETFILTER_DROP: dropped by netfilter */ 119 SKB_DROP_REASON_NETFILTER_DROP, 120 /** 121 * @SKB_DROP_REASON_OTHERHOST: packet don't belong to current host 122 * (interface is in promisc mode) 123 */ 124 SKB_DROP_REASON_OTHERHOST, 125 /** @SKB_DROP_REASON_IP_CSUM: IP checksum error */ 126 SKB_DROP_REASON_IP_CSUM, 127 /** 128 * @SKB_DROP_REASON_IP_INHDR: there is something wrong with IP header (see 129 * IPSTATS_MIB_INHDRERRORS) 130 */ 131 SKB_DROP_REASON_IP_INHDR, 132 /** 133 * @SKB_DROP_REASON_IP_RPFILTER: IP rpfilter validate failed. see the 134 * document for rp_filter in ip-sysctl.rst for more information 135 */ 136 SKB_DROP_REASON_IP_RPFILTER, 137 /** 138 * @SKB_DROP_REASON_UNICAST_IN_L2_MULTICAST: destination address of L2 is 139 * multicast, but L3 is unicast. 140 */ 141 SKB_DROP_REASON_UNICAST_IN_L2_MULTICAST, 142 /** @SKB_DROP_REASON_XFRM_POLICY: xfrm policy check failed */ 143 SKB_DROP_REASON_XFRM_POLICY, 144 /** @SKB_DROP_REASON_IP_NOPROTO: no support for IP protocol */ 145 SKB_DROP_REASON_IP_NOPROTO, 146 /** @SKB_DROP_REASON_SOCKET_RCVBUFF: socket receive buff is full */ 147 SKB_DROP_REASON_SOCKET_RCVBUFF, 148 /** 149 * @SKB_DROP_REASON_PROTO_MEM: proto memory limition, such as udp packet 150 * drop out of udp_memory_allocated. 151 */ 152 SKB_DROP_REASON_PROTO_MEM, 153 /** 154 * @SKB_DROP_REASON_TCP_AUTH_HDR: TCP-MD5 or TCP-AO hashes are met 155 * twice or set incorrectly. 156 */ 157 SKB_DROP_REASON_TCP_AUTH_HDR, 158 /** 159 * @SKB_DROP_REASON_TCP_MD5NOTFOUND: no MD5 hash and one expected, 160 * corresponding to LINUX_MIB_TCPMD5NOTFOUND 161 */ 162 SKB_DROP_REASON_TCP_MD5NOTFOUND, 163 /** 164 * @SKB_DROP_REASON_TCP_MD5UNEXPECTED: MD5 hash and we're not expecting 165 * one, corresponding to LINUX_MIB_TCPMD5UNEXPECTED 166 */ 167 SKB_DROP_REASON_TCP_MD5UNEXPECTED, 168 /** 169 * @SKB_DROP_REASON_TCP_MD5FAILURE: MD5 hash and its wrong, corresponding 170 * to LINUX_MIB_TCPMD5FAILURE 171 */ 172 SKB_DROP_REASON_TCP_MD5FAILURE, 173 /** 174 * @SKB_DROP_REASON_TCP_AONOTFOUND: no TCP-AO hash and one was expected, 175 * corresponding to LINUX_MIB_TCPAOREQUIRED 176 */ 177 SKB_DROP_REASON_TCP_AONOTFOUND, 178 /** 179 * @SKB_DROP_REASON_TCP_AOUNEXPECTED: TCP-AO hash is present and it 180 * was not expected, corresponding to LINUX_MIB_TCPAOKEYNOTFOUND 181 */ 182 SKB_DROP_REASON_TCP_AOUNEXPECTED, 183 /** 184 * @SKB_DROP_REASON_TCP_AOKEYNOTFOUND: TCP-AO key is unknown, 185 * corresponding to LINUX_MIB_TCPAOKEYNOTFOUND 186 */ 187 SKB_DROP_REASON_TCP_AOKEYNOTFOUND, 188 /** 189 * @SKB_DROP_REASON_TCP_AOFAILURE: TCP-AO hash is wrong, 190 * corresponding to LINUX_MIB_TCPAOBAD 191 */ 192 SKB_DROP_REASON_TCP_AOFAILURE, 193 /** 194 * @SKB_DROP_REASON_SOCKET_BACKLOG: failed to add skb to socket backlog ( 195 * see LINUX_MIB_TCPBACKLOGDROP) 196 */ 197 SKB_DROP_REASON_SOCKET_BACKLOG, 198 /** @SKB_DROP_REASON_TCP_FLAGS: TCP flags invalid */ 199 SKB_DROP_REASON_TCP_FLAGS, 200 /** 201 * @SKB_DROP_REASON_TCP_ZEROWINDOW: TCP receive window size is zero, 202 * see LINUX_MIB_TCPZEROWINDOWDROP 203 */ 204 SKB_DROP_REASON_TCP_ZEROWINDOW, 205 /** 206 * @SKB_DROP_REASON_TCP_OLD_DATA: the TCP data reveived is already 207 * received before (spurious retrans may happened), see 208 * LINUX_MIB_DELAYEDACKLOST 209 */ 210 SKB_DROP_REASON_TCP_OLD_DATA, 211 /** 212 * @SKB_DROP_REASON_TCP_OVERWINDOW: the TCP data is out of window, 213 * the seq of the first byte exceed the right edges of receive 214 * window 215 */ 216 SKB_DROP_REASON_TCP_OVERWINDOW, 217 /** 218 * @SKB_DROP_REASON_TCP_OFOMERGE: the data of skb is already in the ofo 219 * queue, corresponding to LINUX_MIB_TCPOFOMERGE 220 */ 221 SKB_DROP_REASON_TCP_OFOMERGE, 222 /** 223 * @SKB_DROP_REASON_TCP_RFC7323_PAWS: PAWS check, corresponding to 224 * LINUX_MIB_PAWSESTABREJECTED 225 */ 226 SKB_DROP_REASON_TCP_RFC7323_PAWS, 227 /** @SKB_DROP_REASON_TCP_OLD_SEQUENCE: Old SEQ field (duplicate packet) */ 228 SKB_DROP_REASON_TCP_OLD_SEQUENCE, 229 /** @SKB_DROP_REASON_TCP_INVALID_SEQUENCE: Not acceptable SEQ field */ 230 SKB_DROP_REASON_TCP_INVALID_SEQUENCE, 231 /** @SKB_DROP_REASON_TCP_RESET: Invalid RST packet */ 232 SKB_DROP_REASON_TCP_RESET, 233 /** 234 * @SKB_DROP_REASON_TCP_INVALID_SYN: Incoming packet has unexpected 235 * SYN flag 236 */ 237 SKB_DROP_REASON_TCP_INVALID_SYN, 238 /** @SKB_DROP_REASON_TCP_CLOSE: TCP socket in CLOSE state */ 239 SKB_DROP_REASON_TCP_CLOSE, 240 /** @SKB_DROP_REASON_TCP_FASTOPEN: dropped by FASTOPEN request socket */ 241 SKB_DROP_REASON_TCP_FASTOPEN, 242 /** @SKB_DROP_REASON_TCP_OLD_ACK: TCP ACK is old, but in window */ 243 SKB_DROP_REASON_TCP_OLD_ACK, 244 /** @SKB_DROP_REASON_TCP_TOO_OLD_ACK: TCP ACK is too old */ 245 SKB_DROP_REASON_TCP_TOO_OLD_ACK, 246 /** 247 * @SKB_DROP_REASON_TCP_ACK_UNSENT_DATA: TCP ACK for data we haven't 248 * sent yet 249 */ 250 SKB_DROP_REASON_TCP_ACK_UNSENT_DATA, 251 /** @SKB_DROP_REASON_TCP_OFO_QUEUE_PRUNE: pruned from TCP OFO queue */ 252 SKB_DROP_REASON_TCP_OFO_QUEUE_PRUNE, 253 /** @SKB_DROP_REASON_TCP_OFO_DROP: data already in receive queue */ 254 SKB_DROP_REASON_TCP_OFO_DROP, 255 /** @SKB_DROP_REASON_IP_OUTNOROUTES: route lookup failed */ 256 SKB_DROP_REASON_IP_OUTNOROUTES, 257 /** 258 * @SKB_DROP_REASON_BPF_CGROUP_EGRESS: dropped by BPF_PROG_TYPE_CGROUP_SKB 259 * eBPF program 260 */ 261 SKB_DROP_REASON_BPF_CGROUP_EGRESS, 262 /** @SKB_DROP_REASON_IPV6DISABLED: IPv6 is disabled on the device */ 263 SKB_DROP_REASON_IPV6DISABLED, 264 /** @SKB_DROP_REASON_NEIGH_CREATEFAIL: failed to create neigh entry */ 265 SKB_DROP_REASON_NEIGH_CREATEFAIL, 266 /** @SKB_DROP_REASON_NEIGH_FAILED: neigh entry in failed state */ 267 SKB_DROP_REASON_NEIGH_FAILED, 268 /** @SKB_DROP_REASON_NEIGH_QUEUEFULL: arp_queue for neigh entry is full */ 269 SKB_DROP_REASON_NEIGH_QUEUEFULL, 270 /** @SKB_DROP_REASON_NEIGH_DEAD: neigh entry is dead */ 271 SKB_DROP_REASON_NEIGH_DEAD, 272 /** @SKB_DROP_REASON_TC_EGRESS: dropped in TC egress HOOK */ 273 SKB_DROP_REASON_TC_EGRESS, 274 /** 275 * @SKB_DROP_REASON_QDISC_DROP: dropped by qdisc when packet outputting ( 276 * failed to enqueue to current qdisc) 277 */ 278 SKB_DROP_REASON_QDISC_DROP, 279 /** 280 * @SKB_DROP_REASON_CPU_BACKLOG: failed to enqueue the skb to the per CPU 281 * backlog queue. This can be caused by backlog queue full (see 282 * netdev_max_backlog in net.rst) or RPS flow limit 283 */ 284 SKB_DROP_REASON_CPU_BACKLOG, 285 /** @SKB_DROP_REASON_XDP: dropped by XDP in input path */ 286 SKB_DROP_REASON_XDP, 287 /** @SKB_DROP_REASON_TC_INGRESS: dropped in TC ingress HOOK */ 288 SKB_DROP_REASON_TC_INGRESS, 289 /** @SKB_DROP_REASON_UNHANDLED_PROTO: protocol not implemented or not supported */ 290 SKB_DROP_REASON_UNHANDLED_PROTO, 291 /** @SKB_DROP_REASON_SKB_CSUM: sk_buff checksum computation error */ 292 SKB_DROP_REASON_SKB_CSUM, 293 /** @SKB_DROP_REASON_SKB_GSO_SEG: gso segmentation error */ 294 SKB_DROP_REASON_SKB_GSO_SEG, 295 /** 296 * @SKB_DROP_REASON_SKB_UCOPY_FAULT: failed to copy data from user space, 297 * e.g., via zerocopy_sg_from_iter() or skb_orphan_frags_rx() 298 */ 299 SKB_DROP_REASON_SKB_UCOPY_FAULT, 300 /** @SKB_DROP_REASON_DEV_HDR: device driver specific header/metadata is invalid */ 301 SKB_DROP_REASON_DEV_HDR, 302 /** 303 * @SKB_DROP_REASON_DEV_READY: the device is not ready to xmit/recv due to 304 * any of its data structure that is not up/ready/initialized, 305 * e.g., the IFF_UP is not set, or driver specific tun->tfiles[txq] 306 * is not initialized 307 */ 308 SKB_DROP_REASON_DEV_READY, 309 /** @SKB_DROP_REASON_FULL_RING: ring buffer is full */ 310 SKB_DROP_REASON_FULL_RING, 311 /** @SKB_DROP_REASON_NOMEM: error due to OOM */ 312 SKB_DROP_REASON_NOMEM, 313 /** 314 * @SKB_DROP_REASON_HDR_TRUNC: failed to trunc/extract the header from 315 * networking data, e.g., failed to pull the protocol header from 316 * frags via pskb_may_pull() 317 */ 318 SKB_DROP_REASON_HDR_TRUNC, 319 /** 320 * @SKB_DROP_REASON_TAP_FILTER: dropped by (ebpf) filter directly attached 321 * to tun/tap, e.g., via TUNSETFILTEREBPF 322 */ 323 SKB_DROP_REASON_TAP_FILTER, 324 /** 325 * @SKB_DROP_REASON_TAP_TXFILTER: dropped by tx filter implemented at 326 * tun/tap, e.g., check_filter() 327 */ 328 SKB_DROP_REASON_TAP_TXFILTER, 329 /** @SKB_DROP_REASON_ICMP_CSUM: ICMP checksum error */ 330 SKB_DROP_REASON_ICMP_CSUM, 331 /** 332 * @SKB_DROP_REASON_INVALID_PROTO: the packet doesn't follow RFC 2211, 333 * such as a broadcasts ICMP_TIMESTAMP 334 */ 335 SKB_DROP_REASON_INVALID_PROTO, 336 /** 337 * @SKB_DROP_REASON_IP_INADDRERRORS: host unreachable, corresponding to 338 * IPSTATS_MIB_INADDRERRORS 339 */ 340 SKB_DROP_REASON_IP_INADDRERRORS, 341 /** 342 * @SKB_DROP_REASON_IP_INNOROUTES: network unreachable, corresponding to 343 * IPSTATS_MIB_INADDRERRORS 344 */ 345 SKB_DROP_REASON_IP_INNOROUTES, 346 /** 347 * @SKB_DROP_REASON_PKT_TOO_BIG: packet size is too big (maybe exceed the 348 * MTU) 349 */ 350 SKB_DROP_REASON_PKT_TOO_BIG, 351 /** @SKB_DROP_REASON_DUP_FRAG: duplicate fragment */ 352 SKB_DROP_REASON_DUP_FRAG, 353 /** @SKB_DROP_REASON_FRAG_REASM_TIMEOUT: fragment reassembly timeout */ 354 SKB_DROP_REASON_FRAG_REASM_TIMEOUT, 355 /** 356 * @SKB_DROP_REASON_FRAG_TOO_FAR: ipv4 fragment too far. 357 * (/proc/sys/net/ipv4/ipfrag_max_dist) 358 */ 359 SKB_DROP_REASON_FRAG_TOO_FAR, 360 /** 361 * @SKB_DROP_REASON_TCP_MINTTL: ipv4 ttl or ipv6 hoplimit below 362 * the threshold (IP_MINTTL or IPV6_MINHOPCOUNT). 363 */ 364 SKB_DROP_REASON_TCP_MINTTL, 365 /** @SKB_DROP_REASON_IPV6_BAD_EXTHDR: Bad IPv6 extension header. */ 366 SKB_DROP_REASON_IPV6_BAD_EXTHDR, 367 /** @SKB_DROP_REASON_IPV6_NDISC_FRAG: invalid frag (suppress_frag_ndisc). */ 368 SKB_DROP_REASON_IPV6_NDISC_FRAG, 369 /** @SKB_DROP_REASON_IPV6_NDISC_HOP_LIMIT: invalid hop limit. */ 370 SKB_DROP_REASON_IPV6_NDISC_HOP_LIMIT, 371 /** @SKB_DROP_REASON_IPV6_NDISC_BAD_CODE: invalid NDISC icmp6 code. */ 372 SKB_DROP_REASON_IPV6_NDISC_BAD_CODE, 373 /** @SKB_DROP_REASON_IPV6_NDISC_BAD_OPTIONS: invalid NDISC options. */ 374 SKB_DROP_REASON_IPV6_NDISC_BAD_OPTIONS, 375 /** 376 * @SKB_DROP_REASON_IPV6_NDISC_NS_OTHERHOST: NEIGHBOUR SOLICITATION 377 * for another host. 378 */ 379 SKB_DROP_REASON_IPV6_NDISC_NS_OTHERHOST, 380 /** @SKB_DROP_REASON_QUEUE_PURGE: bulk free. */ 381 SKB_DROP_REASON_QUEUE_PURGE, 382 /** 383 * @SKB_DROP_REASON_TC_COOKIE_ERROR: An error occurred whilst 384 * processing a tc ext cookie. 385 */ 386 SKB_DROP_REASON_TC_COOKIE_ERROR, 387 /** 388 * @SKB_DROP_REASON_PACKET_SOCK_ERROR: generic packet socket errors 389 * after its filter matches an incoming packet. 390 */ 391 SKB_DROP_REASON_PACKET_SOCK_ERROR, 392 /** @SKB_DROP_REASON_TC_CHAIN_NOTFOUND: tc chain lookup failed. */ 393 SKB_DROP_REASON_TC_CHAIN_NOTFOUND, 394 /** 395 * @SKB_DROP_REASON_TC_RECLASSIFY_LOOP: tc exceeded max reclassify loop 396 * iterations. 397 */ 398 SKB_DROP_REASON_TC_RECLASSIFY_LOOP, 399 /** 400 * @SKB_DROP_REASON_MAX: the maximum of core drop reasons, which 401 * shouldn't be used as a real 'reason' - only for tracing code gen 402 */ 403 SKB_DROP_REASON_MAX, 404 405 /** 406 * @SKB_DROP_REASON_SUBSYS_MASK: subsystem mask in drop reasons, 407 * see &enum skb_drop_reason_subsys 408 */ 409 SKB_DROP_REASON_SUBSYS_MASK = 0xffff0000, 410 }; 411 412 #define SKB_DROP_REASON_SUBSYS_SHIFT 16 413 414 #define SKB_DR_INIT(name, reason) \ 415 enum skb_drop_reason name = SKB_DROP_REASON_##reason 416 #define SKB_DR(name) \ 417 SKB_DR_INIT(name, NOT_SPECIFIED) 418 #define SKB_DR_SET(name, reason) \ 419 (name = SKB_DROP_REASON_##reason) 420 #define SKB_DR_OR(name, reason) \ 421 do { \ 422 if (name == SKB_DROP_REASON_NOT_SPECIFIED || \ 423 name == SKB_NOT_DROPPED_YET) \ 424 SKB_DR_SET(name, reason); \ 425 } while (0) 426 427 #endif 428