summaryrefslogtreecommitdiffstats
path: root/tests/py/any/ct.t.payload
blob: 9338466d5df415d5146a2ef363e44ede07e3775c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
# ct state new,established, related, untracked
ip test-ip4 output
  [ ct load state => reg 1 ]
  [ bitwise reg 1 = (reg=1 & 0x0000004e ) ^ 0x00000000 ]
  [ cmp neq reg 1 0x00000000 ]

# ct state != related
ip test-ip4 output
  [ ct load state => reg 1 ]
  [ cmp neq reg 1 0x00000004 ]

# ct state {new,established, related, untracked}
__set%d test-ip4 3
__set%d test-ip4 0
	element 00000008  : 0 [end]	element 00000002  : 0 [end]	element 00000004  : 0 [end]	element 00000040  : 0 [end]
ip test-ip4 output
  [ ct load state => reg 1 ]
  [ lookup reg 1 set __set%d ]

# ct state != {new,established, related, untracked}
__set%d test-ip4 3
__set%d test-ip4 0
	element 00000008  : 0 [end]	element 00000002  : 0 [end]	element 00000004  : 0 [end]	element 00000040  : 0 [end]
ip test-ip4 output
  [ ct load state => reg 1 ]
  [ lookup reg 1 set __set%d 0x1 ]

# ct state invalid drop
ip test-ip4 output
  [ ct load state => reg 1 ]
  [ bitwise reg 1 = (reg=1 & 0x00000001 ) ^ 0x00000000 ]
  [ cmp neq reg 1 0x00000000 ]
  [ immediate reg 0 drop ]

# ct state established accept
ip test-ip4 output
  [ ct load state => reg 1 ]
  [ bitwise reg 1 = (reg=1 & 0x00000002 ) ^ 0x00000000 ]
  [ cmp neq reg 1 0x00000000 ]
  [ immediate reg 0 accept ]

# ct state 8
ip test-ip4 output
  [ ct load state => reg 1 ]
  [ bitwise reg 1 = (reg=1 & 0x00000008 ) ^ 0x00000000 ]
  [ cmp neq reg 1 0x00000000 ]

# ct direction original
ip test-ip4 output
  [ ct load direction => reg 1 ]
  [ cmp eq reg 1 0x00000000 ]

# ct direction != original
ip test-ip4 output
  [ ct load direction => reg 1 ]
  [ cmp neq reg 1 0x00000000 ]

# ct direction reply
ip test-ip4 output
  [ ct load direction => reg 1 ]
  [ cmp eq reg 1 0x00000001 ]

# ct direction != reply
ip test-ip4 output
  [ ct load direction => reg 1 ]
  [ cmp neq reg 1 0x00000001 ]

# ct direction {reply, original}
__set%d test-ip4 3
__set%d test-ip4 0
	element 00000001  : 0 [end]	element 00000000  : 0 [end]
ip test-ip4 output
  [ ct load direction => reg 1 ]
  [ lookup reg 1 set __set%d ]

# ct direction != {reply, original}
__set%d test-ip4 3
__set%d test-ip4 0
	element 00000001  : 0 [end]	element 00000000  : 0 [end]
ip test-ip4 output
  [ ct load direction => reg 1 ]
  [ lookup reg 1 set __set%d 0x1 ]

# ct status expected
ip test-ip4 output
  [ ct load status => reg 1 ]
  [ bitwise reg 1 = (reg=1 & 0x00000001 ) ^ 0x00000000 ]
  [ cmp neq reg 1 0x00000000 ]

# ct status != expected
ip test-ip4 output
  [ ct load status => reg 1 ]
  [ cmp neq reg 1 0x00000001 ]

# ct status seen-reply
ip test-ip4 output
  [ ct load status => reg 1 ]
  [ bitwise reg 1 = (reg=1 & 0x00000002 ) ^ 0x00000000 ]
  [ cmp neq reg 1 0x00000000 ]

# ct status != seen-reply
ip test-ip4 output
  [ ct load status => reg 1 ]
  [ cmp neq reg 1 0x00000002 ]

# ct status {expected, seen-reply, assured, confirmed, dying}
__set%d test-ip4 3
__set%d test-ip4 0
	element 00000001  : 0 [end]	element 00000002  : 0 [end]	element 00000004  : 0 [end]	element 00000008  : 0 [end]	element 00000200  : 0 [end]
ip test-ip4 output
  [ ct load status => reg 1 ]
  [ lookup reg 1 set __set%d ]

# ct status != {expected, seen-reply, assured, confirmed, dying}
__set%d test-ip4 3
__set%d test-ip4 0
	element 00000001  : 0 [end]	element 00000002  : 0 [end]	element 00000004  : 0 [end]	element 00000008  : 0 [end]	element 00000200  : 0 [end]
ip test-ip4 output
  [ ct load status => reg 1 ]
  [ lookup reg 1 set __set%d 0x1 ]

# ct mark 0
ip test-ip4 output
  [ ct load mark => reg 1 ]
  [ cmp eq reg 1 0x00000000 ]

# ct mark or 0x23 == 0x11
ip test-ip4 output
  [ ct load mark => reg 1 ]
  [ bitwise reg 1 = (reg=1 & 0xffffffdc ) ^ 0x00000023 ]
  [ cmp eq reg 1 0x00000011 ]

# ct mark or 0x3 != 0x1
ip test-ip4 output
  [ ct load mark => reg 1 ]
  [ bitwise reg 1 = (reg=1 & 0xfffffffc ) ^ 0x00000003 ]
  [ cmp neq reg 1 0x00000001 ]

# ct mark and 0x23 == 0x11
ip test-ip4 output
  [ ct load mark => reg 1 ]
  [ bitwise reg 1 = (reg=1 & 0x00000023 ) ^ 0x00000000 ]
  [ cmp eq reg 1 0x00000011 ]

# ct mark and 0x3 != 0x1
ip test-ip4 output
  [ ct load mark => reg 1 ]
  [ bitwise reg 1 = (reg=1 & 0x00000003 ) ^ 0x00000000 ]
  [ cmp neq reg 1 0x00000001 ]

# ct mark xor 0x23 == 0x11
ip test-ip4 output
  [ ct load mark => reg 1 ]
  [ cmp eq reg 1 0x00000032 ]

# ct mark xor 0x3 != 0x1
ip test-ip4 output
  [ ct load mark => reg 1 ]
  [ cmp neq reg 1 0x00000002 ]

# ct mark 0x00000032
ip test-ip4 output
  [ ct load mark => reg 1 ]
  [ cmp eq reg 1 0x00000032 ]

# ct mark != 0x00000032
ip test-ip4 output
  [ ct load mark => reg 1 ]
  [ cmp neq reg 1 0x00000032 ]

# ct mark 0x00000032-0x00000045
ip test-ip4 output
  [ ct load mark => reg 1 ]
  [ byteorder reg 1 = hton(reg 1, 4, 4) ]
  [ cmp gte reg 1 0x32000000 ]
  [ cmp lte reg 1 0x45000000 ]

# ct mark != 0x00000032-0x00000045
ip test-ip4 output
  [ ct load mark => reg 1 ]
  [ byteorder reg 1 = hton(reg 1, 4, 4) ]
  [ range neq reg 1 0x32000000 0x45000000 ]

# ct mark {0x32, 0x2222, 0x42de3}
__set%d test-ip4 3
__set%d test-ip4 0
	element 00000032  : 0 [end]	element 00002222  : 0 [end]	element 00042de3  : 0 [end]
ip test-ip4 output
  [ ct load mark => reg 1 ]
  [ lookup reg 1 set __set%d ]

