dropdump.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. #ifndef __NET_DROPDUMP_H
  2. #define __NET_DROPDUMP_H
  3. #include <linux/netdevice.h>
  4. #include <linux/version.h>
  5. //#define DRD_WQ
  6. /* vendor driver couldn't be used by builtin, with GKI.
  7. when using dropdump on GKI, check about that /trace/hoooks/net.h
  8. otherwise, by builtin driver, include /net/dropdump.h at /net/dst.h */
  9. /* add definition for logging */
  10. #define ETH_P_LOG 0x00FA
  11. #define SKB_CLONE 0
  12. #define SKB_STACK 1
  13. #define SKB_DUMMY 2
  14. #define ST_MAX 20
  15. #define ST_SIZE 0x30
  16. #define ST_BUF_SIZE (ST_SIZE * ST_MAX)
  17. #define ST_START 5
  18. #define DEBUG_LOG 0x01
  19. #define DEBUG_TRACE 0x02
  20. #define DEBUG_HASH 0x04
  21. #define DEBUG_SAVE 0x10
  22. #define DEBUG_RESTORE 0x20
  23. #define DEBUG_RAW 0x40
  24. #define PKTINFO_COPYLEN_MAX 0x100
  25. #define PKTINFO_OFFSET(skb) (*(u64 *)((u64)skb->data + skb->len - sizeof(u64)))
  26. #define LIMIT_DEPTH_BIT (1 << 0)
  27. #define UPDATE_TIME_BIT (1 << 1)
  28. #define RESTORE_FAIL_BIT (1 << 2)
  29. #define DRD_HSIZE 256
  30. struct _dmy_info {
  31. char magic[3];
  32. u8 depth;
  33. u8 flag;
  34. u8 reason_id;
  35. u16 skip_count;
  36. u64 count;
  37. char reason_str[16];
  38. u64 stack;
  39. } __packed;
  40. #ifdef DRD_WQ
  41. #define BUDGET_DEFAULT 64
  42. struct _drd_worker {
  43. struct workqueue_struct *wq;
  44. struct delayed_work dwork;
  45. struct list_head list;
  46. spinlock_t lock;
  47. u64 num;
  48. };
  49. #endif
  50. struct st_item {
  51. struct list_head list;
  52. u64 p;
  53. u64 matched;
  54. char st[ST_BUF_SIZE];
  55. };
  56. #if IS_ENABLED(CONFIG_SUPPORT_DROPDUMP)
  57. extern void trace_android_vh_ptype_head
  58. (const struct packet_type *pt, struct list_head *vendor_pt);
  59. extern void trace_android_vh_kfree_skb(struct sk_buff *skb);
  60. #else
  61. #define trace_android_vh_ptype_head(pt, vendor_pt)
  62. #define trace_android_vh_kfree_skb(skb)
  63. #endif
  64. const char *const drd_reasons[] = {
  65. #if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0))
  66. "UNUSED_KERN_VER",
  67. };
  68. #define DRD_REASON_MAX 1
  69. #else
  70. "NOT_SPECIFIED",
  71. "NO_SOCKET",
  72. "PKT_TOO_SMALL",
  73. "TCP_CSUM",
  74. "SOCKET_FILTER",
  75. "UDP_CSUM",
  76. "NETFILTER_DROP",
  77. "OTHERHOST",
  78. "IP_CSUM",
  79. "IP_INHDR",
  80. "IP_RPFILTER",
  81. "UNICAST_IN_L2_MULTICAST",
  82. "XFRM_POLICY",
  83. "IP_NOPROTO",
  84. "SOCKET_RCVBUFF",
  85. "PROTO_MEM",
  86. "TCP_MD5NOTFOUND",
  87. "TCP_MD5UNEXPECTED",
  88. "TCP_MD5FAILURE",
  89. "SOCKET_BACKLOG",
  90. "TCP_FLAGS",
  91. "TCP_ZEROWINDOW",
  92. "TCP_OLD_DATA",
  93. "TCP_OVERWINDOW",
  94. "TCP_OFOMERGE",
  95. "TCP_RFC7323_PAWS",
  96. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0))
  97. "TCP_OLD_SEQUENCE",
  98. #endif
  99. "TCP_INVALID_SEQUENCE",
  100. "TCP_RESET",
  101. "TCP_INVALID_SYN",
  102. "TCP_CLOSE",
  103. "TCP_FASTOPEN",
  104. "TCP_OLD_ACK",
  105. "TCP_TOO_OLD_ACK",
  106. "TCP_ACK_UNSENT_DATA",
  107. "TCP_OFO_QUEUE_PRUNE",
  108. "TCP_OFO_DROP",
  109. "IP_OUTNOROUTES",
  110. "BPF_CGROUP_EGRESS",
  111. "IPV6DISABLED",
  112. "NEIGH_CREATEFAIL",
  113. "NEIGH_FAILED",
  114. "NEIGH_QUEUEFULL",
  115. "NEIGH_DEAD",
  116. "TC_EGRESS",
  117. "QDISC_DROP",
  118. "CPU_BACKLOG",
  119. "XDP",
  120. "TC_INGRESS",
  121. "UNHANDLED_PROTO",
  122. "SKB_CSUM",
  123. "SKB_GSO_SEG",
  124. "SKB_UCOPY_FAULT",
  125. "DEV_HDR",
  126. "DEV_READY",
  127. "FULL_RING",
  128. "NOMEM",
  129. "HDR_TRUNC",
  130. "TAP_FILTER",
  131. "TAP_TXFILTER",
  132. "ICMP_CSUM",
  133. "INVALID_PROTO",
  134. "IP_INADDRERRORS",
  135. "IP_INNOROUTES",
  136. "PKT_TOO_BIG",
  137. #if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0))
  138. };
  139. #define DRD_REASON_MAX 64
  140. #else
  141. "DUP_FRAG",
  142. "FRAG_REASM_TIMEOUT",
  143. "FRAG_TOO_FAR",
  144. "TCP_MINTTL",
  145. "IPV6_BAD_EXTHDR",
  146. "IPV6_NDISC_FRAG",
  147. "IPV6_NDISC_HOP_LIMIT",
  148. "IPV6_NDISC_BAD_CODE",
  149. "IPV6_NDISC_BAD_OPTIONS",
  150. "IPV6_NDISC_NS_OTHERHOST",
  151. "QUEUE_PURGE",
  152. };
  153. #define DRD_REASON_MAX 76
  154. #endif
  155. #endif
  156. #endif //__NET_DROPDUMP_H