From 9fdaa42830ee5a42da0253a716a1cc424c9c91ed Mon Sep 17 00:00:00 2001 From: bingwang Date: Wed, 2 Mar 2022 20:30:52 -0800 Subject: [PATCH 1/5] Update YANG for mirror session to support decimal value Signed-off-by: bingwang --- .../yang_model_tests/tests/mirror_session.json | 3 +++ .../tests_config/mirror_session.json | 16 ++++++++++++++++ .../yang-models/sonic-mirror-session.yang | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) 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 6d53b0e9cffb..5af963351077 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 @@ -2,6 +2,9 @@ "MIRROR_ERSPAN_ENTRY_WITH_VALID_VALUES": { "desc": "Configuring ERSPAN entry with valid values." }, + "MIRROR_ERSPAN_ENTRY_WITH_VALID_DEC_VALUES": { + "desc": "Configuring ERSPAN entry with valid decimal values." + }, "MIRROR_ERSPAN_ENTRY_WRONG_TYPE": { "desc": "Configuring ERSPAN entry with invalid type", "eStrKey": "InvalidValue" 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 ddf956c79f83..26f831c353e8 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 @@ -15,6 +15,22 @@ } } }, + "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_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 ba8a1e13c7d6..d55ec6c1927e 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]*|[1-9][0-9]*"; length 1..6 { error-message "Invalid GRE type"; error-app-tag gre-type-invalid; From 9f60594d34abdcffd22550a1149a92bb823a572d Mon Sep 17 00:00:00 2001 From: bingwang Date: Thu, 10 Mar 2022 02:30:44 +0000 Subject: [PATCH 2/5] Address comment Signed-off-by: bingwang --- .../tests/mirror_session.json | 15 +++++ .../tests_config/mirror_session.json | 64 +++++++++++++++++++ .../yang-models/sonic-mirror-session.yang | 2 +- 3 files changed, 80 insertions(+), 1 deletion(-) 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 5af963351077..99e62f0d40dd 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 @@ -5,6 +5,9 @@ "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_WRONG_TYPE": { "desc": "Configuring ERSPAN entry with invalid type", "eStrKey": "InvalidValue" @@ -29,6 +32,18 @@ "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_WRONG_GRE_TYPE_3": { + "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 26f831c353e8..abc357ae994e 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 @@ -31,6 +31,22 @@ } } }, + "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_WRONG_TYPE": { "sonic-mirror-session:sonic-mirror-session": { "MIRROR_SESSION": { @@ -127,6 +143,54 @@ } } }, + "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" + } + ] + } + } + }, + "MIRROR_ERSPAN_ENTRY_WRONG_GRE_TYPE_3": { + "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": "100000", + "dscp": "10" + } + ] + } + } + }, "MIRROR_ERSPAN_ENTRY_GRE_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 d55ec6c1927e..0bc812f03ac4 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]*|[1-9][0-9]*"; + pattern "0[xX][0-9a-fA-F]*|([1-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[1-5])"; length 1..6 { error-message "Invalid GRE type"; error-app-tag gre-type-invalid; From 253efd40dfd408f3a3130cff4462e00b3291ba88 Mon Sep 17 00:00:00 2001 From: bingwang Date: Thu, 10 Mar 2022 02:37:05 +0000 Subject: [PATCH 3/5] Address comment Signed-off-by: bingwang --- .../tests/mirror_session.json | 10 ++-- .../tests_config/mirror_session.json | 50 ++++++++++++------- .../yang-models/sonic-mirror-session.yang | 2 +- 3 files changed, 40 insertions(+), 22 deletions(-) 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 99e62f0d40dd..231e1fe3a59a 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 @@ -8,6 +8,12 @@ "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_WITH_VALID_DEC_VALUES_3": { + "desc": "Configuring ERSPAN entry with valid decimal values." + }, "MIRROR_ERSPAN_ENTRY_WRONG_TYPE": { "desc": "Configuring ERSPAN entry with invalid type", "eStrKey": "InvalidValue" @@ -40,10 +46,6 @@ "desc": "Configuring ERSPAN entry with invalid GRE type", "eStrKey" : "Pattern" }, - "MIRROR_ERSPAN_ENTRY_WRONG_GRE_TYPE_3": { - "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 abc357ae994e..ee5831c1a1c9 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 @@ -47,6 +47,38 @@ } } }, + "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_WITH_VALID_DEC_VALUES_3": { + "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_WRONG_TYPE": { "sonic-mirror-session:sonic-mirror-session": { "MIRROR_SESSION": { @@ -136,7 +168,7 @@ "type": "ERSPAN", "dst_ip": "11.1.1.1", "src_ip": "10.1.1.1", - "gre_type": "0", + "gre_type": "100000", "dscp": "10" } ] @@ -175,22 +207,6 @@ } } }, - "MIRROR_ERSPAN_ENTRY_WRONG_GRE_TYPE_3": { - "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": "100000", - "dscp": "10" - } - ] - } - } - }, "MIRROR_ERSPAN_ENTRY_GRE_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 0bc812f03ac4..8afcbbeba3c3 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]*|([1-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[1-5])"; + 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[1-5])"; length 1..6 { error-message "Invalid GRE type"; error-app-tag gre-type-invalid; From c808798878ff9eea68a8e06c85efc478afede664 Mon Sep 17 00:00:00 2001 From: bingwang Date: Thu, 10 Mar 2022 02:56:33 +0000 Subject: [PATCH 4/5] Fix typo Signed-off-by: bingwang --- src/sonic-yang-models/yang-models/sonic-mirror-session.yang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 8afcbbeba3c3..9ea1954d7a37 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]*|([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[1-5])"; + 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; From 9934ce2ba3ced1c20d6fbd92b97d76bf2b8d8c3e Mon Sep 17 00:00:00 2001 From: bingwang Date: Mon, 14 Mar 2022 21:30:10 -0700 Subject: [PATCH 5/5] Fix typo Signed-off-by: bingwang --- .../yang_model_tests/tests/mirror_session.json | 10 +++++----- .../tests_config/mirror_session.json | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) 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 231e1fe3a59a..c54ca3d9595a 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,9 @@ { - "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." @@ -11,9 +14,6 @@ "MIRROR_ERSPAN_ENTRY_WITH_VALID_DEC_VALUES_2": { "desc": "Configuring ERSPAN entry with valid decimal values." }, - "MIRROR_ERSPAN_ENTRY_WITH_VALID_DEC_VALUES_3": { - "desc": "Configuring ERSPAN entry with valid decimal values." - }, "MIRROR_ERSPAN_ENTRY_WRONG_TYPE": { "desc": "Configuring ERSPAN entry with invalid type", "eStrKey": "InvalidValue" 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 ee5831c1a1c9..5e820b5f5fdf 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,7 +15,7 @@ } } }, - "MIRROR_ERSPAN_ENTRY_WITH_VALID_DEC_VALUES": { + "MIRROR_ERSPAN_ENTRY_WITH_VALID_HEX_VALUES_1": { "sonic-mirror-session:sonic-mirror-session": { "MIRROR_SESSION": { "MIRROR_SESSION_LIST": [ @@ -24,14 +24,14 @@ "type": "ERSPAN", "dst_ip": "11.1.1.1", "src_ip": "10.1.1.1", - "gre_type": "1234", + "gre_type": "0x0", "dscp": "10" } ] } } }, - "MIRROR_ERSPAN_ENTRY_WITH_VALID_DEC_VALUES_1": { + "MIRROR_ERSPAN_ENTRY_WITH_VALID_DEC_VALUES": { "sonic-mirror-session:sonic-mirror-session": { "MIRROR_SESSION": { "MIRROR_SESSION_LIST": [ @@ -40,14 +40,14 @@ "type": "ERSPAN", "dst_ip": "11.1.1.1", "src_ip": "10.1.1.1", - "gre_type": "65535", + "gre_type": "1234", "dscp": "10" } ] } } }, - "MIRROR_ERSPAN_ENTRY_WITH_VALID_DEC_VALUES_2": { + "MIRROR_ERSPAN_ENTRY_WITH_VALID_DEC_VALUES_1": { "sonic-mirror-session:sonic-mirror-session": { "MIRROR_SESSION": { "MIRROR_SESSION_LIST": [ @@ -56,14 +56,14 @@ "type": "ERSPAN", "dst_ip": "11.1.1.1", "src_ip": "10.1.1.1", - "gre_type": "0", + "gre_type": "65535", "dscp": "10" } ] } } }, - "MIRROR_ERSPAN_ENTRY_WITH_VALID_DEC_VALUES_3": { + "MIRROR_ERSPAN_ENTRY_WITH_VALID_DEC_VALUES_2": { "sonic-mirror-session:sonic-mirror-session": { "MIRROR_SESSION": { "MIRROR_SESSION_LIST": [ @@ -72,7 +72,7 @@ "type": "ERSPAN", "dst_ip": "11.1.1.1", "src_ip": "10.1.1.1", - "gre_type": "0x0", + "gre_type": "0", "dscp": "10" } ]