# ct mark {0x32-0x2222, 0x4444-0x42de3}
__set%d test-ip4 7
__set%d test-ip4 0
        element 00000000  : 1 [end]     element 32000000  : 0 [end]     element 23220000  : 1 [end]     element 44440000  : 0 [end]     element e42d0400  : 1 [end]
ip test-ip4 output
  [ ct load mark => reg 1 ]
  [ byteorder reg 1 = hton(reg 1, 4, 4) ]
  [ lookup reg 1 set __set%d ]

# ct mark != {0x32, 0x2222, 0x42de3}
__set%d test-ip4 3
__set%d test-ip4 0
	element 00000032  : 0 [end]	element 00002222  : 0 [end]	element 00042de3  : 0 [end]
ip test-ip4 output
  [ ct load mark => reg 1 ]
  [ lookup reg 1 set __set%d 0x1 ]

# ct mark set 0x11 xor 0x1331
ip test-ip4 output
  [ immediate reg 1 0x00001320 ]
  [ ct set mark with reg 1 ]

# ct mark set 0x11333 and 0x11
ip test-ip4 output
  [ immediate reg 1 0x00000011 ]
  [ ct set mark with reg 1 ]

# ct mark set 0x12 or 0x11
ip test-ip4 output
  [ immediate reg 1 0x00000013 ]
  [ ct set mark with reg 1 ]

# ct mark set 0x11
ip test-ip4 output
  [ immediate reg 1 0x00000011 ]
  [ ct set mark with reg 1 ]

# ct expiration 30s
ip test-ip4 output
  [ ct load expiration => reg 1 ]
  [ cmp eq reg 1 0x00007530 ]

# ct expiration 30000ms
ip test-ip4 output
  [ ct load expiration => reg 1 ]
  [ cmp eq reg 1 0x00007530 ]

# ct expiration 1m-1h
ip test-ip4 output
  [ ct load expiration => reg 1 ]
  [ byteorder reg 1 = hton(reg 1, 4, 4) ]
  [ cmp gte reg 1 0x60ea0000 ]
  [ cmp lte reg 1 0x80ee3600 ]

# ct expiration > 4d23h59m59s
ip test-ip4 output
  [ ct load expiration => reg 1 ]
  [ byteorder reg 1 = hton(reg 1, 4, 4) ]
  [ cmp gt reg 1 0x18c8bf19 ]

# ct expiration != 233
ip test-ip4 output
  [ ct load expiration => reg 1 ]
  [ cmp neq reg 1 0x00038e28 ]

# ct expiration 33-45
ip test-ip4 output
  [ ct load expiration => reg 1 ]
  [ byteorder reg 1 = hton(reg 1, 4, 4) ]
  [ cmp gte reg 1 0xe8800000 ]
  [ cmp lte reg 1 0xc8af0000 ]

# ct expiration != 33-45
ip test-ip4 output
  [ ct load expiration => reg 1 ]
  [ byteorder reg 1 = hton(reg 1, 4, 4) ]
  [ range neq reg 1 0xe8800000 0xc8af0000 ]

# ct expiration {33, 55, 67, 88}
__set%d test-ip4 3
__set%d test-ip4 0
	element 000080e8  : 0 [end]	element 0000d6d8  : 0 [end]	element 000105b8  : 0 [end]	element 000157c0  : 0 [end]
ip test-ip4 output
  [ ct load expiration => reg 1 ]
  [ lookup reg 1 set __set%d ]

# ct expiration != {33, 55, 67, 88}
__set%d test-ip4 3
__set%d test-ip4 0
	element 000080e8  : 0 [end]	element 0000d6d8  : 0 [end]	element 000105b8  : 0 [end]	element 000157c0  : 0 [end]
ip test-ip4 output
  [ ct load expiration => reg 1 ]
  [ lookup reg 1 set __set%d 0x1 ]

# ct expiration {33-55}
__set%d test-ip4 7
__set%d test-ip4 0
	element 00000000  : 1 [end]	element e8800000  : 0 [end]	element d9d60000  : 1 [end]
