Skip to content

Commit ff8372a

Browse files
menglongdongPaolo Abeni
authored andcommitted
net: skb: move enum skb_drop_reason to standalone header file
As the skb drop reasons are getting more and more, move the enum 'skb_drop_reason' and related function to the standalone header 'dropreason.h', as Jakub Kicinski suggested. Signed-off-by: Menglong Dong <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 12de1eb commit ff8372a

File tree

2 files changed

+185
-178
lines changed

2 files changed

+185
-178
lines changed

include/linux/skbuff.h

Lines changed: 1 addition & 178 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include <linux/netfilter/nf_conntrack_common.h>
4444
#endif
4545
#include <net/net_debug.h>
46+
#include <net/dropreason.h>
4647

4748
/**
4849
* DOC: skb checksums
@@ -337,184 +338,6 @@ struct sk_buff_head {
337338

338339
struct sk_buff;
339340

340-
/* The reason of skb drop, which is used in kfree_skb_reason().
341-
* en...maybe they should be splited by group?
342-
*
343-
* Each item here should also be in 'TRACE_SKB_DROP_REASON', which is
344-
* used to translate the reason to string.
345-
*/
346-
enum skb_drop_reason {
347-
SKB_NOT_DROPPED_YET = 0,
348-
SKB_DROP_REASON_NOT_SPECIFIED, /* drop reason is not specified */
349-
SKB_DROP_REASON_NO_SOCKET, /* socket not found */
350-
SKB_DROP_REASON_PKT_TOO_SMALL, /* packet size is too small */
351-
SKB_DROP_REASON_TCP_CSUM, /* TCP checksum error */
352-
SKB_DROP_REASON_SOCKET_FILTER, /* dropped by socket filter */
353-
SKB_DROP_REASON_UDP_CSUM, /* UDP checksum error */
354-
SKB_DROP_REASON_NETFILTER_DROP, /* dropped by netfilter */
355-
SKB_DROP_REASON_OTHERHOST, /* packet don't belong to current
356-
* host (interface is in promisc
357-
* mode)
358-
*/
359-
SKB_DROP_REASON_IP_CSUM, /* IP checksum error */
360-
SKB_DROP_REASON_IP_INHDR, /* there is something wrong with
361-
* IP header (see
362-
* IPSTATS_MIB_INHDRERRORS)
363-
*/
364-
SKB_DROP_REASON_IP_RPFILTER, /* IP rpfilter validate failed.
365-
* see the document for rp_filter
366-
* in ip-sysctl.rst for more
367-
* information
368-
*/
369-
SKB_DROP_REASON_UNICAST_IN_L2_MULTICAST, /* destination address of L2
370-
* is multicast, but L3 is
371-
* unicast.
372-
*/
373-
SKB_DROP_REASON_XFRM_POLICY, /* xfrm policy check failed */
374-
SKB_DROP_REASON_IP_NOPROTO, /* no support for IP protocol */
375-
SKB_DROP_REASON_SOCKET_RCVBUFF, /* socket receive buff is full */
376-
SKB_DROP_REASON_PROTO_MEM, /* proto memory limition, such as
377-
* udp packet drop out of
378-
* udp_memory_allocated.
379-
*/
380-
SKB_DROP_REASON_TCP_MD5NOTFOUND, /* no MD5 hash and one
381-
* expected, corresponding
382-
* to LINUX_MIB_TCPMD5NOTFOUND
383-
*/
384-
SKB_DROP_REASON_TCP_MD5UNEXPECTED, /* MD5 hash and we're not
385-
* expecting one, corresponding
386-
* to LINUX_MIB_TCPMD5UNEXPECTED
387-
*/
388-
SKB_DROP_REASON_TCP_MD5FAILURE, /* MD5 hash and its wrong,
389-
* corresponding to
390-
* LINUX_MIB_TCPMD5FAILURE
391-
*/
392-
SKB_DROP_REASON_SOCKET_BACKLOG, /* failed to add skb to socket
393-
* backlog (see
394-
* LINUX_MIB_TCPBACKLOGDROP)
395-
*/
396-
SKB_DROP_REASON_TCP_FLAGS, /* TCP flags invalid */
397-
SKB_DROP_REASON_TCP_ZEROWINDOW, /* TCP receive window size is zero,
398-
* see LINUX_MIB_TCPZEROWINDOWDROP
399-
*/
400-
SKB_DROP_REASON_TCP_OLD_DATA, /* the TCP data reveived is already
401-
* received before (spurious retrans
402-
* may happened), see
403-
* LINUX_MIB_DELAYEDACKLOST
404-
*/
405-
SKB_DROP_REASON_TCP_OVERWINDOW, /* the TCP data is out of window,
406-
* the seq of the first byte exceed
407-
* the right edges of receive
408-
* window
409-
*/
410-
SKB_DROP_REASON_TCP_OFOMERGE, /* the data of skb is already in
411-
* the ofo queue, corresponding to
412-
* LINUX_MIB_TCPOFOMERGE
413-
*/
414-
SKB_DROP_REASON_TCP_RFC7323_PAWS, /* PAWS check, corresponding to
415-
* LINUX_MIB_PAWSESTABREJECTED
416-
*/
417-
SKB_DROP_REASON_TCP_INVALID_SEQUENCE, /* Not acceptable SEQ field */
418-
SKB_DROP_REASON_TCP_RESET, /* Invalid RST packet */
419-
SKB_DROP_REASON_TCP_INVALID_SYN, /* Incoming packet has unexpected SYN flag */
420-
SKB_DROP_REASON_TCP_CLOSE, /* TCP socket in CLOSE state */
421-
SKB_DROP_REASON_TCP_FASTOPEN, /* dropped by FASTOPEN request socket */
422-
SKB_DROP_REASON_TCP_OLD_ACK, /* TCP ACK is old, but in window */
423-
SKB_DROP_REASON_TCP_TOO_OLD_ACK, /* TCP ACK is too old */
424-
SKB_DROP_REASON_TCP_ACK_UNSENT_DATA, /* TCP ACK for data we haven't sent yet */
425-
SKB_DROP_REASON_TCP_OFO_QUEUE_PRUNE, /* pruned from TCP OFO queue */
426-
SKB_DROP_REASON_TCP_OFO_DROP, /* data already in receive queue */
427-
SKB_DROP_REASON_IP_OUTNOROUTES, /* route lookup failed */
428-
SKB_DROP_REASON_BPF_CGROUP_EGRESS, /* dropped by
429-
* BPF_PROG_TYPE_CGROUP_SKB
430-
* eBPF program
431-
*/
432-
SKB_DROP_REASON_IPV6DISABLED, /* IPv6 is disabled on the device */
433-
SKB_DROP_REASON_NEIGH_CREATEFAIL, /* failed to create neigh
434-
* entry
435-
*/
436-
SKB_DROP_REASON_NEIGH_FAILED, /* neigh entry in failed state */
437-
SKB_DROP_REASON_NEIGH_QUEUEFULL, /* arp_queue for neigh
438-
* entry is full
439-
*/
440-
SKB_DROP_REASON_NEIGH_DEAD, /* neigh entry is dead */
441-
SKB_DROP_REASON_TC_EGRESS, /* dropped in TC egress HOOK */
442-
SKB_DROP_REASON_QDISC_DROP, /* dropped by qdisc when packet
443-
* outputting (failed to enqueue to
444-
* current qdisc)
445-
*/
446-
SKB_DROP_REASON_CPU_BACKLOG, /* failed to enqueue the skb to
447-
* the per CPU backlog queue. This
448-
* can be caused by backlog queue
449-
* full (see netdev_max_backlog in
450-
* net.rst) or RPS flow limit
451-
*/
452-
SKB_DROP_REASON_XDP, /* dropped by XDP in input path */
453-
SKB_DROP_REASON_TC_INGRESS, /* dropped in TC ingress HOOK */
454-
SKB_DROP_REASON_UNHANDLED_PROTO, /* protocol not implemented
455-
* or not supported
456-
*/
457-
SKB_DROP_REASON_SKB_CSUM, /* sk_buff checksum computation
458-
* error
459-
*/
460-
SKB_DROP_REASON_SKB_GSO_SEG, /* gso segmentation error */
461-
SKB_DROP_REASON_SKB_UCOPY_FAULT, /* failed to copy data from
462-
* user space, e.g., via
463-
* zerocopy_sg_from_iter()
464-
* or skb_orphan_frags_rx()
465-
*/
466-
SKB_DROP_REASON_DEV_HDR, /* device driver specific
467-
* header/metadata is invalid
468-
*/
469-
/* the device is not ready to xmit/recv due to any of its data
470-
* structure that is not up/ready/initialized, e.g., the IFF_UP is
471-
* not set, or driver specific tun->tfiles[txq] is not initialized
472-
*/
473-
SKB_DROP_REASON_DEV_READY,
474-
SKB_DROP_REASON_FULL_RING, /* ring buffer is full */
475-
SKB_DROP_REASON_NOMEM, /* error due to OOM */
476-
SKB_DROP_REASON_HDR_TRUNC, /* failed to trunc/extract the header
477-
* from networking data, e.g., failed
478-
* to pull the protocol header from
479-
* frags via pskb_may_pull()
480-
*/
481-
SKB_DROP_REASON_TAP_FILTER, /* dropped by (ebpf) filter directly
482-
* attached to tun/tap, e.g., via
483-
* TUNSETFILTEREBPF
484-
*/
485-
SKB_DROP_REASON_TAP_TXFILTER, /* dropped by tx filter implemented
486-
* at tun/tap, e.g., check_filter()
487-
*/
488-
SKB_DROP_REASON_ICMP_CSUM, /* ICMP checksum error */
489-
SKB_DROP_REASON_INVALID_PROTO, /* the packet doesn't follow RFC
490-
* 2211, such as a broadcasts
491-
* ICMP_TIMESTAMP
492-
*/
493-
SKB_DROP_REASON_IP_INADDRERRORS, /* host unreachable, corresponding
494-
* to IPSTATS_MIB_INADDRERRORS
495-
*/
496-
SKB_DROP_REASON_IP_INNOROUTES, /* network unreachable, corresponding
497-
* to IPSTATS_MIB_INADDRERRORS
498-
*/
499-
SKB_DROP_REASON_PKT_TOO_BIG, /* packet size is too big (maybe exceed
500-
* the MTU)
501-
*/
502-
SKB_DROP_REASON_MAX,
503-
};
504-
505-
#define SKB_DR_INIT(name, reason) \
506-
enum skb_drop_reason name = SKB_DROP_REASON_##reason
507-
#define SKB_DR(name) \
508-
SKB_DR_INIT(name, NOT_SPECIFIED)
509-
#define SKB_DR_SET(name, reason) \
510-
(name = SKB_DROP_REASON_##reason)
511-
#define SKB_DR_OR(name, reason) \
512-
do { \
513-
if (name == SKB_DROP_REASON_NOT_SPECIFIED || \
514-
name == SKB_NOT_DROPPED_YET) \
515-
SKB_DR_SET(name, reason); \
516-
} while (0)
517-
518341
/* To allow 64K frame to be packed as single skb without frag_list we
519342
* require 64K/PAGE_SIZE pages plus 1 additional page to allow for
520343
* buffers which do not start on a page boundary.

include/net/dropreason.h

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

0 commit comments

Comments
 (0)