-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathEverflow-test-plan.md
1213 lines (1062 loc) · 54 KB
/
Everflow-test-plan.md
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
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
- [Overview](#overview)
- [Scope](#scope)
- [Summary of the existing everflow test plan](#summary-of-the-existing-everflow-test-plan)
- [Extend the test plan to cover both ingress and egress mirroring](#extend-the-test-plan-to-cover-both-ingress-and-egress-mirroring)
- [What new enhancements need to be covered?](#what-new-enhancements-need-to-be-covered)
- [Egress ACL table](#egress-acl-table)
- [Egress mirroring](#egress-mirroring)
- [Some existing areas not covered by the existing scripts](#some-existing-areas-not-covered-by-the-existing-scripts)
- [ACL rule for matching "IN_PORTS"](#acl-rule-for-matching-in_ports)
- [ACL rule for matching ICMP type and code](#acl-rule-for-matching-icmp-type-and-code)
- [IPv6 everflow](#ipv6-everflow)
- [How to extend the testing](#how-to-extend-the-testing)
- [Combine the existing test cases](#combine-the-existing-test-cases)
- [Test configurations](#test-configurations)
- [ACL table configurations](#acl-table-configurations)
- [Related **DUT** CLI commands](#related-dut-cli-commands)
- [`sonic-cfggen` Advanced config_db updating tool](#sonic-cfggen-advanced-config_db-updating-tool)
- [`config acl add table <table_name> <table_type>` Add ACL table](#config-acl-add-table-table_name-table_type-add-acl-table)
- [`config acl remove table <table_name>` Remove ACL table](#config-acl-remove-table-table_name-remove-acl-table)
- [`config acl update` Update ACL rules](#config-acl-update-update-acl-rules)
- [`acl-loader` Update ACL rules](#acl-loader-update-acl-rules)
- [`aclshow` Show ACL rule counters](#aclshow-show-acl-rule-counters)
- [`config mirror_session` Configure everflow mirror session](#config-mirror_session-configure-everflow-mirror-session)
- [Test structure](#test-structure)
- [Overall structure](#overall-structure)
- [Prepare some variables for testing](#prepare-some-variables-for-testing)
- [Add everflow configuration](#add-everflow-configuration)
- [ACL tables](#acl-tables)
- [Mirror sessions](#mirror-sessions)
- [ACL rules](#acl-rules)
- [Run test](#run-test)
- [PTF Test](#ptf-test)
- [Test cases](#test-cases)
- [Test case \#1 - Packets mirrored to best match resolved route](#test-case-1---packets-mirrored-to-best-match-resolved-route)
- [Test objective](#test-objective)
- [Test steps](#test-steps)
- [Test case \#2 - Change neighbor MAC address.](#test-case-2---change-neighbor-mac-address)
- [Test objective](#test-objective-1)
- [Test steps](#test-steps-1)
- [Test case \#3 - ECMP route change (remove next hop not used by session).](#test-case-3---ecmp-route-change-remove-next-hop-not-used-by-session)
- [Test objective](#test-objective-2)
- [Test steps](#test-steps-2)
- [Test case \#4 - ECMP route change (remove next hop used by session).](#test-case-4---ecmp-route-change-remove-next-hop-used-by-session)
- [Test objective](#test-objective-3)
- [Test steps](#test-steps-3)
- [Test case \#5 - Policer enforced DSCP value/mask test.](#test-case-5---policer-enforced-dscp-valuemask-test)
- [Test objective](#test-objective-4)
- [Test steps](#test-steps-4)
- [TODO](#todo)
- [Open Questions](#open-questions)
## Overview
This document is an updated version of the existing everflow test plan: https://github.com/sonic-net/SONiC/wiki/Everflow-test-plan
The purpose is to test functionality of Everflow on the SONIC switch DUT with and without LAGs configured, closely resembling production environment.
The test assumes all necessary configuration, including Everflow session and ACL rules, LAG configuration and BGP routes, are already pre-configured on the SONIC switch before test runs.
### Scope
The test is targeting a running SONIC system with fully functioning configuration.
The purpose of the test is not to test specific SAI API, but functional testing of Everflow on SONiC system, making sure that traffic flows correctly, according to BGP routes advertised by BGP peers of SONIC switch, and the LAG configuration.
NOTE: Everflow+LAG test will be able to run **only** in the testbed specifically created for LAG.
### Summary of the existing everflow test plan
The existing everflow scripts:
```
ansible/
roles/
test/
tasks/
everflow_testbed.yml
everflow_testbed/
apply_config/
acl_rule_persistent.json
expect_messages.txt
del_config/
acl_rule_persistent-del.json
acl_rule_persistent.json
acl_table.json
expect_messages.txt
session.json
apply_config.yml
del_config.yml
get_neighbor_info.yml
get_port_info.yml
get_session_info.yml
run_test.yml
testcase_1.yml
testcase_2.yml
testcase_3.yml
testcase_4.yml
testcase_5.yml
testcase_6.yml
testcase_7.yml
testcase_8.yml
files/
acstests/
everflow_tb_test.py
everflow_policer_test.py
```
The existing everflow test plan only covers ingress mirroring. ACL rules are added to ACL table of type "MIRROR". And by default, packets are only checked against the ACL rules on ingress stage. On ports that are bound to everflow ACL table, any ingress packets hitting the ACL rules are copied to associated mirror destination in GRE tunnel.
Two packet directions are covered in the exist testing: SPINE -> TOR ports and TOR -> SPINE ports. When the injected packets hit any of the configured ACL rules in the ingress stage, the packets will be mirrored to configured mirror destination. GRE tunnel is used for sending mirrored packets with src, dst IP and other parameters configured in the mirror session. Below test cases are used for verifying that the DUT switch can properly forwarded the mirrored packets according to different routing configurations for mirror session destination.
Example ACL table in config_db for everflow testing, type of the table is `MIRROR`:
```
{
"ACL_TABLE": {
"EVERFLOW": {
"policy_desc": "EVERFLOW",
"ports": [
"Ethernet100",
"Ethernet104",
"Ethernet92",
"Ethernet96",
"Ethernet84",
"Ethernet88",
"Ethernet76",
"Ethernet80",
"Ethernet108",
"Ethernet112",
"Ethernet64",
"Ethernet60",
"Ethernet52",
"Ethernet48",
"Ethernet44",
"Ethernet40",
"Ethernet36",
"Ethernet120",
"Ethernet116",
"Ethernet56",
"Ethernet124",
"Ethernet72",
"Ethernet68",
"Ethernet24",
"Ethernet20",
"Ethernet16",
"Ethernet12",
"Ethernet8",
"Ethernet4",
"Ethernet0",
"Ethernet32",
"Ethernet28"
],
"type": "MIRROR"
}
}
}
```
Example ACL rules in config_db for everflow testing, action field and value of the ACL rules is `MIRROR_ACTION: <session_name>`:
```
{
"ACL_RULE": {
"EVERFLOW|RULE_1": {
"MIRROR_ACTION": "test_session_1",
"PRIORITY": "9999",
"SRC_IP": "20.0.0.10/32"
},
"EVERFLOW|RULE_2": {
"DST_IP": "30.0.0.10/32",
"MIRROR_ACTION": "test_session_1",
"PRIORITY": "9998"
},
"EVERFLOW|RULE_3": {
"L4_SRC_PORT": "4661",
"MIRROR_ACTION": "test_session_1",
"PRIORITY": "9997"
},
"EVERFLOW|RULE_4": {
"L4_DST_PORT": "4661",
"MIRROR_ACTION": "test_session_1",
"PRIORITY": "9996"
},
"EVERFLOW|RULE_5": {
"ETHER_TYPE": "4660",
"MIRROR_ACTION": "test_session_1",
"PRIORITY": "9995"
},
"EVERFLOW|RULE_6": {
"IP_PROTOCOL": "126",
"MIRROR_ACTION": "test_session_1",
"PRIORITY": "9994"
},
"EVERFLOW|RULE_7": {
"MIRROR_ACTION": "test_session_1",
"PRIORITY": "9993",
"TCP_FLAGS": "0x12/0x12"
},
"EVERFLOW|RULE_8": {
"L4_SRC_PORT_RANGE": "4672-4681",
"MIRROR_ACTION": "test_session_1",
"PRIORITY": "9992"
},
"EVERFLOW|RULE_9": {
"L4_DST_PORT_RANGE": "4672-4681",
"MIRROR_ACTION": "test_session_1",
"PRIORITY": "9991"
},
"EVERFLOW|RULE_10": {
"DSCP": "51",
"MIRROR_ACTION": "test_session_1",
"PRIORITY": "9990"
}
}
}
```
Examples of show the ACL table and rules configuration from command line:
```
$ show acl table EVERFLOW
Name Type Binding Description
-------- ------ ----------- -------------
EVERFLOW MIRROR Ethernet0 EVERFLOW
Ethernet4
Ethernet8
Ethernet12
Ethernet16
Ethernet20
Ethernet24
Ethernet28
Ethernet32
Ethernet36
Ethernet40
Ethernet44
Ethernet48
Ethernet52
Ethernet56
Ethernet60
Ethernet64
Ethernet68
Ethernet72
Ethernet76
Ethernet80
Ethernet84
Ethernet88
Ethernet92
Ethernet96
Ethernet100
Ethernet104
Ethernet108
Ethernet112
Ethernet116
Ethernet120
Ethernet124
$ show acl rule
Table Rule Priority Action Match
-------- ------- ---------- ---------------------- ----------------------------
EVERFLOW RULE_1 9999 MIRROR: test_session_1 SRC_IP: 20.0.0.10/32
EVERFLOW RULE_2 9998 MIRROR: test_session_1 DST_IP: 30.0.0.10/32
EVERFLOW RULE_3 9997 MIRROR: test_session_1 L4_SRC_PORT: 4661
EVERFLOW RULE_4 9996 MIRROR: test_session_1 L4_DST_PORT: 4661
EVERFLOW RULE_5 9995 MIRROR: test_session_1 ETHER_TYPE: 4660
EVERFLOW RULE_6 9994 MIRROR: test_session_1 IP_PROTOCOL: 126
EVERFLOW RULE_7 9993 MIRROR: test_session_1 TCP_FLAGS: 0x12/0x12
EVERFLOW RULE_8 9992 MIRROR: test_session_1 L4_SRC_PORT_RANGE: 4672-4681
EVERFLOW RULE_9 9991 MIRROR: test_session_1 L4_DST_PORT_RANGE: 4672-4681
EVERFLOW RULE_10 9990 MIRROR: test_session_1 DSCP: 51
```
Existing test cases:
* testcase 1 - Resolved route
* testcase 2 - Longer prefix route with resolved next hop
* testcase 3 - Remove longer prefix route
* testcase 4 - Change neighbor MAC address
* testcase 5 - Resolved ECMP route
* testcase 6 - ECMP route change (remove next hop not used by session)
* testcase 7 - ECMP route change (remove next hop used by session)
* testcase 8 - Policer enforced DSCP value/mask test
### Extend the test plan to cover both ingress and egress mirroring
#### What new enhancements need to be covered?
##### Egress ACL table
In Jan 2019, egress ACL table support is added (https://github.com/sonic-net/SONiC/pull/322, https://github.com/sonic-net/sonic-swss/pull/741) to SONiC. Then ACL table can have an extra field `stage` indicting on which stage will the ACL rules be checked against packets. If the `stage` is ignored or is set to 'ingress', the behavior is same as before, ingress packets will be checked against ACL rules. If the `stage` field is set to 'egress', then on ports bound to ACL table, egress packets will be checked against the ACL rules and will be handled according to the action configured for the ACL rules. The action could be `PACKET_ACTION` or `MIRROR_ACTION`.
##### Egress mirroring
Besides the egress ACL table support, a recent enhancement (Design: https://github.com/sonic-net/SONiC/pull/411 Implementations: https://github.com/sonic-net/sonic-swss/pull/963 https://github.com/sonic-net/sonic-utilities/pull/575) added egress mirroring support. This enhancement added two ACL rule action types based on the existing mirroring action `MIRROR_ACTION`:
* MIRROR_INGRESS_ACTION
* MIRROR_EGRESS_ACTION
The `MIRROR_INGRESS_ACTION` type new. But its behavior is same as the existing ingress mirroring. Packets hit ACL rule will be mirrored at the ingress stage.
The `MIRROR_EGRESS_ACTION` is a new action type which is for egress mirroring. It means that on ports bound to everflow ACL table, when packets hit ACL rules of that table, the packets will be mirrored at the egress stage. The original `MIRROR_ACTION` is kept for backward compatibility and it is implicitly set to "ingress" by default.
Combining these two enhancements, there are 4 scenarios for everflow.
1. ACL table of type `MIRROR` have `stage` field ignored or set to "ingress". Action type of ACL_RULE is `MIRROR_ACTION` or `MIRROR_INGRESS_ACTION`.
2. ACL table of type `MIRROR` have `stage` field ignored or set to "ingress". Action type of ACL_RULE is `MIRROR_EGRESS_ACTION`.
3. ACL table of type `MIRROR` have `stage` field set to "egress". Action type of ACL_RULE is `MIRROR_ACTION` or `MIRROR_INGRESS_ACTION`.
4. ACL table of type `MIRROR` have `stage` field set to "egress". Action type of ACL_RULE is `MIRROR_EGRESS_ACTION`.
Expected behaviors for the combinations:
| - | ACL table stage: ingress | ACL table stage: egress |
| ---------------------------------- | -------------------------------------------------------- | ------------------------------------------------------ |
| Action type: MIRROR_INGRESS_ACTION | Ingress packets hit ACL rules, mirrored at ingress stage | Not applicable |
| Action type: MIRROR_EGRESS_ACTION | Ingress packets hit ACL rules, mirrored at egress stage | Egress packets hit ACL rules, mirrored at egress stage |
Since not all the combinations are supported by all vendors, the enhancement also added ACL capability detection. The supported ACL action types at different stage are detected and stored in redis. The below is an example of showing detected capabilities:
```
$ redis-cli -n 6 hgetall 'SWITCH_CAPABILITY|switch'
1) "MIRROR"
2) "true"
3) "MIRRORV6"
4) "true"
5) "ACL_ACTIONS|INGRESS"
6) "PACKET_ACTION,REDIRECT_ACTION,MIRROR_INGRESS_ACTION"
7) "ACL_ACTIONS|EGRESS"
8) "PACKET_ACTION,MIRROR_EGRESS_ACTION"
9) "ACL_ACTION|PACKET_ACTION"
1) "DROP,FORWARD"
```
In the above example output, two everflow combinations are supported on the platform being checked:
* INGRESS stage, MIRROR_INGRESS_ACTION
* EGRESS stage, MIRROR_EGRESS_ACTION
This test plan needs to be extended to cover both the existing everflow function and the newly added capabilities.
#### Some existing areas not covered by the existing scripts
##### ACL rule for matching "IN_PORTS"
Now the SONiC ACL rules support matching "IN_PORTS". New ACL rule for matching "IN_PORTS" need to be added and covered.
#### ACL rule for matching ICMP type and code
The SONiC ACL rules also support matching ICMP type and code. New ACL rules for matching ICMP type and code need to be added and covered. The acl-loader utility does not support ICMP type and code yet. The sonic-cfggen tool will be used for directly loading such ACL rules to config_db.
##### IPv6 everflow
The existing scripts only covered IPv6. IPv6 is also supported by SONiC now. The scripts need to be extended to cover IPv6 everflow too. To cover IPv6:
* Everflow ACL table of type "MIRRORV6" needs to be defined and loaded during testing.
* Different stages (ingress & egress) also need to be covered.
* Different ACL rule mirror actions also need to be covered.
* New set of IPv6 ACL rules need to be defined and loaded during testing.
* The PTF script needs to be extended to inject and monitor IPv6 packets.
#### How to extend the testing
To cover the new enhancements, the existing scripts need to be extended:
* The existing structure, sub-tests and PTF scripts can be reused.
* Add new sets of configurations.
* We can refactor the run_test.yml to run the existing sub-tests in multiple iteration. Each iteration loads a different set of ACL table and ACL rules configuration.
* Adjust initialization of variables used in testing if needed.
* Add a new class in the existing PTF script to inject and monitor IPv6 packets.
* Add a sub-test and add a new class in the PTF script to cover ACL rule matching "IN_PORTS".
In a summary, the extended scripts need to do below work:
1. Firstly the script need to get capability info of the DUT from hard coded resource, then check against the detected capabilities in DB. Fail the test if capabilities do not match.
2. Create everflow ACL table with different stage setting. Load ACL rules with different action type.
3. Run test cases in the existing scripts (8 test cases at the time of writing).
4. Ensure that each combination of the supported ACL table stages and ACL rule action types are covered.
Summary of the possible combinations:
| Combinations | ACL table stage: ingress | ACL table stage: egress |
| ------------------------------ | ------------------------ | ----------------------- |
| ACL Rule MIRROR_INGRESS_ACTION | [x] | N/A |
| ACL Rule MIRROR_EGRESS_ACTION | [x] | [x] |
Totally there are 3 possible combinations. Not all the combinations are supported by all platforms. The actual combinations to be tested are determined the actual DUT platform.
Switch's ACL capability can be queried from DB table `SWITCH_CAPABILITY|switch`. The testing script can query ACL capability first. And then run the supported combinations, skip the unsupported combinations.
For example, if query SWITCH_CAPABILITY got below results:
```
$ redis-cli -n 6 hgetall "SWITCH_CAPABILITY|switch"
1) "ACL_ACTIONS|INGRESS"
2) "PACKET_ACTION,REDIRECT_ACTION,MIRROR_ACTION_INGRESS"
3) "ACL_ACTIONS|EGRESS"
4) "PACKET_ACTION,MIRROR_ACTION_EGRESS"
...
```
Then the platform only supports two combinations:
* ACL table stage ingress + ACL Rule MIRROR_INGRESS_ACTION
* ACL table stage egress + ACL Rule MIRROR_EGRESS_ACTION
The third combination would be skipped on this platform.
#### Combine the existing test cases
Some of the existing test cases are similar and doing repetitive testing. We remove and combine them to have a shorter list of test cases:
* Test case #1 is covered in #2, #3 and #4. It can be removed.
* Test case #2 and #3 can be combined to one case.
* Test case #5 is covered in #6. It can be removed.
### Test configurations
#### ACL table configurations
New ACL tables of type MIRROR and MIRRORv6 need to be created in testing. The new ACL tables also need to set different values for their "stage" attribute.
### Related **DUT** CLI commands
Summary of the CLI commands that will be used for configuring DUT.
#### `sonic-cfggen` Advanced config_db updating tool
This is the advanced tool for updating the config_db. It can be used for adding/removing ACL tables, ACL rules, mirror sessions and many more other configurations.
Some example usages:
* `sonic-cfggen -j <configuration_json_file> --write-to-db`: Load configuration in json format to config_db. The json file could be ACL table configuration.
* `sonic-cfggen -d -v ACL_TABLE`: Dump current ACL_TABLE configuration from config_db.
* `sonic-cfggen -d -v ACL_RULE`: Dump current ACL_RULE configuration from config_db.
#### `config acl add table <table_name> <table_type>` Add ACL table
Usage: `config acl add table [OPTIONS] <table_name> <table_type>`
This is the formal command for adding ACL table. ACL table added using this command is associated with all interfaces. If ACL table associated with a fraction of the interfaces is needed, the above `sonic-cfggen` method can be used. On versions that this formal command is not supported yet, the `sonic-cfggen` tool can be used.
#### `config acl remove table <table_name>` Remove ACL table
Usage: `config acl remove table [OPTIONS] <table_name>`
This is the formal command for removing ACL table.
#### `config acl update` Update ACL rules
Usages:
* `config acl update full [OPTIONS] FILE_NAME`
* `config acl update incremental [OPTIONS] FILE_NAME`
This is the formal command for loading ACL rules configuration from file specified by the FILE_NAME.
#### `acl-loader` Update ACL rules
Under the hood, the `config acl update` command called this `acl-loader` tool to load ACL rules configurations. For example:
* `acl-loader update full <acl_rule_configuration_json_file> [--session_name=<session_name> --mirror_stage=<ingress|egress>]`: Load acl rules specified in a json file to config_db.
On versions that the formal `config acl update` is not supported yet, this `acl-loader` tool or the `sonic-cfggen` tool can be used.
The acl-loader utility does not support load ACL rules matching ICMP type and code yet as the time of writing. The `sonic-cfggen` tool will be used for loading ACL rules matching ICMP type&code.
#### `aclshow` Show ACL rule counters
This tool is for collecting ACL rule counters. For example:
* `aclshow -a`
#### `config mirror_session` Configure everflow mirror session
This tool is for configuring everflow mirror session. For example:
* `config mirror_session add <session_name> <src_ip> <dst_ip> <dscp> <ttl> [gre_type] [queue]`
## Test structure
### Overall structure
The extended ansible test playbook will have below parts:
1. Prepare some variables for testing
2. Add everflow configuration
3. Run everflow sub-tests
4. Clear everflow configuration
5. Repeat steps 1-3 for other configuration scenarios
The subsequent sections will have more detailed description of part
### Prepare some variables for testing
Firstly, some variables need to be prepared for testing. For example, the source ports for injecting traffic. The expected destination ports for mirrored packets.
### Add everflow configuration
Before run the sub-tests for each scenario, the scripts need to setup by loading configurations to DUT for the scenario to be covered.
There will be j2 template files for generating ACL tables and ACL rules configurations. Ansible playbook will generate ACL tables and ACL rules json configuration files to DUT based on these templates, switch capability and running topology. Then commands `sonic-cfggen` and `acl-loader` can be used for loading the configurations.
Different sets of configuration files will be generated for different test scenarios:
* IPv4 in IPv4
* ACL table: MIRROR, ingress; IPv4 ACL rules, MIRROR_INGRESS_ACTION; Mirror session IPv4 src & dst IP address
* ACL table: MIRROR, ingress; IPv4 ACL rules, MIRROR_EGRESS_ACTION; Mirror session IPv4 src & dst IP address
* ACL table: MIRROR, egress; IPv4 ACL rules, MIRROR_EGRESS_ACTION; Mirror session IPv4 src & dst IP address
* IPv4 in IPv6
* ACL table: MIRROR, ingress; IPv4 ACL rules, MIRROR_INGRESS_ACTION; Mirror session IPv6 src & dst IP address
* ACL table: MIRROR, ingress; IPv4 ACL rules, MIRROR_EGRESS_ACTION; Mirror session IPv6 src & dst IP address
* ACL table: MIRROR, egress; IPv4 ACL rules, MIRROR_EGRESS_ACTION; Mirror session IPv6 src & dst IP address
* IPv6 in IPv4
* ACL table: MIRRORV6, ingress; IPv6 ACL rules, MIRROR_INGRESS_ACTION; Mirror session IPv4 src & dst IP address
* ACL table: MIRRORV6, ingress; IPv6 ACL rules, MIRROR_EGRESS_ACTION; Mirror session IPv4 src & dst IP address
* ACL table: MIRRORV6, egress; IPv6 ACL rules, MIRROR_EGRESS_ACTION; Mirror session IPv4 src & dst IP address
* IPv6 in IPv6
* ACL table: MIRRORV6, ingress; IPv6 ACL rules, MIRROR_INGRESS_ACTION; Mirror session IPv6 src & dst IP address
* ACL table: MIRRORV6, ingress; IPv6 ACL rules, MIRROR_EGRESS_ACTION; Mirror session IPv6 src & dst IP address
* ACL table: MIRRORV6, egress; IPv6 ACL rules, MIRROR_EGRESS_ACTION; Mirror session IPv6 src & dst IP address
Totally there are 12 scenarios to cover. To make the scripts flexible, command line options should be added for selecting which scenarios to run.
#### ACL tables
For each test scenario, an ACL table configuration need to be created and loaded to DUT. Command `sonic-cfggen` can be used to load the ACL table configuration into config_db. Command syntax: `sonic-cfggen -j <acl_table_configuration_filename> --write-to-db`.
Example ACL table configuration files to be generated for each scenario:
* ACL table: MIRROR, ingress
```
{
"ACL_TABLE": {
"EF_INGRESS": {
"policy_desc": "EVERFLOW ingress",
"ports": [
"Ethernet100", "Ethernet104", "Ethernet92", "Ethernet96", "Ethernet84", "Ethernet88", "Ethernet76", "Ethernet80", "Ethernet108", "Ethernet112", "Ethernet64", "Ethernet60", "Ethernet52", "Ethernet48", "Ethernet44", "Ethernet40", "Ethernet36", "Ethernet120", "Ethernet116", "Ethernet56", "Ethernet124", "Ethernet72", "Ethernet68", "Ethernet24", "Ethernet20", "Ethernet16", "Ethernet12", "Ethernet8", "Ethernet4", "Ethernet0", "Ethernet32", "Ethernet28"
],
"type": "MIRROR",
"stage": "ingress"
}
}
}
```
* ACL table: MIRROR, egress
```
{
"ACL_TABLE": {
"EF_EGRESS": {
"policy_desc": "EVERFLOW egress",
"ports": [
"Ethernet100", "Ethernet104", "Ethernet92", "Ethernet96", "Ethernet84", "Ethernet88", "Ethernet76", "Ethernet80", "Ethernet108", "Ethernet112", "Ethernet64", "Ethernet60", "Ethernet52", "Ethernet48", "Ethernet44", "Ethernet40", "Ethernet36", "Ethernet120", "Ethernet116", "Ethernet56", "Ethernet124", "Ethernet72", "Ethernet68", "Ethernet24", "Ethernet20", "Ethernet16", "Ethernet12", "Ethernet8", "Ethernet4", "Ethernet0", "Ethernet32", "Ethernet28"
],
"type": "MIRROR",
"stage": "egress"
}
}
}
```
* ACL table: MIRRORV6, ingress
```
{
"ACL_TABLE": {
"EFV6_INGRESS": {
"policy_desc": "EVERFLOW IPv6 ingress",
"ports": [
"Ethernet100", "Ethernet104", "Ethernet92", "Ethernet96", "Ethernet84", "Ethernet88", "Ethernet76", "Ethernet80", "Ethernet108", "Ethernet112", "Ethernet64", "Ethernet60", "Ethernet52", "Ethernet48", "Ethernet44", "Ethernet40", "Ethernet36", "Ethernet120", "Ethernet116", "Ethernet56", "Ethernet124", "Ethernet72", "Ethernet68", "Ethernet24", "Ethernet20", "Ethernet16", "Ethernet12", "Ethernet8", "Ethernet4", "Ethernet0", "Ethernet32", "Ethernet28"
],
"type": "MIRRORV6",
"stage": "ingress"
}
}
}
```
* ACL table: MIRRORV6, egress
```
{
"ACL_TABLE": {
"EFV6_EGRESS": {
"policy_desc": "EVERFLOW IPv6 egress",
"ports": [
"Ethernet100", "Ethernet104", "Ethernet92", "Ethernet96", "Ethernet84", "Ethernet88", "Ethernet76", "Ethernet80", "Ethernet108", "Ethernet112", "Ethernet64", "Ethernet60", "Ethernet52", "Ethernet48", "Ethernet44", "Ethernet40", "Ethernet36", "Ethernet120", "Ethernet116", "Ethernet56", "Ethernet124", "Ethernet72", "Ethernet68", "Ethernet24", "Ethernet20", "Ethernet16", "Ethernet12", "Ethernet8", "Ethernet4", "Ethernet0", "Ethernet32", "Ethernet28"
],
"type": "MIRRORV6",
"stage": "egress"
}
}
}
```
#### Mirror sessions
For each scenario, a mirror session is required. Totally two types of mirror sessions are required for all the scenarios:
* Mirror session using IPv4 source and destination IP addresses.
* Mirror session using IPv6 source and destination IP addresses.
The script will configure appropriate mirror session using `config mirror_session` while testing each of the scenario.
Add mirror_session using IPv4 source and destination IP addresses:
```
$ config mirror_session add session_v4 1.1.1.1 2.2.2.2 8 64 0x6558 0
$ acl-loader show session
Name Status SRC IP DST IP GRE DSCP TTL Queue
---------- -------- --------- -------- ------ ------ ----- -------
session_v4 inactive 1.1.1.1 2.2.2.2 0x6558 8 64 0
```
Add mirror_session using IPv6 source and destination IP addresses:
```
$ config mirror_session add session_v6 2000::1:1:1:1 2000::2:2:2:2 8 64 0x6558 0
$ acl-loader show session
Name Status SRC IP DST IP GRE DSCP TTL Queue
---------- -------- ------------- ------------- ------ ------ ----- -------
session_v6 inactive 2000::1:1:1:1 2000::2:2:2:2 0x6558 8 64 0
```
#### ACL rules
Generate different sets of ACL rules from template. Load the ACL rules using below command:
`acl-loader update full <acl_rule_configuration_json_file> --session_name=<mirror_session_name> --mirror_stage=<ingress|egress>`
For IPv4 testing, the ACL rules template:
```
{
"acl": {
"acl-sets": {
"acl-set": {
"{{ acl_table_name }}": {
"acl-entries": {
"acl-entry": {
"1": {
"actions": {
"config": {
"forwarding-action": "ACCEPT"
}
},
"config": {
"sequence-id": 1
},
"ip": {
"config": {
"source-ip-address": "20.0.0.10/32"
}
}
},
"2": {
"actions": {
"config": {
"forwarding-action": "ACCEPT"
}
},
"config": {
"sequence-id": 2
},
"ip": {
"config": {
"destination-ip-address": "192.168.0.10/32"
}
}
},
"3": {
"actions": {
"config": {
"forwarding-action": "ACCEPT"
}
},
"config": {
"sequence-id": 3
},
"transport": {
"config": {
"source-port": "4661"
}
}
},
"4": {
"actions": {
"config": {
"forwarding-action": "ACCEPT"
}
},
"config": {
"sequence-id": 4
},
"transport": {
"config": {
"destination-port": "4661"
}
}
},
"5": {
"actions": {
"config": {
"forwarding-action": "ACCEPT"
}
},
"config": {
"sequence-id": 5
},
"l2": {
"config": {
"ethertype": "4660"
}
}
},
"6": {
"actions": {
"config": {
"forwarding-action": "ACCEPT"
}
},
"config": {
"sequence-id": 6
},
"ip": {
"config": {
"protocol": 126
}
}
},
"7": {
"actions": {
"config": {
"forwarding-action": "ACCEPT"
}
},
"config": {
"sequence-id": 7
},
"transport": {
"config": {
"tcp-flags": ["TCP_ACK", "TCP_SYN"]
}
}
},
"8": {
"actions": {
"config": {
"forwarding-action": "ACCEPT"
}
},
"config": {
"sequence-id": 8
},
"transport": {
"config": {
"source-port": "4672..4681"
}
}
},
"9": {
"actions": {
"config": {
"forwarding-action": "ACCEPT"
}
},
"config": {
"sequence-id": 9
},
"transport": {
"config": {
"destination-port": "4672..4681"
}
}
},
"10": {
"actions": {
"config": {
"forwarding-action": "ACCEPT"
}
},
"config": {
"sequence-id": 10
},
"ip": {
"config": {
"dscp": "51"
}
}
},
"11": {
"actions": {
"config": {
"forwarding-action": "ACCEPT"
}
},
"config": {
"sequence-id": 10
},
"input_interface": {
"interface_ref": {
"config": {
"interface": "{{ acl_in_ports }}"
}
}
}
}
}
}
}
}
}
}
}
```
For IPv6 testing, the ACL rules template:
```
{
"acl": {
"acl-sets": {
"acl-set": {
"{{ acl_table_name }}": {
"acl-entries": {
"acl-entry": {
"1": {
"actions": {
"config": {
"forwarding-action": "ACCEPT"
}
},
"config": {
"sequence-id": 1
},
"ip": {
"config": {
"source-ip-address": "2000::20:0:0:10/64"
}
}
},
"2": {
"actions": {
"config": {
"forwarding-action": "ACCEPT"
}
},
"config": {
"sequence-id": 2
},
"ip": {
"config": {
"destination-ip-address": "fe80::192:168:0:10/64"
}
}
},
"3": {
"actions": {
"config": {
"forwarding-action": "ACCEPT"
}
},
"config": {
"sequence-id": 3
},
"transport": {
"config": {
"source-port": "4661"
}
}
},
"4": {
"actions": {
"config": {
"forwarding-action": "ACCEPT"
}
},
"config": {
"sequence-id": 4
},
"transport": {
"config": {
"destination-port": "4661"
}
}
},
"5": {
"actions": {
"config": {
"forwarding-action": "ACCEPT"
}
},
"config": {
"sequence-id": 5
},
"l2": {
"config": {
"ethertype": "4660"
}
}
},
"6": {
"actions": {
"config": {
"forwarding-action": "ACCEPT"
}
},
"config": {
"sequence-id": 6
},
"ip": {
"config": {
"protocol": 126
}
}
},
"7": {
"actions": {
"config": {
"forwarding-action": "ACCEPT"
}
},
"config": {
"sequence-id": 7
},
"transport": {
"config": {
"tcp-flags": ["TCP_ACK", "TCP_SYN"]
}
}
},
"8": {
"actions": {
"config": {
"forwarding-action": "ACCEPT"
}
},
"config": {
"sequence-id": 8
},
"transport": {
"config": {
"source-port": "4672..4681"
}
}
},
"9": {
"actions": {
"config": {
"forwarding-action": "ACCEPT"
}
},
"config": {
"sequence-id": 9
},
"transport": {
"config": {
"destination-port": "4672..4681"
}
}
},
"10": {
"actions": {
"config": {
"forwarding-action": "ACCEPT"
}
},
"config": {
"sequence-id": 10
},
"ip": {
"config": {
"dscp": "51"
}
}
},
"11": {
"actions": {
"config": {
"forwarding-action": "ACCEPT"
}
},
"config": {
"sequence-id": 10
},
"input_interface": {
"interface_ref": {
"config": {
"interface": "{{ acl_in_ports }}"
}
}
}
}
}
}
}
}
}
}
}
```
For example, if loaded IPv4 ACL rules into ACL table EF_EGRESS, used MIRROR_EGRESS_ACTION, used mirror session session_v4, they should be like below in config_db:
```
{
"ACL_RULE": {
"EF_EGRESS|RULE_1": {
"MIRROR_EGRESS_ACTION": "session_v4",
"PRIORITY": "9999",
"SRC_IP": "20.0.0.10/32"
},
"EF_EGRESS|RULE_2": {
"DST_IP": "30.0.0.10/32",
"MIRROR_EGRESS_ACTION": "session_v4",
"PRIORITY": "9998"
},
"EF_EGRESS|RULE_3": {
"L4_SRC_PORT": "4661",
"MIRROR_EGRESS_ACTION": "session_v4",
"PRIORITY": "9997"
},
"EF_EGRESS|RULE_4": {
"L4_DST_PORT": "4661",
"MIRROR_EGRESS_ACTION": "session_v4",
"PRIORITY": "9996"
},
"EF_EGRESS|RULE_5": {
"ETHER_TYPE": "4660",
"MIRROR_EGRESS_ACTION": "session_v4",
"PRIORITY": "9995"
},
"EF_EGRESS|RULE_6": {
"IP_PROTOCOL": "126",
"MIRROR_EGRESS_ACTION": "session_v4",
"PRIORITY": "9994"
},
"EF_EGRESS|RULE_7": {
"MIRROR_EGRESS_ACTION": "session_v4",
"PRIORITY": "9993",
"TCP_FLAGS": "0x12/0x12"
},
"EF_EGRESS|RULE_8": {
"L4_SRC_PORT_RANGE": "4672-4681",
"MIRROR_EGRESS_ACTION": "session_v4",
"PRIORITY": "9992"