ip test-ip4 output
  [ ct load expiration => reg 1 ]
  [ byteorder reg 1 = hton(reg 1, 4, 4) ]
  [ lookup reg 1 set __set%d ]

# ct expiration != {33-55}
__set%d test-ip4 7
__set%d test-ip4 0
	element 00000000  : 1 [end]	element e8800000  : 0 [end]	element d9d60000  : 1 [end]
ip test-ip4 output
  [ ct load expiration => reg 1 ]
  [ byteorder reg 1 = hton(reg 1, 4, 4) ]
  [ lookup reg 1 set __set%d 0x1 ]

# ct helper "ftp"
ip test-ip4 output
  [ ct load helper => reg 1 ]
  [ cmp eq reg 1 0x00707466 0x00000000 0x00000000 0x00000000 ]

# ct state . ct mark { new . 0x12345678}
__set%d test 3
__set%d test 0
	element 00000008 12345678  : 0 [end]
ip test-ip4 output
  [ ct load state => reg 1 ]
  [ ct load mark => reg 9 ]
  [ lookup reg 1 set __set%d ]

# ct state . ct mark { new . 0x12345678, new . 0x34127856, established . 0x12785634}
__set%d test-ip4 3
__set%d test-ip4 0
	element 00000008 12345678  : 0 [end]	element 00000008 34127856  : 0 [end]	element 00000002 12785634  : 0 [end]
ip test-ip4 output
  [ ct load state => reg 1 ]
  [ ct load mark => reg 9 ]
  [ lookup reg 1 set __set%d ]

# ct direction . ct mark { original . 0x12345678}
__set%d test 3
__set%d test 0
	element 00000000 12345678  : 0 [end]
ip test-ip4 output
  [ ct load direction => reg 1 ]
  [ ct load mark => reg 9 ]
  [ lookup reg 1 set __set%d ]

# ct state . ct mark vmap { new . 0x12345678 : drop}
__map%d test-ip4 b
__map%d test-ip4 0
	element 00000008 12345678  : 0 [end]
ip test-ip4 output
  [ ct load state => reg 1 ]
  [ ct load mark => reg 9 ]
  [ lookup reg 1 set __map%d dreg 0 ]

# ct mark set mark
ip test-ip4 output
  [ meta load mark => reg 1 ]
  [ ct set mark with reg 1 ]

# ct mark set mark map { 1 : 10, 2 : 20, 3 : 30 }
__map%d test-ip4 b
__map%d test-ip4 0
        element 00000001  : 0000000a 0 [end]    element 00000002  : 00000014 0 [end]    element 00000003  : 0000001e 0 [end]
ip test-ip4 output
  [ meta load mark => reg 1 ]
  [ lookup reg 1 set __map%d dreg 1 ]
  [ ct set mark with reg 1 ]

# ct original bytes > 100000
ip test-ip4 output
  [ ct load bytes => reg 1 , dir original ]
  [ byteorder reg 1 = hton(reg 1, 8, 8) ]
  [ cmp gt reg 1 0x00000000 0xa0860100 ]

# ct reply packets < 100
ip test-ip4 output
  [ ct load packets => reg 1 , dir reply ]
  [ byteorder reg 1 = hton(reg 1, 8, 8) ]
  [ cmp lt reg 1 0x00000000 0x64000000 ]

# ct bytes > 100000
ip test-ip4 output
  [ ct load bytes => reg 1 ]
  [ byteorder reg 1 = hton(reg 1, 8, 8) ]
  [ cmp gt reg 1 0x00000000 0xa0860100 ]

# ct avgpkt > 200
ip test-ip4 output
  [ ct load avgpkt => reg 1 ]
  [ byteorder reg 1 = hton(reg 1, 8, 8) ]
  [ cmp gt reg 1 0x00000000 0xc8000000 ]

