pkt_cls.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. #ifndef __LINUX_PKT_CLS_H
  2. #define __LINUX_PKT_CLS_H
  3. #include <linux/types.h>
  4. #include <linux/pkt_sched.h>
  5. /* Action attributes */
  6. enum {
  7. TCA_ACT_UNSPEC,
  8. TCA_ACT_KIND,
  9. TCA_ACT_OPTIONS,
  10. TCA_ACT_INDEX,
  11. TCA_ACT_STATS,
  12. __TCA_ACT_MAX
  13. };
  14. #define TCA_ACT_MAX __TCA_ACT_MAX
  15. #define TCA_OLD_COMPAT (TCA_ACT_MAX+1)
  16. #define TCA_ACT_MAX_PRIO 32
  17. #define TCA_ACT_BIND 1
  18. #define TCA_ACT_NOBIND 0
  19. #define TCA_ACT_UNBIND 1
  20. #define TCA_ACT_NOUNBIND 0
  21. #define TCA_ACT_REPLACE 1
  22. #define TCA_ACT_NOREPLACE 0
  23. #define TC_ACT_UNSPEC (-1)
  24. #define TC_ACT_OK 0
  25. #define TC_ACT_RECLASSIFY 1
  26. #define TC_ACT_SHOT 2
  27. #define TC_ACT_PIPE 3
  28. #define TC_ACT_STOLEN 4
  29. #define TC_ACT_QUEUED 5
  30. #define TC_ACT_REPEAT 6
  31. #define TC_ACT_REDIRECT 7
  32. #define TC_ACT_JUMP 0x10000000
  33. /* Action type identifiers*/
  34. enum {
  35. TCA_ID_UNSPEC=0,
  36. TCA_ID_POLICE=1,
  37. /* other actions go here */
  38. __TCA_ID_MAX=255
  39. };
  40. #define TCA_ID_MAX __TCA_ID_MAX
  41. struct tc_police {
  42. __u32 index;
  43. int action;
  44. #define TC_POLICE_UNSPEC TC_ACT_UNSPEC
  45. #define TC_POLICE_OK TC_ACT_OK
  46. #define TC_POLICE_RECLASSIFY TC_ACT_RECLASSIFY
  47. #define TC_POLICE_SHOT TC_ACT_SHOT
  48. #define TC_POLICE_PIPE TC_ACT_PIPE
  49. __u32 limit;
  50. __u32 burst;
  51. __u32 mtu;
  52. struct tc_ratespec rate;
  53. struct tc_ratespec peakrate;
  54. int refcnt;
  55. int bindcnt;
  56. __u32 capab;
  57. };
  58. struct tcf_t {
  59. __u64 install;
  60. __u64 lastuse;
  61. __u64 expires;
  62. };
  63. struct tc_cnt {
  64. int refcnt;
  65. int bindcnt;
  66. };
  67. #define tc_gen \
  68. __u32 index; \
  69. __u32 capab; \
  70. int action; \
  71. int refcnt; \
  72. int bindcnt
  73. enum {
  74. TCA_POLICE_UNSPEC,
  75. TCA_POLICE_TBF,
  76. TCA_POLICE_RATE,
  77. TCA_POLICE_PEAKRATE,
  78. TCA_POLICE_AVRATE,
  79. TCA_POLICE_RESULT,
  80. __TCA_POLICE_MAX
  81. #define TCA_POLICE_RESULT TCA_POLICE_RESULT
  82. };
  83. #define TCA_POLICE_MAX (__TCA_POLICE_MAX - 1)
  84. /* U32 filters */
  85. #define TC_U32_HTID(h) ((h)&0xFFF00000)
  86. #define TC_U32_USERHTID(h) (TC_U32_HTID(h)>>20)
  87. #define TC_U32_HASH(h) (((h)>>12)&0xFF)
  88. #define TC_U32_NODE(h) ((h)&0xFFF)
  89. #define TC_U32_KEY(h) ((h)&0xFFFFF)
  90. #define TC_U32_UNSPEC 0
  91. #define TC_U32_ROOT (0xFFF00000)
  92. enum {
  93. TCA_U32_UNSPEC,
  94. TCA_U32_CLASSID,
  95. TCA_U32_HASH,
  96. TCA_U32_LINK,
  97. TCA_U32_DIVISOR,
  98. TCA_U32_SEL,
  99. TCA_U32_POLICE,
  100. TCA_U32_ACT,
  101. TCA_U32_INDEV,
  102. TCA_U32_PCNT,
  103. TCA_U32_MARK,
  104. __TCA_U32_MAX
  105. };
  106. #define TCA_U32_MAX (__TCA_U32_MAX - 1)
  107. struct tc_u32_key {
  108. __be32 mask;
  109. __be32 val;
  110. int off;
  111. int offmask;
  112. };
  113. struct tc_u32_sel {
  114. unsigned char flags;
  115. unsigned char offshift;
  116. unsigned char nkeys;
  117. __be16 offmask;
  118. __u16 off;
  119. short offoff;
  120. short hoff;
  121. __be32 hmask;
  122. struct tc_u32_key keys[0];
  123. };
  124. struct tc_u32_mark {
  125. __u32 val;
  126. __u32 mask;
  127. __u32 success;
  128. };
  129. struct tc_u32_pcnt {
  130. __u64 rcnt;
  131. __u64 rhit;
  132. __u64 kcnts[0];
  133. };
  134. /* Flags */
  135. #define TC_U32_TERMINAL 1
  136. #define TC_U32_OFFSET 2
  137. #define TC_U32_VAROFFSET 4
  138. #define TC_U32_EAT 8
  139. #define TC_U32_MAXDEPTH 8
  140. /* RSVP filter */
  141. enum {
  142. TCA_RSVP_UNSPEC,
  143. TCA_RSVP_CLASSID,
  144. TCA_RSVP_DST,
  145. TCA_RSVP_SRC,
  146. TCA_RSVP_PINFO,
  147. TCA_RSVP_POLICE,
  148. TCA_RSVP_ACT,
  149. __TCA_RSVP_MAX
  150. };
  151. #define TCA_RSVP_MAX (__TCA_RSVP_MAX - 1 )
  152. struct tc_rsvp_gpi {
  153. __u32 key;
  154. __u32 mask;
  155. int offset;
  156. };
  157. struct tc_rsvp_pinfo {
  158. struct tc_rsvp_gpi dpi;
  159. struct tc_rsvp_gpi spi;
  160. __u8 protocol;
  161. __u8 tunnelid;
  162. __u8 tunnelhdr;
  163. __u8 pad;
  164. };
  165. /* ROUTE filter */
  166. enum {
  167. TCA_ROUTE4_UNSPEC,
  168. TCA_ROUTE4_CLASSID,
  169. TCA_ROUTE4_TO,
  170. TCA_ROUTE4_FROM,
  171. TCA_ROUTE4_IIF,
  172. TCA_ROUTE4_POLICE,
  173. TCA_ROUTE4_ACT,
  174. __TCA_ROUTE4_MAX
  175. };
  176. #define TCA_ROUTE4_MAX (__TCA_ROUTE4_MAX - 1)
  177. /* FW filter */
  178. enum {
  179. TCA_FW_UNSPEC,
  180. TCA_FW_CLASSID,
  181. TCA_FW_POLICE,
  182. TCA_FW_INDEV, /* used by CONFIG_NET_CLS_IND */
  183. TCA_FW_ACT, /* used by CONFIG_NET_CLS_ACT */
  184. TCA_FW_MASK,
  185. __TCA_FW_MAX
  186. };
  187. #define TCA_FW_MAX (__TCA_FW_MAX - 1)
  188. /* TC index filter */
  189. enum {
  190. TCA_TCINDEX_UNSPEC,
  191. TCA_TCINDEX_HASH,
  192. TCA_TCINDEX_MASK,
  193. TCA_TCINDEX_SHIFT,
  194. TCA_TCINDEX_FALL_THROUGH,
  195. TCA_TCINDEX_CLASSID,
  196. TCA_TCINDEX_POLICE,
  197. TCA_TCINDEX_ACT,
  198. __TCA_TCINDEX_MAX
  199. };
  200. #define TCA_TCINDEX_MAX (__TCA_TCINDEX_MAX - 1)
  201. /* Flow filter */
  202. enum {
  203. FLOW_KEY_SRC,
  204. FLOW_KEY_DST,
  205. FLOW_KEY_PROTO,
  206. FLOW_KEY_PROTO_SRC,
  207. FLOW_KEY_PROTO_DST,
  208. FLOW_KEY_IIF,
  209. FLOW_KEY_PRIORITY,
  210. FLOW_KEY_MARK,
  211. FLOW_KEY_NFCT,
  212. FLOW_KEY_NFCT_SRC,
  213. FLOW_KEY_NFCT_DST,
  214. FLOW_KEY_NFCT_PROTO_SRC,
  215. FLOW_KEY_NFCT_PROTO_DST,
  216. FLOW_KEY_RTCLASSID,
  217. FLOW_KEY_SKUID,
  218. FLOW_KEY_SKGID,
  219. FLOW_KEY_VLAN_TAG,
  220. FLOW_KEY_RXHASH,
  221. __FLOW_KEY_MAX,
  222. };
  223. #define FLOW_KEY_MAX (__FLOW_KEY_MAX - 1)
  224. enum {
  225. FLOW_MODE_MAP,
  226. FLOW_MODE_HASH,
  227. };
  228. enum {
  229. TCA_FLOW_UNSPEC,
  230. TCA_FLOW_KEYS,
  231. TCA_FLOW_MODE,
  232. TCA_FLOW_BASECLASS,
  233. TCA_FLOW_RSHIFT,
  234. TCA_FLOW_ADDEND,
  235. TCA_FLOW_MASK,
  236. TCA_FLOW_XOR,
  237. TCA_FLOW_DIVISOR,
  238. TCA_FLOW_ACT,
  239. TCA_FLOW_POLICE,
  240. TCA_FLOW_EMATCHES,
  241. TCA_FLOW_PERTURB,
  242. __TCA_FLOW_MAX
  243. };
  244. #define TCA_FLOW_MAX (__TCA_FLOW_MAX - 1)
  245. /* Basic filter */
  246. enum {
  247. TCA_BASIC_UNSPEC,
  248. TCA_BASIC_CLASSID,
  249. TCA_BASIC_EMATCHES,
  250. TCA_BASIC_ACT,
  251. TCA_BASIC_POLICE,
  252. __TCA_BASIC_MAX
  253. };
  254. #define TCA_BASIC_MAX (__TCA_BASIC_MAX - 1)
  255. /* Cgroup classifier */
  256. enum {
  257. TCA_CGROUP_UNSPEC,
  258. TCA_CGROUP_ACT,
  259. TCA_CGROUP_POLICE,
  260. TCA_CGROUP_EMATCHES,
  261. __TCA_CGROUP_MAX,
  262. };
  263. #define TCA_CGROUP_MAX (__TCA_CGROUP_MAX - 1)
  264. /* BPF classifier */
  265. #define TCA_BPF_FLAG_ACT_DIRECT (1 << 0)
  266. enum {
  267. TCA_BPF_UNSPEC,
  268. TCA_BPF_ACT,
  269. TCA_BPF_POLICE,
  270. TCA_BPF_CLASSID,
  271. TCA_BPF_OPS_LEN,
  272. TCA_BPF_OPS,
  273. TCA_BPF_FD,
  274. TCA_BPF_NAME,
  275. TCA_BPF_FLAGS,
  276. __TCA_BPF_MAX,
  277. };
  278. #define TCA_BPF_MAX (__TCA_BPF_MAX - 1)
  279. /* Flower classifier */
  280. enum {
  281. TCA_FLOWER_UNSPEC,
  282. TCA_FLOWER_CLASSID,
  283. TCA_FLOWER_INDEV,
  284. TCA_FLOWER_ACT,
  285. TCA_FLOWER_KEY_ETH_DST, /* ETH_ALEN */
  286. TCA_FLOWER_KEY_ETH_DST_MASK, /* ETH_ALEN */
  287. TCA_FLOWER_KEY_ETH_SRC, /* ETH_ALEN */
  288. TCA_FLOWER_KEY_ETH_SRC_MASK, /* ETH_ALEN */
  289. TCA_FLOWER_KEY_ETH_TYPE, /* be16 */
  290. TCA_FLOWER_KEY_IP_PROTO, /* u8 */
  291. TCA_FLOWER_KEY_IPV4_SRC, /* be32 */
  292. TCA_FLOWER_KEY_IPV4_SRC_MASK, /* be32 */
  293. TCA_FLOWER_KEY_IPV4_DST, /* be32 */
  294. TCA_FLOWER_KEY_IPV4_DST_MASK, /* be32 */
  295. TCA_FLOWER_KEY_IPV6_SRC, /* struct in6_addr */
  296. TCA_FLOWER_KEY_IPV6_SRC_MASK, /* struct in6_addr */
  297. TCA_FLOWER_KEY_IPV6_DST, /* struct in6_addr */
  298. TCA_FLOWER_KEY_IPV6_DST_MASK, /* struct in6_addr */
  299. TCA_FLOWER_KEY_TCP_SRC, /* be16 */
  300. TCA_FLOWER_KEY_TCP_DST, /* be16 */
  301. TCA_FLOWER_KEY_UDP_SRC, /* be16 */
  302. TCA_FLOWER_KEY_UDP_DST, /* be16 */
  303. __TCA_FLOWER_MAX,
  304. };
  305. #define TCA_FLOWER_MAX (__TCA_FLOWER_MAX - 1)
  306. /* Extended Matches */
  307. struct tcf_ematch_tree_hdr {
  308. __u16 nmatches;
  309. __u16 progid;
  310. };
  311. enum {
  312. TCA_EMATCH_TREE_UNSPEC,
  313. TCA_EMATCH_TREE_HDR,
  314. TCA_EMATCH_TREE_LIST,
  315. __TCA_EMATCH_TREE_MAX
  316. };
  317. #define TCA_EMATCH_TREE_MAX (__TCA_EMATCH_TREE_MAX - 1)
  318. struct tcf_ematch_hdr {
  319. __u16 matchid;
  320. __u16 kind;
  321. __u16 flags;
  322. __u16 pad; /* currently unused */
  323. };
  324. /* 0 1
  325. * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
  326. * +-----------------------+-+-+---+
  327. * | Unused |S|I| R |
  328. * +-----------------------+-+-+---+
  329. *
  330. * R(2) ::= relation to next ematch
  331. * where: 0 0 END (last ematch)
  332. * 0 1 AND
  333. * 1 0 OR
  334. * 1 1 Unused (invalid)
  335. * I(1) ::= invert result
  336. * S(1) ::= simple payload
  337. */
  338. #define TCF_EM_REL_END 0
  339. #define TCF_EM_REL_AND (1<<0)
  340. #define TCF_EM_REL_OR (1<<1)
  341. #define TCF_EM_INVERT (1<<2)
  342. #define TCF_EM_SIMPLE (1<<3)
  343. #define TCF_EM_REL_MASK 3
  344. #define TCF_EM_REL_VALID(v) (((v) & TCF_EM_REL_MASK) != TCF_EM_REL_MASK)
  345. enum {
  346. TCF_LAYER_LINK,
  347. TCF_LAYER_NETWORK,
  348. TCF_LAYER_TRANSPORT,
  349. __TCF_LAYER_MAX
  350. };
  351. #define TCF_LAYER_MAX (__TCF_LAYER_MAX - 1)
  352. /* Ematch type assignments
  353. * 1..32767 Reserved for ematches inside kernel tree
  354. * 32768..65535 Free to use, not reliable
  355. */
  356. #define TCF_EM_CONTAINER 0
  357. #define TCF_EM_CMP 1
  358. #define TCF_EM_NBYTE 2
  359. #define TCF_EM_U32 3
  360. #define TCF_EM_META 4
  361. #define TCF_EM_TEXT 5
  362. #define TCF_EM_VLAN 6
  363. #define TCF_EM_CANID 7
  364. #define TCF_EM_IPSET 8
  365. #define TCF_EM_MAX 8
  366. enum {
  367. TCF_EM_PROG_TC
  368. };
  369. enum {
  370. TCF_EM_OPND_EQ,
  371. TCF_EM_OPND_GT,
  372. TCF_EM_OPND_LT
  373. };
  374. #endif