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 FNe(MAX) 72 73 /** 74 * enum skb_drop_reason - the reasons of skb drops 75 * 76 * The reason of skb drop, which is used in kfree_skb_reason(). 77 */ 78 enum skb_drop_reason { 79 /** 80 * @SKB_NOT_DROPPED_YET: skb is not dropped yet (used for no-drop case) 81 */ 82 SKB_NOT_DROPPED_YET = 0, 83 /** @SKB_DROP_REASON_NOT_SPECIFIED: drop reason is not specified */ 84 SKB_DROP_REASON_NOT_SPECIFIED, 85 /** @SKB_DROP_REASON_NO_SOCKET: socket not found */ 86 SKB_DROP_REASON_NO_SOCKET, 87 /** @SKB_DROP_REASON_PKT_TOO_SMALL: packet size is too small */ 88 SKB_DROP_REASON_PKT_TOO_SMALL, 89 /** @SKB_DROP_REASON_TCP_CSUM: TCP checksum error */ 90 SKB_DROP_REASON_TCP_CSUM, 91 /** @SKB_DROP_REASON_SOCKET_FILTER: dropped by socket filter */ 92 SKB_DROP_REASON_SOCKET_FILTER, 93 /** @SKB_DROP_REASON_UDP_CSUM: UDP checksum error */ 94 SKB_DROP_REASON_UDP_CSUM, 95 /** @SKB_DROP_REASON_NETFILTER_DROP: dropped by netfilter */ 96 SKB_DROP_REASON_NETFILTER_DROP, 97 /** 98 * @SKB_DROP_REASON_OTHERHOST: packet don't belong to current host 99 * (interface is in promisc mode) 100 */ 101 SKB_DROP_REASON_OTHERHOST, 102 /** @SKB_DROP_REASON_IP_CSUM: IP checksum error */ 103 SKB_DROP_REASON_IP_CSUM, 104 /** 105 * @SKB_DROP_REASON_IP_INHDR: there is something wrong with IP header (see 106 * IPSTATS_MIB_INHDRERRORS) 107 */ 108 SKB_DROP_REASON_IP_INHDR, 109 /** 110 * @SKB_DROP_REASON_IP_RPFILTER: IP rpfilter validate failed. see the 111 * document for rp_filter in ip-sysctl.rst for more information 112 */ 113 SKB_DROP_REASON_IP_RPFILTER, 114 /** 115 * @SKB_DROP_REASON_UNICAST_IN_L2_MULTICAST: destination address of L2 is 116 * multicast, but L3 is unicast. 117 */ 118 SKB_DROP_REASON_UNICAST_IN_L2_MULTICAST, 119 /** @SKB_DROP_REASON_XFRM_POLICY: xfrm policy check failed */ 120 SKB_DROP_REASON_XFRM_POLICY, 121 /** @SKB_DROP_REASON_IP_NOPROTO: no support for IP protocol */ 122 SKB_DROP_REASON_IP_NOPROTO, 123 /** @SKB_DROP_REASON_SOCKET_RCVBUFF: socket receive buff is full */ 124 SKB_DROP_REASON_SOCKET_RCVBUFF, 125 /** 126 * @SKB_DROP_REASON_PROTO_MEM: proto memory limition, such as udp packet 127 * drop out of udp_memory_allocated. 128 */ 129 SKB_DROP_REASON_PROTO_MEM, 130 /** 131 * @SKB_DROP_REASON_TCP_MD5NOTFOUND: no MD5 hash and one expected, 132 * corresponding to LINUX_MIB_TCPMD5NOTFOUND 133 */ 134 SKB_DROP_REASON_TCP_MD5NOTFOUND, 135 /** 136 * @SKB_DROP_REASON_TCP_MD5UNEXPECTED: MD5 hash and we're not expecting 137 * one, corresponding to LINUX_MIB_TCPMD5UNEXPECTED 138 */ 139 SKB_DROP_REASON_TCP_MD5UNEXPECTED, 140 /** 141 * @SKB_DROP_REASON_TCP_MD5FAILURE: MD5 hash and its wrong, corresponding 142 * to LINUX_MIB_TCPMD5FAILURE 143 */ 144 SKB_DROP_REASON_TCP_MD5FAILURE, 145 /** 146 * @SKB_DROP_REASON_SOCKET_BACKLOG: failed to add skb to socket backlog ( 147 * see LINUX_MIB_TCPBACKLOGDROP) 148 */ 149 SKB_DROP_REASON_SOCKET_BACKLOG, 150 /** @SKB_DROP_REASON_TCP_FLAGS: TCP flags invalid */ 151 SKB_DROP_REASON_TCP_FLAGS, 152 /** 153 * @SKB_DROP_REASON_TCP_ZEROWINDOW: TCP receive window size is zero, 154 * see LINUX_MIB_TCPZEROWINDOWDROP 155 */ 156 SKB_DROP_REASON_TCP_ZEROWINDOW, 157 /** 158 * @SKB_DROP_REASON_TCP_OLD_DATA: the TCP data reveived is already 159 * received before (spurious retrans may happened), see 160 * LINUX_MIB_DELAYEDACKLOST 161 */ 162 SKB_DROP_REASON_TCP_OLD_DATA, 163 /** 164 * @SKB_DROP_REASON_TCP_OVERWINDOW: the TCP data is out of window, 165 * the seq of the first byte exceed the right edges of receive 166 * window 167 */ 168 SKB_DROP_REASON_TCP_OVERWINDOW, 169 /** 170 * @SKB_DROP_REASON_TCP_OFOMERGE: the data of skb is already in the ofo 171 * queue, corresponding to LINUX_MIB_TCPOFOMERGE 172 */ 173 SKB_DROP_REASON_TCP_OFOMERGE, 174 /** 175 * @SKB_DROP_REASON_TCP_RFC7323_PAWS: PAWS check, corresponding to 176 * LINUX_MIB_PAWSESTABREJECTED 177 */ 178 SKB_DROP_REASON_TCP_RFC7323_PAWS, 179 /** @SKB_DROP_REASON_TCP_INVALID_SEQUENCE: Not acceptable SEQ field */ 180 SKB_DROP_REASON_TCP_INVALID_SEQUENCE, 181 /** @SKB_DROP_REASON_TCP_RESET: Invalid RST packet */ 182 SKB_DROP_REASON_TCP_RESET, 183 /** 184 * @SKB_DROP_REASON_TCP_INVALID_SYN: Incoming packet has unexpected 185 * SYN flag 186 */ 187 SKB_DROP_REASON_TCP_INVALID_SYN, 188 /** @SKB_DROP_REASON_TCP_CLOSE: TCP socket in CLOSE state */ 189 SKB_DROP_REASON_TCP_CLOSE, 190 /** @SKB_DROP_REASON_TCP_FASTOPEN: dropped by FASTOPEN request socket */ 191 SKB_DROP_REASON_TCP_FASTOPEN, 192 /** @SKB_DROP_REASON_TCP_OLD_ACK: TCP ACK is old, but in window */ 193 SKB_DROP_REASON_TCP_OLD_ACK, 194 /** @SKB_DROP_REASON_TCP_TOO_OLD_ACK: TCP ACK is too old */ 195 SKB_DROP_REASON_TCP_TOO_OLD_ACK, 196 /** 197 * @SKB_DROP_REASON_TCP_ACK_UNSENT_DATA: TCP ACK for data we haven't 198 * sent yet 199 */ 200 SKB_DROP_REASON_TCP_ACK_UNSENT_DATA, 201 /** @SKB_DROP_REASON_TCP_OFO_QUEUE_PRUNE: pruned from TCP OFO queue */ 202 SKB_DROP_REASON_TCP_OFO_QUEUE_PRUNE, 203 /** @SKB_DROP_REASON_TCP_OFO_DROP: data already in receive queue */ 204 SKB_DROP_REASON_TCP_OFO_DROP, 205 /** @SKB_DROP_REASON_IP_OUTNOROUTES: route lookup failed */ 206 SKB_DROP_REASON_IP_OUTNOROUTES, 207 /** 208 * @SKB_DROP_REASON_BPF_CGROUP_EGRESS: dropped by BPF_PROG_TYPE_CGROUP_SKB 209 * eBPF program 210 */ 211 SKB_DROP_REASON_BPF_CGROUP_EGRESS, 212 /** @SKB_DROP_REASON_IPV6DISABLED: IPv6 is disabled on the device */ 213 SKB_DROP_REASON_IPV6DISABLED, 214 /** @SKB_DROP_REASON_NEIGH_CREATEFAIL: failed to create neigh entry */ 215 SKB_DROP_REASON_NEIGH_CREATEFAIL, 216 /** @SKB_DROP_REASON_NEIGH_FAILED: neigh entry in failed state */ 217 SKB_DROP_REASON_NEIGH_FAILED, 218 /** @SKB_DROP_REASON_NEIGH_QUEUEFULL: arp_queue for neigh entry is full */ 219 SKB_DROP_REASON_NEIGH_QUEUEFULL, 220 /** @SKB_DROP_REASON_NEIGH_DEAD: neigh entry is dead */ 221 SKB_DROP_REASON_NEIGH_DEAD, 222 /** @SKB_DROP_REASON_TC_EGRESS: dropped in TC egress HOOK */ 223 SKB_DROP_REASON_TC_EGRESS, 224 /** 225 * @SKB_DROP_REASON_QDISC_DROP: dropped by qdisc when packet outputting ( 226 * failed to enqueue to current qdisc) 227 */ 228 SKB_DROP_REASON_QDISC_DROP, 229 /** 230 * @SKB_DROP_REASON_CPU_BACKLOG: failed to enqueue the skb to the per CPU 231 * backlog queue. This can be caused by backlog queue full (see 232 * netdev_max_backlog in net.rst) or RPS flow limit 233 */ 234 SKB_DROP_REASON_CPU_BACKLOG, 235 /** @SKB_DROP_REASON_XDP: dropped by XDP in input path */ 236 SKB_DROP_REASON_XDP, 237 /** @SKB_DROP_REASON_TC_INGRESS: dropped in TC ingress HOOK */ 238 SKB_DROP_REASON_TC_INGRESS, 239 /** @SKB_DROP_REASON_UNHANDLED_PROTO: protocol not implemented or not supported */ 240 SKB_DROP_REASON_UNHANDLED_PROTO, 241 /** @SKB_DROP_REASON_SKB_CSUM: sk_buff checksum computation error */ 242 SKB_DROP_REASON_SKB_CSUM, 243 /** @SKB_DROP_REASON_SKB_GSO_SEG: gso segmentation error */ 244 SKB_DROP_REASON_SKB_GSO_SEG, 245 /** 246 * @SKB_DROP_REASON_SKB_UCOPY_FAULT: failed to copy data from user space, 247 * e.g., via zerocopy_sg_from_iter() or skb_orphan_frags_rx() 248 */ 249 SKB_DROP_REASON_SKB_UCOPY_FAULT, 250 /** @SKB_DROP_REASON_DEV_HDR: device driver specific header/metadata is invalid */ 251 SKB_DROP_REASON_DEV_HDR, 252 /** 253 * @SKB_DROP_REASON_DEV_READY: the device is not ready to xmit/recv due to 254 * any of its data structure that is not up/ready/initialized, 255 * e.g., the IFF_UP is not set, or driver specific tun->tfiles[txq] 256 * is not initialized 257 */ 258 SKB_DROP_REASON_DEV_READY, 259 /** @SKB_DROP_REASON_FULL_RING: ring buffer is full */ 260 SKB_DROP_REASON_FULL_RING, 261 /** @SKB_DROP_REASON_NOMEM: error due to OOM */ 262 SKB_DROP_REASON_NOMEM, 263 /** 264 * @SKB_DROP_REASON_HDR_TRUNC: failed to trunc/extract the header from 265 * networking data, e.g., failed to pull the protocol header from 266 * frags via pskb_may_pull() 267 */ 268 SKB_DROP_REASON_HDR_TRUNC, 269 /** 270 * @SKB_DROP_REASON_TAP_FILTER: dropped by (ebpf) filter directly attached 271 * to tun/tap, e.g., via TUNSETFILTEREBPF 272 */ 273 SKB_DROP_REASON_TAP_FILTER, 274 /** 275 * @SKB_DROP_REASON_TAP_TXFILTER: dropped by tx filter implemented at 276 * tun/tap, e.g., check_filter() 277 */ 278 SKB_DROP_REASON_TAP_TXFILTER, 279 /** @SKB_DROP_REASON_ICMP_CSUM: ICMP checksum error */ 280 SKB_DROP_REASON_ICMP_CSUM, 281 /** 282 * @SKB_DROP_REASON_INVALID_PROTO: the packet doesn't follow RFC 2211, 283 * such as a broadcasts ICMP_TIMESTAMP 284 */ 285 SKB_DROP_REASON_INVALID_PROTO, 286 /** 287 * @SKB_DROP_REASON_IP_INADDRERRORS: host unreachable, corresponding to 288 * IPSTATS_MIB_INADDRERRORS 289 */ 290 SKB_DROP_REASON_IP_INADDRERRORS, 291 /** 292 * @SKB_DROP_REASON_IP_INNOROUTES: network unreachable, corresponding to 293 * IPSTATS_MIB_INADDRERRORS 294 */ 295 SKB_DROP_REASON_IP_INNOROUTES, 296 /** 297 * @SKB_DROP_REASON_PKT_TOO_BIG: packet size is too big (maybe exceed the 298 * MTU) 299 */ 300 SKB_DROP_REASON_PKT_TOO_BIG, 301 /** 302 * @SKB_DROP_REASON_MAX: the maximum of drop reason, which shouldn't be 303 * used as a real 'reason' 304 */ 305 SKB_DROP_REASON_MAX, 306 }; 307 308 #define SKB_DR_INIT(name, reason) \ 309 enum skb_drop_reason name = SKB_DROP_REASON_##reason 310 #define SKB_DR(name) \ 311 SKB_DR_INIT(name, NOT_SPECIFIED) 312 #define SKB_DR_SET(name, reason) \ 313 (name = SKB_DROP_REASON_##reason) 314 #define SKB_DR_OR(name, reason) \ 315 do { \ 316 if (name == SKB_DROP_REASON_NOT_SPECIFIED || \ 317 name == SKB_NOT_DROPPED_YET) \ 318 SKB_DR_SET(name, reason); \ 319 } while (0) 320 321 extern const char * const drop_reasons[]; 322 323 #endif 324