From 7e2a48514117be4eb7e49621b46e0687e8dea908 Mon Sep 17 00:00:00 2001 From: Mingzhi Leng Date: Mon, 27 Feb 2023 09:51:19 -0800 Subject: [PATCH 01/14] add fine-grained-ecmp model --- src/sonic-yang-models/doc/Configuration.md | 54 ++++++ src/sonic-yang-models/setup.py | 2 + .../tests/fine-grained-ecmp.json | 5 + .../tests_config/fine_grained_ecmp.json | 44 +++++ .../yang-models/sonic-fine-grained-ecmp.yang | 171 ++++++++++++++++++ 5 files changed, 276 insertions(+) create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json create mode 100644 src/sonic-yang-models/yang-models/sonic-fine-grained-ecmp.yang diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index a7726d8b5695..bfc97850bbfa 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -26,6 +26,9 @@ Table of Contents * [Device Metadata](#device-metadata) * [Device neighbor metada](#device-neighbor-metada) * [DSCP_TO_TC_MAP](#dscp_to_tc_map) + * [FG_NHG](#fg_nhg) + * [FG_NHG_MEMBER](#fg_nhg_member) + * [FG_NHG_PREFIX](#fg_nhg_prefix) * [FLEX_COUNTER_TABLE](#flex_counter_table) * [Hash](#hash) * [KDUMP](#kdump) @@ -892,6 +895,57 @@ instance is supported in SONiC. ``` +### FG_NHG + +The FG_NHG table provides information on Next Hop Groups, including a specified Hash Bucket Size (bucket_size) and match mode for each group. + +``` +"FG_NHG": { + "fgnhg_v4": { + "bucket_size": "120", + "match_mode": "nexthop-based" + }, + "fgnhg_v6": { + "bucket_size": "120", + "match_mode": "nexthop-based" + } +} +``` + +### FG_NHG_MEMBER + +The FG_NHG_MEMBER table provides information about the members of a next hop group, including the group name (FG_NHG), the index at which redistribution is performed (bank), and the link associated with the next-hop-ip (link). + +``` +"FG_NHG_MEMBER": { + "200.200.200.4": { + "FG_NHG": "fgnhg_v4", + "bank": "0", + "link": "Ethernet8" + }, + "200.200.200.5": { + "FG_NHG": "fgnhg_v4", + "bank": "1", + "link": "Ethernet12" + } +} +``` + +### FG_NHG_PREFIX + +The FG_NHG_PREFIX table provides the FG_NHG_PREFIX for which FG behavior is desired, and Fine Grained next-hop group name. + +``` +"FG_NHG_PREFIX": { + "100.50.25.12/32": { + "FG_NHG": "fgnhg_v4" + }, + "fc:05::/128": { + "FG_NHG": "fgnhg_v6" + } +} +``` + ### MPLS_TC_TO_TC_MAP ``` diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index 2736465ead3e..26582723f132 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -116,6 +116,7 @@ def run(self): './yang-models/sonic-events-syncd.yang', './yang-models/sonic-extension.yang', './yang-models/sonic-flex_counter.yang', + './yang-models/sonic-fine-grained-ecmp.yang', './yang-models/sonic-feature.yang', './yang-models/sonic-hash.yang', './yang-models/sonic-system-defaults.yang', @@ -203,6 +204,7 @@ def run(self): './cvlyang-models/sonic-extension.yang', './cvlyang-models/sonic-flex_counter.yang', './cvlyang-models/sonic-feature.yang', + './cvlyang-models/sonic-fine-grained-ecmp.yang', './cvlyang-models/sonic-hash.yang', './cvlyang-models/sonic-system-defaults.yang', './cvlyang-models/sonic-interface.yang', diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json b/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json new file mode 100644 index 000000000000..caeda39992eb --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json @@ -0,0 +1,5 @@ +{ + "VALID_FINE_GRAINED_ECMP": { + "desc": "VALID_FINE_GRAINED_ECMP no failure." + } +} \ No newline at end of file diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json new file mode 100644 index 000000000000..27ae645734c9 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json @@ -0,0 +1,44 @@ +{ + "VALID_FINE_GRAINED_ECMP":{ + "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp":{ + "sonic-fine-grained-ecmp:FG_NHG":{ + "FG_NHG_LIST":[ + { + "name":"fgnhg_v4", + "bucket_size": "120", + "match_mode": "nexthop-based" + }, + { + "name":"fgnhg_v6", + "bucket_size": "120", + "match_mode": "nexthop-based" + } + ], + "FG_NHG_PREFIX_LIST":[ + { + "ip_prefix":"100.50.25.12/32", + "FG_NHG": "fgnhg_v4" + }, + { + "ip_prefix":"fc:05::/128", + "FG_NHG": "fgnhg_v6" + } + ], + "FG_NHG_MEMBER_LIST":[ + { + "next_hop_ip":"200.200.200.4", + "FG_NHG": "fgnhg_v4", + "bank": "0", + "link": "Ethernet8" + }, + { + "next_hop_ip":"200.200.200.5", + "FG_NHG": "fgnhg_v4", + "bank": "1", + "link": "Ethernet12" + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/sonic-yang-models/yang-models/sonic-fine-grained-ecmp.yang b/src/sonic-yang-models/yang-models/sonic-fine-grained-ecmp.yang new file mode 100644 index 000000000000..46d117d118e5 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-fine-grained-ecmp.yang @@ -0,0 +1,171 @@ +module sonic-fine-grained-ecmp { + + yang-version 1.1; + + namespace "http://github.com/Azure/sonic-fine-grained-ecmp"; + prefix sfgecmp; + + import ietf-inet-types { + prefix inet; + } + + import sonic-portchannel { + prefix lag; + } + + import sonic-port { + prefix port; + } + + import sonic-types { + prefix stypes; + } + + organization + "SONiC"; + + contact + "SONiC"; + + description + "SONIC Fine Grained ECMP"; + + revision 2023-01-19 { + description "Initial revision."; + } + + typedef match-mode-name { + + type enumeration { + + enum route-based { + description + "Fine grained ecmp is used when the route prefix matches the FG_NHG_PREFIX prefix"; + } + + enum nexthop-based { + description + "Fine grained ecmp is used when the nexthop IPs match the FG_NHG_MEMBER IPs"; + } + + } + + description + "This enumeration type defines the method used to determine whether fine grained ecmp should be applied."; + } + + container sonic-fine-grained-ecmp { + + container FG_NHG { + + description "FG_NHG part of config_db.json"; + + list FG_NHG_LIST{ + + key "name"; + + leaf name{ + type string; + description "FG_NHG group name"; + } + + leaf bucket_size{ + type uint16; + mandatory true; + description "total hash bucket size desired, + recommended value of Lowest Common Multiple + of 1..{max # of next-hops}"; + } + + leaf match_mode{ + type match-mode-name; + mandatory true; + description " The filtering method used to identify + when to use Fine Grained vs regular route handling. + nexthop-based looks to next-hop IP to filter routes + and uses fine grained ecmp when nexthop IPs matches + FG_NHG_MEMBER IPs. route-based looks to prefix to + filter routes, and uses fine grained ecmp when the + route prefix matches the FG_NHG_PREFIX prefix."; + } + } + /* end of list FG_NHG_LIST */ + } + /* end of container FG_NHG */ + + container FG_NHG_PREFIX{ + + description "FG_NHG_PREFIX part of config_db.json"; + + list FG_NHG_PREFIX_LIST{ + + key "ip_prefix"; + + leaf ip_prefix{ + type stypes:sonic-ip-prefix; + description "FG_NHG_PREFIX for which FG behavior is + desired"; + } + + leaf FG_NHG{ + type leafref { + path "/sfgecmp:sonic-fine-grained-ecmp/sfgecmp:FG_NHG/sfgecmp:FG_NHG_LIST/sfgecmp:name"; + } + mandatory true; + description "Fine Grained next-hop group name"; + } + } + /* end of list FG_NHG_PREFIX_LIST */ + } + /* end of container FG_NHG_PREFIX */ + + container FG_NHG_MEMBER{ + + description "FG_NHG_MEMBER part of config_db.json"; + + list FG_NHG_MEMBER_LIST{ + + key "next_hop_ip"; + + leaf next_hop_ip{ + type inet:ip-address; + description "FG_NHG next-hop-ip member associated + with prefix"; + } + + leaf FG_NHG{ + type leafref { + path "/sfgecmp:sonic-fine-grained-ecmp/sfgecmp:FG_NHG/sfgecmp:FG_NHG_LIST/sfgecmp:name"; + } + mandatory true; + description "Fine Grained next-hop group name"; + } + + leaf bank{ + type uint16; + mandatory true; + description "An index which specifies a bank/group + in which the redistribution is performed"; + } + + leaf link{ + type union { + type leafref { + path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name"; + } + type leafref { + path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; + } + } + description "Link associated with next-hop-ip, if + configured, enables next-hop withdrawal/addition + per link's operational state changes"; + } + } + /* end of list FG_NHG_MEMBER_LIST */ + } + /* end of container FG_NHG_MEMBER */ + } + /* end of container sonic-fine-grained-ecmp */ +} +/* end of module sonic-fine-grained-ecmp */ \ No newline at end of file From 859deb3cc4a7f756f876db9d79da68d4c5b32a3a Mon Sep 17 00:00:00 2001 From: Mingzhi Leng Date: Mon, 27 Feb 2023 11:30:21 -0800 Subject: [PATCH 02/14] update unit test cases --- .../tests/fine-grained-ecmp.json | 44 +++- .../tests_config/fine_grained_ecmp.json | 207 ++++++++++++++++-- 2 files changed, 224 insertions(+), 27 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json b/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json index caeda39992eb..b502fb5dc5b6 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json @@ -1,5 +1,43 @@ { - "VALID_FINE_GRAINED_ECMP": { - "desc": "VALID_FINE_GRAINED_ECMP no failure." + "FG_NHG_TEST": { + "desc": "Fine-grained ECMP next-hop group configuration in FG_NHG_LIST table." + }, + "FG_NHG_PREFIX_TEST": { + "desc": "Fine-grained ECMP prefix configuration in FG_NHG_PREFIX_LIST table." + }, + "FG_NHG_MEMBER_TEST": { + "desc": "Fine-grained ECMP next-hop member configuration in FG_NHG_MEMBER_LIST table." + }, + "FG_NHG_MEMBER_TEST_INVALID_IP": { + "desc": "Fine-grained ECMP next-hop member configuration with invalid IP value in FG_NHG_MEMBER_LIST table.", + "eStr": "Invalid value" + }, + "FG_NHG_PREFIX_TEST_INVALID_PREFIX":{ + "desc": "Fine-grained ECMP prefix configuration with invalid prefix value in FG_NHG_PREFIX_LIST table.", + "eStr": "Invalid value" + }, + "FG_NHG_MEMBER_TEST_MISSING_FG_NHG_REF": { + "desc": "Fine-grained ECMP next-hop member configuration with missing FG_NHG reference in FG_NHG_MEMBER_LIST table.", + "eStr": "Missing reference" + }, + "FG_NHG_PREFIX_TEST_MISSING_FG_NHG_REF": { + "desc": "Fine-grained ECMP prefix configuration with missing FG_NHG reference in FG_NHG_PREFIX_LIST table.", + "eStr": "Missing reference" + }, + "FG_NHG_MEMBER_TEST_MISSING_BANK": { + "desc": "Fine-grained ECMP next-hop member configuration with missing bank in FG_NHG_MEMBER_LIST table.", + "eStr": "Mandatory leaf 'bank' missing" + }, + "FG_NHG_TEST_DUPLICATE_ENTRY": { + "desc": "Fine-grained ECMP next-hop group configuration with duplicate entry in FG_NHG_LIST table.", + "eStr": "Duplicate entry" + }, + "FG_NHG_PREFIX_TEST_DUPLICATE_ENTRY": { + "desc": "Fine-grained ECMP prefix configuration with duplicate entry in FG_NHG_PREFIX_LIST table.", + "eStr": "Duplicate entry" + }, + "FG_NHG_MEMBER_TEST_DUPLICATE_MEMBER": { + "desc": "Fine-grained ECMP next-hop member configuration with duplicate member in FG_NHG_MEMBER_LIST table.", + "eStr": "Duplicate member" } -} \ No newline at end of file +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json index 27ae645734c9..67494e18ff9f 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json @@ -1,41 +1,200 @@ { - "VALID_FINE_GRAINED_ECMP":{ - "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp":{ - "sonic-fine-grained-ecmp:FG_NHG":{ - "FG_NHG_LIST":[ + "FG_NHG_TEST": { + "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { + "sonic-fine-grained-ecmp:FG_NHG": { + "FG_NHG_LIST": [ { - "name":"fgnhg_v4", - "bucket_size": "120", + "name": "group1", + "bucket_size": 10, "match_mode": "nexthop-based" }, { - "name":"fgnhg_v6", - "bucket_size": "120", + "name": "group2", + "bucket_size": 20, + "match_mode": "route-based" + } + ] + } + } + }, + "FG_NHG_PREFIX_TEST": { + "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { + "sonic-fine-grained-ecmp:FG_NHG_PREFIX": { + "FG_NHG_PREFIX_LIST": [ + { + "ip_prefix": "10.0.0.0/24", + "FG_NHG": "group1" + }, + { + "ip_prefix": "10.1.0.0/24", + "FG_NHG": "group2" + } + ] + } + } + }, + "FG_NHG_MEMBER_TEST": { + "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { + "sonic-fine-grained-ecmp:FG_NHG_MEMBER": { + "FG_NHG_MEMBER_LIST": [ + { + "next_hop_ip": "10.0.0.1", + "FG_NHG": "group1", + "bank": 1, + "link": "Ethernet1" + }, + { + "next_hop_ip": "10.0.0.2", + "FG_NHG": "group1", + "bank": 2, + "link": "Ethernet2" + }, + { + "next_hop_ip": "10.1.0.1", + "FG_NHG": "group2", + "bank": 3, + "link": "PortChannel1" + } + ] + } + } + }, + "FG_NHG_TEST_DUPLICATE_NAME": { + "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { + "sonic-fine-grained-ecmp:FG_NHG": { + "FG_NHG_LIST": [ + { + "name": "group1", + "bucket_size": 10, "match_mode": "nexthop-based" + }, + { + "name": "group1", + "bucket_size": 20, + "match_mode": "route-based" + } + ] + } + } + }, + "FG_NHG_MEMBER_TEST_INVALID_IP": { + "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { + "sonic-fine-grained-ecmp:FG_NHG_MEMBER": { + "FG_NHG_MEMBER_LIST": [ + { + "next_hop_ip": "invalid_ip", + "FG_NHG": "group1", + "bank": 1, + "link": "Ethernet1" } - ], - "FG_NHG_PREFIX_LIST":[ + ] + } + } + }, + "FG_NHG_PREFIX_TEST_INVALID_PREFIX": { + "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { + "sonic-fine-grained-ecmp:FG_NHG_PREFIX": { + "FG_NHG_PREFIX_LIST": [ { - "ip_prefix":"100.50.25.12/32", - "FG_NHG": "fgnhg_v4" + "ip_prefix": "invalid_prefix", + "FG_NHG": "group1" + } + ] + } + } + }, + "FG_NHG_MEMBER_TEST_MISSING_FG_NHG_REF": { + "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { + "sonic-fine-grained-ecmp:FG_NHG_MEMBER": { + "FG_NHG_MEMBER_LIST": [ + { + "next_hop_ip": "10.0.0.1", + "bank": 1, + "link": "Ethernet1" + } + ] + } + } + }, + "FG_NHG_PREFIX_TEST_MISSING_FG_NHG_REF": { + "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { + "sonic-fine-grained-ecmp:FG_NHG_PREFIX": { + "FG_NHG_PREFIX_LIST": [ + { + "ip_prefix": "10.0.0.0/24" + } + ] + } + } + }, + "FG_NHG_MEMBER_TEST_MISSING_BANK": { + "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { + "sonic-fine-grained-ecmp:FG_NHG_MEMBER": { + "FG_NHG_MEMBER_LIST": [ + { + "next_hop_ip": "10.0.0.1", + "FG_NHG": "group1", + "link": "Ethernet1" + } + ] + } + } + }, + "FG_NHG_TEST_DUPLICATE_ENTRY": { + "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { + "sonic-fine-grained-ecmp:FG_NHG": { + "FG_NHG_LIST": [ + { + "name": "group1", + "bucket_size": 16, + "match_mode": "nexthop-based" + }, + { + "name": "group1", + "bucket_size": 8, + "match_mode": "nexthop-based" + } + ] + } + } + }, + "FG_NHG_PREFIX_TEST_DUPLICATE_ENTRY": { + "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { + "sonic-fine-grained-ecmp:FG_NHG_PREFIX": { + "FG_NHG_PREFIX_LIST": [ + { + "ip_prefix": "10.0.0.0/24", + "FG_NHG": "group1" }, { - "ip_prefix":"fc:05::/128", - "FG_NHG": "fgnhg_v6" + "ip_prefix": "10.0.0.0/24", + "FG_NHG": "group2" } - ], - "FG_NHG_MEMBER_LIST":[ + ] + } + } + }, + "FG_NHG_MEMBER_TEST_DUPLICATE_MEMBER": { + "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { + "sonic-fine-grained-ecmp:FG_NHG_MEMBER": { + "FG_NHG_MEMBER_LIST": [ + { + "next_hop_ip": "10.0.0.1", + "FG_NHG": "group1", + "bank": 1, + "link": "Ethernet1" + }, { - "next_hop_ip":"200.200.200.4", - "FG_NHG": "fgnhg_v4", - "bank": "0", - "link": "Ethernet8" + "next_hop_ip": "10.0.0.2", + "FG_NHG": "group1", + "bank": 2, + "link": "Ethernet2" }, { - "next_hop_ip":"200.200.200.5", - "FG_NHG": "fgnhg_v4", - "bank": "1", - "link": "Ethernet12" + "next_hop_ip": "10.0.0.1", + "FG_NHG": "group1", + "bank": 3, + "link": "Ethernet3" } ] } From c50b7502e281e7f89f899ea6441f93a5fc3fd3d8 Mon Sep 17 00:00:00 2001 From: Mingzhi Leng Date: Mon, 27 Feb 2023 12:52:42 -0800 Subject: [PATCH 03/14] update unit test cases --- .../tests/fine-grained-ecmp.json | 14 ++++-- .../tests_config/fine_grained_ecmp.json | 48 +++++++++++++++++++ 2 files changed, 57 insertions(+), 5 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json b/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json index b502fb5dc5b6..a8e047d2b087 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json @@ -8,13 +8,17 @@ "FG_NHG_MEMBER_TEST": { "desc": "Fine-grained ECMP next-hop member configuration in FG_NHG_MEMBER_LIST table." }, + "FG_NHG_TEST_DUPLICATE_NAME": { + "desc": "Fine-grained ECMP next-hop group configuration with duplicate name in FG_NHG_LIST table.", + "eStr": "Duplicated instance of \"FG_NHG_LIST\" list." + }, "FG_NHG_MEMBER_TEST_INVALID_IP": { "desc": "Fine-grained ECMP next-hop member configuration with invalid IP value in FG_NHG_MEMBER_LIST table.", - "eStr": "Invalid value" + "eStr": "Invalid value .* next_hop_ip" }, "FG_NHG_PREFIX_TEST_INVALID_PREFIX":{ "desc": "Fine-grained ECMP prefix configuration with invalid prefix value in FG_NHG_PREFIX_LIST table.", - "eStr": "Invalid value" + "eStr": "Invalid value .* ip_prefix" }, "FG_NHG_MEMBER_TEST_MISSING_FG_NHG_REF": { "desc": "Fine-grained ECMP next-hop member configuration with missing FG_NHG reference in FG_NHG_MEMBER_LIST table.", @@ -30,14 +34,14 @@ }, "FG_NHG_TEST_DUPLICATE_ENTRY": { "desc": "Fine-grained ECMP next-hop group configuration with duplicate entry in FG_NHG_LIST table.", - "eStr": "Duplicate entry" + "eStr": "Duplicated instance of \"FG_NHG_LIST\" list." }, "FG_NHG_PREFIX_TEST_DUPLICATE_ENTRY": { "desc": "Fine-grained ECMP prefix configuration with duplicate entry in FG_NHG_PREFIX_LIST table.", - "eStr": "Duplicate entry" + "eStr": "Duplicated instance of \"FG_NHG_PREFIX_LIST\" list." }, "FG_NHG_MEMBER_TEST_DUPLICATE_MEMBER": { "desc": "Fine-grained ECMP next-hop member configuration with duplicate member in FG_NHG_MEMBER_LIST table.", - "eStr": "Duplicate member" + "eStr": "Duplicated instance of \"FG_NHG_MEMBER_LIST\" list." } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json index 67494e18ff9f..2e0329d79229 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json @@ -20,6 +20,18 @@ "FG_NHG_PREFIX_TEST": { "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { "sonic-fine-grained-ecmp:FG_NHG_PREFIX": { + "FG_NHG_LIST": [ + { + "name": "group1", + "bucket_size": 10, + "match_mode": "nexthop-based" + }, + { + "name": "group2", + "bucket_size": 20, + "match_mode": "route-based" + } + ], "FG_NHG_PREFIX_LIST": [ { "ip_prefix": "10.0.0.0/24", @@ -36,6 +48,18 @@ "FG_NHG_MEMBER_TEST": { "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { "sonic-fine-grained-ecmp:FG_NHG_MEMBER": { + "FG_NHG_LIST": [ + { + "name": "group1", + "bucket_size": 10, + "match_mode": "nexthop-based" + }, + { + "name": "group2", + "bucket_size": 20, + "match_mode": "route-based" + } + ], "FG_NHG_MEMBER_LIST": [ { "next_hop_ip": "10.0.0.1", @@ -119,6 +143,18 @@ "FG_NHG_PREFIX_TEST_MISSING_FG_NHG_REF": { "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { "sonic-fine-grained-ecmp:FG_NHG_PREFIX": { + "FG_NHG_LIST": [ + { + "name": "group1", + "bucket_size": 10, + "match_mode": "nexthop-based" + }, + { + "name": "group2", + "bucket_size": 20, + "match_mode": "route-based" + } + ], "FG_NHG_PREFIX_LIST": [ { "ip_prefix": "10.0.0.0/24" @@ -130,6 +166,18 @@ "FG_NHG_MEMBER_TEST_MISSING_BANK": { "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { "sonic-fine-grained-ecmp:FG_NHG_MEMBER": { + "FG_NHG_LIST": [ + { + "name": "group1", + "bucket_size": 10, + "match_mode": "nexthop-based" + }, + { + "name": "group2", + "bucket_size": 20, + "match_mode": "route-based" + } + ], "FG_NHG_MEMBER_LIST": [ { "next_hop_ip": "10.0.0.1", From b750e8240ca32c9006710cc4d6465a98072a7c2a Mon Sep 17 00:00:00 2001 From: Mingzhi Leng Date: Mon, 27 Feb 2023 14:21:25 -0800 Subject: [PATCH 04/14] update unit test --- .../tests/fine-grained-ecmp.json | 6 ++-- .../tests_config/fine_grained_ecmp.json | 36 +++++-------------- 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json b/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json index a8e047d2b087..b2273992a439 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json @@ -14,11 +14,13 @@ }, "FG_NHG_MEMBER_TEST_INVALID_IP": { "desc": "Fine-grained ECMP next-hop member configuration with invalid IP value in FG_NHG_MEMBER_LIST table.", - "eStr": "Invalid value .* next_hop_ip" + "eStrKey" : "InvalidValue", + "eStr": "next_hop_ip" }, "FG_NHG_PREFIX_TEST_INVALID_PREFIX":{ "desc": "Fine-grained ECMP prefix configuration with invalid prefix value in FG_NHG_PREFIX_LIST table.", - "eStr": "Invalid value .* ip_prefix" + "eStrKey" : "InvalidValue", + "eStr": "ip_prefix" }, "FG_NHG_MEMBER_TEST_MISSING_FG_NHG_REF": { "desc": "Fine-grained ECMP next-hop member configuration with missing FG_NHG reference in FG_NHG_MEMBER_LIST table.", diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json index 2e0329d79229..dc9a10d69e33 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json @@ -19,7 +19,7 @@ }, "FG_NHG_PREFIX_TEST": { "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { - "sonic-fine-grained-ecmp:FG_NHG_PREFIX": { + "sonic-fine-grained-ecmp:FG_NHG": { "FG_NHG_LIST": [ { "name": "group1", @@ -31,7 +31,9 @@ "bucket_size": 20, "match_mode": "route-based" } - ], + ] + }, + "sonic-fine-grained-ecmp:FG_NHG_PREFIX": { "FG_NHG_PREFIX_LIST": [ { "ip_prefix": "10.0.0.0/24", @@ -47,7 +49,7 @@ }, "FG_NHG_MEMBER_TEST": { "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { - "sonic-fine-grained-ecmp:FG_NHG_MEMBER": { + "sonic-fine-grained-ecmp:FG_NHG": { "FG_NHG_LIST": [ { "name": "group1", @@ -59,7 +61,9 @@ "bucket_size": 20, "match_mode": "route-based" } - ], + ] + }, + "sonic-fine-grained-ecmp:FG_NHG_MEMBER": { "FG_NHG_MEMBER_LIST": [ { "next_hop_ip": "10.0.0.1", @@ -143,18 +147,6 @@ "FG_NHG_PREFIX_TEST_MISSING_FG_NHG_REF": { "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { "sonic-fine-grained-ecmp:FG_NHG_PREFIX": { - "FG_NHG_LIST": [ - { - "name": "group1", - "bucket_size": 10, - "match_mode": "nexthop-based" - }, - { - "name": "group2", - "bucket_size": 20, - "match_mode": "route-based" - } - ], "FG_NHG_PREFIX_LIST": [ { "ip_prefix": "10.0.0.0/24" @@ -166,18 +158,6 @@ "FG_NHG_MEMBER_TEST_MISSING_BANK": { "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { "sonic-fine-grained-ecmp:FG_NHG_MEMBER": { - "FG_NHG_LIST": [ - { - "name": "group1", - "bucket_size": 10, - "match_mode": "nexthop-based" - }, - { - "name": "group2", - "bucket_size": 20, - "match_mode": "route-based" - } - ], "FG_NHG_MEMBER_LIST": [ { "next_hop_ip": "10.0.0.1", From d836f46726ac58b22b924e93a64cc44071d81ec4 Mon Sep 17 00:00:00 2001 From: Mingzhi Leng Date: Mon, 27 Feb 2023 15:55:08 -0800 Subject: [PATCH 05/14] update unit test cases --- .../tests/fine-grained-ecmp.json | 8 ++--- .../tests_config/fine_grained_ecmp.json | 29 +++++++++++++++++-- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json b/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json index b2273992a439..ea0c6c2e4d2d 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json @@ -15,20 +15,20 @@ "FG_NHG_MEMBER_TEST_INVALID_IP": { "desc": "Fine-grained ECMP next-hop member configuration with invalid IP value in FG_NHG_MEMBER_LIST table.", "eStrKey" : "InvalidValue", - "eStr": "next_hop_ip" + "eStr": ["next_hop_ip"] }, "FG_NHG_PREFIX_TEST_INVALID_PREFIX":{ "desc": "Fine-grained ECMP prefix configuration with invalid prefix value in FG_NHG_PREFIX_LIST table.", "eStrKey" : "InvalidValue", - "eStr": "ip_prefix" + "eStr": ["ip_prefix"] }, "FG_NHG_MEMBER_TEST_MISSING_FG_NHG_REF": { "desc": "Fine-grained ECMP next-hop member configuration with missing FG_NHG reference in FG_NHG_MEMBER_LIST table.", - "eStr": "Missing reference" + "eStr": "Missing required element \"FG_NHG\" in \"FG_NHG_MEMBER_LIST\". " }, "FG_NHG_PREFIX_TEST_MISSING_FG_NHG_REF": { "desc": "Fine-grained ECMP prefix configuration with missing FG_NHG reference in FG_NHG_PREFIX_LIST table.", - "eStr": "Missing reference" + "eStr": "Missing required element \"FG_NHG\" in \"FG_NHG_PREFIX_LIST\". " }, "FG_NHG_MEMBER_TEST_MISSING_BANK": { "desc": "Fine-grained ECMP next-hop member configuration with missing bank in FG_NHG_MEMBER_LIST table.", diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json index dc9a10d69e33..489156e04045 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json @@ -48,6 +48,15 @@ } }, "FG_NHG_MEMBER_TEST": { + "sonic-portchannel:PORTCHANNEL:PORTCHANNEL_LIST": [ + { + "name": "PortChannel", + "admin_status": "up" + },{ + "name": "PortChannel2", + "admin_status": "up" + } + ], "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { "sonic-fine-grained-ecmp:FG_NHG": { "FG_NHG_LIST": [ @@ -69,13 +78,13 @@ "next_hop_ip": "10.0.0.1", "FG_NHG": "group1", "bank": 1, - "link": "Ethernet1" + "link": "PortChannel" }, { "next_hop_ip": "10.0.0.2", "FG_NHG": "group1", "bank": 2, - "link": "Ethernet2" + "link": "PortChannel2" }, { "next_hop_ip": "10.1.0.1", @@ -132,13 +141,18 @@ } }, "FG_NHG_MEMBER_TEST_MISSING_FG_NHG_REF": { + "sonic-portchannel:PORTCHANNEL:PORTCHANNEL_LIST":[ + { + "name": "PortChannel1", + "admin_status": "up" + }], "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { "sonic-fine-grained-ecmp:FG_NHG_MEMBER": { "FG_NHG_MEMBER_LIST": [ { "next_hop_ip": "10.0.0.1", "bank": 1, - "link": "Ethernet1" + "link": "PortChannel1" } ] } @@ -157,6 +171,15 @@ }, "FG_NHG_MEMBER_TEST_MISSING_BANK": { "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { + "sonic-fine-grained-ecmp:FG_NHG": { + "FG_NHG_LIST": [ + { + "name": "group1", + "bucket_size": 10, + "match_mode": "nexthop-based" + } + ] + }, "sonic-fine-grained-ecmp:FG_NHG_MEMBER": { "FG_NHG_MEMBER_LIST": [ { From d0643c0d0207c3c5ca72000efa2316af8d3aed86 Mon Sep 17 00:00:00 2001 From: Mingzhi Leng Date: Mon, 27 Feb 2023 17:04:15 -0800 Subject: [PATCH 06/14] update test cases --- .../tests_config/fine_grained_ecmp.json | 72 ++++++++++++++----- 1 file changed, 53 insertions(+), 19 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json index 489156e04045..57da0cdd91d2 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json @@ -48,15 +48,22 @@ } }, "FG_NHG_MEMBER_TEST": { - "sonic-portchannel:PORTCHANNEL:PORTCHANNEL_LIST": [ - { - "name": "PortChannel", - "admin_status": "up" - },{ - "name": "PortChannel2", - "admin_status": "up" + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "lanes": "65", + "mtu": "9000", + "name": "Ethernet1", + "tpid": "0x8100", + "speed": "25000" + } + ] } - ], + }, "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { "sonic-fine-grained-ecmp:FG_NHG": { "FG_NHG_LIST": [ @@ -78,19 +85,19 @@ "next_hop_ip": "10.0.0.1", "FG_NHG": "group1", "bank": 1, - "link": "PortChannel" + "link": "Ethernet1" }, { "next_hop_ip": "10.0.0.2", "FG_NHG": "group1", "bank": 2, - "link": "PortChannel2" + "link": "Ethernet1" }, { "next_hop_ip": "10.1.0.1", "FG_NHG": "group2", "bank": 3, - "link": "PortChannel1" + "link": "Ethernet1" } ] } @@ -141,18 +148,29 @@ } }, "FG_NHG_MEMBER_TEST_MISSING_FG_NHG_REF": { - "sonic-portchannel:PORTCHANNEL:PORTCHANNEL_LIST":[ - { - "name": "PortChannel1", - "admin_status": "up" - }], + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "lanes": "65", + "mtu": "9000", + "name": "Ethernet1", + "tpid": "0x8100", + "speed": "25000" + } + ] + } + }, "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { "sonic-fine-grained-ecmp:FG_NHG_MEMBER": { "FG_NHG_MEMBER_LIST": [ { "next_hop_ip": "10.0.0.1", "bank": 1, - "link": "PortChannel1" + "link": "Ethernet1" } ] } @@ -181,6 +199,22 @@ ] }, "sonic-fine-grained-ecmp:FG_NHG_MEMBER": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "lanes": "65", + "mtu": "9000", + "name": "Ethernet1", + "tpid": "0x8100", + "speed": "25000" + } + ] + } + }, "FG_NHG_MEMBER_LIST": [ { "next_hop_ip": "10.0.0.1", @@ -239,13 +273,13 @@ "next_hop_ip": "10.0.0.2", "FG_NHG": "group1", "bank": 2, - "link": "Ethernet2" + "link": "Ethernet1" }, { "next_hop_ip": "10.0.0.1", "FG_NHG": "group1", "bank": 3, - "link": "Ethernet3" + "link": "Ethernet1" } ] } From a8d001d4d0b9d1d9c62612dcb8219c53c0606f35 Mon Sep 17 00:00:00 2001 From: Mingzhi Leng Date: Mon, 27 Feb 2023 22:13:10 -0800 Subject: [PATCH 07/14] update unit test cases --- .../tests/fine-grained-ecmp.json | 18 +++++++---- .../tests_config/fine_grained_ecmp.json | 32 +++++++++---------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json b/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json index ea0c6c2e4d2d..86bd816692ae 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json @@ -14,13 +14,17 @@ }, "FG_NHG_MEMBER_TEST_INVALID_IP": { "desc": "Fine-grained ECMP next-hop member configuration with invalid IP value in FG_NHG_MEMBER_LIST table.", - "eStrKey" : "InvalidValue", - "eStr": ["next_hop_ip"] + "eStrKey": "InvalidValue", + "eStr": [ + "next_hop_ip" + ] }, - "FG_NHG_PREFIX_TEST_INVALID_PREFIX":{ + "FG_NHG_PREFIX_TEST_INVALID_PREFIX": { "desc": "Fine-grained ECMP prefix configuration with invalid prefix value in FG_NHG_PREFIX_LIST table.", - "eStrKey" : "InvalidValue", - "eStr": ["ip_prefix"] + "eStrKey": "InvalidValue", + "eStr": [ + "ip_prefix" + ] }, "FG_NHG_MEMBER_TEST_MISSING_FG_NHG_REF": { "desc": "Fine-grained ECMP next-hop member configuration with missing FG_NHG reference in FG_NHG_MEMBER_LIST table.", @@ -32,7 +36,7 @@ }, "FG_NHG_MEMBER_TEST_MISSING_BANK": { "desc": "Fine-grained ECMP next-hop member configuration with missing bank in FG_NHG_MEMBER_LIST table.", - "eStr": "Mandatory leaf 'bank' missing" + "eStr": "Missing required element \"bank\"" }, "FG_NHG_TEST_DUPLICATE_ENTRY": { "desc": "Fine-grained ECMP next-hop group configuration with duplicate entry in FG_NHG_LIST table.", @@ -46,4 +50,4 @@ "desc": "Fine-grained ECMP next-hop member configuration with duplicate member in FG_NHG_MEMBER_LIST table.", "eStr": "Duplicated instance of \"FG_NHG_MEMBER_LIST\" list." } -} +} \ No newline at end of file diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json index 57da0cdd91d2..11fb30d9249f 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json @@ -198,23 +198,23 @@ } ] }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "lanes": "65", + "mtu": "9000", + "name": "Ethernet1", + "tpid": "0x8100", + "speed": "25000" + } + ] + } + }, "sonic-fine-grained-ecmp:FG_NHG_MEMBER": { - "sonic-port:sonic-port": { - "sonic-port:PORT": { - "PORT_LIST": [ - { - "admin_status": "up", - "alias": "eth0", - "description": "Ethernet0", - "lanes": "65", - "mtu": "9000", - "name": "Ethernet1", - "tpid": "0x8100", - "speed": "25000" - } - ] - } - }, "FG_NHG_MEMBER_LIST": [ { "next_hop_ip": "10.0.0.1", From e782153480ba05776e3206324e78e5c709fb357b Mon Sep 17 00:00:00 2001 From: Mingzhi Leng Date: Tue, 28 Feb 2023 00:12:37 -0800 Subject: [PATCH 08/14] update unit test cases --- .../tests_config/fine_grained_ecmp.json | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json index 11fb30d9249f..f29876e99435 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json @@ -188,6 +188,22 @@ } }, "FG_NHG_MEMBER_TEST_MISSING_BANK": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "lanes": "65", + "mtu": "9000", + "name": "Ethernet1", + "tpid": "0x8100", + "speed": "25000" + } + ] + } + }, "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { "sonic-fine-grained-ecmp:FG_NHG": { "FG_NHG_LIST": [ @@ -198,22 +214,6 @@ } ] }, - "sonic-port:sonic-port": { - "sonic-port:PORT": { - "PORT_LIST": [ - { - "admin_status": "up", - "alias": "eth0", - "description": "Ethernet0", - "lanes": "65", - "mtu": "9000", - "name": "Ethernet1", - "tpid": "0x8100", - "speed": "25000" - } - ] - } - }, "sonic-fine-grained-ecmp:FG_NHG_MEMBER": { "FG_NHG_MEMBER_LIST": [ { From 7d887f600920d6b96191d3f129d6fcc61dcf8048 Mon Sep 17 00:00:00 2001 From: Mingzhi Leng Date: Tue, 28 Feb 2023 09:36:09 -0800 Subject: [PATCH 09/14] update sample config db --- .../tests/files/sample_config_db.json | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/sonic-yang-models/tests/files/sample_config_db.json b/src/sonic-yang-models/tests/files/sample_config_db.json index 8b80631f4fb4..4cc976cccd37 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -2285,5 +2285,45 @@ "global": { } } + }, + "FG_NHG": { + "nhg1": { + "bucket_size": "16", + "match_mode": "nexthop-based" + }, + "nhg2": { + "bucket_size": "32", + "match_mode": "route-based" + } + }, + "FG_NHG_PREFIX": { + "10.0.0.0/24": { + "FG_NHG": "nhg1" + }, + "192.168.0.0/16": { + "FG_NHG": "nhg2" + } + }, + "FG_NHG_MEMBER": { + "192.168.1.1": { + "FG_NHG": "nhg1", + "bank": "0", + "link": "Ethernet1" + }, + "192.168.1.2": { + "FG_NHG": "nhg1", + "bank": "0", + "link": "Ethernet2" + }, + "10.0.0.1": { + "FG_NHG": "nhg2", + "bank": "1", + "link": "PortChannel1" + }, + "10.0.0.2": { + "FG_NHG": "nhg2", + "bank": "1", + "link": "PortChannel2" + } } } From c66751b907001e236d8376b717ecd9ad12ebb1eb Mon Sep 17 00:00:00 2001 From: Mingzhi Leng Date: Tue, 28 Feb 2023 22:08:32 -0800 Subject: [PATCH 10/14] move FG_NHG* tables to right place --- .../tests/files/sample_config_db.json | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/src/sonic-yang-models/tests/files/sample_config_db.json b/src/sonic-yang-models/tests/files/sample_config_db.json index 4cc976cccd37..e326ee07852b 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -2273,6 +2273,46 @@ "vni": "10", "guid":"guid-vnet1" } + }, + "FG_NHG": { + "nhg1": { + "bucket_size": "16", + "match_mode": "nexthop-based" + }, + "nhg2": { + "bucket_size": "32", + "match_mode": "route-based" + } + }, + "FG_NHG_PREFIX": { + "10.0.0.0/24": { + "FG_NHG": "nhg1" + }, + "192.168.0.0/16": { + "FG_NHG": "nhg2" + } + }, + "FG_NHG_MEMBER": { + "192.168.1.1": { + "FG_NHG": "nhg1", + "bank": "0", + "link": "Ethernet1" + }, + "192.168.1.2": { + "FG_NHG": "nhg1", + "bank": "0", + "link": "Ethernet2" + }, + "10.0.0.1": { + "FG_NHG": "nhg2", + "bank": "1", + "link": "PortChannel42" + }, + "10.0.0.2": { + "FG_NHG": "nhg2", + "bank": "1", + "link": "PortChannel2" + } } }, "SAMPLE_CONFIG_DB_UNKNOWN": { @@ -2285,45 +2325,5 @@ "global": { } } - }, - "FG_NHG": { - "nhg1": { - "bucket_size": "16", - "match_mode": "nexthop-based" - }, - "nhg2": { - "bucket_size": "32", - "match_mode": "route-based" - } - }, - "FG_NHG_PREFIX": { - "10.0.0.0/24": { - "FG_NHG": "nhg1" - }, - "192.168.0.0/16": { - "FG_NHG": "nhg2" - } - }, - "FG_NHG_MEMBER": { - "192.168.1.1": { - "FG_NHG": "nhg1", - "bank": "0", - "link": "Ethernet1" - }, - "192.168.1.2": { - "FG_NHG": "nhg1", - "bank": "0", - "link": "Ethernet2" - }, - "10.0.0.1": { - "FG_NHG": "nhg2", - "bank": "1", - "link": "PortChannel1" - }, - "10.0.0.2": { - "FG_NHG": "nhg2", - "bank": "1", - "link": "PortChannel2" - } } } From 4a09443ab6749dccc2667b9d0d94dc052e865a48 Mon Sep 17 00:00:00 2001 From: Mingzhi Leng Date: Wed, 1 Mar 2023 09:57:34 -0800 Subject: [PATCH 11/14] change name space to sonic-net --- src/sonic-yang-models/yang-models/sonic-fine-grained-ecmp.yang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-yang-models/yang-models/sonic-fine-grained-ecmp.yang b/src/sonic-yang-models/yang-models/sonic-fine-grained-ecmp.yang index 46d117d118e5..0570b7c4e904 100644 --- a/src/sonic-yang-models/yang-models/sonic-fine-grained-ecmp.yang +++ b/src/sonic-yang-models/yang-models/sonic-fine-grained-ecmp.yang @@ -2,7 +2,7 @@ module sonic-fine-grained-ecmp { yang-version 1.1; - namespace "http://github.com/Azure/sonic-fine-grained-ecmp"; + namespace "http://github.com/sonic-net/sonic-fine-grained-ecmp"; prefix sfgecmp; import ietf-inet-types { From e3dd36ac3fb4bec8937deee9800ee6827b84f273 Mon Sep 17 00:00:00 2001 From: Mingzhi Leng Date: Wed, 1 Mar 2023 11:09:40 -0800 Subject: [PATCH 12/14] remove duplicate case, add new, fix indentation --- .../tests/fine-grained-ecmp.json | 14 +- .../tests_config/fine_grained_ecmp.json | 123 +++++++++++++++--- .../yang-models/sonic-fine-grained-ecmp.yang | 8 +- 3 files changed, 119 insertions(+), 26 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json b/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json index 86bd816692ae..2eed9fb8f34f 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json @@ -8,6 +8,9 @@ "FG_NHG_MEMBER_TEST": { "desc": "Fine-grained ECMP next-hop member configuration in FG_NHG_MEMBER_LIST table." }, + "FG_NHG_MEMBER_MULTI_LINK_TEST": { + "desc": "Fine-grained ECMP next-hop member configuration with multiple links in FG_NHG_MEMBER_LIST table." + }, "FG_NHG_TEST_DUPLICATE_NAME": { "desc": "Fine-grained ECMP next-hop group configuration with duplicate name in FG_NHG_LIST table.", "eStr": "Duplicated instance of \"FG_NHG_LIST\" list." @@ -26,6 +29,13 @@ "ip_prefix" ] }, + "FG_NHG_MEMBER_TEST_INVALID_LINK": { + "desc": "Fine-grained ECMP next-hop member configuration with invalid link value in FG_NHG_MEMBER_LIST table.", + "eStrKey": "InvalidValue", + "eStr": [ + "link" + ] + }, "FG_NHG_MEMBER_TEST_MISSING_FG_NHG_REF": { "desc": "Fine-grained ECMP next-hop member configuration with missing FG_NHG reference in FG_NHG_MEMBER_LIST table.", "eStr": "Missing required element \"FG_NHG\" in \"FG_NHG_MEMBER_LIST\". " @@ -38,10 +48,6 @@ "desc": "Fine-grained ECMP next-hop member configuration with missing bank in FG_NHG_MEMBER_LIST table.", "eStr": "Missing required element \"bank\"" }, - "FG_NHG_TEST_DUPLICATE_ENTRY": { - "desc": "Fine-grained ECMP next-hop group configuration with duplicate entry in FG_NHG_LIST table.", - "eStr": "Duplicated instance of \"FG_NHG_LIST\" list." - }, "FG_NHG_PREFIX_TEST_DUPLICATE_ENTRY": { "desc": "Fine-grained ECMP prefix configuration with duplicate entry in FG_NHG_PREFIX_LIST table.", "eStr": "Duplicated instance of \"FG_NHG_PREFIX_LIST\" list." diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json index f29876e99435..5359347552ed 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json @@ -103,6 +103,72 @@ } } }, + "FG_NHG_MEMBER_MULTI_LINK_TEST": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "lanes": "65", + "mtu": "9000", + "name": "Ethernet1", + "tpid": "0x8100", + "speed": "25000" + }, + { + "admin_status": "up", + "alias": "eth1", + "description": "Ethernet1", + "lanes": "65", + "mtu": "9000", + "name": "Ethernet2", + "tpid": "0x8100", + "speed": "25000" + } + ] + } + }, + "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { + "sonic-fine-grained-ecmp:FG_NHG": { + "FG_NHG_LIST": [ + { + "name": "group1", + "bucket_size": 10, + "match_mode": "nexthop-based" + }, + { + "name": "group2", + "bucket_size": 20, + "match_mode": "route-based" + } + ] + }, + "sonic-fine-grained-ecmp:FG_NHG_MEMBER": { + "FG_NHG_MEMBER_LIST": [ + { + "next_hop_ip": "10.0.0.1", + "FG_NHG": "group1", + "bank": 1, + "link": "Ethernet1" + }, + { + "next_hop_ip": "10.0.0.2", + "FG_NHG": "group1", + "bank": 2, + "link": "Ethernet2" + }, + { + "next_hop_ip": "10.1.0.1", + "FG_NHG": "group2", + "bank": 3, + "link": "Ethernet1" + } + ] + } + } + }, "FG_NHG_TEST_DUPLICATE_NAME": { "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { "sonic-fine-grained-ecmp:FG_NHG": { @@ -147,6 +213,45 @@ } } }, + "FG_NHG_MEMBER_TEST_INVALID_LINK": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "lanes": "65", + "mtu": "9000", + "name": "Ethernet1", + "tpid": "0x8100", + "speed": "25000" + } + ] + } + }, + "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { + "sonic-fine-grained-ecmp:FG_NHG_MEMBER": { + "sonic-fine-grained-ecmp:FG_NHG": { + "FG_NHG_LIST": [ + { + "name": "group1", + "bucket_size": 10, + "match_mode": "nexthop-based" + } + ] + }, + "FG_NHG_MEMBER_LIST": [ + { + "next_hop_ip": "10.0.0.1", + "FG_NHG": "group1", + "bank": 1, + "link": "invalidLink" + } + ] + } + } + }, "FG_NHG_MEMBER_TEST_MISSING_FG_NHG_REF": { "sonic-port:sonic-port": { "sonic-port:PORT": { @@ -225,24 +330,6 @@ } } }, - "FG_NHG_TEST_DUPLICATE_ENTRY": { - "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { - "sonic-fine-grained-ecmp:FG_NHG": { - "FG_NHG_LIST": [ - { - "name": "group1", - "bucket_size": 16, - "match_mode": "nexthop-based" - }, - { - "name": "group1", - "bucket_size": 8, - "match_mode": "nexthop-based" - } - ] - } - } - }, "FG_NHG_PREFIX_TEST_DUPLICATE_ENTRY": { "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { "sonic-fine-grained-ecmp:FG_NHG_PREFIX": { diff --git a/src/sonic-yang-models/yang-models/sonic-fine-grained-ecmp.yang b/src/sonic-yang-models/yang-models/sonic-fine-grained-ecmp.yang index 0570b7c4e904..b5811f06f0c3 100644 --- a/src/sonic-yang-models/yang-models/sonic-fine-grained-ecmp.yang +++ b/src/sonic-yang-models/yang-models/sonic-fine-grained-ecmp.yang @@ -109,8 +109,8 @@ module sonic-fine-grained-ecmp { leaf FG_NHG{ type leafref { - path "/sfgecmp:sonic-fine-grained-ecmp/sfgecmp:FG_NHG/sfgecmp:FG_NHG_LIST/sfgecmp:name"; - } + path "/sfgecmp:sonic-fine-grained-ecmp/sfgecmp:FG_NHG/sfgecmp:FG_NHG_LIST/sfgecmp:name"; + } mandatory true; description "Fine Grained next-hop group name"; } @@ -135,8 +135,8 @@ module sonic-fine-grained-ecmp { leaf FG_NHG{ type leafref { - path "/sfgecmp:sonic-fine-grained-ecmp/sfgecmp:FG_NHG/sfgecmp:FG_NHG_LIST/sfgecmp:name"; - } + path "/sfgecmp:sonic-fine-grained-ecmp/sfgecmp:FG_NHG/sfgecmp:FG_NHG_LIST/sfgecmp:name"; + } mandatory true; description "Fine Grained next-hop group name"; } From 24bc65b6de1423e05eef57280e4ba893babfca04 Mon Sep 17 00:00:00 2001 From: Mingzhi Leng Date: Wed, 1 Mar 2023 11:13:17 -0800 Subject: [PATCH 13/14] fix test case --- .../tests_config/fine_grained_ecmp.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json index 5359347552ed..54065742931f 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json @@ -231,16 +231,16 @@ } }, "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { + "sonic-fine-grained-ecmp:FG_NHG": { + "FG_NHG_LIST": [ + { + "name": "group1", + "bucket_size": 10, + "match_mode": "nexthop-based" + } + ] + }, "sonic-fine-grained-ecmp:FG_NHG_MEMBER": { - "sonic-fine-grained-ecmp:FG_NHG": { - "FG_NHG_LIST": [ - { - "name": "group1", - "bucket_size": 10, - "match_mode": "nexthop-based" - } - ] - }, "FG_NHG_MEMBER_LIST": [ { "next_hop_ip": "10.0.0.1", From ce6edb8b93ec48744416036c76a00addace82045 Mon Sep 17 00:00:00 2001 From: Mingzhi Leng Date: Wed, 1 Mar 2023 11:37:11 -0800 Subject: [PATCH 14/14] add ipv6 address and a prefix test cases --- .../tests_config/fine_grained_ecmp.json | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json index 54065742931f..2bfbbb6239c0 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json @@ -42,6 +42,14 @@ { "ip_prefix": "10.1.0.0/24", "FG_NHG": "group2" + }, + { + "ip_prefix": "fe80::/64", + "FG_NHG": "group1" + }, + { + "ip_prefix": "::/0", + "FG_NHG": "group2" } ] } @@ -98,6 +106,18 @@ "FG_NHG": "group2", "bank": 3, "link": "Ethernet1" + }, + { + "next_hop_ip": "2001:0db8:85a3:0000:0000:8a2e:0370:7334", + "FG_NHG": "group1", + "bank": 4, + "link": "Ethernet1" + }, + { + "next_hop_ip": "2001:db8::1", + "FG_NHG": "group2", + "bank": 5, + "link": "Ethernet1" } ] }