Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __LINUX_PKT_CLS_H |
| 2 | #define __LINUX_PKT_CLS_H |
| 3 | |
Jaswinder Singh Rajput | ed30744 | 2009-01-30 22:05:32 +0530 | [diff] [blame] | 4 | #include <linux/types.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | #include <linux/pkt_sched.h> |
| 6 | |
Florian Westphal | bd5850d | 2015-05-21 02:26:24 +0200 | [diff] [blame] | 7 | #ifdef __KERNEL__ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | /* I think i could have done better macros ; for now this is stolen from |
| 9 | * some arch/mips code - jhs |
| 10 | */ |
| 11 | #define _TC_MAKE32(x) ((x)) |
| 12 | |
| 13 | #define _TC_MAKEMASK1(n) (_TC_MAKE32(1) << _TC_MAKE32(n)) |
| 14 | #define _TC_MAKEMASK(v,n) (_TC_MAKE32((_TC_MAKE32(1)<<(v))-1) << _TC_MAKE32(n)) |
| 15 | #define _TC_MAKEVALUE(v,n) (_TC_MAKE32(v) << _TC_MAKE32(n)) |
| 16 | #define _TC_GETVALUE(v,n,m) ((_TC_MAKE32(v) & _TC_MAKE32(m)) >> _TC_MAKE32(n)) |
| 17 | |
| 18 | /* verdict bit breakdown |
| 19 | * |
| 20 | bit 0: when set -> this packet has been munged already |
| 21 | |
| 22 | bit 1: when set -> It is ok to munge this packet |
| 23 | |
| 24 | bit 2,3,4,5: Reclassify counter - sort of reverse TTL - if exceeded |
| 25 | assume loop |
| 26 | |
| 27 | bit 6,7: Where this packet was last seen |
| 28 | 0: Above the transmit example at the socket level |
| 29 | 1: on the Ingress |
| 30 | 2: on the Egress |
| 31 | |
| 32 | bit 8: when set --> Request not to classify on ingress. |
| 33 | |
| 34 | bits 9,10,11: redirect counter - redirect TTL. Loop avoidance |
| 35 | |
| 36 | * |
| 37 | * */ |
| 38 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | #define S_TC_FROM _TC_MAKE32(6) |
| 40 | #define M_TC_FROM _TC_MAKEMASK(2,S_TC_FROM) |
| 41 | #define G_TC_FROM(x) _TC_GETVALUE(x,S_TC_FROM,M_TC_FROM) |
| 42 | #define V_TC_FROM(x) _TC_MAKEVALUE(x,S_TC_FROM) |
| 43 | #define SET_TC_FROM(v,n) ((V_TC_FROM(n)) | (v & ~M_TC_FROM)) |
| 44 | #define AT_STACK 0x0 |
| 45 | #define AT_INGRESS 0x1 |
| 46 | #define AT_EGRESS 0x2 |
| 47 | |
| 48 | #define TC_NCLS _TC_MAKEMASK1(8) |
| 49 | #define SET_TC_NCLS(v) ( TC_NCLS | (v & ~TC_NCLS)) |
| 50 | #define CLR_TC_NCLS(v) ( v & ~TC_NCLS) |
| 51 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | #define S_TC_AT _TC_MAKE32(12) |
| 53 | #define M_TC_AT _TC_MAKEMASK(2,S_TC_AT) |
| 54 | #define G_TC_AT(x) _TC_GETVALUE(x,S_TC_AT,M_TC_AT) |
| 55 | #define V_TC_AT(x) _TC_MAKEVALUE(x,S_TC_AT) |
| 56 | #define SET_TC_AT(v,n) ((V_TC_AT(n)) | (v & ~M_TC_AT)) |
| 57 | |
Florian Westphal | bd5850d | 2015-05-21 02:26:24 +0200 | [diff] [blame] | 58 | #define MAX_REC_LOOP 4 |
| 59 | #define MAX_RED_LOOP 4 |
| 60 | #endif |
| 61 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | /* Action attributes */ |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 63 | enum { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | TCA_ACT_UNSPEC, |
| 65 | TCA_ACT_KIND, |
| 66 | TCA_ACT_OPTIONS, |
| 67 | TCA_ACT_INDEX, |
| 68 | TCA_ACT_STATS, |
| 69 | __TCA_ACT_MAX |
| 70 | }; |
| 71 | |
| 72 | #define TCA_ACT_MAX __TCA_ACT_MAX |
| 73 | #define TCA_OLD_COMPAT (TCA_ACT_MAX+1) |
| 74 | #define TCA_ACT_MAX_PRIO 32 |
| 75 | #define TCA_ACT_BIND 1 |
| 76 | #define TCA_ACT_NOBIND 0 |
| 77 | #define TCA_ACT_UNBIND 1 |
| 78 | #define TCA_ACT_NOUNBIND 0 |
| 79 | #define TCA_ACT_REPLACE 1 |
| 80 | #define TCA_ACT_NOREPLACE 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | |
| 82 | #define TC_ACT_UNSPEC (-1) |
| 83 | #define TC_ACT_OK 0 |
| 84 | #define TC_ACT_RECLASSIFY 1 |
| 85 | #define TC_ACT_SHOT 2 |
| 86 | #define TC_ACT_PIPE 3 |
| 87 | #define TC_ACT_STOLEN 4 |
| 88 | #define TC_ACT_QUEUED 5 |
| 89 | #define TC_ACT_REPEAT 6 |
Alexei Starovoitov | 27b29f6 | 2015-09-15 23:05:43 -0700 | [diff] [blame^] | 90 | #define TC_ACT_REDIRECT 7 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | #define TC_ACT_JUMP 0x10000000 |
| 92 | |
| 93 | /* Action type identifiers*/ |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 94 | enum { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | TCA_ID_UNSPEC=0, |
| 96 | TCA_ID_POLICE=1, |
| 97 | /* other actions go here */ |
| 98 | __TCA_ID_MAX=255 |
| 99 | }; |
| 100 | |
| 101 | #define TCA_ID_MAX __TCA_ID_MAX |
| 102 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 103 | struct tc_police { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | __u32 index; |
| 105 | int action; |
| 106 | #define TC_POLICE_UNSPEC TC_ACT_UNSPEC |
| 107 | #define TC_POLICE_OK TC_ACT_OK |
| 108 | #define TC_POLICE_RECLASSIFY TC_ACT_RECLASSIFY |
| 109 | #define TC_POLICE_SHOT TC_ACT_SHOT |
| 110 | #define TC_POLICE_PIPE TC_ACT_PIPE |
| 111 | |
| 112 | __u32 limit; |
| 113 | __u32 burst; |
| 114 | __u32 mtu; |
| 115 | struct tc_ratespec rate; |
| 116 | struct tc_ratespec peakrate; |
| 117 | int refcnt; |
| 118 | int bindcnt; |
| 119 | __u32 capab; |
| 120 | }; |
| 121 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 122 | struct tcf_t { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | __u64 install; |
| 124 | __u64 lastuse; |
| 125 | __u64 expires; |
| 126 | }; |
| 127 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 128 | struct tc_cnt { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | int refcnt; |
| 130 | int bindcnt; |
| 131 | }; |
| 132 | |
| 133 | #define tc_gen \ |
| 134 | __u32 index; \ |
| 135 | __u32 capab; \ |
| 136 | int action; \ |
| 137 | int refcnt; \ |
| 138 | int bindcnt |
| 139 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 140 | enum { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | TCA_POLICE_UNSPEC, |
| 142 | TCA_POLICE_TBF, |
| 143 | TCA_POLICE_RATE, |
| 144 | TCA_POLICE_PEAKRATE, |
| 145 | TCA_POLICE_AVRATE, |
| 146 | TCA_POLICE_RESULT, |
| 147 | __TCA_POLICE_MAX |
| 148 | #define TCA_POLICE_RESULT TCA_POLICE_RESULT |
| 149 | }; |
| 150 | |
| 151 | #define TCA_POLICE_MAX (__TCA_POLICE_MAX - 1) |
| 152 | |
| 153 | /* U32 filters */ |
| 154 | |
| 155 | #define TC_U32_HTID(h) ((h)&0xFFF00000) |
| 156 | #define TC_U32_USERHTID(h) (TC_U32_HTID(h)>>20) |
| 157 | #define TC_U32_HASH(h) (((h)>>12)&0xFF) |
| 158 | #define TC_U32_NODE(h) ((h)&0xFFF) |
| 159 | #define TC_U32_KEY(h) ((h)&0xFFFFF) |
| 160 | #define TC_U32_UNSPEC 0 |
| 161 | #define TC_U32_ROOT (0xFFF00000) |
| 162 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 163 | enum { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | TCA_U32_UNSPEC, |
| 165 | TCA_U32_CLASSID, |
| 166 | TCA_U32_HASH, |
| 167 | TCA_U32_LINK, |
| 168 | TCA_U32_DIVISOR, |
| 169 | TCA_U32_SEL, |
| 170 | TCA_U32_POLICE, |
| 171 | TCA_U32_ACT, |
| 172 | TCA_U32_INDEV, |
| 173 | TCA_U32_PCNT, |
| 174 | TCA_U32_MARK, |
| 175 | __TCA_U32_MAX |
| 176 | }; |
| 177 | |
| 178 | #define TCA_U32_MAX (__TCA_U32_MAX - 1) |
| 179 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 180 | struct tc_u32_key { |
Al Viro | 0382b9c | 2008-03-17 22:46:46 -0700 | [diff] [blame] | 181 | __be32 mask; |
| 182 | __be32 val; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | int off; |
| 184 | int offmask; |
| 185 | }; |
| 186 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 187 | struct tc_u32_sel { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | unsigned char flags; |
| 189 | unsigned char offshift; |
| 190 | unsigned char nkeys; |
| 191 | |
Al Viro | 0382b9c | 2008-03-17 22:46:46 -0700 | [diff] [blame] | 192 | __be16 offmask; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | __u16 off; |
| 194 | short offoff; |
| 195 | |
| 196 | short hoff; |
Al Viro | 0382b9c | 2008-03-17 22:46:46 -0700 | [diff] [blame] | 197 | __be32 hmask; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | struct tc_u32_key keys[0]; |
| 199 | }; |
| 200 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 201 | struct tc_u32_mark { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | __u32 val; |
| 203 | __u32 mask; |
| 204 | __u32 success; |
| 205 | }; |
| 206 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 207 | struct tc_u32_pcnt { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | __u64 rcnt; |
| 209 | __u64 rhit; |
| 210 | __u64 kcnts[0]; |
| 211 | }; |
| 212 | |
| 213 | /* Flags */ |
| 214 | |
| 215 | #define TC_U32_TERMINAL 1 |
| 216 | #define TC_U32_OFFSET 2 |
| 217 | #define TC_U32_VAROFFSET 4 |
| 218 | #define TC_U32_EAT 8 |
| 219 | |
| 220 | #define TC_U32_MAXDEPTH 8 |
| 221 | |
| 222 | |
| 223 | /* RSVP filter */ |
| 224 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 225 | enum { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | TCA_RSVP_UNSPEC, |
| 227 | TCA_RSVP_CLASSID, |
| 228 | TCA_RSVP_DST, |
| 229 | TCA_RSVP_SRC, |
| 230 | TCA_RSVP_PINFO, |
| 231 | TCA_RSVP_POLICE, |
| 232 | TCA_RSVP_ACT, |
| 233 | __TCA_RSVP_MAX |
| 234 | }; |
| 235 | |
| 236 | #define TCA_RSVP_MAX (__TCA_RSVP_MAX - 1 ) |
| 237 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 238 | struct tc_rsvp_gpi { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | __u32 key; |
| 240 | __u32 mask; |
| 241 | int offset; |
| 242 | }; |
| 243 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 244 | struct tc_rsvp_pinfo { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | struct tc_rsvp_gpi dpi; |
| 246 | struct tc_rsvp_gpi spi; |
| 247 | __u8 protocol; |
| 248 | __u8 tunnelid; |
| 249 | __u8 tunnelhdr; |
Patrick McHardy | 8a47077 | 2005-06-28 12:56:45 -0700 | [diff] [blame] | 250 | __u8 pad; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | }; |
| 252 | |
| 253 | /* ROUTE filter */ |
| 254 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 255 | enum { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | TCA_ROUTE4_UNSPEC, |
| 257 | TCA_ROUTE4_CLASSID, |
| 258 | TCA_ROUTE4_TO, |
| 259 | TCA_ROUTE4_FROM, |
| 260 | TCA_ROUTE4_IIF, |
| 261 | TCA_ROUTE4_POLICE, |
| 262 | TCA_ROUTE4_ACT, |
| 263 | __TCA_ROUTE4_MAX |
| 264 | }; |
| 265 | |
| 266 | #define TCA_ROUTE4_MAX (__TCA_ROUTE4_MAX - 1) |
| 267 | |
| 268 | |
| 269 | /* FW filter */ |
| 270 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 271 | enum { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | TCA_FW_UNSPEC, |
| 273 | TCA_FW_CLASSID, |
| 274 | TCA_FW_POLICE, |
| 275 | TCA_FW_INDEV, /* used by CONFIG_NET_CLS_IND */ |
| 276 | TCA_FW_ACT, /* used by CONFIG_NET_CLS_ACT */ |
Patrick McHardy | b4e9b52 | 2006-08-25 16:11:42 -0700 | [diff] [blame] | 277 | TCA_FW_MASK, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | __TCA_FW_MAX |
| 279 | }; |
| 280 | |
| 281 | #define TCA_FW_MAX (__TCA_FW_MAX - 1) |
| 282 | |
| 283 | /* TC index filter */ |
| 284 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 285 | enum { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | TCA_TCINDEX_UNSPEC, |
| 287 | TCA_TCINDEX_HASH, |
| 288 | TCA_TCINDEX_MASK, |
| 289 | TCA_TCINDEX_SHIFT, |
| 290 | TCA_TCINDEX_FALL_THROUGH, |
| 291 | TCA_TCINDEX_CLASSID, |
| 292 | TCA_TCINDEX_POLICE, |
| 293 | TCA_TCINDEX_ACT, |
| 294 | __TCA_TCINDEX_MAX |
| 295 | }; |
| 296 | |
| 297 | #define TCA_TCINDEX_MAX (__TCA_TCINDEX_MAX - 1) |
| 298 | |
Patrick McHardy | e5dfb81 | 2008-01-31 18:37:42 -0800 | [diff] [blame] | 299 | /* Flow filter */ |
| 300 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 301 | enum { |
Patrick McHardy | e5dfb81 | 2008-01-31 18:37:42 -0800 | [diff] [blame] | 302 | FLOW_KEY_SRC, |
| 303 | FLOW_KEY_DST, |
| 304 | FLOW_KEY_PROTO, |
| 305 | FLOW_KEY_PROTO_SRC, |
| 306 | FLOW_KEY_PROTO_DST, |
| 307 | FLOW_KEY_IIF, |
| 308 | FLOW_KEY_PRIORITY, |
| 309 | FLOW_KEY_MARK, |
| 310 | FLOW_KEY_NFCT, |
| 311 | FLOW_KEY_NFCT_SRC, |
| 312 | FLOW_KEY_NFCT_DST, |
| 313 | FLOW_KEY_NFCT_PROTO_SRC, |
| 314 | FLOW_KEY_NFCT_PROTO_DST, |
| 315 | FLOW_KEY_RTCLASSID, |
| 316 | FLOW_KEY_SKUID, |
| 317 | FLOW_KEY_SKGID, |
Patrick McHardy | 9ec1381 | 2008-02-05 16:21:04 -0800 | [diff] [blame] | 318 | FLOW_KEY_VLAN_TAG, |
Changli Gao | 739a91e | 2010-08-21 06:23:15 +0000 | [diff] [blame] | 319 | FLOW_KEY_RXHASH, |
Patrick McHardy | e5dfb81 | 2008-01-31 18:37:42 -0800 | [diff] [blame] | 320 | __FLOW_KEY_MAX, |
| 321 | }; |
| 322 | |
| 323 | #define FLOW_KEY_MAX (__FLOW_KEY_MAX - 1) |
| 324 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 325 | enum { |
Patrick McHardy | e5dfb81 | 2008-01-31 18:37:42 -0800 | [diff] [blame] | 326 | FLOW_MODE_MAP, |
| 327 | FLOW_MODE_HASH, |
| 328 | }; |
| 329 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 330 | enum { |
Patrick McHardy | e5dfb81 | 2008-01-31 18:37:42 -0800 | [diff] [blame] | 331 | TCA_FLOW_UNSPEC, |
| 332 | TCA_FLOW_KEYS, |
| 333 | TCA_FLOW_MODE, |
| 334 | TCA_FLOW_BASECLASS, |
| 335 | TCA_FLOW_RSHIFT, |
| 336 | TCA_FLOW_ADDEND, |
| 337 | TCA_FLOW_MASK, |
| 338 | TCA_FLOW_XOR, |
| 339 | TCA_FLOW_DIVISOR, |
| 340 | TCA_FLOW_ACT, |
| 341 | TCA_FLOW_POLICE, |
| 342 | TCA_FLOW_EMATCHES, |
Patrick McHardy | 72d9794 | 2008-07-14 20:36:32 -0700 | [diff] [blame] | 343 | TCA_FLOW_PERTURB, |
Patrick McHardy | e5dfb81 | 2008-01-31 18:37:42 -0800 | [diff] [blame] | 344 | __TCA_FLOW_MAX |
| 345 | }; |
| 346 | |
| 347 | #define TCA_FLOW_MAX (__TCA_FLOW_MAX - 1) |
| 348 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | /* Basic filter */ |
| 350 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 351 | enum { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | TCA_BASIC_UNSPEC, |
| 353 | TCA_BASIC_CLASSID, |
| 354 | TCA_BASIC_EMATCHES, |
| 355 | TCA_BASIC_ACT, |
| 356 | TCA_BASIC_POLICE, |
| 357 | __TCA_BASIC_MAX |
| 358 | }; |
| 359 | |
| 360 | #define TCA_BASIC_MAX (__TCA_BASIC_MAX - 1) |
| 361 | |
Thomas Graf | f400923 | 2008-11-07 22:56:00 -0800 | [diff] [blame] | 362 | |
| 363 | /* Cgroup classifier */ |
| 364 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 365 | enum { |
Thomas Graf | f400923 | 2008-11-07 22:56:00 -0800 | [diff] [blame] | 366 | TCA_CGROUP_UNSPEC, |
| 367 | TCA_CGROUP_ACT, |
| 368 | TCA_CGROUP_POLICE, |
| 369 | TCA_CGROUP_EMATCHES, |
| 370 | __TCA_CGROUP_MAX, |
| 371 | }; |
| 372 | |
| 373 | #define TCA_CGROUP_MAX (__TCA_CGROUP_MAX - 1) |
| 374 | |
Daniel Borkmann | 7d1d65c | 2013-10-28 16:43:02 +0100 | [diff] [blame] | 375 | /* BPF classifier */ |
| 376 | |
Daniel Borkmann | 045efa8 | 2015-09-15 23:05:42 -0700 | [diff] [blame] | 377 | #define TCA_BPF_FLAG_ACT_DIRECT (1 << 0) |
| 378 | |
Daniel Borkmann | 7d1d65c | 2013-10-28 16:43:02 +0100 | [diff] [blame] | 379 | enum { |
| 380 | TCA_BPF_UNSPEC, |
| 381 | TCA_BPF_ACT, |
| 382 | TCA_BPF_POLICE, |
| 383 | TCA_BPF_CLASSID, |
| 384 | TCA_BPF_OPS_LEN, |
| 385 | TCA_BPF_OPS, |
Daniel Borkmann | e2e9b65 | 2015-03-01 12:31:48 +0100 | [diff] [blame] | 386 | TCA_BPF_FD, |
| 387 | TCA_BPF_NAME, |
Daniel Borkmann | 045efa8 | 2015-09-15 23:05:42 -0700 | [diff] [blame] | 388 | TCA_BPF_FLAGS, |
Daniel Borkmann | 7d1d65c | 2013-10-28 16:43:02 +0100 | [diff] [blame] | 389 | __TCA_BPF_MAX, |
| 390 | }; |
| 391 | |
| 392 | #define TCA_BPF_MAX (__TCA_BPF_MAX - 1) |
| 393 | |
Jiri Pirko | 77b9900 | 2015-05-12 14:56:21 +0200 | [diff] [blame] | 394 | /* Flower classifier */ |
| 395 | |
| 396 | enum { |
| 397 | TCA_FLOWER_UNSPEC, |
| 398 | TCA_FLOWER_CLASSID, |
| 399 | TCA_FLOWER_INDEV, |
| 400 | TCA_FLOWER_ACT, |
| 401 | TCA_FLOWER_KEY_ETH_DST, /* ETH_ALEN */ |
| 402 | TCA_FLOWER_KEY_ETH_DST_MASK, /* ETH_ALEN */ |
| 403 | TCA_FLOWER_KEY_ETH_SRC, /* ETH_ALEN */ |
| 404 | TCA_FLOWER_KEY_ETH_SRC_MASK, /* ETH_ALEN */ |
| 405 | TCA_FLOWER_KEY_ETH_TYPE, /* be16 */ |
| 406 | TCA_FLOWER_KEY_IP_PROTO, /* u8 */ |
| 407 | TCA_FLOWER_KEY_IPV4_SRC, /* be32 */ |
| 408 | TCA_FLOWER_KEY_IPV4_SRC_MASK, /* be32 */ |
| 409 | TCA_FLOWER_KEY_IPV4_DST, /* be32 */ |
| 410 | TCA_FLOWER_KEY_IPV4_DST_MASK, /* be32 */ |
| 411 | TCA_FLOWER_KEY_IPV6_SRC, /* struct in6_addr */ |
| 412 | TCA_FLOWER_KEY_IPV6_SRC_MASK, /* struct in6_addr */ |
| 413 | TCA_FLOWER_KEY_IPV6_DST, /* struct in6_addr */ |
| 414 | TCA_FLOWER_KEY_IPV6_DST_MASK, /* struct in6_addr */ |
| 415 | TCA_FLOWER_KEY_TCP_SRC, /* be16 */ |
| 416 | TCA_FLOWER_KEY_TCP_DST, /* be16 */ |
| 417 | TCA_FLOWER_KEY_UDP_SRC, /* be16 */ |
| 418 | TCA_FLOWER_KEY_UDP_DST, /* be16 */ |
| 419 | __TCA_FLOWER_MAX, |
| 420 | }; |
| 421 | |
| 422 | #define TCA_FLOWER_MAX (__TCA_FLOWER_MAX - 1) |
| 423 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | /* Extended Matches */ |
| 425 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 426 | struct tcf_ematch_tree_hdr { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | __u16 nmatches; |
| 428 | __u16 progid; |
| 429 | }; |
| 430 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 431 | enum { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | TCA_EMATCH_TREE_UNSPEC, |
| 433 | TCA_EMATCH_TREE_HDR, |
| 434 | TCA_EMATCH_TREE_LIST, |
| 435 | __TCA_EMATCH_TREE_MAX |
| 436 | }; |
| 437 | #define TCA_EMATCH_TREE_MAX (__TCA_EMATCH_TREE_MAX - 1) |
| 438 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 439 | struct tcf_ematch_hdr { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | __u16 matchid; |
| 441 | __u16 kind; |
| 442 | __u16 flags; |
| 443 | __u16 pad; /* currently unused */ |
| 444 | }; |
| 445 | |
| 446 | /* 0 1 |
| 447 | * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 |
| 448 | * +-----------------------+-+-+---+ |
| 449 | * | Unused |S|I| R | |
| 450 | * +-----------------------+-+-+---+ |
| 451 | * |
| 452 | * R(2) ::= relation to next ematch |
| 453 | * where: 0 0 END (last ematch) |
| 454 | * 0 1 AND |
| 455 | * 1 0 OR |
| 456 | * 1 1 Unused (invalid) |
| 457 | * I(1) ::= invert result |
| 458 | * S(1) ::= simple payload |
| 459 | */ |
| 460 | #define TCF_EM_REL_END 0 |
| 461 | #define TCF_EM_REL_AND (1<<0) |
| 462 | #define TCF_EM_REL_OR (1<<1) |
| 463 | #define TCF_EM_INVERT (1<<2) |
| 464 | #define TCF_EM_SIMPLE (1<<3) |
| 465 | |
| 466 | #define TCF_EM_REL_MASK 3 |
| 467 | #define TCF_EM_REL_VALID(v) (((v) & TCF_EM_REL_MASK) != TCF_EM_REL_MASK) |
| 468 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 469 | enum { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | TCF_LAYER_LINK, |
| 471 | TCF_LAYER_NETWORK, |
| 472 | TCF_LAYER_TRANSPORT, |
| 473 | __TCF_LAYER_MAX |
| 474 | }; |
| 475 | #define TCF_LAYER_MAX (__TCF_LAYER_MAX - 1) |
| 476 | |
| 477 | /* Ematch type assignments |
| 478 | * 1..32767 Reserved for ematches inside kernel tree |
| 479 | * 32768..65535 Free to use, not reliable |
| 480 | */ |
Patrick McHardy | db3d99c | 2007-07-11 19:46:26 -0700 | [diff] [blame] | 481 | #define TCF_EM_CONTAINER 0 |
| 482 | #define TCF_EM_CMP 1 |
| 483 | #define TCF_EM_NBYTE 2 |
| 484 | #define TCF_EM_U32 3 |
| 485 | #define TCF_EM_META 4 |
| 486 | #define TCF_EM_TEXT 5 |
Rostislav Lisovy | f057bbb | 2012-07-04 05:32:03 +0200 | [diff] [blame] | 487 | #define TCF_EM_VLAN 6 |
| 488 | #define TCF_EM_CANID 7 |
Florian Westphal | 6d4fa85 | 2012-07-11 10:56:57 +0000 | [diff] [blame] | 489 | #define TCF_EM_IPSET 8 |
| 490 | #define TCF_EM_MAX 8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 492 | enum { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | TCF_EM_PROG_TC |
| 494 | }; |
| 495 | |
Eric Dumazet | d94d9fe | 2009-11-04 09:50:58 -0800 | [diff] [blame] | 496 | enum { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 497 | TCF_EM_OPND_EQ, |
| 498 | TCF_EM_OPND_GT, |
| 499 | TCF_EM_OPND_LT |
| 500 | }; |
| 501 | |
| 502 | #endif |