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 6d53b0e9cf..c54ca3d959 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 @@ -1,6 +1,18 @@ { - "MIRROR_ERSPAN_ENTRY_WITH_VALID_VALUES": { - "desc": "Configuring ERSPAN entry with valid values." + "MIRROR_ERSPAN_ENTRY_WITH_VALID_HEX_VALUES": { + "desc": "Configuring ERSPAN entry with valid heximal values." + }, + "MIRROR_ERSPAN_ENTRY_WITH_VALID_HEX_VALUES_1": { + "desc": "Configuring ERSPAN entry with valid heximal values." + }, + "MIRROR_ERSPAN_ENTRY_WITH_VALID_DEC_VALUES": { + "desc": "Configuring ERSPAN entry with valid decimal values." + }, + "MIRROR_ERSPAN_ENTRY_WITH_VALID_DEC_VALUES_1": { + "desc": "Configuring ERSPAN entry with valid decimal values." + }, + "MIRROR_ERSPAN_ENTRY_WITH_VALID_DEC_VALUES_2": { + "desc": "Configuring ERSPAN entry with valid decimal values." }, "MIRROR_ERSPAN_ENTRY_WRONG_TYPE": { "desc": "Configuring ERSPAN entry with invalid type", @@ -26,6 +38,14 @@ "desc": "Configuring ERSPAN entry with invalid GRE type", "eStrKey" : "Pattern" }, + "MIRROR_ERSPAN_ENTRY_WRONG_GRE_TYPE_1": { + "desc": "Configuring ERSPAN entry with invalid GRE type", + "eStrKey" : "Pattern" + }, + "MIRROR_ERSPAN_ENTRY_WRONG_GRE_TYPE_2": { + "desc": "Configuring ERSPAN entry with invalid GRE type", + "eStrKey" : "Pattern" + }, "MIRROR_ERSPAN_ENTRY_GRE_WRONG_TYPE": { "desc": "Configuring ERSPAN entry with invalid GRE type", "eStrKey" : "When" 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 ddf956c79f..5e820b5f5f 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 @@ -1,5 +1,5 @@ { - "MIRROR_ERSPAN_ENTRY_WITH_VALID_VALUES": { + "MIRROR_ERSPAN_ENTRY_WITH_VALID_HEX_VALUES": { "sonic-mirror-session:sonic-mirror-session": { "MIRROR_SESSION": { "MIRROR_SESSION_LIST": [ @@ -15,6 +15,70 @@ } } }, + "MIRROR_ERSPAN_ENTRY_WITH_VALID_HEX_VALUES_1": { + "sonic-mirror-session:sonic-mirror-session": { + "MIRROR_SESSION": { + "MIRROR_SESSION_LIST": [ + { + "name": "erspan", + "type": "ERSPAN", + "dst_ip": "11.1.1.1", + "src_ip": "10.1.1.1", + "gre_type": "0x0", + "dscp": "10" + } + ] + } + } + }, + "MIRROR_ERSPAN_ENTRY_WITH_VALID_DEC_VALUES": { + "sonic-mirror-session:sonic-mirror-session": { + "MIRROR_SESSION": { + "MIRROR_SESSION_LIST": [ + { + "name": "erspan", + "type": "ERSPAN", + "dst_ip": "11.1.1.1", + "src_ip": "10.1.1.1", + "gre_type": "1234", + "dscp": "10" + } + ] + } + } + }, + "MIRROR_ERSPAN_ENTRY_WITH_VALID_DEC_VALUES_1": { + "sonic-mirror-session:sonic-mirror-session": { + "MIRROR_SESSION": { + "MIRROR_SESSION_LIST": [ + { + "name": "erspan", + "type": "ERSPAN", + "dst_ip": "11.1.1.1", + "src_ip": "10.1.1.1", + "gre_type": "65535", + "dscp": "10" + } + ] + } + } + }, + "MIRROR_ERSPAN_ENTRY_WITH_VALID_DEC_VALUES_2": { + "sonic-mirror-session:sonic-mirror-session": { + "MIRROR_SESSION": { + "MIRROR_SESSION_LIST": [ + { + "name": "erspan", + "type": "ERSPAN", + "dst_ip": "11.1.1.1", + "src_ip": "10.1.1.1", + "gre_type": "0", + "dscp": "10" + } + ] + } + } + }, "MIRROR_ERSPAN_ENTRY_WRONG_TYPE": { "sonic-mirror-session:sonic-mirror-session": { "MIRROR_SESSION": { @@ -104,7 +168,39 @@ "type": "ERSPAN", "dst_ip": "11.1.1.1", "src_ip": "10.1.1.1", - "gre_type": "0", + "gre_type": "100000", + "dscp": "10" + } + ] + } + } + }, + "MIRROR_ERSPAN_ENTRY_WRONG_GRE_TYPE_1": { + "sonic-mirror-session:sonic-mirror-session": { + "MIRROR_SESSION": { + "MIRROR_SESSION_LIST": [ + { + "name": "erspan", + "type": "ERSPAN", + "dst_ip": "11.1.1.1", + "src_ip": "10.1.1.1", + "gre_type": "-1", + "dscp": "10" + } + ] + } + } + }, + "MIRROR_ERSPAN_ENTRY_WRONG_GRE_TYPE_2": { + "sonic-mirror-session:sonic-mirror-session": { + "MIRROR_SESSION": { + "MIRROR_SESSION_LIST": [ + { + "name": "erspan", + "type": "ERSPAN", + "dst_ip": "11.1.1.1", + "src_ip": "10.1.1.1", + "gre_type": "65536", "dscp": "10" } ] 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 ba8a1e13c7..9ea1954d7a 100644 --- a/src/sonic-yang-models/yang-models/sonic-mirror-session.yang +++ b/src/sonic-yang-models/yang-models/sonic-mirror-session.yang @@ -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]*|([0-9]|[1-5]?[0-9]{2,4}|6[1-4][0-9]{3}|65[1-4][0-9]{2}|655[1-2][0-9]|6553[0-5])"; length 1..6 { error-message "Invalid GRE type"; error-app-tag gre-type-invalid;