diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/mirror_session.json b/src/sonic-yang-models/tests/yang_model_tests/tests/mirror_session.json index 5bc6b54a044..74e068dae4d 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/mirror_session.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/mirror_session.json @@ -14,13 +14,16 @@ "MIRROR_ERSPAN_ENTRY_WITH_VALID_DEC_VALUES_2": { "desc": "Configuring ERSPAN entry with valid decimal values." }, + "MIRROR_ERSPAN_ENTRY_WITH_VALID_IPV6_SRC_AND_DST_IP": { + "desc": "Configuring ERSPAN entry with valid IPv6 source and destination IPs." + }, "MIRROR_ERSPAN_ENTRY_WRONG_TYPE": { "desc": "Configuring ERSPAN entry with invalid type", "eStrKey": "InvalidValue" }, "MIRROR_ERSPAN_ENTRY_WRONG_DST_IP": { "desc": "Configuring ERSPAN entry with invalid dst_ip", - "eStrKey" : "Pattern" + "eStr" : "src_ip and dst_ip must have the same IP version." }, "MIRROR_ERSPAN_ENTRY_WRONG_DST_IP_TYPE": { "desc": "Configuring ERSPAN entry with invalid dst_ip", @@ -28,7 +31,7 @@ }, "MIRROR_ERSPAN_ENTRY_WRONG_SRC_IP": { "desc": "Configuring ERSPAN entry with invalid src_ip", - "eStrKey" : "Pattern" + "eStr" : "src_ip and dst_ip must have the same IP version." }, "MIRROR_ERSPAN_ENTRY_WRONG_SRC_IP_TYPE": { "desc": "Configuring ERSPAN entry with invalid src_ip", diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/mirror_session.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/mirror_session.json index ac8293e88c1..af912165297 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/mirror_session.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/mirror_session.json @@ -79,6 +79,25 @@ } } }, + "MIRROR_ERSPAN_ENTRY_WITH_VALID_IPV6_SRC_AND_DST_IP": { + "sonic-mirror-session:sonic-mirror-session": { + "MIRROR_SESSION": { + "MIRROR_SESSION_LIST": [ + { + "name": "erspan", + "type": "ERSPAN", + "dst_ip": "1001::1", + "src_ip": "2002::2", + "gre_type": "0x1234", + "dscp": "10", + "ttl": "64", + "queue": "0", + "direction": "RX" + } + ] + } + } + }, "MIRROR_ERSPAN_ENTRY_WRONG_TYPE": { "sonic-mirror-session:sonic-mirror-session": { "MIRROR_SESSION": { diff --git a/src/sonic-yang-models/yang-models/sonic-mirror-session.yang b/src/sonic-yang-models/yang-models/sonic-mirror-session.yang index b0f695fbe9c..8fc858879bf 100644 --- a/src/sonic-yang-models/yang-models/sonic-mirror-session.yang +++ b/src/sonic-yang-models/yang-models/sonic-mirror-session.yang @@ -82,7 +82,10 @@ module sonic-mirror-session { leaf src_ip { when "current()/../type = 'ERSPAN'"; - type inet:ipv4-address; + must "(contains(current(), ':') and contains(../dst_ip, ':')) or (not(contains(current(), ':')) and not(contains(../dst_ip, ':')))" { + error-message "src_ip and dst_ip must have the same IP version."; + } + type inet:ip-address; description "ERSPAN source ip. This IP will be set as source ip in outer header of mirrored frame "; @@ -90,7 +93,10 @@ module sonic-mirror-session { leaf dst_ip { when "current()/../type = 'ERSPAN'"; - type inet:ipv4-address; + must "(contains(current(), ':') and contains(../src_ip, ':')) or (not(contains(current(), ':')) and not(contains(../src_ip, ':')))" { + error-message "src_ip and dst_ip must have the same IP version."; + } + type inet:ip-address; description "ERSPAN destination ip. Mirrored frames will be routed to this destination. This IP will be set as destination ip in outer header of mirrored frame ";