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