-
Notifications
You must be signed in to change notification settings - Fork 669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validate input of config mirror_session add
#1825
Validate input of config mirror_session add
#1825
Conversation
Signed-off-by: bingwang <bingwang@microsoft.com>
Signed-off-by: bingwang <bingwang@microsoft.com>
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the queue parameter is also used in span, I suggest adding a test for it with the config mirror-session span add command.
Signed-off-by: bingwang <wang.bing@microsoft.com>
Thanks. Updated |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
@raphaelt-nvidia Hi, could you help to take a look again? Thanks |
Question about how the test works: If the test runs only in the mock environment, then LGTM. If it calls real SAI, then whether trying to configure queue=100 produces errors in the log is platform-dependent, and how it is dependent should change soon when I submit a PR to check the actual maximum queue value via SAI. |
The UT is only running in mocked environment, and there is no orchagent and no syncd, and so there is no SAI. The verification is on CLI level. |
SO LGTM. Should someone else review? |
@@ -953,6 +958,19 @@ def cache_arp_entries(): | |||
open(restore_flag_file, 'w').close() | |||
return success | |||
|
|||
|
|||
def validate_ipv4_address(ctx, param, ip_addr): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please move this to common so it can be used by other files in future? -
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Impmenting a common function to validate IP address is a good suggestion, but this interface is not to be common because this one is implemented as a callback interface of click. I will implement that common interface in another PR.
* Validate input of add mirror session Signed-off-by: bingwang <bingwang@microsoft.com>
Our QA has noticed that the new range checking for gre requires the value to be entered in decimal. The command reference https://github.com/Azure/sonic-utilities/blob/master/doc/Command-Reference.md#mirroring-config-commands doesn't define it explicitly, but the following text suggests that hex format should at least be allowed, if not preferred: optional - GRE Type in case if user wants to send the packet via GRE tunnel. GRE type could be anything; it could also be left as empty; by default, it is 0x8949 for Mellanox; and 0x88be for the rest of the chips. @bingwang-ms , what do you think? |
…for GRE type (#10140) #### Why I did it PR sonic-net/sonic-utilities#1825 added validation for the input of `config mirror session add`, and only decimal value is accepted. An issue #10096 was raised to suggest accepting HEX value as well, and the suggestion makes sense to me. To accept HEX value for GRE type, and keep backward compatibility as well, I updated the YANG model to support both decimal and hexadecimal input for GRE type. #### How I did it Update the regex for GRE type. #### How to verify it Verified by UT ``` platform linux -- Python 3.9.2, pytest-6.0.2, py-1.10.0, pluggy-0.13.0 rootdir: /sonic/src/sonic-yang-models plugins: pyfakefs-4.5.4, cov-2.10.1 collected 3 items tests/test_sonic_yang_models.py .. [ 66%] tests/yang_model_tests/test_yang_model.py . [100%] ========================================================================================== 3 passed in 2.53s ========================================================================================== ``` #### Description for the changelog Update YANG model for mirror session to support decimal value for GRE type.
…for GRE type (#10140) #### Why I did it PR sonic-net/sonic-utilities#1825 added validation for the input of `config mirror session add`, and only decimal value is accepted. An issue #10096 was raised to suggest accepting HEX value as well, and the suggestion makes sense to me. To accept HEX value for GRE type, and keep backward compatibility as well, I updated the YANG model to support both decimal and hexadecimal input for GRE type. #### How I did it Update the regex for GRE type. #### How to verify it Verified by UT ``` platform linux -- Python 3.9.2, pytest-6.0.2, py-1.10.0, pluggy-0.13.0 rootdir: /sonic/src/sonic-yang-models plugins: pyfakefs-4.5.4, cov-2.10.1 collected 3 items tests/test_sonic_yang_models.py .. [ 66%] tests/yang_model_tests/test_yang_model.py . [100%] ========================================================================================== 3 passed in 2.53s ========================================================================================== ``` #### Description for the changelog Update YANG model for mirror session to support decimal value for GRE type.
8768089 (HEAD -> 202012, origin/202012) Remove exec from platform_reboot_plugin call to handle any hang issue. (sonic-net#1879) ae5d90c Validate input of ```config mirror_session add``` (sonic-net#1825) 44d3a3b [show][config] fix the muxcable commands for interface naming mode (sonic-net#1862) 0a4933e [TH3] Skipp Control Plane Assist on WARM Reboot for TH3 HWSKUs (sonic-net#1861) Signed-off-by: vaibhav-dahiya <vdahiya@microsoft.com>
…for GRE type (sonic-net#10140) #### Why I did it PR sonic-net/sonic-utilities#1825 added validation for the input of `config mirror session add`, and only decimal value is accepted. An issue sonic-net#10096 was raised to suggest accepting HEX value as well, and the suggestion makes sense to me. To accept HEX value for GRE type, and keep backward compatibility as well, I updated the YANG model to support both decimal and hexadecimal input for GRE type. #### How I did it Update the regex for GRE type. #### How to verify it Verified by UT ``` platform linux -- Python 3.9.2, pytest-6.0.2, py-1.10.0, pluggy-0.13.0 rootdir: /sonic/src/sonic-yang-models plugins: pyfakefs-4.5.4, cov-2.10.1 collected 3 items tests/test_sonic_yang_models.py .. [ 66%] tests/yang_model_tests/test_yang_model.py . [100%] ========================================================================================== 3 passed in 2.53s ========================================================================================== ``` #### Description for the changelog Update YANG model for mirror session to support decimal value for GRE type.
What I did
This PR fixed sonic-net/sonic-buildimage#7990
Type and value validation is added for CLI
config mirror_session add
.The value range is defined below
How I did it
Add a value validation at CLI level.
How to verify it
Verified by UT
Previous command output (if the output of a command-line utility has changed)
New command output (if the output of a command-line utility has changed)