# ct original avgpkt < 500
ip test-ip4 output
  [ ct load avgpkt => reg 1 , dir original ]
  [ byteorder reg 1 = hton(reg 1, 8, 8) ]
  [ cmp lt reg 1 0x00000000 0xf4010000 ]

# ct status expected,seen-reply,assured,confirmed,snat,dnat,dying
ip test-ip4 output
  [ ct load status => reg 1 ]
  [ bitwise reg 1 = (reg=1 & 0x0000023f ) ^ 0x00000000 ]
  [ cmp neq reg 1 0x00000000 ]

# ct status snat
ip test-ip4 output
  [ ct load status => reg 1 ]
  [ bitwise reg 1 = (reg=1 & 0x00000010 ) ^ 0x00000000 ]
  [ cmp neq reg 1 0x00000000 ]

# ct status dnat
ip test-ip4 output
  [ ct load status => reg 1 ]
  [ bitwise reg 1 = (reg=1 & 0x00000020 ) ^ 0x00000000 ]
  [ cmp neq reg 1 0x00000000 ]

# ct event set new
ip test-ip4 output
  [ immediate reg 1 0x00000001 ]
  [ ct set event with reg 1 ]

# ct event set new | related | destroy | label
ip test-ip4 output
  [ immediate reg 1 0x00000407 ]
  [ ct set event with reg 1 ]

# ct event set new,related,destroy,label
ip test-ip4 output
  [ immediate reg 1 0x00000407 ]
  [ ct set event with reg 1 ]

# ct event set new,destroy
ip test-ip4 output
  [ immediate reg 1 0x00000005 ]
  [ ct set event with reg 1 ]

# ct event set 1
ip test-ip4 output
  [ immediate reg 1 0x00000001 ]
  [ ct set event with reg 1 ]

# ct event set 0x0
ip test-ip4 output
  [ immediate reg 1 0x00000000 ]
  [ ct set event with reg 1 ]

# ct label 127
ip test-ip4 output
  [ ct load label => reg 1 ]
  [ bitwise reg 1 = (reg=1 & 0x00000000 0x00000000 0x00000000 0x80000000 ) ^ 0x00000000 0x00000000 0x00000000 0x00000000 ]
  [ cmp neq reg 1 0x00000000 0x00000000 0x00000000 0x00000000 ]

# ct label set 127
ip test-ip4 output
  [ immediate reg 1 0x00000000 0x00000000 0x00000000 0x80000000 ]
  [ ct set label with reg 1 ]

# ct zone 0
ip test-ip4 output
  [ ct load zone => reg 1 ]
  [ cmp eq reg 1 0x00000000 ]

# ct zone 23
ip test-ip4 output
  [ ct load zone => reg 1 ]
  [ cmp eq reg 1 0x00000017 ]

# ct original zone 1
ip test-ip4 output
  [ ct load zone => reg 1 , dir original ]
  [ cmp eq reg 1 0x00000001 ]

# ct reply zone 1
ip test-ip4 output
  [ ct load zone => reg 1 , dir reply ]
  [ cmp eq reg 1 0x00000001 ]

# ct zone set 1
ip test-ip4 output
  [ immediate reg 1 0x00000001 ]
  [ ct set zone with reg 1 ]

# ct original zone set 1
ip test-ip4 output
  [ immediate reg 1 0x00000001 ]
  [ ct set zone with reg 1 , dir original ]

# ct reply zone set 1
ip test-ip4 output
  [ immediate reg 1 0x00000001 ]
  [ ct set zone with reg 1 , dir reply ]

# ct zone set mark map { 1 : 1,  2 : 2 }
__map%d test-ip4 b
__map%d test-ip4 0
        element 00000001  : 00000001 0 [end]    element 00000002  : 00000002 0 [end]
ip test-ip4 output
  [ meta load mark => reg 1 ]
  [ lookup reg 1 set __map%d dreg 1 ]
  [ ct set zone with reg 1 ]

# notrack
ip test-ip4 output
  [ notrack ]