Skip to content

[mirror] erspan ipv6 underlay (see PR #1817)#3317

Merged
prsunny merged 13 commits intosonic-net:masterfrom
mramezani95:v6erspan
Nov 18, 2024
Merged

[mirror] erspan ipv6 underlay (see PR #1817)#3317
prsunny merged 13 commits intosonic-net:masterfrom
mramezani95:v6erspan

Conversation

@mramezani95
Copy link
Contributor

Why I did it
Unlock erspan capability on td3 and beyond that supports erspan ipv6 encap.

What I did

How I verified it

  1. Extend test_MirrorAddSetRemove, test_MirrorToVlanAddRemove, test_MirrorToLagAddRemove, test_MirrorDestMoveVlan, test_MirrorDestMoveLag to vs test erspan ipv6 encap
  2. On td3

Details if related
Used brcm sai 4.3.3 that interacts with sdk 6.5.21

Notes
Copied from PR #1817

@mramezani95 mramezani95 requested a review from prsunny as a code owner October 8, 2024 01:01
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 8, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@prsunny
Copy link
Collaborator

prsunny commented Oct 8, 2024

@mramezani95 , can you please check the VS test failures?

@mramezani95
Copy link
Contributor Author

@prsunny This test fails: test_duplicate_eni_route_group.

@prsunny prsunny merged commit c865803 into sonic-net:master Nov 18, 2024
github-actions bot pushed a commit to bradh352/sonic-swss that referenced this pull request Nov 19, 2024
* Applied changes from PR sonic-net#1817
Why I did it
Unlock erspan capability on td3 and beyond that supports erspan ipv6 encap.

What I did
Extend test_MirrorAddSetRemove, test_MirrorToVlanAddRemove, test_MirrorToLagAddRemove, test_MirrorDestMoveVlan, test_MirrorDestMoveLag to vs test erspan ipv6 encap
On td3
bradh352 pushed a commit to bradh352/sonic-swss that referenced this pull request Nov 19, 2024
* Applied changes from PR sonic-net#1817
Why I did it
Unlock erspan capability on td3 and beyond that supports erspan ipv6 encap.

What I did
Extend test_MirrorAddSetRemove, test_MirrorToVlanAddRemove, test_MirrorToLagAddRemove, test_MirrorDestMoveVlan, test_MirrorDestMoveLag to vs test erspan ipv6 encap
On td3
mlok-nokia pushed a commit to mlok-nokia/sonic-swss that referenced this pull request Nov 22, 2024
* Applied changes from PR sonic-net#1817
Why I did it
Unlock erspan capability on td3 and beyond that supports erspan ipv6 encap.

What I did
Extend test_MirrorAddSetRemove, test_MirrorToVlanAddRemove, test_MirrorToLagAddRemove, test_MirrorDestMoveVlan, test_MirrorDestMoveLag to vs test erspan ipv6 encap
On td3
bradh352 pushed a commit to bradh352/sonic-swss that referenced this pull request Dec 4, 2024
* Applied changes from PR sonic-net#1817
Why I did it
Unlock erspan capability on td3 and beyond that supports erspan ipv6 encap.

What I did
Extend test_MirrorAddSetRemove, test_MirrorToVlanAddRemove, test_MirrorToLagAddRemove, test_MirrorDestMoveVlan, test_MirrorDestMoveLag to vs test erspan ipv6 encap
On td3
divyachandralekha pushed a commit to divyachandralekha/sonic-swss that referenced this pull request Dec 12, 2024
* Applied changes from PR sonic-net#1817
Why I did it
Unlock erspan capability on td3 and beyond that supports erspan ipv6 encap.

What I did
Extend test_MirrorAddSetRemove, test_MirrorToVlanAddRemove, test_MirrorToLagAddRemove, test_MirrorDestMoveVlan, test_MirrorDestMoveLag to vs test erspan ipv6 encap
On td3
divyachandralekha pushed a commit to divyachandralekha/sonic-swss that referenced this pull request Dec 12, 2024
* Applied changes from PR sonic-net#1817
Why I did it
Unlock erspan capability on td3 and beyond that supports erspan ipv6 encap.

What I did
Extend test_MirrorAddSetRemove, test_MirrorToVlanAddRemove, test_MirrorToLagAddRemove, test_MirrorDestMoveVlan, test_MirrorDestMoveLag to vs test erspan ipv6 encap
On td3
@prsunny
Copy link
Collaborator

prsunny commented Feb 1, 2025

sonic-mgmt tests - sonic-net/sonic-mgmt#16752

shiraez pushed a commit to Marvell-switching/sonic-swss that referenced this pull request Feb 17, 2025
* Applied changes from PR sonic-net#1817
Why I did it
Unlock erspan capability on td3 and beyond that supports erspan ipv6 encap.

What I did
Extend test_MirrorAddSetRemove, test_MirrorToVlanAddRemove, test_MirrorToLagAddRemove, test_MirrorDestMoveVlan, test_MirrorDestMoveLag to vs test erspan ipv6 encap
On td3
mssonicbld added a commit to mssonicbld/sonic-mgmt.msft that referenced this pull request Mar 3, 2025
<!--
Please make sure you've read and understood our contributing guidelines;
https://github.com/sonic-net/SONiC/blob/gh-pages/CONTRIBUTING.md

Please provide following information to help code review process a bit easier:
-->
### Description of PR
<!--
- Please include a summary of the change and which issue is fixed.
- Please also include relevant motivation and context. Where should reviewer start? background context?
- List any dependencies that are required for this change.
-->

Summary:
Microsoft ADO id: 30441649
After [PR 3317 in sonic-swss repo](sonic-net/sonic-swss#3317), it is possible to configure ERSPAN sessions with IPv6 source and destination addresses. This PR parametrizes existing Everflow tests with the IP version of the mirrored GRE packets (i.e., the version of the outer IP header).

### Type of change

<!--
- Fill x for your type of change.
- e.g.
- [x] Bug fix
-->

- [ ] Bug fix
- [ ] Testbed and Framework(new/improvement)
- [ ] New Test case
    - [ ] Skipped for non-supported platforms
- [x] Test case improvement

### Back port request
- [ ] 202012
- [ ] 202205
- [ ] 202305
- [ ] 202311
- [ ] 202405
- [ ] 202411

### Approach
#### What is the motivation for this PR?
Adding support for IPv6 encapsulation to Everflow packet mirroring tests.

#### How did you do it?
Parametrized existing Everflow tests with the IP version of the outer IP header.

#### How did you verify/test it?
Tested on Broadcom T0.

#### Any platform specific information?
N/A

#### Supported testbed topology if it's a new test case?
T0, T1, T2, and M0

### Documentation
<!--
(If it's a new feature, new test case)
Did you update documentation/Wiki relevant to your implementation?
Link to the wiki page?
-->
N/A
mssonicbld added a commit to Azure/sonic-mgmt.msft that referenced this pull request Mar 3, 2025
…sts (#132)

<!--
Please make sure you've read and understood our contributing guidelines;
https://github.com/sonic-net/SONiC/blob/gh-pages/CONTRIBUTING.md

Please provide following information to help code review process a bit easier:
-->
### Description of PR
<!--
- Please include a summary of the change and which issue is fixed.
- Please also include relevant motivation and context. Where should reviewer start? background context?
- List any dependencies that are required for this change.
-->

Summary:
Microsoft ADO id: 30441649
After [PR 3317 in sonic-swss repo](sonic-net/sonic-swss#3317), it is possible to configure ERSPAN sessions with IPv6 source and destination addresses. This PR parametrizes existing Everflow tests with the IP version of the mirrored GRE packets (i.e., the version of the outer IP header).

### Type of change

<!--
- Fill x for your type of change.
- e.g.
- [x] Bug fix
-->

- [ ] Bug fix
- [ ] Testbed and Framework(new/improvement)
- [ ] New Test case
 - [ ] Skipped for non-supported platforms
- [x] Test case improvement

### Back port request
- [ ] 202012
- [ ] 202205
- [ ] 202305
- [ ] 202311
- [ ] 202405
- [ ] 202411

### Approach
#### What is the motivation for this PR?
Adding support for IPv6 encapsulation to Everflow packet mirroring tests.

#### How did you do it?
Parametrized existing Everflow tests with the IP version of the outer IP header.

#### How did you verify/test it?
Tested on Broadcom T0.

#### Any platform specific information?
N/A

#### Supported testbed topology if it's a new test case?
T0, T1, T2, and M0

### Documentation
<!--
(If it's a new feature, new test case)
Did you update documentation/Wiki relevant to your implementation?
Link to the wiki page?
-->
N/A
mssonicbld added a commit to mssonicbld/sonic-buildimage that referenced this pull request Jul 12, 2025
<!--
     Please make sure you've read and understood our contributing guidelines:
     https://github.com/Azure/SONiC/blob/gh-pages/CONTRIBUTING.md

     ** Make sure all your commits include a signature generated with `git commit -s` **

     If this is a bug fix, make sure your description includes "fixes #xxxx", or
     "closes #xxxx" or "resolves #xxxx"

     Please provide the following information:
-->

#### Why I did it
[PR 3317](sonic-net/sonic-swss#3317) in sonic-swss enables configuration of IPv6 mirror sessions (in which both `src_ip` and `dst_ip` are IPv6 addresses). This PR updates the YANG model for ERSPAN mirror sessions so that IPv6 mirror sessions can be configured using the `config apply-patch` command.

##### Work item tracking
- Microsoft ADO **(number only)**: 33501400

#### How I did it
1. Changed the type of `src_ip` and `dst_ip` for ERSPAN mirror sessions to `ip-address` so that IPv6 addresses are also accepted.
2. Added a condition to ensure that both `src_ip` and `dst_ip` have the same IP version.
3. Added a test to verify that a mirror session with IPv6 `src_ip` and `dst_ip` can be successfully configured.

#### How to verify it
Use `config apply-patch` to configure an ERSPAN mirror session with IPv6 `src_ip` and `dst_ip` addresses. For example:
```
$ cat ./mirror_session.patch
[
        {
                "op": "add",
                "path": "/MIRROR_SESSION",
                "value": {
                        "test_session": {
                                "type": "ERSPAN",
                                "src_ip": "1001::1",
                                "dst_ip": "2002::2",
                                "gre_type": "0x8949",
                                "dscp": "8",
                                "ttl": "64",
                                "queue": "0",
                                "direction": "RX"
                        }
                }
        }
]
$ sudo config apply-patch ./mirror_session.patch
Patch Applier: localhost: Patch application starting.
Patch Applier: localhost: Patch: [{"op": "add", "path": "/MIRROR_SESSION", "value": {"test_session": {"type": "ERSPAN", "src_ip": "1001::1", "dst_ip": "2002::2", "gre_type": "0x8949", "dscp": "8", "ttl": "64", "queue": "0", "direction": "RX"}}}]
Patch Applier: localhost getting current config db.
Patch Applier: localhost: simulating the target full config after applying the patch.
Patch Applier: localhost: validating all JsonPatch operations are permitted on the specified fields
Patch Applier: localhost: validating target config does not have empty tables,
                            since they do not show up in ConfigDb.
Patch Applier: localhost: sorting patch updates.
Patch Applier: The localhost patch was converted into 1 change:
Patch Applier: localhost: applying 1 change in order:
Patch Applier:   * [{"op": "add", "path": "/MIRROR_SESSION", "value": {"test_session": {"type": "ERSPAN", "src_ip": "1001::1", "dst_ip": "2002::2", "gre_type": "0x8949", "dscp": "8", "ttl": "64", "queue": "0", "direction": "RX"}}}]
Patch Applier: localhost: verifying patch updates are reflected on ConfigDB.
Patch Applier: localhost patch application completed.
Patch applied successfully.
$ show mirror_session
ERSPAN Sessions
Name          Status    SRC IP    DST IP    GRE       DSCP    TTL    Queue  Policer    Monitor Port    SRC Port    Direction
------------  --------  --------  --------  ------  ------  -----  -------  ---------  --------------  ----------  -----------
test_session  active    1001::1   2002::2   0x8949       8     64        0             Ethernet104                 rx
```
If `src_ip` and `dst_ip` have different IP versions, the `apply-patch` command should fail:
```
$ cat ./mirror_session.patch
[
        {
                "op": "add",
                "path": "/MIRROR_SESSION",
                "value": {
                        "invalid_session": {
                                "type": "ERSPAN",
                                "src_ip": "1.1.1.1",
                                "dst_ip": "2002::2",
                                "gre_type": "0x8949",
                                "dscp": "8",
                                "ttl": "64",
                                "queue": "0",
                                "direction": "RX"
                        }
                }
        }
]
$ sudo config apply-patch ./mirror_session.patch
libyang[0]: Must condition "(contains(current(), ':') and contains(../dst_ip, ':')) or (contains(current(), '.') and contains(../dst_ip, '.'))" not satisfied. (path: /sonic-mirror-session:sonic-mirror-session/MIRROR_SESSION/MIRROR_SESSION_LIST[name='invalid_session']/src_ip)
libyang[0]: src_ip and dst_ip must have the same IP version. (path: /sonic-mirror-session:sonic-mirror-session/MIRROR_SESSION/MIRROR_SESSION_LIST[name='invalid_session']/src_ip)
sonic_yang(3):Data Loading Failed:src_ip and dst_ip must have the same IP version.
Failed to apply patch due to: Validate json patch: [{"op": "add", "path": "/MIRROR_SESSION", "value": {"invalid_session": {"type": "ERSPAN", "src_ip": "1.1.1.1", "dst_ip": "2002::2", "gre_type": "0x8949", "dscp": "8", "ttl": "64", "queue": "0", "direction": "RX"}}}] failed due to:Data Loading Failed
src_ip and dst_ip must have the same IP version.
Usage: config apply-patch [OPTIONS] PATCH_FILE_PATH
Try "config apply-patch -h" for help.

Error: Validate json patch: [{"op": "add", "path": "/MIRROR_SESSION", "value": {"invalid_session": {"type": "ERSPAN", "src_ip": "1.1.1.1", "dst_ip": "2002::2", "gre_type": "0x8949", "dscp": "8", "ttl": "64", "queue": "0", "direction": "RX"}}}] failed due to:Data Loading Failed
src_ip and dst_ip must have the same IP version.
```

<!--
If PR needs to be backported, then the PR must be tested against the base branch and the earliest backport release branch and provide tested image version on these two branches. For example, if the PR is requested for master, 202211 and 202012, then the requester needs to provide test results on master and 202012.
-->

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

<!--
- Note we only backport fixes to a release branch, *not* features!
- Please also provide a reason for the backporting below.
- e.g.
- [x] 202006
-->

- [ ] 202205
- [ ] 202211
- [ ] 202305
- [ ] 202311
- [ ] 202405
- [ ] 202411
- [ ] 202505

#### Tested branch (Please provide the tested image version)

<!--
- Please provide tested image version
- e.g.
- [x] 20201231.100
-->

- [x] 20250625.014807

#### Description for the changelog
<!--
Write a short (one line) summary that describes the changes in this
pull request for inclusion in the changelog:
-->

<!--
 Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU.
-->
Updated the YANG model for ERSPAN mirror sessions to support IPv6 source and destination addresses.

#### Link to config_db schema for YANG module changes
<!--
Provide a link to config_db schema for the table for which YANG model
is defined
Link should point to correct section on https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-yang-models/doc/Configuration.md
-->
https://github.com/sonic-net/sonic-buildimage/blob/master/src/sonic-yang-models/doc/Configuration.md#acl-and-mirroring
mssonicbld added a commit to sonic-net/sonic-buildimage that referenced this pull request Jul 14, 2025
<!--
 Please make sure you've read and understood our contributing guidelines:
 https://github.com/Azure/SONiC/blob/gh-pages/CONTRIBUTING.md

 failure_prs.log skip_prs.log Make sure all your commits include a signature generated with `git commit -s` **

 If this is a bug fix, make sure your description includes "fixes #xxxx", or
 "closes #xxxx" or "resolves #xxxx"

 Please provide the following information:
-->

#### Why I did it
[PR 3317](sonic-net/sonic-swss#3317) in sonic-swss enables configuration of IPv6 mirror sessions (in which both `src_ip` and `dst_ip` are IPv6 addresses). This PR updates the YANG model for ERSPAN mirror sessions so that IPv6 mirror sessions can be configured using the `config apply-patch` command.

##### Work item tracking
- Microsoft ADO **(number only)**: 33501400

#### How I did it
1. Changed the type of `src_ip` and `dst_ip` for ERSPAN mirror sessions to `ip-address` so that IPv6 addresses are also accepted.
2. Added a condition to ensure that both `src_ip` and `dst_ip` have the same IP version.
3. Added a test to verify that a mirror session with IPv6 `src_ip` and `dst_ip` can be successfully configured.

#### How to verify it
Use `config apply-patch` to configure an ERSPAN mirror session with IPv6 `src_ip` and `dst_ip` addresses. For example:
```
$ cat ./mirror_session.patch
[
 {
 "op": "add",
 "path": "/MIRROR_SESSION",
 "value": {
 "test_session": {
 "type": "ERSPAN",
 "src_ip": "1001::1",
 "dst_ip": "2002::2",
 "gre_type": "0x8949",
 "dscp": "8",
 "ttl": "64",
 "queue": "0",
 "direction": "RX"
 }
 }
 }
]
$ sudo config apply-patch ./mirror_session.patch
Patch Applier: localhost: Patch application starting.
Patch Applier: localhost: Patch: [{"op": "add", "path": "/MIRROR_SESSION", "value": {"test_session": {"type": "ERSPAN", "src_ip": "1001::1", "dst_ip": "2002::2", "gre_type": "0x8949", "dscp": "8", "ttl": "64", "queue": "0", "direction": "RX"}}}]
Patch Applier: localhost getting current config db.
Patch Applier: localhost: simulating the target full config after applying the patch.
Patch Applier: localhost: validating all JsonPatch operations are permitted on the specified fields
Patch Applier: localhost: validating target config does not have empty tables,
 since they do not show up in ConfigDb.
Patch Applier: localhost: sorting patch updates.
Patch Applier: The localhost patch was converted into 1 change:
Patch Applier: localhost: applying 1 change in order:
Patch Applier: failure_prs.log skip_prs.log [{"op": "add", "path": "/MIRROR_SESSION", "value": {"test_session": {"type": "ERSPAN", "src_ip": "1001::1", "dst_ip": "2002::2", "gre_type": "0x8949", "dscp": "8", "ttl": "64", "queue": "0", "direction": "RX"}}}]
Patch Applier: localhost: verifying patch updates are reflected on ConfigDB.
Patch Applier: localhost patch application completed.
Patch applied successfully.
$ show mirror_session
ERSPAN Sessions
Name Status SRC IP DST IP GRE DSCP TTL Queue Policer Monitor Port SRC Port Direction
------------ -------- -------- -------- ------ ------ ----- ------- --------- -------------- ---------- -----------
test_session active 1001::1 2002::2 0x8949 8 64 0 Ethernet104 rx
```
If `src_ip` and `dst_ip` have different IP versions, the `apply-patch` command should fail:
```
$ cat ./mirror_session.patch
[
 {
 "op": "add",
 "path": "/MIRROR_SESSION",
 "value": {
 "invalid_session": {
 "type": "ERSPAN",
 "src_ip": "1.1.1.1",
 "dst_ip": "2002::2",
 "gre_type": "0x8949",
 "dscp": "8",
 "ttl": "64",
 "queue": "0",
 "direction": "RX"
 }
 }
 }
]
$ sudo config apply-patch ./mirror_session.patch
libyang[0]: Must condition "(contains(current(), ':') and contains(../dst_ip, ':')) or (contains(current(), '.') and contains(../dst_ip, '.'))" not satisfied. (path: /sonic-mirror-session:sonic-mirror-session/MIRROR_SESSION/MIRROR_SESSION_LIST[name='invalid_session']/src_ip)
libyang[0]: src_ip and dst_ip must have the same IP version. (path: /sonic-mirror-session:sonic-mirror-session/MIRROR_SESSION/MIRROR_SESSION_LIST[name='invalid_session']/src_ip)
sonic_yang(3):Data Loading Failed:src_ip and dst_ip must have the same IP version.
Failed to apply patch due to: Validate json patch: [{"op": "add", "path": "/MIRROR_SESSION", "value": {"invalid_session": {"type": "ERSPAN", "src_ip": "1.1.1.1", "dst_ip": "2002::2", "gre_type": "0x8949", "dscp": "8", "ttl": "64", "queue": "0", "direction": "RX"}}}] failed due to:Data Loading Failed
src_ip and dst_ip must have the same IP version.
Usage: config apply-patch [OPTIONS] PATCH_FILE_PATH
Try "config apply-patch -h" for help.

Error: Validate json patch: [{"op": "add", "path": "/MIRROR_SESSION", "value": {"invalid_session": {"type": "ERSPAN", "src_ip": "1.1.1.1", "dst_ip": "2002::2", "gre_type": "0x8949", "dscp": "8", "ttl": "64", "queue": "0", "direction": "RX"}}}] failed due to:Data Loading Failed
src_ip and dst_ip must have the same IP version.
```

<!--
If PR needs to be backported, then the PR must be tested against the base branch and the earliest backport release branch and provide tested image version on these two branches. For example, if the PR is requested for master, 202211 and 202012, then the requester needs to provide test results on master and 202012.
-->

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

<!--
- Note we only backport fixes to a release branch, *not* features!
- Please also provide a reason for the backporting below.
- e.g.
- [x] 202006
-->

- [ ] 202205
- [ ] 202211
- [ ] 202305
- [ ] 202311
- [ ] 202405
- [ ] 202411
- [ ] 202505

#### Tested branch (Please provide the tested image version)

<!--
- Please provide tested image version
- e.g.
- [x] 20201231.100
-->

- [x] 20250625.014807

#### Description for the changelog
<!--
Write a short (one line) summary that describes the changes in this
pull request for inclusion in the changelog:
-->

<!--
 Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU.
-->
Updated the YANG model for ERSPAN mirror sessions to support IPv6 source and destination addresses.

#### Link to config_db schema for YANG module changes
<!--
Provide a link to config_db schema for the table for which YANG model
is defined
Link should point to correct section on https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-yang-models/doc/Configuration.md
-->
https://github.com/sonic-net/sonic-buildimage/blob/master/src/sonic-yang-models/doc/Configuration.md#acl-and-mirroring
mssonicbld added a commit to mssonicbld/sonic-buildimage-msft that referenced this pull request Oct 1, 2025
<!--
     Please make sure you've read and understood our contributing guidelines:
     https://github.com/Azure/SONiC/blob/gh-pages/CONTRIBUTING.md

     ** Make sure all your commits include a signature generated with `git commit -s` **

     If this is a bug fix, make sure your description includes "fixes #xxxx", or
     "closes #xxxx" or "resolves #xxxx"

     Please provide the following information:
-->

#### Why I did it
[PR 3317](sonic-net/sonic-swss#3317) in sonic-swss enables configuration of IPv6 mirror sessions (in which both `src_ip` and `dst_ip` are IPv6 addresses). This PR updates the YANG model for ERSPAN mirror sessions so that IPv6 mirror sessions can be configured using the `config apply-patch` command.

##### Work item tracking
- Microsoft ADO **(number only)**: 33501400

#### How I did it
1. Changed the type of `src_ip` and `dst_ip` for ERSPAN mirror sessions to `ip-address` so that IPv6 addresses are also accepted.
2. Added a condition to ensure that both `src_ip` and `dst_ip` have the same IP version.
3. Added a test to verify that a mirror session with IPv6 `src_ip` and `dst_ip` can be successfully configured.

#### How to verify it
Use `config apply-patch` to configure an ERSPAN mirror session with IPv6 `src_ip` and `dst_ip` addresses. For example:
```
$ cat ./mirror_session.patch
[
        {
                "op": "add",
                "path": "/MIRROR_SESSION",
                "value": {
                        "test_session": {
                                "type": "ERSPAN",
                                "src_ip": "1001::1",
                                "dst_ip": "2002::2",
                                "gre_type": "0x8949",
                                "dscp": "8",
                                "ttl": "64",
                                "queue": "0",
                                "direction": "RX"
                        }
                }
        }
]
$ sudo config apply-patch ./mirror_session.patch
Patch Applier: localhost: Patch application starting.
Patch Applier: localhost: Patch: [{"op": "add", "path": "/MIRROR_SESSION", "value": {"test_session": {"type": "ERSPAN", "src_ip": "1001::1", "dst_ip": "2002::2", "gre_type": "0x8949", "dscp": "8", "ttl": "64", "queue": "0", "direction": "RX"}}}]
Patch Applier: localhost getting current config db.
Patch Applier: localhost: simulating the target full config after applying the patch.
Patch Applier: localhost: validating all JsonPatch operations are permitted on the specified fields
Patch Applier: localhost: validating target config does not have empty tables,
                            since they do not show up in ConfigDb.
Patch Applier: localhost: sorting patch updates.
Patch Applier: The localhost patch was converted into 1 change:
Patch Applier: localhost: applying 1 change in order:
Patch Applier:   * [{"op": "add", "path": "/MIRROR_SESSION", "value": {"test_session": {"type": "ERSPAN", "src_ip": "1001::1", "dst_ip": "2002::2", "gre_type": "0x8949", "dscp": "8", "ttl": "64", "queue": "0", "direction": "RX"}}}]
Patch Applier: localhost: verifying patch updates are reflected on ConfigDB.
Patch Applier: localhost patch application completed.
Patch applied successfully.
$ show mirror_session
ERSPAN Sessions
Name          Status    SRC IP    DST IP    GRE       DSCP    TTL    Queue  Policer    Monitor Port    SRC Port    Direction
------------  --------  --------  --------  ------  ------  -----  -------  ---------  --------------  ----------  -----------
test_session  active    1001::1   2002::2   0x8949       8     64        0             Ethernet104                 rx
```
If `src_ip` and `dst_ip` have different IP versions, the `apply-patch` command should fail:
```
$ cat ./mirror_session.patch
[
        {
                "op": "add",
                "path": "/MIRROR_SESSION",
                "value": {
                        "invalid_session": {
                                "type": "ERSPAN",
                                "src_ip": "1.1.1.1",
                                "dst_ip": "2002::2",
                                "gre_type": "0x8949",
                                "dscp": "8",
                                "ttl": "64",
                                "queue": "0",
                                "direction": "RX"
                        }
                }
        }
]
$ sudo config apply-patch ./mirror_session.patch
libyang[0]: Must condition "(contains(current(), ':') and contains(../dst_ip, ':')) or (contains(current(), '.') and contains(../dst_ip, '.'))" not satisfied. (path: /sonic-mirror-session:sonic-mirror-session/MIRROR_SESSION/MIRROR_SESSION_LIST[name='invalid_session']/src_ip)
libyang[0]: src_ip and dst_ip must have the same IP version. (path: /sonic-mirror-session:sonic-mirror-session/MIRROR_SESSION/MIRROR_SESSION_LIST[name='invalid_session']/src_ip)
sonic_yang(3):Data Loading Failed:src_ip and dst_ip must have the same IP version.
Failed to apply patch due to: Validate json patch: [{"op": "add", "path": "/MIRROR_SESSION", "value": {"invalid_session": {"type": "ERSPAN", "src_ip": "1.1.1.1", "dst_ip": "2002::2", "gre_type": "0x8949", "dscp": "8", "ttl": "64", "queue": "0", "direction": "RX"}}}] failed due to:Data Loading Failed
src_ip and dst_ip must have the same IP version.
Usage: config apply-patch [OPTIONS] PATCH_FILE_PATH
Try "config apply-patch -h" for help.

Error: Validate json patch: [{"op": "add", "path": "/MIRROR_SESSION", "value": {"invalid_session": {"type": "ERSPAN", "src_ip": "1.1.1.1", "dst_ip": "2002::2", "gre_type": "0x8949", "dscp": "8", "ttl": "64", "queue": "0", "direction": "RX"}}}] failed due to:Data Loading Failed
src_ip and dst_ip must have the same IP version.
```

<!--
If PR needs to be backported, then the PR must be tested against the base branch and the earliest backport release branch and provide tested image version on these two branches. For example, if the PR is requested for master, 202211 and 202012, then the requester needs to provide test results on master and 202012.
-->

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

<!--
- Note we only backport fixes to a release branch, *not* features!
- Please also provide a reason for the backporting below.
- e.g.
- [x] 202006
-->

- [ ] 202205
- [ ] 202211
- [ ] 202305
- [ ] 202311
- [ ] 202405
- [ ] 202411
- [ ] 202505

#### Tested branch (Please provide the tested image version)

<!--
- Please provide tested image version
- e.g.
- [x] 20201231.100
-->

- [x] 20250625.014807

#### Description for the changelog
<!--
Write a short (one line) summary that describes the changes in this
pull request for inclusion in the changelog:
-->

<!--
 Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU.
-->
Updated the YANG model for ERSPAN mirror sessions to support IPv6 source and destination addresses.

#### Link to config_db schema for YANG module changes
<!--
Provide a link to config_db schema for the table for which YANG model
is defined
Link should point to correct section on https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-yang-models/doc/Configuration.md
-->
https://github.com/sonic-net/sonic-buildimage/blob/master/src/sonic-yang-models/doc/Configuration.md#acl-and-mirroring
mssonicbld added a commit to Azure/sonic-buildimage-msft that referenced this pull request Oct 2, 2025
…#1682)

<!--
 Please make sure you've read and understood our contributing guidelines:
 https://github.com/Azure/SONiC/blob/gh-pages/CONTRIBUTING.md

 failure_prs.log skip_prs.log Make sure all your commits include a signature generated with `git commit -s` **

 If this is a bug fix, make sure your description includes "fixes #xxxx", or
 "closes #xxxx" or "resolves #xxxx"

 Please provide the following information:
-->

#### Why I did it
[PR 3317](sonic-net/sonic-swss#3317) in sonic-swss enables configuration of IPv6 mirror sessions (in which both `src_ip` and `dst_ip` are IPv6 addresses). This PR updates the YANG model for ERSPAN mirror sessions so that IPv6 mirror sessions can be configured using the `config apply-patch` command.

##### Work item tracking
- Microsoft ADO **(number only)**: 33501400

#### How I did it
1. Changed the type of `src_ip` and `dst_ip` for ERSPAN mirror sessions to `ip-address` so that IPv6 addresses are also accepted.
2. Added a condition to ensure that both `src_ip` and `dst_ip` have the same IP version.
3. Added a test to verify that a mirror session with IPv6 `src_ip` and `dst_ip` can be successfully configured.

#### How to verify it
Use `config apply-patch` to configure an ERSPAN mirror session with IPv6 `src_ip` and `dst_ip` addresses. For example:
```
$ cat ./mirror_session.patch
[
 {
 "op": "add",
 "path": "/MIRROR_SESSION",
 "value": {
 "test_session": {
 "type": "ERSPAN",
 "src_ip": "1001::1",
 "dst_ip": "2002::2",
 "gre_type": "0x8949",
 "dscp": "8",
 "ttl": "64",
 "queue": "0",
 "direction": "RX"
 }
 }
 }
]
$ sudo config apply-patch ./mirror_session.patch
Patch Applier: localhost: Patch application starting.
Patch Applier: localhost: Patch: [{"op": "add", "path": "/MIRROR_SESSION", "value": {"test_session": {"type": "ERSPAN", "src_ip": "1001::1", "dst_ip": "2002::2", "gre_type": "0x8949", "dscp": "8", "ttl": "64", "queue": "0", "direction": "RX"}}}]
Patch Applier: localhost getting current config db.
Patch Applier: localhost: simulating the target full config after applying the patch.
Patch Applier: localhost: validating all JsonPatch operations are permitted on the specified fields
Patch Applier: localhost: validating target config does not have empty tables,
 since they do not show up in ConfigDb.
Patch Applier: localhost: sorting patch updates.
Patch Applier: The localhost patch was converted into 1 change:
Patch Applier: localhost: applying 1 change in order:
Patch Applier: failure_prs.log skip_prs.log [{"op": "add", "path": "/MIRROR_SESSION", "value": {"test_session": {"type": "ERSPAN", "src_ip": "1001::1", "dst_ip": "2002::2", "gre_type": "0x8949", "dscp": "8", "ttl": "64", "queue": "0", "direction": "RX"}}}]
Patch Applier: localhost: verifying patch updates are reflected on ConfigDB.
Patch Applier: localhost patch application completed.
Patch applied successfully.
$ show mirror_session
ERSPAN Sessions
Name Status SRC IP DST IP GRE DSCP TTL Queue Policer Monitor Port SRC Port Direction
------------ -------- -------- -------- ------ ------ ----- ------- --------- -------------- ---------- -----------
test_session active 1001::1 2002::2 0x8949 8 64 0 Ethernet104 rx
```
If `src_ip` and `dst_ip` have different IP versions, the `apply-patch` command should fail:
```
$ cat ./mirror_session.patch
[
 {
 "op": "add",
 "path": "/MIRROR_SESSION",
 "value": {
 "invalid_session": {
 "type": "ERSPAN",
 "src_ip": "1.1.1.1",
 "dst_ip": "2002::2",
 "gre_type": "0x8949",
 "dscp": "8",
 "ttl": "64",
 "queue": "0",
 "direction": "RX"
 }
 }
 }
]
$ sudo config apply-patch ./mirror_session.patch
libyang[0]: Must condition "(contains(current(), ':') and contains(../dst_ip, ':')) or (contains(current(), '.') and contains(../dst_ip, '.'))" not satisfied. (path: /sonic-mirror-session:sonic-mirror-session/MIRROR_SESSION/MIRROR_SESSION_LIST[name='invalid_session']/src_ip)
libyang[0]: src_ip and dst_ip must have the same IP version. (path: /sonic-mirror-session:sonic-mirror-session/MIRROR_SESSION/MIRROR_SESSION_LIST[name='invalid_session']/src_ip)
sonic_yang(3):Data Loading Failed:src_ip and dst_ip must have the same IP version.
Failed to apply patch due to: Validate json patch: [{"op": "add", "path": "/MIRROR_SESSION", "value": {"invalid_session": {"type": "ERSPAN", "src_ip": "1.1.1.1", "dst_ip": "2002::2", "gre_type": "0x8949", "dscp": "8", "ttl": "64", "queue": "0", "direction": "RX"}}}] failed due to:Data Loading Failed
src_ip and dst_ip must have the same IP version.
Usage: config apply-patch [OPTIONS] PATCH_FILE_PATH
Try "config apply-patch -h" for help.

Error: Validate json patch: [{"op": "add", "path": "/MIRROR_SESSION", "value": {"invalid_session": {"type": "ERSPAN", "src_ip": "1.1.1.1", "dst_ip": "2002::2", "gre_type": "0x8949", "dscp": "8", "ttl": "64", "queue": "0", "direction": "RX"}}}] failed due to:Data Loading Failed
src_ip and dst_ip must have the same IP version.
```

<!--
If PR needs to be backported, then the PR must be tested against the base branch and the earliest backport release branch and provide tested image version on these two branches. For example, if the PR is requested for master, 202211 and 202012, then the requester needs to provide test results on master and 202012.
-->

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

<!--
- Note we only backport fixes to a release branch, *not* features!
- Please also provide a reason for the backporting below.
- e.g.
- [x] 202006
-->

- [ ] 202205
- [ ] 202211
- [ ] 202305
- [ ] 202311
- [ ] 202405
- [ ] 202411
- [ ] 202505

#### Tested branch (Please provide the tested image version)

<!--
- Please provide tested image version
- e.g.
- [x] 20201231.100
-->

- [x] 20250625.014807

#### Description for the changelog
<!--
Write a short (one line) summary that describes the changes in this
pull request for inclusion in the changelog:
-->

<!--
 Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU.
-->
Updated the YANG model for ERSPAN mirror sessions to support IPv6 source and destination addresses.

#### Link to config_db schema for YANG module changes
<!--
Provide a link to config_db schema for the table for which YANG model
is defined
Link should point to correct section on https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-yang-models/doc/Configuration.md
-->
https://github.com/sonic-net/sonic-buildimage/blob/master/src/sonic-yang-models/doc/Configuration.md#acl-and-mirroring
r12f pushed a commit to Azure/sonic-buildimage-msft that referenced this pull request Oct 26, 2025
…#1682)

<!--
 Please make sure you've read and understood our contributing guidelines:
 https://github.com/Azure/SONiC/blob/gh-pages/CONTRIBUTING.md

 failure_prs.log skip_prs.log Make sure all your commits include a signature generated with `git commit -s` **

 If this is a bug fix, make sure your description includes "fixes #xxxx", or
 "closes #xxxx" or "resolves #xxxx"

 Please provide the following information:
-->

#### Why I did it
[PR 3317](sonic-net/sonic-swss#3317) in sonic-swss enables configuration of IPv6 mirror sessions (in which both `src_ip` and `dst_ip` are IPv6 addresses). This PR updates the YANG model for ERSPAN mirror sessions so that IPv6 mirror sessions can be configured using the `config apply-patch` command.

##### Work item tracking
- Microsoft ADO **(number only)**: 33501400

#### How I did it
1. Changed the type of `src_ip` and `dst_ip` for ERSPAN mirror sessions to `ip-address` so that IPv6 addresses are also accepted.
2. Added a condition to ensure that both `src_ip` and `dst_ip` have the same IP version.
3. Added a test to verify that a mirror session with IPv6 `src_ip` and `dst_ip` can be successfully configured.

#### How to verify it
Use `config apply-patch` to configure an ERSPAN mirror session with IPv6 `src_ip` and `dst_ip` addresses. For example:
```
$ cat ./mirror_session.patch
[
 {
 "op": "add",
 "path": "/MIRROR_SESSION",
 "value": {
 "test_session": {
 "type": "ERSPAN",
 "src_ip": "1001::1",
 "dst_ip": "2002::2",
 "gre_type": "0x8949",
 "dscp": "8",
 "ttl": "64",
 "queue": "0",
 "direction": "RX"
 }
 }
 }
]
$ sudo config apply-patch ./mirror_session.patch
Patch Applier: localhost: Patch application starting.
Patch Applier: localhost: Patch: [{"op": "add", "path": "/MIRROR_SESSION", "value": {"test_session": {"type": "ERSPAN", "src_ip": "1001::1", "dst_ip": "2002::2", "gre_type": "0x8949", "dscp": "8", "ttl": "64", "queue": "0", "direction": "RX"}}}]
Patch Applier: localhost getting current config db.
Patch Applier: localhost: simulating the target full config after applying the patch.
Patch Applier: localhost: validating all JsonPatch operations are permitted on the specified fields
Patch Applier: localhost: validating target config does not have empty tables,
 since they do not show up in ConfigDb.
Patch Applier: localhost: sorting patch updates.
Patch Applier: The localhost patch was converted into 1 change:
Patch Applier: localhost: applying 1 change in order:
Patch Applier: failure_prs.log skip_prs.log [{"op": "add", "path": "/MIRROR_SESSION", "value": {"test_session": {"type": "ERSPAN", "src_ip": "1001::1", "dst_ip": "2002::2", "gre_type": "0x8949", "dscp": "8", "ttl": "64", "queue": "0", "direction": "RX"}}}]
Patch Applier: localhost: verifying patch updates are reflected on ConfigDB.
Patch Applier: localhost patch application completed.
Patch applied successfully.
$ show mirror_session
ERSPAN Sessions
Name Status SRC IP DST IP GRE DSCP TTL Queue Policer Monitor Port SRC Port Direction
------------ -------- -------- -------- ------ ------ ----- ------- --------- -------------- ---------- -----------
test_session active 1001::1 2002::2 0x8949 8 64 0 Ethernet104 rx
```
If `src_ip` and `dst_ip` have different IP versions, the `apply-patch` command should fail:
```
$ cat ./mirror_session.patch
[
 {
 "op": "add",
 "path": "/MIRROR_SESSION",
 "value": {
 "invalid_session": {
 "type": "ERSPAN",
 "src_ip": "1.1.1.1",
 "dst_ip": "2002::2",
 "gre_type": "0x8949",
 "dscp": "8",
 "ttl": "64",
 "queue": "0",
 "direction": "RX"
 }
 }
 }
]
$ sudo config apply-patch ./mirror_session.patch
libyang[0]: Must condition "(contains(current(), ':') and contains(../dst_ip, ':')) or (contains(current(), '.') and contains(../dst_ip, '.'))" not satisfied. (path: /sonic-mirror-session:sonic-mirror-session/MIRROR_SESSION/MIRROR_SESSION_LIST[name='invalid_session']/src_ip)
libyang[0]: src_ip and dst_ip must have the same IP version. (path: /sonic-mirror-session:sonic-mirror-session/MIRROR_SESSION/MIRROR_SESSION_LIST[name='invalid_session']/src_ip)
sonic_yang(3):Data Loading Failed:src_ip and dst_ip must have the same IP version.
Failed to apply patch due to: Validate json patch: [{"op": "add", "path": "/MIRROR_SESSION", "value": {"invalid_session": {"type": "ERSPAN", "src_ip": "1.1.1.1", "dst_ip": "2002::2", "gre_type": "0x8949", "dscp": "8", "ttl": "64", "queue": "0", "direction": "RX"}}}] failed due to:Data Loading Failed
src_ip and dst_ip must have the same IP version.
Usage: config apply-patch [OPTIONS] PATCH_FILE_PATH
Try "config apply-patch -h" for help.

Error: Validate json patch: [{"op": "add", "path": "/MIRROR_SESSION", "value": {"invalid_session": {"type": "ERSPAN", "src_ip": "1.1.1.1", "dst_ip": "2002::2", "gre_type": "0x8949", "dscp": "8", "ttl": "64", "queue": "0", "direction": "RX"}}}] failed due to:Data Loading Failed
src_ip and dst_ip must have the same IP version.
```

<!--
If PR needs to be backported, then the PR must be tested against the base branch and the earliest backport release branch and provide tested image version on these two branches. For example, if the PR is requested for master, 202211 and 202012, then the requester needs to provide test results on master and 202012.
-->

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

<!--
- Note we only backport fixes to a release branch, *not* features!
- Please also provide a reason for the backporting below.
- e.g.
- [x] 202006
-->

- [ ] 202205
- [ ] 202211
- [ ] 202305
- [ ] 202311
- [ ] 202405
- [ ] 202411
- [ ] 202505

#### Tested branch (Please provide the tested image version)

<!--
- Please provide tested image version
- e.g.
- [x] 20201231.100
-->

- [x] 20250625.014807

#### Description for the changelog
<!--
Write a short (one line) summary that describes the changes in this
pull request for inclusion in the changelog:
-->

<!--
 Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU.
-->
Updated the YANG model for ERSPAN mirror sessions to support IPv6 source and destination addresses.

#### Link to config_db schema for YANG module changes
<!--
Provide a link to config_db schema for the table for which YANG model
is defined
Link should point to correct section on https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-yang-models/doc/Configuration.md
-->
https://github.com/sonic-net/sonic-buildimage/blob/master/src/sonic-yang-models/doc/Configuration.md#acl-and-mirroring
Janetxxx pushed a commit to Janetxxx/sonic-swss that referenced this pull request Nov 10, 2025
* Applied changes from PR sonic-net#1817
Why I did it
Unlock erspan capability on td3 and beyond that supports erspan ipv6 encap.

What I did
Extend test_MirrorAddSetRemove, test_MirrorToVlanAddRemove, test_MirrorToLagAddRemove, test_MirrorDestMoveVlan, test_MirrorDestMoveLag to vs test erspan ipv6 encap
On td3
baorliu pushed a commit to baorliu/sonic-swss that referenced this pull request Feb 23, 2026
* Applied changes from PR sonic-net#1817
Why I did it
Unlock erspan capability on td3 and beyond that supports erspan ipv6 encap.

What I did
Extend test_MirrorAddSetRemove, test_MirrorToVlanAddRemove, test_MirrorToLagAddRemove, test_MirrorDestMoveVlan, test_MirrorDestMoveLag to vs test erspan ipv6 encap
On td3

Signed-off-by: Baorong Liu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants