Skip to content
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

[yang] Update YANG model for mirror session to support decimal value for GRE type #10140

Merged

Conversation

bingwang-ms
Copy link
Contributor

Signed-off-by: bingwang bingwang@microsoft.com

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 ==========================================================================================

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111

Description for the changelog

Update YANG model for mirror session to support decimal value for GRE type.

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

Signed-off-by: bingwang <bingwang@microsoft.com>
@bingwang-ms bingwang-ms requested a review from qiluo-msft as a code owner March 3, 2022 04:54
@bingwang-ms
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

You have several pipelines (over 10) configured to build pull requests in this repository. Specify which pipelines you would like to run by using /azp run [pipelines] command. You can specify multiple pipelines using a comma separated list.

@@ -99,7 +99,7 @@ module sonic-mirror-session {
leaf gre_type {
when "current()/../type = 'ERSPAN'";
type string {
pattern "0[xX][0-9a-fA-F]*";
pattern "0[xX][0-9a-fA-F]*|[1-9][0-9]*";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be the pattern. This would allow values out of range. The pattern should restrict values from 0-65535.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I updated the pattern for matching decimal, and some test cases as well. Not we only accept values in range [0, 65535].
Please be noticed that values as 0x0 and 0 are also accepted.

@dgsudharsan dgsudharsan added YANG YANG model related changes Request for 202111 Branch For PRs being requested for 202111 branch labels Mar 9, 2022
Signed-off-by: bingwang <wang.bing@microsoft.com>
Signed-off-by: bingwang <wang.bing@microsoft.com>
Signed-off-by: bingwang <wang.bing@microsoft.com>
@bingwang-ms
Copy link
Contributor Author

@dgsudharsan Please help take a look one more time. Thanks

}
}
},
"MIRROR_ERSPAN_ENTRY_WITH_VALID_DEC_VALUES_3": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this hex value example for GRE type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I fixed the typo. Thanks

Signed-off-by: bingwang <bingwang@microsoft.com>
@bingwang-ms
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

You have several pipelines (over 10) configured to build pull requests in this repository. Specify which pipelines you would like to run by using /azp run [pipelines] command. You can specify multiple pipelines using a comma separated list.

@bingwang-ms
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

You have several pipelines (over 10) configured to build pull requests in this repository. Specify which pipelines you would like to run by using /azp run [pipelines] command. You can specify multiple pipelines using a comma separated list.

@bingwang-ms
Copy link
Contributor Author

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@dgsudharsan
Copy link
Collaborator

@qiluo-msft Can you please review and sign off?

@qiluo-msft qiluo-msft merged commit fb7f046 into sonic-net:master Mar 19, 2022
@qiluo-msft qiluo-msft changed the title Update YANG model for mirror session to support decimal value for GRE type [yang] Update YANG model for mirror session to support decimal value for GRE type Mar 19, 2022
judyjoseph pushed a commit that referenced this pull request Mar 20, 2022
…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.
praveen-li pushed a commit to praveen-li/sonic-buildimage that referenced this pull request Dec 23, 2022
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Included in 202111 Branch Request for 202111 Branch For PRs being requested for 202111 branch YANG YANG model related changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants