Skip to content

Commit ba36c5b

Browse files
author
Paolo Abeni
committed
Merge branch 'reorganize-the-code-of-the-enum-skb_drop_reason'
Menglong Dong says: ==================== reorganize the code of the enum skb_drop_reason The code of skb_drop_reason is a little wild, let's reorganize them. Three things and three patches: 1) Move the enum 'skb_drop_reason' and related function to the standalone header 'dropreason.h', as Jakub Kicinski suggested, as the skb drop reasons are getting more and more. 2) use auto-generation to generate the source file that convert enum skb_drop_reason to string. 3) make the comment of skb drop reasons kernel-doc style. Changes since v3: 3/3: remove some useless comment (Jakub Kicinski) Changes since v2: 2/3: - add new line in the end of .gitignore - fix awk warning by make '\;' to ';', as ';' is not need to be escaped - export 'drop_reasons' in skbuff.c Changes since v1: 1/3: move dropreason.h from include/linux/ to include/net/ (Jakub Kicinski) 2/3: generate source file instead of header file for drop reasons string array (Jakub Kicinski) 3/3: use inline comment (Jakub Kicinski) ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents 12de1eb + b160f72 commit ba36c5b

File tree

7 files changed

+284
-280
lines changed

7 files changed

+284
-280
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.

0 commit comments

Comments
 (0)