From 872ac281e853272f45a2d4a0d71f475bf904e2dd Mon Sep 17 00:00:00 2001 From: Venkatesan Mahalingam Date: Wed, 13 May 2020 20:31:38 -0700 Subject: [PATCH 01/28] Added support to allow/deny packets matching source IP/destination IP --- files/image_config/caclmgrd/caclmgrd | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/files/image_config/caclmgrd/caclmgrd b/files/image_config/caclmgrd/caclmgrd index b2fc3c92a0c0..eeaff56161f3 100755 --- a/files/image_config/caclmgrd/caclmgrd +++ b/files/image_config/caclmgrd/caclmgrd @@ -84,6 +84,14 @@ class ControlPlaneAclManager(object): "SSH": { "ip_protocols": ["tcp"], "dst_ports": ["22"] + }, + "IP_ANY": { + "ip_protocols": ["any"], + "dst_ports": ["0"] + }, + "IPV6_ANY": { + "ip_protocols": ["any"], + "dst_ports": ["0"] } } @@ -368,14 +376,18 @@ class ControlPlaneAclManager(object): for ip_protocol in ip_protocols: for dst_port in dst_ports: rule_cmd = "ip6tables" if table_ip_version == 6 else "iptables" - rule_cmd += " -A INPUT -p {}".format(ip_protocol) + if ip_protocol != "any": + rule_cmd += " -A INPUT -p {}".format(ip_protocol) + else: + rule_cmd += " -A INPUT " if "SRC_IPV6" in rule_props and rule_props["SRC_IPV6"]: rule_cmd += " -s {}".format(rule_props["SRC_IPV6"]) elif "SRC_IP" in rule_props and rule_props["SRC_IP"]: rule_cmd += " -s {}".format(rule_props["SRC_IP"]) - rule_cmd += " --dport {}".format(dst_port) + if dst_port != "0": + rule_cmd += " --dport {}".format(dst_port) # If there are TCP flags present and ip protocol is TCP, append them if ip_protocol == "tcp" and "TCP_FLAGS" in rule_props and rule_props["TCP_FLAGS"]: From bceff9f30149daeba24162446de0837874baa06b Mon Sep 17 00:00:00 2001 From: Venkatesan Mahalingam Date: Wed, 13 May 2020 20:41:54 -0700 Subject: [PATCH 02/28] Added support to allow/deny packets matching source IP/destination IP in kernel Signed-off-by: Venkatesan Mahalingam --- files/image_config/caclmgrd/caclmgrd | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/files/image_config/caclmgrd/caclmgrd b/files/image_config/caclmgrd/caclmgrd index b2fc3c92a0c0..eeaff56161f3 100755 --- a/files/image_config/caclmgrd/caclmgrd +++ b/files/image_config/caclmgrd/caclmgrd @@ -84,6 +84,14 @@ class ControlPlaneAclManager(object): "SSH": { "ip_protocols": ["tcp"], "dst_ports": ["22"] + }, + "IP_ANY": { + "ip_protocols": ["any"], + "dst_ports": ["0"] + }, + "IPV6_ANY": { + "ip_protocols": ["any"], + "dst_ports": ["0"] } } @@ -368,14 +376,18 @@ class ControlPlaneAclManager(object): for ip_protocol in ip_protocols: for dst_port in dst_ports: rule_cmd = "ip6tables" if table_ip_version == 6 else "iptables" - rule_cmd += " -A INPUT -p {}".format(ip_protocol) + if ip_protocol != "any": + rule_cmd += " -A INPUT -p {}".format(ip_protocol) + else: + rule_cmd += " -A INPUT " if "SRC_IPV6" in rule_props and rule_props["SRC_IPV6"]: rule_cmd += " -s {}".format(rule_props["SRC_IPV6"]) elif "SRC_IP" in rule_props and rule_props["SRC_IP"]: rule_cmd += " -s {}".format(rule_props["SRC_IP"]) - rule_cmd += " --dport {}".format(dst_port) + if dst_port != "0": + rule_cmd += " --dport {}".format(dst_port) # If there are TCP flags present and ip protocol is TCP, append them if ip_protocol == "tcp" and "TCP_FLAGS" in rule_props and rule_props["TCP_FLAGS"]: From 93d1a2b48deb3cb85bdc590819c8f1620d2d788b Mon Sep 17 00:00:00 2001 From: Venkatesan Mahalingam Date: Tue, 2 Jun 2020 22:14:37 -0700 Subject: [PATCH 03/28] Addressed the comment. Signed-off-by: Venkatesan Mahalingam --- files/image_config/caclmgrd/caclmgrd | 1 + 1 file changed, 1 insertion(+) diff --git a/files/image_config/caclmgrd/caclmgrd b/files/image_config/caclmgrd/caclmgrd index eeaff56161f3..495cd16923b6 100755 --- a/files/image_config/caclmgrd/caclmgrd +++ b/files/image_config/caclmgrd/caclmgrd @@ -386,6 +386,7 @@ class ControlPlaneAclManager(object): elif "SRC_IP" in rule_props and rule_props["SRC_IP"]: rule_cmd += " -s {}".format(rule_props["SRC_IP"]) + # Destination port 0 is reserved/unused port, so, using it to apply the rule to all ports. if dst_port != "0": rule_cmd += " --dport {}".format(dst_port) From a2e31bb8bc22d3c19674cf04b0f2be80266def06 Mon Sep 17 00:00:00 2001 From: Venkatesan Mahalingam Date: Mon, 29 Jun 2020 23:55:38 -0700 Subject: [PATCH 04/28] Comments addressed. Signed-off-by: Venkatesan Mahalingam --- files/image_config/caclmgrd/caclmgrd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/files/image_config/caclmgrd/caclmgrd b/files/image_config/caclmgrd/caclmgrd index 495cd16923b6..78c3ef155a09 100755 --- a/files/image_config/caclmgrd/caclmgrd +++ b/files/image_config/caclmgrd/caclmgrd @@ -376,11 +376,11 @@ class ControlPlaneAclManager(object): for ip_protocol in ip_protocols: for dst_port in dst_ports: rule_cmd = "ip6tables" if table_ip_version == 6 else "iptables" - if ip_protocol != "any": - rule_cmd += " -A INPUT -p {}".format(ip_protocol) - else: - rule_cmd += " -A INPUT " + rule_cmd += " -A INPUT" + if ip_protocol != "any": + rule_cmd += " -p {}".format(ip_protocol) + if "SRC_IPV6" in rule_props and rule_props["SRC_IPV6"]: rule_cmd += " -s {}".format(rule_props["SRC_IPV6"]) elif "SRC_IP" in rule_props and rule_props["SRC_IP"]: From 77aca99b13970af7082f0d009a29d64be1ac4997 Mon Sep 17 00:00:00 2001 From: Venkatesan Mahalingam Date: Wed, 23 Sep 2020 00:14:36 -0700 Subject: [PATCH 05/28] Addressed the comment Signed-off-by: Venkatesan Mahalingam --- files/image_config/caclmgrd/caclmgrd | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/files/image_config/caclmgrd/caclmgrd b/files/image_config/caclmgrd/caclmgrd index 78c3ef155a09..c14e3a437ca7 100755 --- a/files/image_config/caclmgrd/caclmgrd +++ b/files/image_config/caclmgrd/caclmgrd @@ -85,11 +85,7 @@ class ControlPlaneAclManager(object): "ip_protocols": ["tcp"], "dst_ports": ["22"] }, - "IP_ANY": { - "ip_protocols": ["any"], - "dst_ports": ["0"] - }, - "IPV6_ANY": { + "ANY": { "ip_protocols": ["any"], "dst_ports": ["0"] } From ce770fe5b7f301dce362802ccd15597347fb1862 Mon Sep 17 00:00:00 2001 From: Venkatesan Mahalingam Date: Fri, 26 Feb 2021 17:05:49 -0800 Subject: [PATCH 06/28] [YANG] Add to support BGP and route-map YANG models Signed-off-by: Venkatesan Mahalingam --- .../yang-models/sonic-bgp-common.yang | 554 ++++++++++++++++++ .../yang-models/sonic-bgp-global.yang | 500 ++++++++++++++++ .../yang-models/sonic-bgp-neighbor.yang | 112 ++++ .../yang-models/sonic-bgp-peergroup.yang | 97 +++ .../yang-models/sonic-device_metadata.yang | 5 + .../yang-models/sonic-route-common.yang | 77 +++ .../yang-models/sonic-route-map.yang | 354 +++++++++++ .../sonic-routing-policy-sets.yang | 219 +++++++ .../yang-models/sonic-vrf.yang | 54 ++ 9 files changed, 1972 insertions(+) create mode 100644 src/sonic-yang-models/yang-models/sonic-bgp-common.yang create mode 100644 src/sonic-yang-models/yang-models/sonic-bgp-global.yang create mode 100644 src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang create mode 100644 src/sonic-yang-models/yang-models/sonic-bgp-peergroup.yang create mode 100644 src/sonic-yang-models/yang-models/sonic-route-common.yang create mode 100644 src/sonic-yang-models/yang-models/sonic-route-map.yang create mode 100644 src/sonic-yang-models/yang-models/sonic-routing-policy-sets.yang create mode 100644 src/sonic-yang-models/yang-models/sonic-vrf.yang diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-common.yang b/src/sonic-yang-models/yang-models/sonic-bgp-common.yang new file mode 100644 index 000000000000..af6ab47f35dc --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-bgp-common.yang @@ -0,0 +1,554 @@ +module sonic-bgp-common { + namespace "http://github.com/Azure/sonic-bgp-common"; + prefix sbc; + yang-version 1.1; + + import ietf-inet-types { + prefix inet; + } + + import sonic-port { + prefix prt; + } + + import sonic-portchannel { + prefix spc; + } + + import sonic-vlan { + prefix svlan; + } + + import sonic-loopback { + prefix lo; + } + + import sonic-routing-policy-sets { + prefix srpolsets; + } + + import sonic-route-map { + prefix srmap; + } + + import sonic-common { + prefix cmn; + } + + import ietf-yang-types { + prefix ietf-yang; + } + + import sonic-interface { + prefix sintf; + } + + import sonic-extension { + prefix sonic-ext; + } + + organization + "SONiC"; + + contact + "SONiC"; + + description + "SONIC BGP common YANG attributes for Neighbors and Peer group"; + + revision 2021-02-01 { + description + "Added CVL check to compare strict_capability_match and override_capability."; + } + + revision 2021-01-08 { + description + "Added support for routed vlan-sub-interface."; + } + + revision 2020-07-26 { + description + "Change for sonic-loopback.yang."; + } + revision 2019-11-04 { + description + "Initial revision."; + } + + typedef bgp_peer_type { + type enumeration { + enum internal { + description "Internal peer"; + } + enum external { + description "External peer"; + } + } + } + + typedef bgp_tx_add_paths_type { + type enumeration { + enum tx_all_paths { + description + "Send multiple path advertisements for an NLRI from + the neighbor or group"; + } + enum tx_best_path_per_as { + description + "Send only best path per AS advertisements for an NLRI from + the neighbor or group"; + } + } + description + "Type to describe the add paths advertisement method."; + } + + typedef bgp_community_type { + type enumeration { + enum standard { + description "Standard communities"; + } + + enum extended { + description "Extended communities"; + } + + enum both { + description "Both standard and extended communities"; + } + + enum large { + description "Large communities"; + } + + enum all { + description "Standard, Extended and Large communities"; + } + + enum none { + description "No community attribute"; + } + } + description + "type describing variations of community attributes"; + } + + typedef sonic_bgp_direction { + type enumeration { + enum in { + description + "Refers to information received from the BGP peer"; + } + enum out { + description + "Refers to information advertised to the BGP peer"; + } + } + description + "Type to describe the direction"; + } + + typedef sonic_bgp_orf { + type enumeration { + enum send { + description + "Capability to receive the outbound route filtering from this neighbor"; + } + enum receive { + description + "Capability to send the outbound route filtering to this neighbor"; + } + enum both { + description + "Capability to send and receive the outbound route filtering to/from this neighbor"; + } + } + description + "Type to describe the BGP ORF(Outbound route filtering) capability"; + } + + grouping sonic-bgp-cmn { + + leaf local_asn { + type uint32 { + range "1..4294967295"; + } + description "Local AS number"; + } + + leaf name { + type string; + description "Peer description"; + } + + leaf asn { + type uint32 { + range "1..4294967295"; + } + description "Peer AS number"; + } + + leaf peer_type { + type bgp_peer_type; + } + + leaf ebgp_multihop { + type boolean; + description "EBGP Multihop enabled"; + } + + leaf ebgp_multihop_ttl { + type uint8 { + range "1..255"; + } + description "EBGP Multihop TTL"; + } + + leaf auth_password { + type string; + description "Authuntiation password"; + } + + leaf keepalive { + type uint16; + description "Keepalive interval"; + } + + leaf holdtime { + type uint16; + description "Hold time"; + } + + leaf conn_retry { + type uint16 { + range "1..65535"; + } + description "Connection retry time"; + } + + leaf min_adv_interval { + type uint16 { + range "0..600"; + } + description "minium advertisement interval"; + } + + leaf local_addr { + type union { + type inet:ip-address; + type leafref { + path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:port_name"; + } + type leafref { + path "/spc:sonic-portchannel/spc:PORTCHANNEL/spc:PORTCHANNEL_LIST/spc:portchannel_name"; + } + type leafref { + path "/svlan:sonic-vlan/svlan:VLAN/svlan:VLAN_LIST/svlan:vlan_name"; + } + type leafref { + path "/lo:sonic-loopback/lo:LOOPBACK/lo:LOOPBACK_LIST/lo:name"; + } + } + description "Local source address or interface name to use for connection."; + } + + leaf passive_mode { + type boolean; + description "Passive mode"; + } + + leaf capability_ext_nexthop { + type boolean; + description "Advertise extended nexthop capability"; + } + + leaf disable_ebgp_connected_route_check { + type boolean; + description "Connected checked disabled"; + sonic-ext:custom-validation ValidateDisableConnectedCheck; + } + + leaf enforce_first_as { + type boolean; + description "Enforce first AS for EBGP"; + } + + leaf solo_peer { + type boolean; + description "Part of own update group"; + } + + leaf ttl_security_hops { + type uint8 { + range 1..254; + } + must "((current() = 1 and (starts-with(current()/../neighbor, 'Eth') or starts-with(current()/../neighbor, 'Po') or starts-with(current()/../neighbor, 'Vlan'))) or (not(starts-with(current()/../neighbor, 'Eth') or starts-with(current()/../neighbor, 'Po') or starts-with(current()/../neighbor, 'Vlan'))))" { + error-message "Hops for connected neighbor cannot exceed 1"; + } + description "TTL"; + } + + leaf bfd { + type boolean; + description "BFD status"; + } + + leaf bfd_check_ctrl_plane_failure { + type boolean; + description "Link dataplane status with BGP control plane"; + } + + leaf capability_dynamic { + type boolean; + description "Advertise dynamic capability"; + } + + leaf dont_negotiate_capability { + type boolean; + description "Do not perform capability negotiation"; + } + + leaf enforce_multihop { + type boolean; + description "Enforce EBGP neighbors perform multihop"; + } + + leaf override_capability { + type boolean; + description "Override capability negotiation result"; + } + + leaf peer_port { + type uint16; + description "Peer port number"; + } + + leaf shutdown_message { + type string { + length "1..127"; + } + description "Message on peer/Neighbor shutdown"; + } + + leaf strict_capability_match { + type boolean; + sonic-ext:custom-validation ValidateStrictAndOverRideCapability; + description "Strict capability negotiation match"; + } + + leaf admin_status { + type boolean; + description "To enable BGP peer"; + } + + leaf local_as_no_prepend { + type boolean; + description "Do not prepend local-as to updates from ebgp peers"; + } + + leaf local_as_replace_as { + type boolean; + description "Do not prepend local-as to updates from ibgp peers"; + } + } + + + grouping sonic-bgp-cmn-af { + + leaf afi_safi { + type string; + description "Address family"; + } + + leaf admin_status { + type boolean; + description "Enabled status"; + } + + leaf send_default_route { + type boolean; + description "Send default route"; + } + + leaf default_rmap { + type leafref { + path "/srmap:sonic-route-map/srmap:ROUTE_MAP_SET/srmap:ROUTE_MAP_SET_LIST/srmap:name"; + } + description "Default route map to originate"; + } + + leaf max_prefix_limit { + type uint32; + description "Maximum prefix limit"; + } + + leaf max_prefix_warning_only { + type boolean; + description "On maximum prefix limit, warn only"; + } + + leaf max_prefix_warning_threshold { + type uint8 { + range "1..100"; + } + description "Maximum prefix limit threshold for warning"; + } + + leaf max_prefix_restart_interval { + type uint16 { + range "1..65535"; + } + description "Interval after which connection will get re-established"; + } + + leaf-list route_map_in { + type leafref { + path "/srmap:sonic-route-map/srmap:ROUTE_MAP_SET/srmap:ROUTE_MAP_SET_LIST/srmap:name"; + } + must "(/cmn:operation/cmn:operation = 'DELETE') or (count(current()) = 1)" { + error-app-tag "max-allowed-route-map-reached"; + error-message "Only one route-map can be associated"; + } + } + + leaf-list route_map_out { + type leafref { + path "/srmap:sonic-route-map/srmap:ROUTE_MAP_SET/srmap:ROUTE_MAP_SET_LIST/srmap:name"; + } + must "(/cmn:operation/cmn:operation = 'DELETE') or (count(current()) = 1)" { + error-app-tag "max-allowed-route-map-reached"; + error-message "Only one route-map can be associated"; + } + } + + leaf soft_reconfiguration_in { + type boolean; + description "Inbound soft reconfiguration"; + } + + leaf unsuppress_map_name { + type leafref { + path "/srmap:sonic-route-map/srmap:ROUTE_MAP_SET/srmap:ROUTE_MAP_SET_LIST/srmap:name"; + } + description "Route map"; + } + + leaf rrclient { + type boolean; + description "Route reflector client"; + } + + leaf weight { + type uint16 { + range 0..65535; + } + } + + leaf as_override { + type boolean; + } + + leaf send_community { + type bgp_community_type; + } + + leaf tx_add_paths { + type bgp_tx_add_paths_type; + description "Advertise all paths or best path per AS using add path"; + } + + leaf unchanged_as_path { + type boolean; + description "AS path attribute unchanged"; + } + + leaf unchanged_med{ + type boolean; + description "MED attribute unchanged"; + } + + leaf unchanged_nexthop { + type boolean; + description "nexthop attribute unchanged"; + } + + leaf filter_list_in { + type leafref { + path "/srpolsets:sonic-routing-policy-sets/srpolsets:AS_PATH_SET/srpolsets:AS_PATH_SET_LIST/srpolsets:name"; + } + description "Filter list name"; + } + + leaf filter_list_out { + type leafref { + path "/srpolsets:sonic-routing-policy-sets/srpolsets:AS_PATH_SET/srpolsets:AS_PATH_SET_LIST/srpolsets:name"; + } + description "Filter list name"; + } + + leaf nhself { + type boolean; + description "Nexthop is self, no nexthop calculation"; + } + + leaf nexthop_self_force { + type boolean; + description "Force nexthop to be self for reflected routes"; + } + + leaf prefix_list_in { + type leafref { + path "/srpolsets:sonic-routing-policy-sets/srpolsets:PREFIX_SET/srpolsets:PREFIX_SET_LIST/srpolsets:name"; + } + description "Prefix list name"; + } + + leaf prefix_list_out { + type leafref { + path "/srpolsets:sonic-routing-policy-sets/srpolsets:PREFIX_SET/srpolsets:PREFIX_SET_LIST/srpolsets:name"; + } + description "Prefix list name"; + } + + leaf remove_private_as_enabled { + type boolean; + description "Remove private ASN's in outbound updates"; + } + + leaf replace_private_as { + type boolean; + description "Replace private ASN's with our ASN in outbound updates"; + } + + leaf remove_private_as_all { + type boolean; + description "Remove all ASN's in outbound updates"; + } + + leaf allow_as_in { + type boolean; + description "Allow own ASN in AS path"; + } + + leaf allow_as_count { + type uint8; + description "Number of occurances of ASN"; + } + + leaf allow_as_origin { + type boolean; + description "Allow own AS in AS path, if route originated in own AS"; + } + + leaf cap_orf { + type sonic_bgp_orf; + description "ORF(Outbound Route Filtering) capability"; + } + + leaf route_server_client { + type boolean; + description "Route server client"; + } + } + +} diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-global.yang b/src/sonic-yang-models/yang-models/sonic-bgp-global.yang new file mode 100644 index 000000000000..4ee358e93064 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-bgp-global.yang @@ -0,0 +1,500 @@ +module sonic-bgp-global { + namespace "http://github.com/Azure/sonic-bgp-global"; + prefix sbgpg; + yang-version 1.1; + + import sonic-vrf { + prefix svrf; + } + + import ietf-inet-types { + prefix inet; + } + + import sonic-bgp-common { + prefix sbc; + } + + import sonic-route-map { + prefix srmap; + } + + import sonic-extension { + prefix sonic-ext; + } + + import sonic-common { + prefix cmn; + } + + organization + "SONiC"; + + contact + "SONiC"; + + description + "SONIC BGP Global YANG"; + + revision 2020-12-10 { + description + "Added CVL validation condition to compare max_delay and establish_wait values."; + } + + revision 2019-11-20 { + description + "Added BGP fields for extensive features."; + } + + revision 2019-09-15 { + description + "Initial revision."; + } + + container sonic-bgp-global { + container BGP_GLOBALS { + list BGP_GLOBALS_LIST { + key "vrf_name"; + + leaf vrf_name { + type union { + type string { + pattern "default"; + } + type leafref { + path "/svrf:sonic-vrf/svrf:VRF/svrf:VRF_LIST/svrf:vrf_name"; + } + } + } + + leaf router_id { + type inet:ipv4-address; + } + + leaf local_asn { + type uint32 { + range "1..4294967295"; + } + } + + leaf always_compare_med { + type boolean; + } + + leaf load_balance_mp_relax { + type boolean; + } + + leaf graceful_restart_enable { + type boolean; + } + + leaf gr_preserve_fw_state { + type boolean; + description + "Set F-bit indication that FIB is preserved while doing Graceful Restart."; + } + + leaf gr_restart_time { + type uint16 { + range "1..3600"; + } + } + + leaf gr_stale_routes_time { + type uint16 { + range "1..3600"; + } + } + + leaf external_compare_router_id { + type boolean; + } + + leaf ignore_as_path_length { + type boolean; + } + + leaf log_nbr_state_changes { + type boolean; + } + + leaf rr_cluster_id { + type string; + } + + leaf rr_allow_out_policy { + type boolean; + } + + leaf disable_ebgp_connected_rt_check { + type boolean; + } + + leaf fast_external_failover { + type boolean; + } + + leaf network_import_check { + type boolean; + } + + leaf graceful_shutdown { + type boolean; + } + + leaf rr_clnt_to_clnt_reflection { + type boolean; + description + "Enable client to client route reflection."; + } + + leaf max_dynamic_neighbors { + type uint16 { + range 1..5000; + } + description + "Maximum number of BGP dynamic neighbors that can be created."; + } + + leaf read_quanta { + type uint8 { + range 1..10; + } + description + "This indicates how many packets to read from peer socket per I/O cycle"; + } + + leaf write_quanta { + type uint8 { + range 1..10; + } + description + "This indicates how many packets to write to peer socket per run"; + } + + leaf coalesce_time { + type uint32; + description + "Subgroup coalesce timer value in milli-sec"; + } + + leaf route_map_process_delay { + type uint16 { + range 0..600; + } + description + "0 disables the timer, no route updates happen when route-maps change"; + } + + leaf deterministic_med { + type boolean; + description + "Pick the best-MED path among paths advertised from the neighboring AS."; + } + + leaf med_confed { + type boolean; + description + "Compare MED among confederation paths when set to true."; + } + + leaf med_missing_as_worst { + type boolean; + description + "Treat missing MED as the least preferred one when set to true."; + } + + leaf compare_confed_as_path { + type boolean; + description + "Compare path lengths including confederation sets & sequences in selecting a route"; + } + + leaf as_path_mp_as_set { + type boolean; + description + "Generate an AS_SET."; + } + + leaf default_ipv4_unicast { + type boolean; + description + "Activate ipv4-unicast for a peer by default"; + } + + leaf default_local_preference { + type uint32; + description + "Configure default local preference value."; + } + + leaf default_show_hostname { + type boolean; + description + "Show hostname in BGP dumps."; + } + + leaf default_shutdown { + type boolean; + description + "Apply administrative shutdown to newly configured peers."; + } + + leaf default_subgroup_pkt_queue_max { + type uint8 { + range 20..100; + } + description + "Configure subgroup packet queue max."; + } + + leaf max_med_time { + type uint32{ + range 5..86400; + } + description + "Time (seconds) period for max-med"; + } + + leaf max_med_val { + type uint32; + description + "Max MED value to be used"; + } + + leaf max_med_admin { + type boolean; + description + "Enable Max MED admin status."; + } + + leaf max_med_admin_val { + type uint32; + description + "Administrative Max MED value to be used"; + } + + + leaf max_delay { + type uint16 { + range 0..3600; + } + description + "Maximum delay for best path calculation."; + } + + leaf establish_wait { + type uint16 { + range 0..3600; + } + sonic-ext:custom-validation ValidateMaxDelayAndEstWait; + description + "Maximum delay for updates."; + } + + leaf confed_id { + type uint32 { + range "1..4294967295"; + } + description + "Set routing domain confederation AS."; + } + + leaf-list confed_peers { + type uint32 { + range "1..4294967295"; + } + description + "Peer ASs in BGP confederation"; + } + + leaf keepalive { + type uint16; + description "Keepalive interval"; + } + + leaf holdtime { + type uint16; + description "Hold time"; + } + } + } + + container BGP_GLOBALS_AF { + list BGP_GLOBALS_AF_LIST { + key "vrf_name afi_safi"; + + leaf vrf_name { + type leafref { + path "../../../BGP_GLOBALS/BGP_GLOBALS_LIST/vrf_name"; + } + } + + leaf afi_safi { + type string; + } + + leaf max_ebgp_paths { + type uint16 { + range "1..256"; + } + } + + leaf max_ibgp_paths { + type uint16 { + range "1..256"; + } + } + + leaf import_vrf { + type union { + type string { + pattern "default"; + } + type leafref { + path "../../../BGP_GLOBALS/BGP_GLOBALS_LIST/vrf_name"; + } + } + must "current() != current()/../vrf_name" { + error-message "Import VRF should be different than self!"; + } + } + + leaf import_vrf_route_map { + type leafref { + path "/srmap:sonic-route-map/srmap:ROUTE_MAP_SET/srmap:ROUTE_MAP_SET_LIST/srmap:name"; + } + } + + leaf route_download_filter { + type leafref { + path "/srmap:sonic-route-map/srmap:ROUTE_MAP_SET/srmap:ROUTE_MAP_SET_LIST/srmap:name"; + } + } + + leaf ebgp_route_distance { + type uint8 { + range "1..255"; + } + } + + leaf ibgp_route_distance { + type uint8 { + range "1..255"; + } + } + + leaf local_route_distance { + type uint8 { + range "1..255"; + } + } + + leaf ibgp_equal_cluster_length { + type boolean; + description + "Match the cluster length."; + } + + leaf route_flap_dampen { + must "current()/../afi_safi = 'ipv4_unicast'" { error-message "Route flap dampening is supported only for IPv4 address family!"; } + type boolean; + } + + leaf route_flap_dampen_half_life { + must "current()/../afi_safi = 'ipv4_unicast'" { error-message "Route flap dampening is supported only for IPv4 address family!"; } + type uint8 { + range "1..45"; + } + } + + leaf route_flap_dampen_reuse_threshold { + must "current()/../afi_safi = 'ipv4_unicast'" { error-message "Route flap dampening is supported only for IPv4 address family!"; } + type uint16 { + range "1..20000"; + } + } + + leaf route_flap_dampen_suppress_threshold { + must "current()/../afi_safi = 'ipv4_unicast'" { error-message "Route flap dampening is supported only for IPv4 address family!"; } + type uint16 { + range "1..20000"; + } + } + + leaf route_flap_dampen_max_suppress { + must "current()/../afi_safi = 'ipv4_unicast'" { error-message "Route flap dampening is supported only for IPv4 address family!"; } + type uint8 { + range "1..255"; + } + } + } + } + + container BGP_GLOBALS_AF_AGGREGATE_ADDR { + list BGP_GLOBALS_AF_AGGREGATE_ADDR_LIST { + key "vrf_name afi_safi ip_prefix"; + + leaf vrf_name { + type leafref { + path "../../../BGP_GLOBALS/BGP_GLOBALS_LIST/vrf_name"; + } + } + + leaf afi_safi { + type string; + } + + leaf ip_prefix { + type inet:ip-prefix; + } + + leaf as_set { + type boolean; + } + + leaf summary_only { + type boolean; + } + + leaf policy { + type leafref { + path "/srmap:sonic-route-map/srmap:ROUTE_MAP_SET/srmap:ROUTE_MAP_SET_LIST/srmap:name"; + } + } + } + } + + container BGP_GLOBALS_AF_NETWORK { + list BGP_GLOBALS_AF_NETWORK_LIST { + key "vrf_name afi_safi ip_prefix"; + + leaf vrf_name { + type leafref { + path "../../../BGP_GLOBALS/BGP_GLOBALS_LIST/vrf_name"; + } + } + + leaf afi_safi { + type string; + } + + leaf ip_prefix { + type inet:ip-prefix; + } + + leaf policy { + type leafref { + path "/srmap:sonic-route-map/srmap:ROUTE_MAP_SET/srmap:ROUTE_MAP_SET_LIST/srmap:name"; + } + } + + leaf backdoor { + type boolean; + sonic-ext:custom-validation ValidateAfisafiForBackdoor; + } + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang b/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang new file mode 100644 index 000000000000..35488fe78f91 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang @@ -0,0 +1,112 @@ +module sonic-bgp-neighbor { + namespace "http://github.com/Azure/sonic-bgp-neighbor"; + prefix sbnbr; + yang-version 1.1; + + import ietf-inet-types { + prefix inet; + } + + import sonic-bgp-common { + prefix sbc; + } + + import sonic-port { + prefix prt; + } + + import sonic-portchannel { + prefix spc; + } + + import sonic-vlan { + prefix svlan; + } + + import sonic-bgp-global { + prefix sbgpg; + } + + import sonic-bgp-peergroup { + prefix pg; + } + + organization + "SONiC"; + + contact + "SONiC"; + + description + "SONIC BGP Neighbor"; + + revision 2021-01-08 { + description + "Added support for routed vlan-sub-interface."; + } + + revision 2019-09-23 { + description + "Initial revision."; + } + + container sonic-bgp-neighbor { + container BGP_NEIGHBOR { + list BGP_NEIGHBOR_LIST { + key "vrf_name neighbor"; + + leaf vrf_name { + type leafref { + path "/sbgpg:sonic-bgp-global/sbgpg:BGP_GLOBALS/sbgpg:BGP_GLOBALS_LIST/sbgpg:vrf_name"; + } + description "Network-instance/VRF name"; + } + + leaf neighbor { + type union { + type inet:ip-address; + type leafref { + path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:port_name"; + } + type leafref { + path "/spc:sonic-portchannel/spc:PORTCHANNEL/spc:PORTCHANNEL_LIST/spc:portchannel_name"; + } + type leafref { + path "/svlan:sonic-vlan/svlan:VLAN/svlan:VLAN_LIST/svlan:vlan_name"; + } + } + description "Neighbor description, it will be neighbor address or interface name"; + } + + leaf peer_group_name { + type leafref { + path "/pg:sonic-bgp-peergroup/pg:BGP_PEER_GROUP/pg:BGP_PEER_GROUP_LIST[pg:vrf_name=current()/../vrf_name]/pg:peer_group_name"; + } + description "Peer group name"; + } + + uses sbc:sonic-bgp-cmn; + } + } + + container BGP_NEIGHBOR_AF { + list BGP_NEIGHBOR_AF_LIST { + key "vrf_name neighbor afi_safi"; + + leaf vrf_name { + type leafref { + path "/sbgpg:sonic-bgp-global/sbgpg:BGP_GLOBALS/sbgpg:BGP_GLOBALS_LIST/sbgpg:vrf_name"; + } + description "Network-instance/VRF name"; + } + + leaf neighbor { + type leafref { + path "../../../BGP_NEIGHBOR/BGP_NEIGHBOR_LIST[vrf_name=current()/../vrf_name]/neighbor"; + } + } + uses sbc:sonic-bgp-cmn-af; + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-peergroup.yang b/src/sonic-yang-models/yang-models/sonic-bgp-peergroup.yang new file mode 100644 index 000000000000..8a14e948ade1 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-bgp-peergroup.yang @@ -0,0 +1,97 @@ +module sonic-bgp-peergroup { + namespace "http://github.com/Azure/sonic-bgp-peergroup"; + prefix pg; + yang-version 1.1; + + import ietf-inet-types { + prefix inet; + } + + import sonic-bgp-common { + prefix sbc; + } + + import sonic-bgp-global { + prefix sbgpg; + } + + organization + "SONiC"; + + contact + "SONiC"; + + description + "SONIC BGP Peer Group YANG"; + + revision 2019-10-16 { + description + "Initial revision."; + } + + container sonic-bgp-peergroup { + container BGP_PEER_GROUP { + list BGP_PEER_GROUP_LIST { + key "vrf_name peer_group_name"; + + leaf vrf_name { + type leafref { + path "/sbgpg:sonic-bgp-global/sbgpg:BGP_GLOBALS/sbgpg:BGP_GLOBALS_LIST/sbgpg:vrf_name"; + } + description "Network-instance/VRF name"; + } + + leaf peer_group_name { + type string; + description "Peer group name"; + } + uses sbc:sonic-bgp-cmn; + } + } + + container BGP_PEER_GROUP_AF { + list BGP_PEER_GROUP_AF_LIST { + key "vrf_name peer_group_name afi_safi"; + + leaf vrf_name { + type leafref { + path "/sbgpg:sonic-bgp-global/sbgpg:BGP_GLOBALS/sbgpg:BGP_GLOBALS_LIST/sbgpg:vrf_name"; + } + description "Network-instance/VRF name"; + } + + leaf peer_group_name { + type leafref { + path "../../../BGP_PEER_GROUP/BGP_PEER_GROUP_LIST[vrf_name=current()/../vrf_name]/peer_group_name"; + } + } + + uses sbc:sonic-bgp-cmn-af; + } + } + + container BGP_GLOBALS_LISTEN_PREFIX { + list BGP_GLOBALS_LISTEN_PREFIX_LIST { + key "vrf_name ip_prefix"; + + leaf vrf_name { + type leafref { + path "/sbgpg:sonic-bgp-global/sbgpg:BGP_GLOBALS/sbgpg:BGP_GLOBALS_LIST/sbgpg:vrf_name"; + } + } + + leaf ip_prefix { + type inet:ip-prefix; + } + + leaf peer_group { + type leafref { + path "../../../BGP_PEER_GROUP/BGP_PEER_GROUP_LIST[vrf_name=current()/../vrf_name]/peer_group_name"; + } + description "Peer group name"; + } + } + } + + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-device_metadata.yang b/src/sonic-yang-models/yang-models/sonic-device_metadata.yang index 054b436f2470..26486264345d 100644 --- a/src/sonic-yang-models/yang-models/sonic-device_metadata.yang +++ b/src/sonic-yang-models/yang-models/sonic-device_metadata.yang @@ -89,6 +89,11 @@ module sonic-device_metadata { pattern "ToRRouter|LeafRouter|SpineChassisFrontendRouter|ChassisBackendRouter|ASIC"; } } + leaf frr_mgmt_framework_config { + type boolean; + description "frrcfgd module handles the FRR configuations based on BGP YANG models when set to true."; + default "false"; + } } /* end of container localhost */ } diff --git a/src/sonic-yang-models/yang-models/sonic-route-common.yang b/src/sonic-yang-models/yang-models/sonic-route-common.yang new file mode 100644 index 000000000000..e337dfdc33e8 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-route-common.yang @@ -0,0 +1,77 @@ +module sonic-route-common { + namespace "http://github.com/Azure/sonic-route-common"; + prefix srtcmn; + yang-version 1.1; + + import sonic-vrf { + prefix svrf; + } + + import sonic-route-map { + prefix srmap; + } + + import sonic-common { + prefix cmn; + } + + organization + "SONiC"; + + contact + "SONiC"; + + description + "SONIC ROUTE common YANG"; + + revision 2019-11-08 { + description + "Initial revision."; + } + + container sonic-route-common { + container ROUTE_REDISTRIBUTE { + list ROUTE_REDISTRIBUTE_LIST { + key "vrf_name src_protocol dst_protocol addr_family"; + + leaf vrf_name { + type union { + type string { + pattern "default"; + } + type leafref { + path "/svrf:sonic-vrf/svrf:VRF/svrf:VRF_LIST/svrf:vrf_name"; + } + } + } + + leaf src_protocol { + type string; + } + + leaf dst_protocol { + type string; + } + + leaf addr_family { + type string; + } + + leaf-list route_map { + type leafref { + path "/srmap:sonic-route-map/srmap:ROUTE_MAP_SET/srmap:ROUTE_MAP_SET_LIST/srmap:name"; + } + must "(/cmn:operation/cmn:operation = 'DELETE') or (count(current()) = 1)" { + error-app-tag "max-allowed-route-map-reached"; + error-message "Only one route-map can be associated"; + } + } + + leaf metric { + type uint32; + } + } + } + } +} + diff --git a/src/sonic-yang-models/yang-models/sonic-route-map.yang b/src/sonic-yang-models/yang-models/sonic-route-map.yang new file mode 100644 index 000000000000..d9d9f31fdfd8 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-route-map.yang @@ -0,0 +1,354 @@ +module sonic-route-map { + namespace "http://github.com/Azure/sonic-route-map"; + prefix srmap; + yang-version 1.1; + + import ietf-inet-types { + prefix inet; + } + + import sonic-common { + prefix cmn; + } + + import sonic-port { + prefix prt; + } + + import sonic-portchannel { + prefix spc; + } + + import sonic-routing-policy-sets { + prefix srpolsets; + } + + import sonic-vlan { + prefix svlan; + } + + import sonic-vrf { + prefix svrf; + } + + import sonic-interface { + prefix sintf; + } + + organization + "SONiC"; + + contact + "SONiC"; + + description + "SONIC Route map YANG"; + + revision 2021-01-08 { + description + "Added support for routed vlan-sub-interface."; + } + + revision 2020-09-02 { + description + "Added the field for IPv6 prefix set match."; + } + + revision 2020-04-08 { + description + "Added the fields for IPv6 next hop."; + } + + revision 2019-09-15 { + description + "Initial revision."; + } + + typedef route-map-intf { + type union { + type leafref { + path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:port_name"; + } + type leafref { + path "/spc:sonic-portchannel/spc:PORTCHANNEL/spc:PORTCHANNEL_LIST/spc:portchannel_name"; + } + type leafref { + path "/svlan:sonic-vlan/svlan:VLAN/svlan:VLAN_LIST/svlan:vlan_name"; + } + } + } + + typedef bgp-origin-attr-type { + type enumeration { + enum IGP { + description + "Origin of the NLRI is internal"; + } + enum EGP { + description + "Origin of the NLRI is EGP"; + } + enum INCOMPLETE { + description + "Origin of the NLRI is neither IGP or EGP"; + } + } + description + "Type definition for standard BGP origin attribute"; + reference "RFC 4271 - A Border Gateway Protocol 4 (BGP-4), + Sec 4.3"; + } + + typedef metric-action-type { + type enumeration { + enum METRIC_SET_VALUE { + description "Set a specified metric value."; + } + enum METRIC_ADD_VALUE { + description + "Add a specified metric value from current + set value of metric."; + } + enum METRIC_SUBTRACT_VALUE { + description + "Subtract a specified metric value from current + set value of metric."; + } + enum METRIC_SET_RTT { + description "Add round trip time value as metric." ; + } + enum METRIC_ADD_RTT { + description + "Add round trip time value from current + set value of metric."; + } + enum METRIC_SUBTRACT_RTT { + description + "Subtract round trip time value from current + set value of metric."; + } + } + description + "Type used to specify type of route metric value + to be set in a policy chain."; + } + + container sonic-route-map { + container ROUTE_MAP_SET { + list ROUTE_MAP_SET_LIST { + key "name"; + + leaf name { + type string; + } + } + } + + container ROUTE_MAP { + list ROUTE_MAP_LIST { + key "route_map_name stmt_name"; + + leaf route_map_name { + type string; + } + + leaf stmt_name { + type uint16 { + range 1..65535; + } + } + + leaf route_operation { + type srpolsets:routing-policy-action-type; + } + + leaf match_interface{ + type route-map-intf; + } + + leaf match_prefix_set{ + type leafref { + path "/srpolsets:sonic-routing-policy-sets/srpolsets:PREFIX_SET/srpolsets:PREFIX_SET_LIST/srpolsets:name"; + } + description + "Match a prefix list name that contains IPv4 prefixes."; + } + + leaf match_ipv6_prefix_set{ + type leafref { + path "/srpolsets:sonic-routing-policy-sets/srpolsets:PREFIX_SET/srpolsets:PREFIX_SET_LIST/srpolsets:name"; + } + description + "Match a prefix list name that contains IPv6 prefixes."; + } + + leaf match_protocol { + type string; + } + + leaf match_next_hop_set { + type leafref { + path "/srpolsets:sonic-routing-policy-sets/srpolsets:PREFIX_SET/srpolsets:PREFIX_SET_LIST/srpolsets:name"; + } + } + + leaf match_src_vrf { + type union { + type string { + pattern "default"; + } + type leafref { + path "/svrf:sonic-vrf/svrf:VRF/svrf:VRF_LIST/svrf:vrf_name"; + } + } + } + + leaf-list match_neighbor { + type union { + type inet:ip-address; + type leafref { + path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:port_name"; + } + type leafref { + path "/spc:sonic-portchannel/spc:PORTCHANNEL/spc:PORTCHANNEL_LIST/spc:portchannel_name"; + } + type leafref { + path "/svlan:sonic-vlan/svlan:VLAN/svlan:VLAN_LIST/svlan:vlan_name"; + } + } + description + "IP addresse or interface for match operation."; + must "(/cmn:operation/cmn:operation = 'DELETE') or (count(current()) = 1)" { + error-app-tag "max-allowed-neighbor-reached"; + error-message "Only one neighbor or interface can be configured."; + } + } + + leaf-list match_tag { + type uint32; + description + "Value of the tag match member"; + must "(/cmn:operation/cmn:operation = 'DELETE') or (count(current()) = 1)" { + error-app-tag "max-allowed-tag-reached"; + error-message "Only one tag value can be configured."; + } + } + + leaf match_med{ + type uint32; + } + + leaf match_origin{ + type string; + } + + leaf match_local_pref{ + type uint32; + } + + leaf match_community{ + type leafref { + path "/srpolsets:sonic-routing-policy-sets/srpolsets:COMMUNITY_SET/srpolsets:COMMUNITY_SET_LIST/srpolsets:name"; + } + } + + leaf match_ext_community{ + type leafref { + path "/srpolsets:sonic-routing-policy-sets/srpolsets:EXTENDED_COMMUNITY_SET/srpolsets:EXTENDED_COMMUNITY_SET_LIST/srpolsets:name"; + } + } + + leaf match_as_path{ + type leafref { + path "/srpolsets:sonic-routing-policy-sets/srpolsets:AS_PATH_SET/srpolsets:AS_PATH_SET_LIST/srpolsets:name"; + } + } + leaf call_route_map { + type leafref { + path "../../../ROUTE_MAP_SET/ROUTE_MAP_SET_LIST/name"; + } + } + + leaf set_origin{ + type string; + } + + leaf set_local_pref{ + type uint32; + } + + leaf set_med { + type uint32; + } + + leaf set_metric_action { + type metric-action-type; + } + + leaf set_metric { + /* + when "../set_metric_action = 'METRIC_SET_VALUE' " + + "or ../set_metric_action = 'METRIC_ADD_VALUE' " + + "or ../set_metric_action = 'METRIC_SUBTRACT_VALUE'"; + */ + type uint32; + } + + leaf set_next_hop{ + type string; + } + + leaf set_ipv6_next_hop_global { + type string; + } + + leaf set_ipv6_next_hop_prefer_global { + type boolean; + } + + leaf set_repeat_asn{ + type uint8; + } + + leaf set_asn{ + type uint32; + } + + leaf set_asn_list{ + type string; + } + + leaf-list set_community_inline { + type string; + } + + leaf set_community_ref { + type leafref { + path "/srpolsets:sonic-routing-policy-sets/srpolsets:COMMUNITY_SET/srpolsets:COMMUNITY_SET_LIST/srpolsets:name"; + } + } + + leaf-list set_ext_community_inline { + type string; + } + + leaf set_ext_community_ref { + type leafref { + path "/srpolsets:sonic-routing-policy-sets/srpolsets:EXTENDED_COMMUNITY_SET/srpolsets:EXTENDED_COMMUNITY_SET_LIST/srpolsets:name"; + } + } + + leaf set_tag { + type uint32; + description + "Value of the tag set member"; + } + + leaf set_weight{ + type uint32; + } + + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-routing-policy-sets.yang b/src/sonic-yang-models/yang-models/sonic-routing-policy-sets.yang new file mode 100644 index 000000000000..ce62594b8093 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-routing-policy-sets.yang @@ -0,0 +1,219 @@ +module sonic-routing-policy-sets { + namespace "http://github.com/Azure/sonic-routing-policy-lists"; + prefix srpolsets; + yang-version 1.1; + + import ietf-inet-types { + prefix inet; + } + + import sonic-extension { + prefix sonic-ext; + } + + organization + "SONiC"; + + contact + "SONiC"; + + description + "SONiC ROUTING POLICY SETS"; + + revision 2020-09-14 { + description + "Used enum values permit/deny for action type."; + } + + + revision 2019-10-23 { + description + "Initial revision."; + } + + typedef routing-policy-action-type { + type enumeration { + enum permit { + description "Permit action."; + } + enum deny { + description "Deny action."; + } + } + description + "Routing policy action type permit or deny"; + } + + container sonic-routing-policy-sets { + + container PREFIX_SET { + + list PREFIX_SET_LIST { + key "name"; + + leaf name { + type string; + } + + leaf mode { + type enumeration { + enum IPv4; + enum IPv6; + } + } + } + } + + container PREFIX { + + list PREFIX_LIST { + key "set_name sequence_number ip_prefix masklength_range"; + sonic-ext:custom-validation ValidateIpPrefixListCfg; + + leaf set_name { + type leafref { + path "../../../PREFIX_SET/PREFIX_SET_LIST/name"; + } + } + + leaf sequence_number { + type uint32 { + range "1..4294967295"; + } + description + "The sequence number determines the order in which prefix-list entries are applied. It must be unique + for each prefix in a prefix-list. Target devices should apply the prefixes in ascending order determined + by sequence no (low to high), rather than relying only on order in the list."; + } + + leaf ip_prefix { + /* TODO - Validate ip-prefix based on PREFIX_SET/mode */ + type inet:ip-prefix; + description + "The prefix member in CIDR notation -- while the + prefix may be either IPv4 or IPv6, most + implementations require all members of the prefix set + to be the same address family. Mixing address types in + the same prefix set is likely to cause an error."; + } + + leaf masklength_range { + type string; + description + "Defines a range for the masklength, or 'exact' if + the prefix has an exact length. + + Example: 10.3.192.0/21 through 10.3.192.0/24 would be + expressed as prefix: 10.3.192.0/21, + masklength_range: 21..24. + + Example: 10.3.192.0/21 would be expressed as + prefix: 10.3.192.0/21, + masklength_range: exact"; + } + + leaf action { + type routing-policy-action-type; + description + "Permit/Deny action for the prefix list."; + } + } + } + container COMMUNITY_SET { + + list COMMUNITY_SET_LIST { + key "name"; + + leaf name { + type string; + } + + leaf set_type { + type enumeration { + enum STANDARD; + enum EXPANDED; + } + } + + leaf match_action { + type enumeration { + enum ANY; + enum ALL; + } + } + + leaf action { + type routing-policy-action-type; + description + "Permit/Deny action for the community"; + } + + leaf-list community_member { + type string; + description + "members of the community set."; + } + } + } + + container EXTENDED_COMMUNITY_SET { + + list EXTENDED_COMMUNITY_SET_LIST { + key "name"; + + leaf name { + type string; + } + + leaf set_type { + type enumeration { + enum STANDARD; + enum EXPANDED; + } + } + + leaf match_action { + type enumeration { + enum ANY; + enum ALL; + } + } + + leaf action { + type routing-policy-action-type; + description + "Permit/Deny action for the ext-community"; + } + + leaf-list community_member { + type string; + description + "members of the community set."; + } + } + } + + container AS_PATH_SET { + + list AS_PATH_SET_LIST { + key "name"; + + leaf name { + type string; + } + + leaf action { + type routing-policy-action-type; + description + "Permit/Deny action for the as-path-list."; + } + + leaf-list as_path_set_member { + type string; + description + "AS path expression -- list of ASes in the set"; + } + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-vrf.yang b/src/sonic-yang-models/yang-models/sonic-vrf.yang new file mode 100644 index 000000000000..cf3437782157 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-vrf.yang @@ -0,0 +1,54 @@ +module sonic-vrf { + namespace "http://github.com/Azure/sonic-vrf"; + prefix vrf; + + import sonic-extension { + prefix sonic-ext; + } + + organization + "SONiC"; + + contact + "SONiC"; + + description + "SONIC VRF"; + + revision 2019-11-22 { + description + "Add VRF name check"; + } + + revision 2019-10-30 { + description + "Initial revision."; + } + + container sonic-vrf { + container VRF { + description "Vrf configuration."; + + list VRF_LIST { + key "vrf_name"; + + leaf vrf_name { + type string { + pattern "Vrf[a-zA-Z0-9_-]+" { + error-message "Invalid VRF name"; + error-app-tag vrf-name-invalid; + } + } + } + + leaf fallback { + type boolean; + default false; + description + "Enalbe/disable fallback feature which is useful for specified VRF user to access internet through global/main route."; + } + + } + } + } +} From 8b73264683aebb8aa0c727f1cead9d8d4701199e Mon Sep 17 00:00:00 2001 From: Venkatesan Mahalingam Date: Sat, 27 Feb 2021 21:49:55 -0800 Subject: [PATCH 07/28] Updated the revision. Signed-off-by: Venkatesan Mahalingam --- .../yang-models/sonic-bgp-common.yang | 20 +++---------------- .../yang-models/sonic-bgp-global.yang | 12 +---------- .../yang-models/sonic-bgp-neighbor.yang | 7 +------ .../yang-models/sonic-bgp-peergroup.yang | 2 +- .../yang-models/sonic-device_metadata.yang | 8 +++++++- .../yang-models/sonic-route-common.yang | 2 +- .../yang-models/sonic-route-map.yang | 17 +--------------- .../sonic-routing-policy-sets.yang | 8 +------- .../yang-models/sonic-vrf.yang | 7 +------ 9 files changed, 17 insertions(+), 66 deletions(-) diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-common.yang b/src/sonic-yang-models/yang-models/sonic-bgp-common.yang index af6ab47f35dc..9523ced5ad7e 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-common.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-common.yang @@ -19,7 +19,7 @@ module sonic-bgp-common { prefix svlan; } - import sonic-loopback { + import sonic-loopback-interface { prefix lo; } @@ -56,21 +56,7 @@ module sonic-bgp-common { description "SONIC BGP common YANG attributes for Neighbors and Peer group"; - revision 2021-02-01 { - description - "Added CVL check to compare strict_capability_match and override_capability."; - } - - revision 2021-01-08 { - description - "Added support for routed vlan-sub-interface."; - } - - revision 2020-07-26 { - description - "Change for sonic-loopback.yang."; - } - revision 2019-11-04 { + revision 2021-02-26 { description "Initial revision."; } @@ -246,7 +232,7 @@ module sonic-bgp-common { path "/svlan:sonic-vlan/svlan:VLAN/svlan:VLAN_LIST/svlan:vlan_name"; } type leafref { - path "/lo:sonic-loopback/lo:LOOPBACK/lo:LOOPBACK_LIST/lo:name"; + path "/lo:sonic-loopback-interface/lo:LOOPBACK_INTERFACE/lo:LOOPBACK_INTERFACE_LIST/lo:loopback_interface_name"; } } description "Local source address or interface name to use for connection."; diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-global.yang b/src/sonic-yang-models/yang-models/sonic-bgp-global.yang index 4ee358e93064..813e5b05c592 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-global.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-global.yang @@ -36,17 +36,7 @@ module sonic-bgp-global { description "SONIC BGP Global YANG"; - revision 2020-12-10 { - description - "Added CVL validation condition to compare max_delay and establish_wait values."; - } - - revision 2019-11-20 { - description - "Added BGP fields for extensive features."; - } - - revision 2019-09-15 { + revision 2021-02-26 { description "Initial revision."; } diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang b/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang index 35488fe78f91..01e717deea40 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang @@ -40,12 +40,7 @@ module sonic-bgp-neighbor { description "SONIC BGP Neighbor"; - revision 2021-01-08 { - description - "Added support for routed vlan-sub-interface."; - } - - revision 2019-09-23 { + revision 2021-02-26 { description "Initial revision."; } diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-peergroup.yang b/src/sonic-yang-models/yang-models/sonic-bgp-peergroup.yang index 8a14e948ade1..a5875049d46d 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-peergroup.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-peergroup.yang @@ -24,7 +24,7 @@ module sonic-bgp-peergroup { description "SONIC BGP Peer Group YANG"; - revision 2019-10-16 { + revision 2021-02-26 { description "Initial revision."; } diff --git a/src/sonic-yang-models/yang-models/sonic-device_metadata.yang b/src/sonic-yang-models/yang-models/sonic-device_metadata.yang index 26486264345d..8db1f59b7662 100644 --- a/src/sonic-yang-models/yang-models/sonic-device_metadata.yang +++ b/src/sonic-yang-models/yang-models/sonic-device_metadata.yang @@ -19,6 +19,11 @@ module sonic-device_metadata { } description "DEVICE_METADATA YANG Module for SONiC OS"; + + revision 2021-02-27 { + description "Added frr_mgmt_framework_config field to handle BGP + config DB schema events to configure FRR protocols."; + } revision 2020-04-10 { description "First Revision"; @@ -91,7 +96,8 @@ module sonic-device_metadata { } leaf frr_mgmt_framework_config { type boolean; - description "frrcfgd module handles the FRR configuations based on BGP YANG models when set to true."; + description "FRR configurations are handled by sonic-frr-mgmt-framework module when set to true, + otherwise, sonic-bgpcfgd handles the FRR configurations based on the predefined templates."; default "false"; } } diff --git a/src/sonic-yang-models/yang-models/sonic-route-common.yang b/src/sonic-yang-models/yang-models/sonic-route-common.yang index e337dfdc33e8..9ae6e16fc28f 100644 --- a/src/sonic-yang-models/yang-models/sonic-route-common.yang +++ b/src/sonic-yang-models/yang-models/sonic-route-common.yang @@ -24,7 +24,7 @@ module sonic-route-common { description "SONIC ROUTE common YANG"; - revision 2019-11-08 { + revision 2021-02-26 { description "Initial revision."; } diff --git a/src/sonic-yang-models/yang-models/sonic-route-map.yang b/src/sonic-yang-models/yang-models/sonic-route-map.yang index d9d9f31fdfd8..96875fbbe0a9 100644 --- a/src/sonic-yang-models/yang-models/sonic-route-map.yang +++ b/src/sonic-yang-models/yang-models/sonic-route-map.yang @@ -44,22 +44,7 @@ module sonic-route-map { description "SONIC Route map YANG"; - revision 2021-01-08 { - description - "Added support for routed vlan-sub-interface."; - } - - revision 2020-09-02 { - description - "Added the field for IPv6 prefix set match."; - } - - revision 2020-04-08 { - description - "Added the fields for IPv6 next hop."; - } - - revision 2019-09-15 { + revision 2021-02-26 { description "Initial revision."; } diff --git a/src/sonic-yang-models/yang-models/sonic-routing-policy-sets.yang b/src/sonic-yang-models/yang-models/sonic-routing-policy-sets.yang index ce62594b8093..f87e780a2a77 100644 --- a/src/sonic-yang-models/yang-models/sonic-routing-policy-sets.yang +++ b/src/sonic-yang-models/yang-models/sonic-routing-policy-sets.yang @@ -20,13 +20,7 @@ module sonic-routing-policy-sets { description "SONiC ROUTING POLICY SETS"; - revision 2020-09-14 { - description - "Used enum values permit/deny for action type."; - } - - - revision 2019-10-23 { + revision 2021-02-26 { description "Initial revision."; } diff --git a/src/sonic-yang-models/yang-models/sonic-vrf.yang b/src/sonic-yang-models/yang-models/sonic-vrf.yang index cf3437782157..b56801b00fe8 100644 --- a/src/sonic-yang-models/yang-models/sonic-vrf.yang +++ b/src/sonic-yang-models/yang-models/sonic-vrf.yang @@ -15,12 +15,7 @@ module sonic-vrf { description "SONIC VRF"; - revision 2019-11-22 { - description - "Add VRF name check"; - } - - revision 2019-10-30 { + revision 2021-02-26 { description "Initial revision."; } From 6eb74b10cd5b1d6996e1fb665bb3258a82b9c7ed Mon Sep 17 00:00:00 2001 From: Venkatesan Mahalingam Date: Wed, 31 Mar 2021 22:09:38 +0000 Subject: [PATCH 08/28] Added the unit test cases for BGP & route-map tables. Signed-off-by: Venkatesan Mahalingam --- src/sonic-yang-mgmt/sonic_yang_ext.py | 4 + .../libyang-python-tests/test_sonic_yang.py | 4 +- src/sonic-yang-models/setup.py | 8 + .../tests/files/sample_config_db.json | 72 +++ .../tests/yang_model_tests/tests/bgp.json | 39 ++ .../tests/device_metadata.json | 4 + .../yang_model_tests/tests/route_filter.json | 20 + .../yang_model_tests/tests_config/bgp.json | 491 ++++++++++++++++++ .../tests_config/device_metadata.json | 11 + .../tests_config/route_filter.json | 132 +++++ .../yang-models/sonic-types.yang | 13 + 11 files changed, 796 insertions(+), 2 deletions(-) create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests/route_filter.json create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests_config/route_filter.json diff --git a/src/sonic-yang-mgmt/sonic_yang_ext.py b/src/sonic-yang-mgmt/sonic_yang_ext.py index b01225277aa6..b98abf4c4047 100644 --- a/src/sonic-yang-mgmt/sonic_yang_ext.py +++ b/src/sonic-yang-mgmt/sonic_yang_ext.py @@ -82,6 +82,10 @@ def _createDBTableToModuleMap(self): for j in self.yJson: # get module name moduleName = j['module']['@name'] + # Skip sonic-types and sonic-extensions modules + if moduleName.strip() == 'sonic-types' or moduleName.strip() == 'sonic-extension': + continue + # get top level container topLevelContainer = j['module'].get('container') # if top level container is none, this is common yang files, which may diff --git a/src/sonic-yang-mgmt/tests/libyang-python-tests/test_sonic_yang.py b/src/sonic-yang-mgmt/tests/libyang-python-tests/test_sonic_yang.py index 2de2a8770801..3c5a679ee73e 100644 --- a/src/sonic-yang-mgmt/tests/libyang-python-tests/test_sonic_yang.py +++ b/src/sonic-yang-mgmt/tests/libyang-python-tests/test_sonic_yang.py @@ -293,10 +293,10 @@ def test_validate_yang_models(self, sonic_yang_data): test_file = sonic_yang_data['test_file'] syc = sonic_yang_data['syc'] # Currently only 2 YANG files are not directly related to config - # which are: sonic-extension.yang and sonic-types.yang. Hard coding + # which are: sonic-extension.yang, sonic-types.yang and sonic-bgp-common.yang. Hard coding # it right now. # If any more such helper yang files are added, we need to update here. - NON_CONFIG_YANG_FILES = 2 + NON_CONFIG_YANG_FILES = 3 # read config jIn = self.readIjsonInput(test_file, 'SAMPLE_CONFIG_DB_JSON') jIn = json.loads(jIn) diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index e651bb0d377d..ae7b14ae25c7 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -55,6 +55,14 @@ './yang-models/sonic-types.yang', './yang-models/sonic-versions.yang', './yang-models/sonic-vlan.yang', + './yang-models/sonic-vrf.yang', + './yang-models/sonic-route-common.yang', + './yang-models/sonic-route-map.yang', + './yang-models/sonic-routing-policy-sets.yang', + './yang-models/sonic-bgp-global.yang', + './yang-models/sonic-bgp-common.yang', + './yang-models/sonic-bgp-neighbor.yang', + './yang-models/sonic-bgp-peergroup.yang', './yang-models/sonic_yang_tree']), ], zip_safe=False, 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 350882515fb9..7d49d5210a70 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -686,6 +686,78 @@ "nexthop_group_threshold_type": "percentage", "polling_interval": "0" } + }, + "VRF": { + "default": { + }, + "Vrf1": { + } + }, + "BGP_GLOBALS": { + "default": { + "router_id": "5.5.5.5", + "local_asn": "65001" + } + }, + "BGP_GLOBALS_AF": { + "default|ipv4_unicast": { + "max_ebgp_paths": "2", + "max_ibgp_paths": "2" + }, + "default|ipv6_unicast": { + "max_ebgp_paths": "2", + "max_ibgp_paths": "2" + } + }, + "BGP_GLOBALS_AF_AGGREGATE_ADDR": { + "default|ipv4_unicast|21.0.0.0/8": { + } + }, + "BGP_GLOBALS_AF_NETWORK": { + "default|ipv4_unicast|21.0.0.0/8": { + } + }, + "BGP_NEIGHBOR": { + "default|192.168.1.1": { + } + }, + "BGP_NEIGHBOR_AF": { + "default|192.168.1.1|ipv4_unicast": { + } + }, + "BGP_PEER_GROUP": { + "default|PG1": { + } + }, + "BGP_PEER_GROUP_AF": { + "default|PG1|ipv4_unicast": { + } + }, + "BGP_GLOBALS_LISTEN_PREFIX": { + "default|30.0.0.0/8": { + "peer_group": "PG1" + } + }, + "ROUTE_MAP_SET": { + "map1": { + } + }, + "ROUTE_MAP": { + "map1|1": { + "match_med" : "100" + } + }, + "ROUTE_REDISTRIBUTE": { + "default|connected|bgp|ipv4": { + } + }, + "PREFIX_SET": { + "prefix1": { + } + }, + "PREFIX": { + "prefix1|1|10.0.0.0/8|8..16": { + } } }, diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json b/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json new file mode 100644 index 000000000000..facd191b556d --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json @@ -0,0 +1,39 @@ +{ + "VRF_VALID": { + "desc": "Configure VRF table." + }, + "BGP_GLOBAL_VALID": { + "desc": "Configure BGP global table." + }, + "BGP_NEIGHBOR_ALL_VALID": { + "desc": "Configure BGP neighbor table." + }, + "BGP_PEERGROUP_ALL_VALID": { + "desc": "Configure BGP peer group table." + }, + "BGP_GLOBAL_NEG_VRF_NOT_EXIST": { + "desc": "Referring non-existing VRF table.", + "eStrKey": "InvalidValue" + }, + "BGP_GLOBAL_AF_NEG_GLOBAL_NOT_EXIST": { + "desc": "Referring non-existing BGP global table.", + "eStrKey" : "LeafRef" + }, + "BGP_NEIGHBOR_NEG_GLOBAL_NOT_EXIST": { + "desc": "Referring non-existing BGP global table.", + "eStrKey" : "LeafRef" + }, + "BGP_NEIGHBOR_AF_NEG_NEIGHBOR_NOT_EXIST": { + "desc": "Referring non-existing BGP neighbor table.", + "eStrKey" : "LeafRef" + }, + "BGP_PEER_GROUP_NEG_GLOBAL_NOT_EXIST": { + "desc": "Referring non-existing BGP global table.", + "eStrKey" : "LeafRef" + }, + "BGP_PEER_GROUP_AF_NEG_PEER_GROUP_NOT_EXIST": { + "desc": "Referring non-existing BGP peer group table.", + "eStrKey" : "LeafRef" + } + +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/device_metadata.json b/src/sonic-yang-models/tests/yang_model_tests/tests/device_metadata.json index 1e560257ad71..68d535ce7bf7 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/device_metadata.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/device_metadata.json @@ -32,5 +32,9 @@ "DEVICE_METADATA_TYPE_INCORRECT_PATTERN": { "desc": "DEVICE_METADATA_TYPE_INCORRECT_PATTERN pattern failure.", "eStrKey" : "Pattern" + }, + "DEVICE_METADATA_FRR_MGMT_FWK_CONFIG": { + "desc": "Verifying FRR MGMT framework configuration." } + } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/route_filter.json b/src/sonic-yang-models/tests/yang_model_tests/tests/route_filter.json new file mode 100644 index 000000000000..154c809509eb --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/route_filter.json @@ -0,0 +1,20 @@ +{ + "ROUTE_REDISTRIBUTE_VALID": { + "desc": "Configure route redistribution table." + }, + "ROUTE_MAP_VALID": { + "desc": "Configure route map table." + }, + "ROUTE_PREFIX_VALID": { + "desc": "Configure prefix table." + }, + "BGP_COMMUNITY_VALID": { + "desc": "Configure BGP community table." + }, + "BGP_EXT_COMMUNITY_VALID": { + "desc": "Configure BGP extended community table." + }, + "BGP_AS_PATH_VALID": { + "desc": "Configure BGP AS path table." + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json new file mode 100644 index 000000000000..dda25f4b66b6 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json @@ -0,0 +1,491 @@ +{ + "VRF_VALID": { + "sonic-vrf:sonic-vrf":{ + "sonic-vrf:VRF": { + "VRF_LIST": [ + { + "vrf_name":"default" + }, + { + "vrf_name":"Vrf1" + } + ] + } + } + }, + + "BGP_GLOBAL_VALID": { + "sonic-vrf:sonic-vrf":{ + "sonic-vrf:VRF": { + "VRF_LIST": [ + { + "vrf_name":"Vrf1" + } + ] + } + }, + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name":"default", + "local_asn": 65001 + }, + { + "vrf_name":"Vrf1", + "local_asn": 65001 + } + ] + }, + "sonic-bgp-global:BGP_GLOBALS_AF": { + "BGP_GLOBALS_AF_LIST": [ + { + "vrf_name": "default", + "afi_safi": "ipv4_unicast", + "ibgp_route_distance": 5, + "ebgp_route_distance": 5, + "local_route_distance": 10 + }, + { + "vrf_name": "default", + "afi_safi": "ipv6_unicast", + "ibgp_route_distance": 5, + "ebgp_route_distance": 5, + "local_route_distance": 10 + }, + { + "vrf_name": "Vrf1", + "afi_safi": "ipv6_unicast", + "ibgp_route_distance": 5, + "ebgp_route_distance": 5, + "local_route_distance": 10 + } + ] + }, + "sonic-bgp-global:BGP_GLOBALS_AF_AGGREGATE_ADDR": { + "BGP_GLOBALS_AF_AGGREGATE_ADDR_LIST": [ + { + "vrf_name": "default", + "afi_safi": "ipv4_unicast", + "ip_prefix": "20.0.0.0/8", + "as_set": true + }, + { + "vrf_name": "Vrf1", + "afi_safi": "ipv4_unicast", + "ip_prefix": "21.0.0.0/8", + "as_set": true + } + ] + }, + "sonic-bgp-global:BGP_GLOBALS_AF_NETWORK": { + "BGP_GLOBALS_AF_NETWORK_LIST": [ + { + "vrf_name": "default", + "afi_safi": "ipv4_unicast", + "ip_prefix": "20.0.0.0/8", + "backdoor": false + }, + { + "vrf_name": "Vrf1", + "afi_safi": "ipv4_unicast", + "ip_prefix": "21.0.0.0/8", + "backdoor": false + } + ] + } + } + }, + + "BGP_NEIGHBOR_ALL_VALID": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth8", + "description": "Ethernet8", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet8", + "speed": 25000 + }, + { + "admin_status": "up", + "alias": "eth9", + "description": "Ethernet9", + "lanes": "71", + "mtu": 9000, + "name": "Ethernet9", + "speed": 25000 + } + ] + } + }, + "sonic-vrf:sonic-vrf":{ + "sonic-vrf:VRF": { + "VRF_LIST": [ + { + "vrf_name":"Vrf1" + } + ] + } + }, + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name":"default", + "local_asn": 65001 + }, + { + "vrf_name":"Vrf1", + "local_asn": 65002 + } + + ] + } + }, + "sonic-bgp-neighbor:sonic-bgp-neighbor": { + "sonic-bgp-neighbor:BGP_NEIGHBOR": { + "BGP_NEIGHBOR_LIST": [ + { + "vrf_name": "default", + "neighbor": "20.0.0.1", + "local_asn": 1, + "name": "BGP nbr 1", + "asn": 65003, + "peer_type": "external", + "ebgp_multihop": false, + "ebgp_multihop_ttl": 1, + "auth_password": "AuthPassword-01", + "keepalive": 0, + "holdtime": 0, + "conn_retry": 1, + "min_adv_interval": 0, + "local_addr": "Ethernet8", + "passive_mode": false, + "capability_ext_nexthop": false, + "disable_ebgp_connected_route_check": false, + "enforce_first_as": false, + "solo_peer": false, + "ttl_security_hops": 1, + "bfd": false, + "bfd_check_ctrl_plane_failure": false, + "capability_dynamic": false, + "dont_negotiate_capability": false, + "enforce_multihop": false, + "override_capability": false, + "peer_port": 0, + "shutdown_message": "BGP PeerGroup Shutdown Message", + "strict_capability_match": false, + "admin_status": false, + "local_as_no_prepend": false, + "local_as_replace_as": false + }, + { + "vrf_name": "Vrf1", + "neighbor": "20.0.0.2", + "local_asn": 1, + "name": "BGP nbr 2", + "asn": 65002, + "peer_type": "external", + "ebgp_multihop": false, + "ebgp_multihop_ttl": 1, + "auth_password": "AuthPassword-02", + "keepalive": 0, + "holdtime": 0, + "conn_retry": 1, + "min_adv_interval": 0, + "local_addr": "Ethernet8", + "passive_mode": false, + "capability_ext_nexthop": false, + "disable_ebgp_connected_route_check": false, + "enforce_first_as": false, + "solo_peer": false, + "ttl_security_hops": 1, + "bfd": false, + "bfd_check_ctrl_plane_failure": false, + "capability_dynamic": false, + "dont_negotiate_capability": false, + "enforce_multihop": false, + "override_capability": false, + "peer_port": 0, + "shutdown_message": "BGP PeerGroup Shutdown Message", + "strict_capability_match": false, + "admin_status": false, + "local_as_no_prepend": false, + "local_as_replace_as": false + } + ] }, + + "sonic-bgp-neighbor:BGP_NEIGHBOR_AF": { + "BGP_NEIGHBOR_AF_LIST": [ + { + "vrf_name": "default", + "neighbor": "20.0.0.1", + "afi_safi": "ipv4_unicast", + "admin_status": true, + "send_default_route": true + }, + { + "vrf_name": "Vrf1", + "neighbor": "20.0.0.2", + "afi_safi": "ipv6_unicast", + "admin_status": true, + "send_default_route": true + } + + ] + } + } + }, + + "BGP_PEERGROUP_ALL_VALID": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth8", + "description": "Ethernet8", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet8", + "speed": 25000 + }, + { + "admin_status": "up", + "alias": "eth9", + "description": "Ethernet9", + "lanes": "71", + "mtu": 9000, + "name": "Ethernet9", + "speed": 25000 + } + ] + } + }, + "sonic-vrf:sonic-vrf":{ + "sonic-vrf:VRF": { + "VRF_LIST": [ + { + "vrf_name":"Vrf1" + } + ] + } + }, + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name":"default", + "local_asn": 65001 + }, + { + "vrf_name":"Vrf1", + "local_asn": 65002 + } + + ] + } + }, + "sonic-bgp-peergroup:sonic-bgp-peergroup": { + "sonic-bgp-peergroup:BGP_PEER_GROUP": { + "BGP_PEER_GROUP_LIST": [ + { + "vrf_name": "default", + "peer_group_name": "PG1", + "local_asn": 1, + "name": "BGP PeerGroup 01", + "asn": 65003, + "peer_type": "external", + "ebgp_multihop": false, + "ebgp_multihop_ttl": 1, + "auth_password": "AuthPassword-01", + "keepalive": 0, + "holdtime": 0, + "conn_retry": 1, + "min_adv_interval": 0, + "local_addr": "Ethernet8", + "passive_mode": false, + "capability_ext_nexthop": false, + "disable_ebgp_connected_route_check": false, + "enforce_first_as": false, + "solo_peer": false, + "ttl_security_hops": 1, + "bfd": false, + "bfd_check_ctrl_plane_failure": false, + "capability_dynamic": false, + "dont_negotiate_capability": false, + "enforce_multihop": false, + "override_capability": false, + "peer_port": 0, + "shutdown_message": "BGP PeerGroup Shutdown Message", + "strict_capability_match": false, + "admin_status": false, + "local_as_no_prepend": false, + "local_as_replace_as": false + }, + { + "vrf_name": "Vrf1", + "peer_group_name": "PG2", + "local_asn": 1, + "name": "BGP PeerGroup 02", + "asn": 65002, + "peer_type": "external", + "ebgp_multihop": false, + "ebgp_multihop_ttl": 1, + "auth_password": "AuthPassword-02", + "keepalive": 0, + "holdtime": 0, + "conn_retry": 1, + "min_adv_interval": 0, + "local_addr": "Ethernet8", + "passive_mode": false, + "capability_ext_nexthop": false, + "disable_ebgp_connected_route_check": false, + "enforce_first_as": false, + "solo_peer": false, + "ttl_security_hops": 1, + "bfd": false, + "bfd_check_ctrl_plane_failure": false, + "capability_dynamic": false, + "dont_negotiate_capability": false, + "enforce_multihop": false, + "override_capability": false, + "peer_port": 0, + "shutdown_message": "BGP PeerGroup Shutdown Message", + "strict_capability_match": false, + "admin_status": false, + "local_as_no_prepend": false, + "local_as_replace_as": false + } + ] }, + + "sonic-bgp-peergroup:BGP_PEER_GROUP_AF": { + "BGP_PEER_GROUP_AF_LIST": [ + { + "vrf_name": "default", + "peer_group_name": "PG1", + "afi_safi": "ipv4_unicast", + "admin_status": true, + "send_default_route": true + }, + { + "vrf_name": "Vrf1", + "peer_group_name": "PG2", + "afi_safi": "ipv6_unicast", + "admin_status": true, + "send_default_route": true + } + + ] + } + } + }, + "BGP_GLOBAL_NEG_VRF_NOT_EXIST": { + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name":"Vrf1", + "local_asn": 65001 + } + ] + } + } + }, + + "BGP_GLOBAL_AF_NEG_GLOBAL_NOT_EXIST": { + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS_AF": { + "BGP_GLOBALS_AF_LIST": [ + { + "vrf_name": "default", + "afi_safi": "ipv4_unicast", + "ibgp_route_distance": 5, + "ebgp_route_distance": 5, + "local_route_distance": 10 + } ] } + } + }, + + "BGP_NEIGHBOR_NEG_GLOBAL_NOT_EXIST": { + "sonic-bgp-neighbor:sonic-bgp-neighbor": { + "sonic-bgp-neighbor:BGP_NEIGHBOR": { + "BGP_NEIGHBOR_LIST": [ + { + "vrf_name": "default", + "neighbor": "20.0.0.1", + "local_asn": 1, + "name": "BGP nbr 1", + "asn": 65003, + "peer_type": "external", + "ebgp_multihop": false, + "ebgp_multihop_ttl": 1 + }]}} + }, + + "BGP_NEIGHBOR_AF_NEG_NEIGHBOR_NOT_EXIST": { + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name":"default", + "local_asn": 65001 + }]} + }, + "sonic-bgp-neighbor:sonic-bgp-neighbor": { + "sonic-bgp-neighbor:BGP_NEIGHBOR_AF": { + "BGP_NEIGHBOR_AF_LIST": [ + { + "vrf_name": "default", + "neighbor": "20.0.0.1", + "afi_safi": "ipv4_unicast", + "admin_status": true, + "send_default_route": true + }]} + } + }, + + "BGP_PEER_GROUP_NEG_GLOBAL_NOT_EXIST": { + "sonic-bgp-peergroup:sonic-bgp-peergroup": { + "sonic-bgp-peergroup:BGP_PEER_GROUP": { + "BGP_PEER_GROUP_LIST": [ + { + "vrf_name": "default", + "peer_group_name": "PG1", + "local_asn": 1, + "name": "BGP PeerGroup 01", + "asn": 65003, + "peer_type": "external" + }]} + } + }, + + "BGP_PEER_GROUP_AF_NEG_PEER_GROUP_NOT_EXIST": { + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name":"default", + "local_asn": 65001 + }]} + }, + + "sonic-bgp-peergroup:sonic-bgp-peergroup": { + "sonic-bgp-peergroup:BGP_PEER_GROUP_AF": { + "BGP_PEER_GROUP_AF_LIST": [ + { + "vrf_name": "default", + "peer_group_name": "PG1", + "afi_safi": "ipv4_unicast", + "admin_status": true, + "send_default_route": true + }]} + } + } + +} + diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/device_metadata.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/device_metadata.json index 7a3bf81e1991..53ce7049eba3 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/device_metadata.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/device_metadata.json @@ -90,5 +90,16 @@ } } } + }, + "DEVICE_METADATA_FRR_MGMT_FWK_CONFIG": { + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "sonic-device_metadata:localhost": { + "frr_mgmt_framework_config": true, + "hostname": "DUT-CSW", + "platform": "Stone-DX010" + } + } + } } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/route_filter.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/route_filter.json new file mode 100644 index 000000000000..9df8964751da --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/route_filter.json @@ -0,0 +1,132 @@ +{ + "ROUTE_REDISTRIBUTE_VALID": { + "sonic-route-common:sonic-route-common":{ + "sonic-route-common:ROUTE_REDISTRIBUTE": { + "ROUTE_REDISTRIBUTE_LIST": [ + { + "vrf_name": "default", + "src_protocol": "connected", + "dst_protocol": "bgp", + "addr_family": "ipv4" + } + ] + } + } + }, + "ROUTE_MAP_VALID": { + "sonic-route-map:sonic-route-map":{ + "sonic-route-map:ROUTE_MAP_SET": { + "ROUTE_MAP_SET_LIST": [ + { + "name": "map1" + } + ] + } + }, + "sonic-route-map:sonic-route-map":{ + "sonic-route-map:ROUTE_MAP": { + "ROUTE_MAP_LIST": [ + { + "route_map_name": "map1", + "stmt_name": "1", + "match_med": 100, + "set_metric": 50 + } + ] + } + } + }, + "ROUTE_PREFIX_VALID": { + "sonic-routing-policy-sets:sonic-routing-policy-sets":{ + "sonic-routing-policy-sets:PREFIX_SET": { + "PREFIX_SET_LIST": [ + { + "name": "prefix1", + "mode": "IPv4" + } + ] + }, + "sonic-routing-policy-sets:PREFIX": { + "PREFIX_LIST": [ + { + "set_name": "prefix1", + "sequence_number": "10", + "ip_prefix": "20.0.0.0/8", + "masklength_range": "8..16", + "action": "permit" + }, + { + "set_name": "prefix1", + "sequence_number": "11", + "ip_prefix": "21.0.0.0/8", + "masklength_range": "exact", + "action": "permit" + } + ] + } + } + }, + "BGP_COMMUNITY_VALID": { + "sonic-routing-policy-sets:sonic-routing-policy-sets":{ + "sonic-routing-policy-sets:COMMUNITY_SET": { + "COMMUNITY_SET_LIST": [ + { + "name": "com1", + "set_type": "STANDARD", + "match_action": "ANY", + "action": "permit", + "community_member": ["1:1"] + }, + { + "name": "com2", + "set_type": "STANDARD", + "match_action": "ALL", + "action": "permit", + "community_member": ["1:2"] + } + ] + } + } + }, + "BGP_EXT_COMMUNITY_VALID": { + "sonic-routing-policy-sets:sonic-routing-policy-sets":{ + "sonic-routing-policy-sets:EXTENDED_COMMUNITY_SET": { + "EXTENDED_COMMUNITY_SET_LIST": [ + { + "name": "extcom1", + "set_type": "STANDARD", + "match_action": "ANY", + "action": "permit", + "community_member": ["rt:1:1"] + }, + { + "name": "extcom2", + "set_type": "STANDARD", + "match_action": "ALL", + "action": "permit", + "community_member": ["rt:1:2"] + } + ] + } + } + }, + "BGP_AS_PATH_VALID": { + "sonic-routing-policy-sets:sonic-routing-policy-sets":{ + "sonic-routing-policy-sets:AS_PATH_SET": { + "AS_PATH_SET_LIST": [ + { + "name": "aspath1", + "action": "permit", + "as_path_set_member": ["65001","65003"] + }, + { + "name": "aspath2", + "action": "deny", + "as_path_set_member": ["65002"] + } + ] + } + } + } +} + diff --git a/src/sonic-yang-models/yang-models/sonic-types.yang b/src/sonic-yang-models/yang-models/sonic-types.yang index 93842a11f51e..2dc5d25321d8 100644 --- a/src/sonic-yang-models/yang-models/sonic-types.yang +++ b/src/sonic-yang-models/yang-models/sonic-types.yang @@ -114,4 +114,17 @@ module sonic-types { pattern "percentage|used|free|PERCENTAGE|USED|FREE"; } } + + // Defined as container because it will be used as xpath in MUST/WHEN + // expressions in yang. + container operation { + leaf operation { + type enumeration { + enum CREATE; + enum UPDATE; + enum DELETE; + } + } + description "Sonic data operation types required during validation"; + } } From 3e50732a11765929a066e1a4153f534c8172d295 Mon Sep 17 00:00:00 2001 From: Venkatesan Mahalingam Date: Wed, 31 Mar 2021 23:46:11 +0000 Subject: [PATCH 09/28] Build errors are fixed. Signed-off-by: Venkatesan Mahalingam --- .../tests/files/sample_config_db.json | 2 -- .../tests/yang_model_tests/tests_config/bgp.json | 3 --- .../yang-models/sonic-bgp-common.yang | 10 +++++----- .../yang-models/sonic-bgp-global.yang | 2 +- .../yang-models/sonic-bgp-neighbor.yang | 6 +++--- .../yang-models/sonic-extension.yang | 5 +++++ .../yang-models/sonic-route-common.yang | 2 +- .../yang-models/sonic-route-map.yang | 14 +++++++------- 8 files changed, 22 insertions(+), 22 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 7d49d5210a70..1e13cbe21734 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -688,8 +688,6 @@ } }, "VRF": { - "default": { - }, "Vrf1": { } }, diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json index dda25f4b66b6..9733b257ad6a 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json @@ -3,9 +3,6 @@ "sonic-vrf:sonic-vrf":{ "sonic-vrf:VRF": { "VRF_LIST": [ - { - "vrf_name":"default" - }, { "vrf_name":"Vrf1" } diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-common.yang b/src/sonic-yang-models/yang-models/sonic-bgp-common.yang index 9523ced5ad7e..5e435bfba7f4 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-common.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-common.yang @@ -31,7 +31,7 @@ module sonic-bgp-common { prefix srmap; } - import sonic-common { + import sonic-types { prefix cmn; } @@ -223,16 +223,16 @@ module sonic-bgp-common { type union { type inet:ip-address; type leafref { - path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:port_name"; + path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:name"; } type leafref { - path "/spc:sonic-portchannel/spc:PORTCHANNEL/spc:PORTCHANNEL_LIST/spc:portchannel_name"; + path "/spc:sonic-portchannel/spc:PORTCHANNEL/spc:PORTCHANNEL_LIST/spc:name"; } type leafref { - path "/svlan:sonic-vlan/svlan:VLAN/svlan:VLAN_LIST/svlan:vlan_name"; + path "/svlan:sonic-vlan/svlan:VLAN/svlan:VLAN_LIST/svlan:name"; } type leafref { - path "/lo:sonic-loopback-interface/lo:LOOPBACK_INTERFACE/lo:LOOPBACK_INTERFACE_LIST/lo:loopback_interface_name"; + path "/lo:sonic-loopback-interface/lo:LOOPBACK_INTERFACE/lo:LOOPBACK_INTERFACE_LIST/lo:name"; } } description "Local source address or interface name to use for connection."; diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-global.yang b/src/sonic-yang-models/yang-models/sonic-bgp-global.yang index 813e5b05c592..974ad91a62c9 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-global.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-global.yang @@ -23,7 +23,7 @@ module sonic-bgp-global { prefix sonic-ext; } - import sonic-common { + import sonic-types { prefix cmn; } diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang b/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang index 01e717deea40..7a0c99ad7a48 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang @@ -61,13 +61,13 @@ module sonic-bgp-neighbor { type union { type inet:ip-address; type leafref { - path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:port_name"; + path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:name"; } type leafref { - path "/spc:sonic-portchannel/spc:PORTCHANNEL/spc:PORTCHANNEL_LIST/spc:portchannel_name"; + path "/spc:sonic-portchannel/spc:PORTCHANNEL/spc:PORTCHANNEL_LIST/spc:name"; } type leafref { - path "/svlan:sonic-vlan/svlan:VLAN/svlan:VLAN_LIST/svlan:vlan_name"; + path "/svlan:sonic-vlan/svlan:VLAN/svlan:VLAN_LIST/svlan:name"; } } description "Neighbor description, it will be neighbor address or interface name"; diff --git a/src/sonic-yang-models/yang-models/sonic-extension.yang b/src/sonic-yang-models/yang-models/sonic-extension.yang index 6369b605173c..b8dbad46d9e4 100644 --- a/src/sonic-yang-models/yang-models/sonic-extension.yang +++ b/src/sonic-yang-models/yang-models/sonic-extension.yang @@ -10,4 +10,9 @@ module sonic-extension { revision 2019-07-01 { description "First Revision"; } + + extension custom-validation { + description "Extension for registering custom validation handler."; + argument "handler"; + } } diff --git a/src/sonic-yang-models/yang-models/sonic-route-common.yang b/src/sonic-yang-models/yang-models/sonic-route-common.yang index 9ae6e16fc28f..b98c27f518fb 100644 --- a/src/sonic-yang-models/yang-models/sonic-route-common.yang +++ b/src/sonic-yang-models/yang-models/sonic-route-common.yang @@ -11,7 +11,7 @@ module sonic-route-common { prefix srmap; } - import sonic-common { + import sonic-types { prefix cmn; } diff --git a/src/sonic-yang-models/yang-models/sonic-route-map.yang b/src/sonic-yang-models/yang-models/sonic-route-map.yang index 96875fbbe0a9..91a78c0c1f7b 100644 --- a/src/sonic-yang-models/yang-models/sonic-route-map.yang +++ b/src/sonic-yang-models/yang-models/sonic-route-map.yang @@ -7,7 +7,7 @@ module sonic-route-map { prefix inet; } - import sonic-common { + import sonic-types { prefix cmn; } @@ -52,13 +52,13 @@ module sonic-route-map { typedef route-map-intf { type union { type leafref { - path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:port_name"; + path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:name"; } type leafref { - path "/spc:sonic-portchannel/spc:PORTCHANNEL/spc:PORTCHANNEL_LIST/spc:portchannel_name"; + path "/spc:sonic-portchannel/spc:PORTCHANNEL/spc:PORTCHANNEL_LIST/spc:name"; } type leafref { - path "/svlan:sonic-vlan/svlan:VLAN/svlan:VLAN_LIST/svlan:vlan_name"; + path "/svlan:sonic-vlan/svlan:VLAN/svlan:VLAN_LIST/svlan:name"; } } } @@ -192,13 +192,13 @@ module sonic-route-map { type union { type inet:ip-address; type leafref { - path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:port_name"; + path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:name"; } type leafref { - path "/spc:sonic-portchannel/spc:PORTCHANNEL/spc:PORTCHANNEL_LIST/spc:portchannel_name"; + path "/spc:sonic-portchannel/spc:PORTCHANNEL/spc:PORTCHANNEL_LIST/spc:name"; } type leafref { - path "/svlan:sonic-vlan/svlan:VLAN/svlan:VLAN_LIST/svlan:vlan_name"; + path "/svlan:sonic-vlan/svlan:VLAN/svlan:VLAN_LIST/svlan:name"; } } description From 655b54a90e2b6bf9545807a0e7f85e4bf026793c Mon Sep 17 00:00:00 2001 From: Venkatesan Mahalingam Date: Fri, 9 Apr 2021 23:29:56 +0000 Subject: [PATCH 10/28] Added negative testcases and addressed the comments. Signed-off-by: Venkatesan Mahalingam --- src/sonic-yang-mgmt/sonic_yang_ext.py | 2 +- .../libyang-python-tests/test_sonic_yang.py | 2 +- src/sonic-yang-models/setup.py | 14 +- .../tests/yang_model_tests/tests/bgp.json | 83 +- .../yang_model_tests/tests/route_filter.json | 72 ++ .../yang_model_tests/tests_config/bgp.json | 816 ++++++++++++++++++ .../tests_config/route_filter.json | 418 ++++++++- 7 files changed, 1392 insertions(+), 15 deletions(-) diff --git a/src/sonic-yang-mgmt/sonic_yang_ext.py b/src/sonic-yang-mgmt/sonic_yang_ext.py index b98abf4c4047..89343cac42d8 100644 --- a/src/sonic-yang-mgmt/sonic_yang_ext.py +++ b/src/sonic-yang-mgmt/sonic_yang_ext.py @@ -83,7 +83,7 @@ def _createDBTableToModuleMap(self): # get module name moduleName = j['module']['@name'] # Skip sonic-types and sonic-extensions modules - if moduleName.strip() == 'sonic-types' or moduleName.strip() == 'sonic-extension': + if moduleName.strip() == 'sonic-types': continue # get top level container diff --git a/src/sonic-yang-mgmt/tests/libyang-python-tests/test_sonic_yang.py b/src/sonic-yang-mgmt/tests/libyang-python-tests/test_sonic_yang.py index 3c5a679ee73e..8cd911df7c82 100644 --- a/src/sonic-yang-mgmt/tests/libyang-python-tests/test_sonic_yang.py +++ b/src/sonic-yang-mgmt/tests/libyang-python-tests/test_sonic_yang.py @@ -292,7 +292,7 @@ def test_validate_yang_models(self, sonic_yang_data): ''' test_file = sonic_yang_data['test_file'] syc = sonic_yang_data['syc'] - # Currently only 2 YANG files are not directly related to config + # Currently only 3 YANG files are not directly related to config # which are: sonic-extension.yang, sonic-types.yang and sonic-bgp-common.yang. Hard coding # it right now. # If any more such helper yang files are added, we need to update here. diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index ae7b14ae25c7..d8df0af6de98 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -42,6 +42,10 @@ version='1.0', data_files=[ ('yang-models', ['./yang-models/sonic-acl.yang', + './yang-models/sonic-bgp-common.yang', + './yang-models/sonic-bgp-global.yang', + './yang-models/sonic-bgp-neighbor.yang', + './yang-models/sonic-bgp-peergroup.yang', './yang-models/sonic-breakout_cfg.yang', './yang-models/sonic-crm.yang', './yang-models/sonic-device_metadata.yang', @@ -52,17 +56,13 @@ './yang-models/sonic-loopback-interface.yang', './yang-models/sonic-port.yang', './yang-models/sonic-portchannel.yang', + './yang-models/sonic-route-common.yang', + './yang-models/sonic-route-map.yang', + './yang-models/sonic-routing-policy-sets.yang', './yang-models/sonic-types.yang', './yang-models/sonic-versions.yang', './yang-models/sonic-vlan.yang', './yang-models/sonic-vrf.yang', - './yang-models/sonic-route-common.yang', - './yang-models/sonic-route-map.yang', - './yang-models/sonic-routing-policy-sets.yang', - './yang-models/sonic-bgp-global.yang', - './yang-models/sonic-bgp-common.yang', - './yang-models/sonic-bgp-neighbor.yang', - './yang-models/sonic-bgp-peergroup.yang', './yang-models/sonic_yang_tree']), ], zip_safe=False, diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json b/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json index facd191b556d..5c239978d1c4 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json @@ -27,6 +27,51 @@ "desc": "Referring non-existing BGP neighbor table.", "eStrKey" : "LeafRef" }, + "BGP_NEIGHBOR_NEG_INVALID_NAME": { + "desc": "Incorrect neighbor name.", + "eStrKey": "InvalidValue", + "eStr": ["neighbor"] + }, + "BGP_NEIGHBOR_NEG_INVALID_ASN": { + "desc": "Invalid local AS number.", + "eStrKey" : "InvalidValue" + }, + "BGP_NEIGHBOR_NEG_INVALID_ENFORCE_FIRST_AS": { + "desc": "Invalid boolean value for enforce first AS.", + "eStrKey" : "InvalidValue", + "eStr": ["enforce_first_as"] + }, + "BGP_NEIGHBOR_NEG_INVALID_PEER_TYPE": { + "desc": "Invalid value for peer type.", + "eStrKey" : "InvalidValue", + "eStr": ["peer_type"] + }, + "BGP_NEIGHBOR_NEG_PEERGROUP_NOT_EXIST": { + "desc": "Reference to non-existent peergroup.", + "eStrKey" : "LeafRef" + }, + "BGP_NEIGHBOR_AF_NEG_INVALID_NAME": { + "desc": "Incorrect neighbor name in neighbor AF.", + "eStrKey" : "LeafRef" + }, + "BGP_NEIGHBOR_AF_NEG_INVALID_MAXTHRESHOLD": { + "desc": "Invalid maximum prefix warning threshold in neighbor AF.", + "eStrKey" : "Pattern" + }, + "BGP_NEIGHBOR_AF_NEG_INVALID_SOFT_RECFG_IN": { + "desc": "Invalid boolean value for soft reconfiguration-in in neighbor AF.", + "eStrKey" : "InvalidValue", + "eStr": ["soft_reconfiguration_in"] + }, + "BGP_NEIGHBOR_AF_NEG_INVALID_SEND_COMNTY": { + "desc": "Invalid value for send community type in neighbor AF.", + "eStrKey" : "InvalidValue", + "eStr": ["send_community"] + }, + "BGP_NEIGHBOR_AF_NEG_ROUTE_MAP_NOT_EXIST": { + "desc": "Reference to non-existent route-map.", + "eStrKey" : "LeafRef" + }, "BGP_PEER_GROUP_NEG_GLOBAL_NOT_EXIST": { "desc": "Referring non-existing BGP global table.", "eStrKey" : "LeafRef" @@ -34,6 +79,42 @@ "BGP_PEER_GROUP_AF_NEG_PEER_GROUP_NOT_EXIST": { "desc": "Referring non-existing BGP peer group table.", "eStrKey" : "LeafRef" + }, + "BGP_PEERGROUP_INVALID_ASN": { + "desc": "Invalid local AS number.", + "eStrKey" : "InvalidValue" + }, + "BGP_PEERGROUP_INVALID_ENFORCE_FIRST_AS": { + "desc": "Invalid boolean value for enforce first AS.", + "eStrKey" : "InvalidValue", + "eStr": ["enforce_first_as"] + }, + "BGP_PEERGROUP_INVALID_PEER_TYPE": { + "desc": "Invalid value for peer type.", + "eStrKey" : "InvalidValue", + "eStr": ["peer_type"] + }, + "BGP_PEERGROUP_INVALID_HOPS": { + "desc": "Invalid TTL hops for peergroup.", + "eStrKey" : "Pattern" + }, + "BGP_PEERGROUP_AF_INVALID_MAXTHRESHOLD": { + "desc": "Invalid maximum prefix warning threshold in peergroup AF.", + "eStrKey" : "Pattern" + }, + "BGP_PEERGROUP_AF_INVALID_SOFT_RECFG_IN": { + "desc": "Invalid boolean value for soft reconfiguration-in in peergroup AF.", + "eStrKey" : "InvalidValue", + "eStr": ["soft_reconfiguration_in"] + }, + "BGP_PEERGROUP_AF_INVALID_SEND_COMNTY": { + "desc": "Invalid value for send community type in peergroup AF.", + "eStrKey" : "InvalidValue", + "eStr": ["send_community"] + }, + "BGP_PEERGROUP_AF_ROUTE_MAP_NOT_EXIST": { + "desc": "Missing or non-existent route-map reference in peergroup AF.", + "eStrKey" : "LeafRef" } - } + diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/route_filter.json b/src/sonic-yang-models/tests/yang_model_tests/tests/route_filter.json index 154c809509eb..0e517600383f 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/route_filter.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/route_filter.json @@ -2,15 +2,86 @@ "ROUTE_REDISTRIBUTE_VALID": { "desc": "Configure route redistribution table." }, + "ROUTE_REDISTRIBUTE_NON_EXIST_RT_MAP": { + "desc": "Referring non-existing ROUTE_MAP table", + "eStrKey" : "LeafRef" + }, "ROUTE_MAP_VALID": { "desc": "Configure route map table." }, + "ROUTE_MAP_INVALID_STMT": { + "desc": "Configure route map table with wrong value for stmt_name.", + "eStrKey": "InvalidValue", + "eStr": ["stmt_name"] + }, + "ROUTE_MAP_INVALID_OPERATION_TYPE": { + "desc": "Configure route map table with invalid route operation type.", + "eStrKey": "InvalidValue", + "eStr": ["route_operation"] + }, + "ROUTE_MAP_INVALID_MATCH_INTF": { + "desc": "Configure route map table with invalid match interface name.", + "eStrKey": "InvalidValue", + "eStr": ["match_interface"] + }, + "ROUTE_MAP_INVALID_MATCH_PREFIX": { + "desc": "Configure route map table with non-existent match prefix set name.", + "eStrKey": "LeafRef" + }, + "ROUTE_MAP_INVALID_MATCH_SRC_VRF": { + "desc": "Configure route map table with non-existent match source VRF name.", + "eStrKey": "InvalidValue", + "eStr": ["match_src_vrf"] + }, + "ROUTE_MAP_INVALID_MATCH_NEIGHBOR": { + "desc": "Configure route map table with invalid match neighbor.", + "eStrKey": "InvalidValue", + "eStr": ["match_neighbor"] + }, + "ROUTE_MAP_INVALID_MATCH_COMMUNITY": { + "desc": "Configure route map table with non-existent match community set name.", + "eStrKey": "LeafRef" + }, + "ROUTE_MAP_INVALID_MATCH_AS_PATH": { + "desc": "Configure route map table with non-existent match AS_PATH set name.", + "eStrKey": "LeafRef" + }, + "ROUTE_MAP_INVALID_CALL_ROUTE_MAP": { + "desc": "Configure route map table with non-existent call route map name.", + "eStrKey": "LeafRef" + }, + "ROUTE_MAP_INVALID_SET_METRIC_ACTION": { + "desc": "Configure route map table with invalid set metric action type.", + "eStrKey": "InvalidValue", + "eStr": ["set_metric_action"] + }, + "ROUTE_MAP_INVALID_SET_EXT_COMMUNITY": { + "desc": "Configure route map table with non-existent set extended community set name.", + "eStrKey": "LeafRef" + }, "ROUTE_PREFIX_VALID": { "desc": "Configure prefix table." }, + "ROUTE_PREFIX_INVALID_MODE_ENUM": { + "desc": "Referring invalid Mode", + "eStrKey": "InvalidValue" + }, + "ROUTE_PREFIX_INVALID_SEQ_NO": { + "desc": "Out of range seqence number", + "eStrKey": "Range" + }, + "ROUTE_PREFIX_INVALID_IP_PREFIX": { + "desc": "Invalid IP prefix", + "eStrKey": "InvalidValue" + }, + "BGP_COMMUNITY_VALID": { "desc": "Configure BGP community table." }, + "BGP_COMMUNITY_INVALID_ACTION": { + "desc": "Referring invalid action", + "eStrKey": "InvalidValue" + }, "BGP_EXT_COMMUNITY_VALID": { "desc": "Configure BGP extended community table." }, @@ -18,3 +89,4 @@ "desc": "Configure BGP AS path table." } } + diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json index 9733b257ad6a..a3263fac84af 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json @@ -446,6 +446,462 @@ } }, + "BGP_NEIGHBOR_NEG_INVALID_NAME": { + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-neighbor:sonic-bgp-neighbor": { + "sonic-bgp-neighbor:BGP_NEIGHBOR": { + "BGP_NEIGHBOR_LIST": [ + { + "vrf_name": "default", + "neighbor": "11.12.13.981" + } + ] + } + } + }, + + "BGP_NEIGHBOR_NEG_INVALID_ASN": { + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-neighbor:sonic-bgp-neighbor": { + "sonic-bgp-neighbor:BGP_NEIGHBOR": { + "BGP_NEIGHBOR_LIST": [ + { + "vrf_name": "default", + "neighbor": "20.0.0.1", + "local_asn": "asda" + } + ] + } + } + }, + + "BGP_NEIGHBOR_NEG_INVALID_ENFORCE_FIRST_AS": { + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-neighbor:sonic-bgp-neighbor": { + "sonic-bgp-neighbor:BGP_NEIGHBOR": { + "BGP_NEIGHBOR_LIST": [ + { + "vrf_name": "default", + "neighbor": "20.0.0.1", + "local_asn": 1, + "name": "BGP nbr 1", + "asn": 65003, + "enforce_first_as": "not_true" + } + ] + } + } + }, + + "BGP_NEIGHBOR_NEG_INVALID_PEER_TYPE": { + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-neighbor:sonic-bgp-neighbor": { + "sonic-bgp-neighbor:BGP_NEIGHBOR": { + "BGP_NEIGHBOR_LIST": [ + { + "vrf_name": "default", + "neighbor": "20.0.0.1", + "local_asn": 1, + "name": "BGP nbr 1", + "asn": 65003, + "peer_type": "foobar" + } + ] + } + } + }, + + "BGP_NEIGHBOR_NEG_INVALID_HOPS": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "name": "Ethernet0" + } + ] + } + }, + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-neighbor:sonic-bgp-neighbor": { + "sonic-bgp-neighbor:BGP_NEIGHBOR": { + "BGP_NEIGHBOR_LIST": [ + { + "vrf_name": "default", + "neighbor": "Ethernet0", + "local_asn": 1, + "name": "BGP nbr 1", + "asn": 65003, + "ttl_security_hops": 2 + } + ] + } + } + }, + + "BGP_NEIGHBOR_NEG_PEERGROUP_NOT_EXIST": { + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-neighbor:sonic-bgp-neighbor": { + "sonic-bgp-neighbor:BGP_NEIGHBOR": { + "BGP_NEIGHBOR_LIST": [ + { + "vrf_name": "default", + "neighbor": "20.0.0.1", + "local_asn": 1, + "name": "BGP nbr 1", + "asn": 65003, + "peer_group_name": "PG1" + } + ] + } + } + }, + + "BGP_NEIGHBOR_AF_NEG_INVALID_NAME": { + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-neighbor:sonic-bgp-neighbor": { + "sonic-bgp-neighbor:BGP_NEIGHBOR": { + "BGP_NEIGHBOR_LIST": [ + { + "vrf_name": "default", + "neighbor": "20.0.0.1", + "local_asn": 1, + "name": "BGP nbr 1", + "asn": 65003 + } + ] + }, + "sonic-bgp-neighbor:BGP_NEIGHBOR_AF": { + "BGP_NEIGHBOR_AF_LIST": [ + { + "vrf_name": "default", + "neighbor": "11.12.14.921", + "afi_safi": "ipv4_unicast", + "admin_status": true + } + ] + } + } + }, + + "BGP_NEIGHBOR_AF_NEG_INVALID_MAXTHRESHOLD": { + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-neighbor:sonic-bgp-neighbor": { + "sonic-bgp-neighbor:BGP_NEIGHBOR": { + "BGP_NEIGHBOR_LIST": [ + { + "vrf_name": "default", + "neighbor": "20.0.0.1", + "local_asn": 1, + "name": "BGP nbr 1", + "asn": 65003 + } + ] + }, + "sonic-bgp-neighbor:BGP_NEIGHBOR_AF": { + "BGP_NEIGHBOR_AF_LIST": [ + { + "vrf_name": "default", + "neighbor": "20.0.0.1", + "afi_safi": "ipv4_unicast", + "admin_status": true, + "max_prefix_warning_threshold": 102 + } + ] + } + } + }, + + "BGP_NEIGHBOR_AF_NEG_INVALID_SOFT_RECFG_IN": { + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-neighbor:sonic-bgp-neighbor": { + "sonic-bgp-neighbor:BGP_NEIGHBOR": { + "BGP_NEIGHBOR_LIST": [ + { + "vrf_name": "default", + "neighbor": "20.0.0.1", + "local_asn": 1, + "name": "BGP nbr 1", + "asn": 65003 + } + ] + }, + "sonic-bgp-neighbor:BGP_NEIGHBOR_AF": { + "BGP_NEIGHBOR_AF_LIST": [ + { + "vrf_name": "default", + "neighbor": "20.0.0.1", + "afi_safi": "ipv4_unicast", + "admin_status": true, + "soft_reconfiguration_in": "not_true" + } + ] + } + } + }, + + "BGP_NEIGHBOR_AF_NEG_INVALID_SEND_COMNTY": { + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-neighbor:sonic-bgp-neighbor": { + "sonic-bgp-neighbor:BGP_NEIGHBOR": { + "BGP_NEIGHBOR_LIST": [ + { + "vrf_name": "default", + "neighbor": "20.0.0.1", + "local_asn": 1, + "name": "BGP nbr 1", + "asn": 65003 + } + ] + }, + "sonic-bgp-neighbor:BGP_NEIGHBOR_AF": { + "BGP_NEIGHBOR_AF_LIST": [ + { + "vrf_name": "default", + "neighbor": "20.0.0.1", + "afi_safi": "ipv4_unicast", + "admin_status": true, + "send_community": "foobar" + } + ] + } + } + }, + + "BGP_NEIGHBOR_AF_NEG_ROUTE_MAP_NOT_EXIST": { + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-neighbor:sonic-bgp-neighbor": { + "sonic-bgp-neighbor:BGP_NEIGHBOR": { + "BGP_NEIGHBOR_LIST": [ + { + "vrf_name": "default", + "neighbor": "20.0.0.1", + "local_asn": 1, + "name": "BGP nbr 1", + "asn": 65003 + } + ] + }, + "sonic-bgp-neighbor:BGP_NEIGHBOR_AF": { + "BGP_NEIGHBOR_AF_LIST": [ + { + "vrf_name": "default", + "neighbor": "20.0.0.1", + "afi_safi": "ipv4_unicast", + "admin_status": true, + "route_map_in": [ + "rtmap05" + ] + } + ] + } + } + }, + + "BGP_NEIGHBOR_AF_NEG_INVALID_MAP_IN": { + "sonic-route-map:sonic-route-map": { + "sonic-route-map:ROUTE_MAP_SET": { + "ROUTE_MAP_SET_LIST": [ + { + "name": "rtmap01" + }, + { + "name": "rtmap02" + } + ] + } + }, + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-neighbor:sonic-bgp-neighbor": { + "sonic-bgp-neighbor:BGP_NEIGHBOR": { + "BGP_NEIGHBOR_LIST": [ + { + "vrf_name": "default", + "neighbor": "20.0.0.1", + "local_asn": 1, + "name": "BGP nbr 1", + "asn": 65003 + } + ] + }, + "sonic-bgp-neighbor:BGP_NEIGHBOR_AF": { + "BGP_NEIGHBOR_AF_LIST": [ + { + "vrf_name": "default", + "neighbor": "20.0.0.1", + "afi_safi": "ipv4_unicast", + "admin_status": true, + "route_map_in": [ + "rtmap01", + "rtmap02" + ] + } + ] + } + } + }, + + "BGP_NEIGHBOR_AF_NEG_INVALID_MAP_OUT": { + "sonic-route-map:sonic-route-map": { + "sonic-route-map:ROUTE_MAP_SET": { + "ROUTE_MAP_SET_LIST": [ + { + "name": "rtmap01" + }, + { + "name": "rtmap02" + } + ] + } + }, + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-neighbor:sonic-bgp-neighbor": { + "sonic-bgp-neighbor:BGP_NEIGHBOR": { + "BGP_NEIGHBOR_LIST": [ + { + "vrf_name": "default", + "neighbor": "20.0.0.1", + "local_asn": 1, + "name": "BGP nbr 1", + "asn": 65003 + } + ] + }, + "sonic-bgp-neighbor:BGP_NEIGHBOR_AF": { + "BGP_NEIGHBOR_AF_LIST": [ + { + "vrf_name": "default", + "neighbor": "20.0.0.1", + "afi_safi": "ipv4_unicast", + "admin_status": true, + "route_map_out": [ + "rtmap01", + "rtmap02" + ] + } + ] + } + } + }, + "BGP_PEER_GROUP_NEG_GLOBAL_NOT_EXIST": { "sonic-bgp-peergroup:sonic-bgp-peergroup": { "sonic-bgp-peergroup:BGP_PEER_GROUP": { @@ -482,7 +938,367 @@ "send_default_route": true }]} } + }, + + "BGP_PEERGROUP_INVALID_ASN": { + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-peergroup:sonic-bgp-peergroup": { + "sonic-bgp-peergroup:BGP_PEER_GROUP": { + "BGP_PEER_GROUP_LIST": [ + { + "vrf_name": "default", + "peer_group_name": "PG1", + "local_asn": "adasd" + } + ] + } + } + }, + + "BGP_PEERGROUP_INVALID_ENFORCE_FIRST_AS": { + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-peergroup:sonic-bgp-peergroup": { + "sonic-bgp-peergroup:BGP_PEER_GROUP": { + "BGP_PEER_GROUP_LIST": [ + { + "vrf_name": "default", + "peer_group_name": "PG1", + "local_asn": 1, + "name": "BGP PeerGroup 01", + "asn": 65003, + "enforce_first_as": "not_true" + } + ] + } + } + }, + + "BGP_PEERGROUP_INVALID_PEER_TYPE": { + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-peergroup:sonic-bgp-peergroup": { + "sonic-bgp-peergroup:BGP_PEER_GROUP": { + "BGP_PEER_GROUP_LIST": [ + { + "vrf_name": "default", + "peer_group_name": "PG1", + "local_asn": 1, + "name": "BGP PeerGroup 01", + "asn": 65003, + "peer_type": "foobar" + } + ] + } + } + }, + + "BGP_PEERGROUP_INVALID_HOPS": { + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-peergroup:sonic-bgp-peergroup": { + "sonic-bgp-peergroup:BGP_PEER_GROUP": { + "BGP_PEER_GROUP_LIST": [ + { + "vrf_name": "default", + "peer_group_name": "PG1", + "local_asn": 1, + "name": "BGP PeerGroup 01", + "asn": 65003, + "ttl_security_hops": 255 + } + ] + } + } + }, + + "BGP_PEERGROUP_AF_INVALID_MAXTHRESHOLD": { + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-peergroup:sonic-bgp-peergroup": { + "sonic-bgp-peergroup:BGP_PEER_GROUP": { + "BGP_PEER_GROUP_LIST": [ + { + "vrf_name": "default", + "peer_group_name": "PG1", + "local_asn": 1, + "name": "BGP PeerGroup 01", + "asn": 65003 + } + ] + }, + "sonic-bgp-peergroup:BGP_PEER_GROUP_AF": { + "BGP_PEER_GROUP_AF_LIST": [ + { + "vrf_name": "default", + "peer_group_name": "PG1", + "afi_safi": "ipv4_unicast", + "admin_status": true, + "max_prefix_warning_threshold": 102 + } + ] + } + } + }, + + "BGP_PEERGROUP_AF_INVALID_SOFT_RECFG_IN": { + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-peergroup:sonic-bgp-peergroup": { + "sonic-bgp-peergroup:BGP_PEER_GROUP": { + "BGP_PEER_GROUP_LIST": [ + { + "vrf_name": "default", + "peer_group_name": "PG1", + "local_asn": 1, + "name": "BGP PeerGroup 01", + "asn": 65003 + } + ] + }, + "sonic-bgp-peergroup:BGP_PEER_GROUP_AF": { + "BGP_PEER_GROUP_AF_LIST": [ + { + "vrf_name": "default", + "peer_group_name": "PG1", + "afi_safi": "ipv4_unicast", + "admin_status": true, + "soft_reconfiguration_in": "not_true" + } + ] + } + } + }, + + "BGP_PEERGROUP_AF_INVALID_SEND_COMNTY": { + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-peergroup:sonic-bgp-peergroup": { + "sonic-bgp-peergroup:BGP_PEER_GROUP": { + "BGP_PEER_GROUP_LIST": [ + { + "vrf_name": "default", + "peer_group_name": "PG1", + "local_asn": 1, + "name": "BGP PeerGroup 01", + "asn": 65003 + } + ] + }, + "sonic-bgp-peergroup:BGP_PEER_GROUP_AF": { + "BGP_PEER_GROUP_AF_LIST": [ + { + "vrf_name": "default", + "peer_group_name": "PG1", + "afi_safi": "ipv4_unicast", + "admin_status": true, + "send_community": "foobar" + } + ] + } + } + }, + + "BGP_PEERGROUP_AF_ROUTE_MAP_NOT_EXIST": { + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-peergroup:sonic-bgp-peergroup": { + "sonic-bgp-peergroup:BGP_PEER_GROUP": { + "BGP_PEER_GROUP_LIST": [ + { + "vrf_name": "default", + "peer_group_name": "PG1", + "local_asn": 1, + "name": "BGP PeerGroup 01", + "asn": 65003 + } + ] + }, + "sonic-bgp-peergroup:BGP_PEER_GROUP_AF": { + "BGP_PEER_GROUP_AF_LIST": [ + { + "vrf_name": "default", + "peer_group_name": "PG1", + "afi_safi": "ipv4_unicast", + "admin_status": true, + "route_map_in": [ + "rtmap05" + ] + } + ] + } + } + }, + + "BGP_PEERGROUP_AF_NEG_INVALID_MAP_IN": { + "sonic-route-map:sonic-route-map": { + "sonic-route-map:ROUTE_MAP_SET": { + "ROUTE_MAP_SET_LIST": [ + { + "name": "rtmap01" + }, + { + "name": "rtmap02" + } + ] + } + }, + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-peergroup:sonic-bgp-peergroup": { + "sonic-bgp-peergroup:BGP_PEER_GROUP": { + "BGP_PEER_GROUP_LIST": [ + { + "vrf_name": "default", + "peer_group_name": "PG1", + "local_asn": 1, + "name": "BGP PeerGroup 01", + "asn": 65003 + } + ] + }, + "sonic-bgp-peergroup:BGP_PEER_GROUP_AF": { + "BGP_PEER_GROUP_AF_LIST": [ + { + "vrf_name": "default", + "peer_group_name": "PG1", + "afi_safi": "ipv4_unicast", + "admin_status": true, + "route_map_in": [ + "rtmap01", + "rtmap02" + ] + } + ] + } + } + }, + + "BGP_PEERGROUP_AF_NEG_INVALID_MAP_OUT": { + "sonic-route-map:sonic-route-map": { + "sonic-route-map:ROUTE_MAP_SET": { + "ROUTE_MAP_SET_LIST": [ + { + "name": "rtmap01" + }, + { + "name": "rtmap02" + } + ] + } + }, + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-peergroup:sonic-bgp-peergroup": { + "sonic-bgp-peergroup:BGP_PEER_GROUP": { + "BGP_PEER_GROUP_LIST": [ + { + "vrf_name": "default", + "peer_group_name": "PG1", + "local_asn": 1, + "name": "BGP PeerGroup 01", + "asn": 65003 + } + ] + }, + "sonic-bgp-peergroup:BGP_PEER_GROUP_AF": { + "BGP_PEER_GROUP_AF_LIST": [ + { + "vrf_name": "default", + "peer_group_name": "PG1", + "afi_safi": "ipv4_unicast", + "admin_status": true, + "route_map_out": [ + "rtmap01", + "rtmap02" + ] + } + ] + } + } } } + diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/route_filter.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/route_filter.json index 9df8964751da..25e186ffb3c0 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/route_filter.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/route_filter.json @@ -13,7 +13,24 @@ } } }, - "ROUTE_MAP_VALID": { + + "ROUTE_REDISTRIBUTE_NON_EXIST_RT_MAP": { + "sonic-route-common:sonic-route-common":{ + "sonic-route-common:ROUTE_REDISTRIBUTE": { + "ROUTE_REDISTRIBUTE_LIST": [ + { + "vrf_name": "default", + "src_protocol": "connected", + "dst_protocol": "bgp", + "addr_family": "ipv6", + "route_map":["map2"] + } + ] + } + } + }, + + "ROUTE_REDISTRIBUTE_INVALID_RT_MAP_CNT": { "sonic-route-map:sonic-route-map":{ "sonic-route-map:ROUTE_MAP_SET": { "ROUTE_MAP_SET_LIST": [ @@ -24,13 +41,324 @@ } }, "sonic-route-map:sonic-route-map":{ + "sonic-route-map:ROUTE_MAP_SET": { + "ROUTE_MAP_SET_LIST": [ + { + "name": "map2" + } + ] + } + }, + "sonic-route-common:sonic-route-common":{ + "sonic-route-common:ROUTE_REDISTRIBUTE": { + "ROUTE_REDISTRIBUTE_LIST": [ + { + "vrf_name": "default", + "src_protocol": "connected", + "dst_protocol": "bgp", + "addr_family": "ipv6", + "route_map":["map1","map2"] + } + ] + } + } + }, + + "ROUTE_MAP_VALID": { + "sonic-route-map:sonic-route-map":{ + "sonic-route-map:ROUTE_MAP_SET": { + "ROUTE_MAP_SET_LIST": [ + { + "name": "map1" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet4", + "lanes": "65", + "speed": 25000 + } + ] + } + }, + "sonic-portchannel:sonic-portchannel": { + "sonic-portchannel:PORTCHANNEL": { + "PORTCHANNEL_LIST": [ + { + "name": "PortChannel100", + "admin_status": "up" + } + ] + } + }, + "sonic-routing-policy-sets:sonic-routing-policy-sets":{ + "sonic-routing-policy-sets:PREFIX_SET": { + "PREFIX_SET_LIST": [ + { + "name": "abc", + "mode": "IPv4" + }, + { + "name": "test_pfx", + "mode": "IPv6" + }, + { + "name": "nh_set" + } + ] + }, + "sonic-routing-policy-sets:COMMUNITY_SET": { + "COMMUNITY_SET_LIST": [ + { + "name": "comm", + "set_type": "STANDARD", + "match_action": "ANY", + "action": "permit", + "community_member": ["1:1", "2:2"] + }, + { + "name": "target_comm" + } + ] + }, + "sonic-routing-policy-sets:AS_PATH_SET": { + "AS_PATH_SET_LIST": [ + { + "name": "xyz", + "action": "deny", + "as_path_set_member": ["10", "20", "30"] + } + ] + }, + "sonic-routing-policy-sets:EXTENDED_COMMUNITY_SET": { + "EXTENDED_COMMUNITY_SET_LIST": [ + { + "name": "extcomm" + }, + { + "name": "target_extcomm" + } + ] + } + }, + "sonic-route-map:sonic-route-map": { + "sonic-route-map:ROUTE_MAP_SET": { + "ROUTE_MAP_SET_LIST": [ + { + "name": "sub_map" + } + ] + }, "sonic-route-map:ROUTE_MAP": { "ROUTE_MAP_LIST": [ { "route_map_name": "map1", - "stmt_name": "1", + "stmt_name": 1, + "route_operation": "permit", + "match_interface": "Ethernet4", + "match_prefix_set": "abc", + "match_ipv6_prefix_set": "test_pfx", + "match_protocol": "bgp", + "match_next_hop_set": "nh_set", + "match_src_vrf": "default", + "match_neighbor": ["PortChannel100"], + "match_tag": [2000], "match_med": 100, - "set_metric": 50 + "match_origin": "STATIC", + "match_local_pref": 15, + "match_community": "comm", + "match_ext_community": "extcomm", + "match_as_path": "xyz", + "call_route_map": "sub_map", + "set_origin": "BGP", + "set_local_pref": 50, + "set_med": 234, + "set_metric_action": "METRIC_SET_VALUE", + "set_metric": 50, + "set_next_hop": "10.10.10.10", + "set_ipv6_next_hop_global": "1000::1", + "set_ipv6_next_hop_prefer_global": true, + "set_repeat_asn": 5, + "set_asn": 20, + "set_asn_list": "1,2,3", + "set_community_inline": ["5:6"], + "set_community_ref": "target_comm", + "set_ext_community_inline": ["soo:10:20", "rt:100:27"], + "set_ext_community_ref": "target_extcomm", + "set_tag": 300, + "set_weight": 2 + } + ] + } + } + }, + "ROUTE_MAP_INVALID_STMT": { + "sonic-route-map:sonic-route-map":{ + "sonic-route-map:ROUTE_MAP": { + "ROUTE_MAP_LIST": [ + { + "route_map_name": "map2", + "stmt_name": 10000000 + } + ] + } + } + }, + "ROUTE_MAP_INVALID_OPERATION_TYPE": { + "sonic-route-map:sonic-route-map":{ + "sonic-route-map:ROUTE_MAP": { + "ROUTE_MAP_LIST": [ + { + "route_map_name": "map3", + "stmt_name": 2, + "route_operation": "unknown" + } + ] + } + } + }, + "ROUTE_MAP_INVALID_MATCH_INTF": { + "sonic-route-map:sonic-route-map":{ + "sonic-route-map:ROUTE_MAP": { + "ROUTE_MAP_LIST": [ + { + "route_map_name": "map4", + "stmt_name": 4, + "match_interface": "eth100" + } + ] + } + } + }, + "ROUTE_MAP_INVALID_MATCH_PREFIX": { + "sonic-route-map:sonic-route-map":{ + "sonic-route-map:ROUTE_MAP": { + "ROUTE_MAP_LIST": [ + { + "route_map_name": "map5", + "stmt_name": 5, + "match_prefix_set": "test_pfx" + } + ] + } + } + }, + "ROUTE_MAP_INVALID_MATCH_SRC_VRF": { + "sonic-route-map:sonic-route-map":{ + "sonic-route-map:ROUTE_MAP": { + "ROUTE_MAP_LIST": [ + { + "route_map_name": "map6", + "stmt_name": 6, + "match_src_vrf": "Vrf_red" + } + ] + } + } + }, + "ROUTE_MAP_INVALID_MATCH_NEIGHBOR": { + "sonic-route-map:sonic-route-map":{ + "sonic-route-map:ROUTE_MAP": { + "ROUTE_MAP_LIST": [ + { + "route_map_name": "map7", + "stmt_name": 7, + "match_neighbor": ["efgh"] + } + ] + } + } + }, + "ROUTE_MAP_MATCH_NEIGHBOR_MUST_COND_FALSE": { + "sonic-route-map:sonic-route-map":{ + "sonic-route-map:ROUTE_MAP": { + "ROUTE_MAP_LIST": [ + { + "route_map_name": "map8", + "stmt_name": 8, + "match_neighbor": ["2.3.4.5", "10.1.1.1"] + } + ] + } + } + }, + "ROUTE_MAP_MATCH_TAG_MUST_COND_FALSE": { + "sonic-route-map:sonic-route-map":{ + "sonic-route-map:ROUTE_MAP": { + "ROUTE_MAP_LIST": [ + { + "route_map_name": "map9", + "stmt_name": 9, + "match_tag": [100, 200] + } + ] + } + } + }, + "ROUTE_MAP_INVALID_MATCH_COMMUNITY": { + "sonic-route-map:sonic-route-map":{ + "sonic-route-map:ROUTE_MAP": { + "ROUTE_MAP_LIST": [ + { + "route_map_name": "map10", + "stmt_name": 10, + "match_community": "non_existent_comm" + } + ] + } + } + }, + "ROUTE_MAP_INVALID_MATCH_AS_PATH": { + "sonic-route-map:sonic-route-map":{ + "sonic-route-map:ROUTE_MAP": { + "ROUTE_MAP_LIST": [ + { + "route_map_name": "map11", + "stmt_name": 11, + "match_as_path": "as_path_1" + } + ] + } + } + }, + "ROUTE_MAP_INVALID_CALL_ROUTE_MAP": { + "sonic-route-map:sonic-route-map":{ + "sonic-route-map:ROUTE_MAP": { + "ROUTE_MAP_LIST": [ + { + "route_map_name": "map12", + "stmt_name": 12, + "call_route_map": "rmap002" + } + ] + } + } + }, + "ROUTE_MAP_INVALID_SET_METRIC_ACTION": { + "sonic-route-map:sonic-route-map":{ + "sonic-route-map:ROUTE_MAP": { + "ROUTE_MAP_LIST": [ + { + "route_map_name": "map13", + "stmt_name": 13, + "set_metric_action": "METRIC_ADD_VALUE_0" + } + ] + } + } + }, + "ROUTE_MAP_INVALID_SET_EXT_COMMUNITY": { + "sonic-route-map:sonic-route-map":{ + "sonic-route-map:ROUTE_MAP": { + "ROUTE_MAP_LIST": [ + { + "route_map_name": "map14", + "stmt_name": 14, + "set_ext_community_ref": "null" } ] } @@ -50,14 +378,14 @@ "PREFIX_LIST": [ { "set_name": "prefix1", - "sequence_number": "10", + "sequence_number": 10, "ip_prefix": "20.0.0.0/8", "masklength_range": "8..16", "action": "permit" }, { "set_name": "prefix1", - "sequence_number": "11", + "sequence_number": 11, "ip_prefix": "21.0.0.0/8", "masklength_range": "exact", "action": "permit" @@ -66,6 +394,67 @@ } } }, + + "ROUTE_PREFIX_INVALID_MODE_ENUM": { + "sonic-routing-policy-sets:sonic-routing-policy-sets":{ + "sonic-routing-policy-sets:PREFIX_SET": { + "PREFIX_SET_LIST": [ + { + "name": "prefix1", + "mode": "IP" + } + ] + } + } + }, + "ROUTE_PREFIX_INVALID_SEQ_NO": { + "sonic-routing-policy-sets:sonic-routing-policy-sets":{ + "sonic-routing-policy-sets:PREFIX_SET": { + "PREFIX_SET_LIST": [ + { + "name": "prefix1", + "mode": "IPv6" + } + ] + }, + "sonic-routing-policy-sets:PREFIX": { + "PREFIX_LIST": [ + { + "set_name": "prefix1", + "sequence_number": "0", + "ip_prefix": "20.0.0.0/8", + "masklength_range": "8..16", + "action": "deny" + } + ] + } + } + }, + "ROUTE_PREFIX_INVALID_IP_PREFIX": { + "sonic-routing-policy-sets:sonic-routing-policy-sets":{ + "sonic-routing-policy-sets:PREFIX_SET": { + "PREFIX_SET_LIST": [ + { + "name": "prefix1", + "mode": "IPv6" + } + ] + }, + "sonic-routing-policy-sets:PREFIX": { + "PREFIX_LIST": [ + { + "set_name": "prefix1", + "sequence_number": 1, + "ip_prefix": "20.0.0.0.0/20", + "masklength_range": "8..16", + "action": "deny" + } + ] + } + } + }, + + "BGP_COMMUNITY_VALID": { "sonic-routing-policy-sets:sonic-routing-policy-sets":{ "sonic-routing-policy-sets:COMMUNITY_SET": { @@ -88,6 +477,23 @@ } } }, + + "BGP_COMMUNITY_INVALID_ACTION": { + "sonic-routing-policy-sets:sonic-routing-policy-sets":{ + "sonic-routing-policy-sets:COMMUNITY_SET": { + "COMMUNITY_SET_LIST": [ + { + "name": "com1", + "set_type": "STANDARD", + "match_action": "ANY", + "action": "allow", + "community_member": ["1:1"] + } + ] + } + } + }, + "BGP_EXT_COMMUNITY_VALID": { "sonic-routing-policy-sets:sonic-routing-policy-sets":{ "sonic-routing-policy-sets:EXTENDED_COMMUNITY_SET": { @@ -130,3 +536,5 @@ } } + + From cfd09bf06df6e495ab594bba6211d75daa680b72 Mon Sep 17 00:00:00 2001 From: Venkatesan Mahalingam Date: Thu, 15 Apr 2021 00:27:04 +0000 Subject: [PATCH 11/28] Addressed the review comments and added additional negative test cases. Signed-off-by: Venkatesan Mahalingam --- .../tests/yang_model_tests/tests/bgp.json | 22 ++++++++ .../yang_model_tests/tests/route_filter.json | 15 ++++++ .../tests_config/route_filter.json | 39 +++++++-------- .../yang-models/sonic-bgp-common.yang | 16 +++--- .../yang-models/sonic-bgp-global.yang | 45 +++++++++++++++++ .../yang-models/sonic-bgp-neighbor.yang | 3 +- .../yang-models/sonic-bgp-peergroup.yang | 3 ++ .../yang-models/sonic-route-common.yang | 11 ++-- .../yang-models/sonic-route-map.yang | 50 +++++++++++++------ .../sonic-routing-policy-sets.yang | 14 +++++- 10 files changed, 168 insertions(+), 50 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json b/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json index 5c239978d1c4..97f04161ab5e 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json @@ -115,6 +115,28 @@ "BGP_PEERGROUP_AF_ROUTE_MAP_NOT_EXIST": { "desc": "Missing or non-existent route-map reference in peergroup AF.", "eStrKey" : "LeafRef" + }, + "BGP_NEIGHBOR_AF_NEG_INVALID_MAP_IN": { + "desc": "Invalid route-map in count in neighbor AF.", + "eStr" : "Too many route_map_in elements" + }, + "BGP_NEIGHBOR_AF_NEG_INVALID_MAP_OUT": { + "desc": "Invalid route-map out count in neighbor AF.", + "eStr" : " Too many route_map_out elements" + }, + + "BGP_PEERGROUP_AF_NEG_INVALID_MAP_IN": { + "desc": "Invalid route-map in count in peergroup AF.", + "eStr" : "Too many route_map_in elements" + }, + "BGP_PEERGROUP_AF_NEG_INVALID_MAP_OUT": { + "desc": "Invalid route-map out count in peergroup AF.", + "eStr" : "Too many route_map_out elements" + }, + "BGP_NEIGHBOR_NEG_INVALID_HOPS": { + "desc": "Invalid TTL hops for unnumbered interface neigbhor.", + "eStr" : "Hops for connected neighbor cannot exceed 1" } + } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/route_filter.json b/src/sonic-yang-models/tests/yang_model_tests/tests/route_filter.json index 0e517600383f..da4e0dd2a2e1 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/route_filter.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/route_filter.json @@ -2,6 +2,12 @@ "ROUTE_REDISTRIBUTE_VALID": { "desc": "Configure route redistribution table." }, + + "ROUTE_REDISTRIBUTE_INVALID_RT_MAP_CNT": { + "desc": "Referring 2 route map, when 1 allowed", + "eStrKey" : "LeafRef" + }, + "ROUTE_REDISTRIBUTE_NON_EXIST_RT_MAP": { "desc": "Referring non-existing ROUTE_MAP table", "eStrKey" : "LeafRef" @@ -38,6 +44,10 @@ "eStrKey": "InvalidValue", "eStr": ["match_neighbor"] }, + "ROUTE_MAP_MATCH_NEIGHBOR_MUST_COND_FALSE": { + "desc": "Configure route map table with more than one match neighbor in list.", + "eStr": "Too many match_neighbor elements" + }, "ROUTE_MAP_INVALID_MATCH_COMMUNITY": { "desc": "Configure route map table with non-existent match community set name.", "eStrKey": "LeafRef" @@ -87,6 +97,11 @@ }, "BGP_AS_PATH_VALID": { "desc": "Configure BGP AS path table." + }, + "ROUTE_MAP_MATCH_TAG_MUST_COND_FALSE": { + "desc": "Configure route map table with more than one match tag in list.", + "eStr": "Too many match_tag elements" } + } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/route_filter.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/route_filter.json index 25e186ffb3c0..c599744142c3 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/route_filter.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/route_filter.json @@ -156,7 +156,7 @@ "sonic-route-map:ROUTE_MAP": { "ROUTE_MAP_LIST": [ { - "route_map_name": "map1", + "name": "map1", "stmt_name": 1, "route_operation": "permit", "match_interface": "Ethernet4", @@ -189,8 +189,7 @@ "set_community_ref": "target_comm", "set_ext_community_inline": ["soo:10:20", "rt:100:27"], "set_ext_community_ref": "target_extcomm", - "set_tag": 300, - "set_weight": 2 + "set_tag": 300 } ] } @@ -201,7 +200,7 @@ "sonic-route-map:ROUTE_MAP": { "ROUTE_MAP_LIST": [ { - "route_map_name": "map2", + "name": "map2", "stmt_name": 10000000 } ] @@ -213,7 +212,7 @@ "sonic-route-map:ROUTE_MAP": { "ROUTE_MAP_LIST": [ { - "route_map_name": "map3", + "name": "map3", "stmt_name": 2, "route_operation": "unknown" } @@ -226,7 +225,7 @@ "sonic-route-map:ROUTE_MAP": { "ROUTE_MAP_LIST": [ { - "route_map_name": "map4", + "name": "map4", "stmt_name": 4, "match_interface": "eth100" } @@ -239,7 +238,7 @@ "sonic-route-map:ROUTE_MAP": { "ROUTE_MAP_LIST": [ { - "route_map_name": "map5", + "name": "map5", "stmt_name": 5, "match_prefix_set": "test_pfx" } @@ -252,7 +251,7 @@ "sonic-route-map:ROUTE_MAP": { "ROUTE_MAP_LIST": [ { - "route_map_name": "map6", + "name": "map6", "stmt_name": 6, "match_src_vrf": "Vrf_red" } @@ -265,7 +264,7 @@ "sonic-route-map:ROUTE_MAP": { "ROUTE_MAP_LIST": [ { - "route_map_name": "map7", + "name": "map7", "stmt_name": 7, "match_neighbor": ["efgh"] } @@ -278,7 +277,7 @@ "sonic-route-map:ROUTE_MAP": { "ROUTE_MAP_LIST": [ { - "route_map_name": "map8", + "name": "map8", "stmt_name": 8, "match_neighbor": ["2.3.4.5", "10.1.1.1"] } @@ -291,7 +290,7 @@ "sonic-route-map:ROUTE_MAP": { "ROUTE_MAP_LIST": [ { - "route_map_name": "map9", + "name": "map9", "stmt_name": 9, "match_tag": [100, 200] } @@ -304,7 +303,7 @@ "sonic-route-map:ROUTE_MAP": { "ROUTE_MAP_LIST": [ { - "route_map_name": "map10", + "name": "map10", "stmt_name": 10, "match_community": "non_existent_comm" } @@ -317,7 +316,7 @@ "sonic-route-map:ROUTE_MAP": { "ROUTE_MAP_LIST": [ { - "route_map_name": "map11", + "name": "map11", "stmt_name": 11, "match_as_path": "as_path_1" } @@ -330,7 +329,7 @@ "sonic-route-map:ROUTE_MAP": { "ROUTE_MAP_LIST": [ { - "route_map_name": "map12", + "name": "map12", "stmt_name": 12, "call_route_map": "rmap002" } @@ -343,7 +342,7 @@ "sonic-route-map:ROUTE_MAP": { "ROUTE_MAP_LIST": [ { - "route_map_name": "map13", + "name": "map13", "stmt_name": 13, "set_metric_action": "METRIC_ADD_VALUE_0" } @@ -356,7 +355,7 @@ "sonic-route-map:ROUTE_MAP": { "ROUTE_MAP_LIST": [ { - "route_map_name": "map14", + "name": "map14", "stmt_name": 14, "set_ext_community_ref": "null" } @@ -377,14 +376,14 @@ "sonic-routing-policy-sets:PREFIX": { "PREFIX_LIST": [ { - "set_name": "prefix1", + "name": "prefix1", "sequence_number": 10, "ip_prefix": "20.0.0.0/8", "masklength_range": "8..16", "action": "permit" }, { - "set_name": "prefix1", + "name": "prefix1", "sequence_number": 11, "ip_prefix": "21.0.0.0/8", "masklength_range": "exact", @@ -420,7 +419,7 @@ "sonic-routing-policy-sets:PREFIX": { "PREFIX_LIST": [ { - "set_name": "prefix1", + "name": "prefix1", "sequence_number": "0", "ip_prefix": "20.0.0.0/8", "masklength_range": "8..16", @@ -443,7 +442,7 @@ "sonic-routing-policy-sets:PREFIX": { "PREFIX_LIST": [ { - "set_name": "prefix1", + "name": "prefix1", "sequence_number": 1, "ip_prefix": "20.0.0.0.0/20", "masklength_range": "8..16", diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-common.yang b/src/sonic-yang-models/yang-models/sonic-bgp-common.yang index 5e435bfba7f4..cfe775463afc 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-common.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-common.yang @@ -176,6 +176,7 @@ module sonic-bgp-common { leaf peer_type { type bgp_peer_type; + description "BGP peer type internal/external"; } leaf ebgp_multihop { @@ -391,20 +392,16 @@ module sonic-bgp-common { type leafref { path "/srmap:sonic-route-map/srmap:ROUTE_MAP_SET/srmap:ROUTE_MAP_SET_LIST/srmap:name"; } - must "(/cmn:operation/cmn:operation = 'DELETE') or (count(current()) = 1)" { - error-app-tag "max-allowed-route-map-reached"; - error-message "Only one route-map can be associated"; - } + description "Route-map filter for incoming routes"; + max-elements 1; } leaf-list route_map_out { type leafref { path "/srmap:sonic-route-map/srmap:ROUTE_MAP_SET/srmap:ROUTE_MAP_SET_LIST/srmap:name"; } - must "(/cmn:operation/cmn:operation = 'DELETE') or (count(current()) = 1)" { - error-app-tag "max-allowed-route-map-reached"; - error-message "Only one route-map can be associated"; - } + description "Route-map filter for outgoing routes"; + max-elements 1; } leaf soft_reconfiguration_in { @@ -428,14 +425,17 @@ module sonic-bgp-common { type uint16 { range 0..65535; } + description "Set default weight for routes from this neighbor"; } leaf as_override { type boolean; + description "Override ASNs in outbound updates if aspath equals remote-as"; } leaf send_community { type bgp_community_type; + description "Send Community attribute to this neighbor"; } leaf tx_add_paths { diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-global.yang b/src/sonic-yang-models/yang-models/sonic-bgp-global.yang index 974ad91a62c9..3ebd363ecf9b 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-global.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-global.yang @@ -55,28 +55,34 @@ module sonic-bgp-global { path "/svrf:sonic-vrf/svrf:VRF/svrf:VRF_LIST/svrf:vrf_name"; } } + description "VRF name"; } leaf router_id { type inet:ipv4-address; + description "Router identifier"; } leaf local_asn { type uint32 { range "1..4294967295"; } + description "local AS number"; } leaf always_compare_med { type boolean; + description "Allow comparing MED from different neighbors"; } leaf load_balance_mp_relax { type boolean; + description "Allow load sharing across routes that have different AS paths (but same length)"; } leaf graceful_restart_enable { type boolean; + description "Enable graceful restart"; } leaf gr_preserve_fw_state { @@ -89,48 +95,59 @@ module sonic-bgp-global { type uint16 { range "1..3600"; } + description "Set the time to wait to delete stale routes before a BGP open message is received"; } leaf gr_stale_routes_time { type uint16 { range "1..3600"; } + description "Set the max time to hold onto restarting peer's stale paths"; } leaf external_compare_router_id { type boolean; + description "Compare router-id for identical EBGP paths"; } leaf ignore_as_path_length { type boolean; + description "Ignore as-path length in selecting a route"; } leaf log_nbr_state_changes { type boolean; + description "Log neighbor up/down and reset reason"; } leaf rr_cluster_id { type string; + description "Route-Reflector Cluster-id"; } leaf rr_allow_out_policy { type boolean; + description "Allow modifications made by out route-map"; } leaf disable_ebgp_connected_rt_check { type boolean; + description "Disable checking if nexthop is connected on ebgp sessions"; } leaf fast_external_failover { type boolean; + description "Immediately reset session if a link to a directly connected external peer goes down"; } leaf network_import_check { type boolean; + description "Check BGP network route exists in IGP"; } leaf graceful_shutdown { type boolean; + description "Enable graceful shutdown"; } leaf rr_clnt_to_clnt_reflection { @@ -319,22 +336,28 @@ module sonic-bgp-global { type leafref { path "../../../BGP_GLOBALS/BGP_GLOBALS_LIST/vrf_name"; } + description "Vrf name"; } leaf afi_safi { type string; + description "Address family name and subsequent address family name"; } leaf max_ebgp_paths { type uint16 { range "1..256"; } + description "Maximum eBGP paths"; + default 1; } leaf max_ibgp_paths { type uint16 { range "1..256"; } + description "Maximum iBGP paths"; + default 1; } leaf import_vrf { @@ -349,36 +372,42 @@ module sonic-bgp-global { must "current() != current()/../vrf_name" { error-message "Import VRF should be different than self!"; } + description "Import routes from particular VRF"; } leaf import_vrf_route_map { type leafref { path "/srmap:sonic-route-map/srmap:ROUTE_MAP_SET/srmap:ROUTE_MAP_SET_LIST/srmap:name"; } + description "Import routes from VRF with route filter"; } leaf route_download_filter { type leafref { path "/srmap:sonic-route-map/srmap:ROUTE_MAP_SET/srmap:ROUTE_MAP_SET_LIST/srmap:name"; } + description "Route download filter"; } leaf ebgp_route_distance { type uint8 { range "1..255"; } + description "Distance for routes external to the AS"; } leaf ibgp_route_distance { type uint8 { range "1..255"; } + description "Distance for routes internal to the AS"; } leaf local_route_distance { type uint8 { range "1..255"; } + description "Distance for local routes"; } leaf ibgp_equal_cluster_length { @@ -390,6 +419,7 @@ module sonic-bgp-global { leaf route_flap_dampen { must "current()/../afi_safi = 'ipv4_unicast'" { error-message "Route flap dampening is supported only for IPv4 address family!"; } type boolean; + description "Enable route-flap dampening"; } leaf route_flap_dampen_half_life { @@ -397,6 +427,7 @@ module sonic-bgp-global { type uint8 { range "1..45"; } + description "Half-life time for the penalty"; } leaf route_flap_dampen_reuse_threshold { @@ -404,6 +435,7 @@ module sonic-bgp-global { type uint16 { range "1..20000"; } + description "Value to start reusing a route"; } leaf route_flap_dampen_suppress_threshold { @@ -411,6 +443,7 @@ module sonic-bgp-global { type uint16 { range "1..20000"; } + description "Value to start suppressing a route"; } leaf route_flap_dampen_max_suppress { @@ -418,6 +451,7 @@ module sonic-bgp-global { type uint8 { range "1..255"; } + description "Maximum duration to suppress a stable route"; } } } @@ -430,28 +464,34 @@ module sonic-bgp-global { type leafref { path "../../../BGP_GLOBALS/BGP_GLOBALS_LIST/vrf_name"; } + description "VRF name"; } leaf afi_safi { type string; + description "Address family name and subsequent address family name"; } leaf ip_prefix { type inet:ip-prefix; + description "Aggregate address"; } leaf as_set { type boolean; + description "Generate AS set path information"; } leaf summary_only { type boolean; + description "Filter more specific routes from updates"; } leaf policy { type leafref { path "/srmap:sonic-route-map/srmap:ROUTE_MAP_SET/srmap:ROUTE_MAP_SET_LIST/srmap:name"; } + description "Apply route map to aggregate network"; } } } @@ -464,25 +504,30 @@ module sonic-bgp-global { type leafref { path "../../../BGP_GLOBALS/BGP_GLOBALS_LIST/vrf_name"; } + description "VRF name"; } leaf afi_safi { type string; + description "Address family name and subsequent address family name"; } leaf ip_prefix { type inet:ip-prefix; + description "Network address"; } leaf policy { type leafref { path "/srmap:sonic-route-map/srmap:ROUTE_MAP_SET/srmap:ROUTE_MAP_SET_LIST/srmap:name"; } + description "Route-map to modify the attributes"; } leaf backdoor { type boolean; sonic-ext:custom-validation ValidateAfisafiForBackdoor; + description "Indicates the backdoor route"; } } } diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang b/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang index 7a0c99ad7a48..ad82d2b7cd5e 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang @@ -70,7 +70,7 @@ module sonic-bgp-neighbor { path "/svlan:sonic-vlan/svlan:VLAN/svlan:VLAN_LIST/svlan:name"; } } - description "Neighbor description, it will be neighbor address or interface name"; + description "BGP Neighbor, it will be neighbor address or interface name"; } leaf peer_group_name { @@ -99,6 +99,7 @@ module sonic-bgp-neighbor { type leafref { path "../../../BGP_NEIGHBOR/BGP_NEIGHBOR_LIST[vrf_name=current()/../vrf_name]/neighbor"; } + description "BGP Neighbor, it will be neighbor address or interface name"; } uses sbc:sonic-bgp-cmn-af; } diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-peergroup.yang b/src/sonic-yang-models/yang-models/sonic-bgp-peergroup.yang index a5875049d46d..8abe69b1c53f 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-peergroup.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-peergroup.yang @@ -64,6 +64,7 @@ module sonic-bgp-peergroup { type leafref { path "../../../BGP_PEER_GROUP/BGP_PEER_GROUP_LIST[vrf_name=current()/../vrf_name]/peer_group_name"; } + description "Peer group name"; } uses sbc:sonic-bgp-cmn-af; @@ -78,10 +79,12 @@ module sonic-bgp-peergroup { type leafref { path "/sbgpg:sonic-bgp-global/sbgpg:BGP_GLOBALS/sbgpg:BGP_GLOBALS_LIST/sbgpg:vrf_name"; } + description "Network-instance/VRF name"; } leaf ip_prefix { type inet:ip-prefix; + description "Configure BGP dynamic neighbors listen range"; } leaf peer_group { diff --git a/src/sonic-yang-models/yang-models/sonic-route-common.yang b/src/sonic-yang-models/yang-models/sonic-route-common.yang index b98c27f518fb..558c1ea0a26b 100644 --- a/src/sonic-yang-models/yang-models/sonic-route-common.yang +++ b/src/sonic-yang-models/yang-models/sonic-route-common.yang @@ -43,32 +43,35 @@ module sonic-route-common { path "/svrf:sonic-vrf/svrf:VRF/svrf:VRF_LIST/svrf:vrf_name"; } } + description "VRF name"; } leaf src_protocol { type string; + description "IP protocols such as connected, ospf and static"; } leaf dst_protocol { type string; + description "IP protocol such as bgp"; } leaf addr_family { type string; + description "Address family ipv4/ipv6"; } leaf-list route_map { type leafref { path "/srmap:sonic-route-map/srmap:ROUTE_MAP_SET/srmap:ROUTE_MAP_SET_LIST/srmap:name"; } - must "(/cmn:operation/cmn:operation = 'DELETE') or (count(current()) = 1)" { - error-app-tag "max-allowed-route-map-reached"; - error-message "Only one route-map can be associated"; - } + max-elements 1; + description "Router filter to apply while redistributing the routes from another protocol."; } leaf metric { type uint32; + description "Metric for redistributed routes"; } } } diff --git a/src/sonic-yang-models/yang-models/sonic-route-map.yang b/src/sonic-yang-models/yang-models/sonic-route-map.yang index 91a78c0c1f7b..b0530bf93d27 100644 --- a/src/sonic-yang-models/yang-models/sonic-route-map.yang +++ b/src/sonic-yang-models/yang-models/sonic-route-map.yang @@ -125,30 +125,36 @@ module sonic-route-map { leaf name { type string; + description "Route map name"; } } } container ROUTE_MAP { list ROUTE_MAP_LIST { - key "route_map_name stmt_name"; + key "name stmt_name"; - leaf route_map_name { + leaf name { type string; + description "Route map name"; } leaf stmt_name { type uint16 { range 1..65535; } + description "Statement name, this helps to provide multiple statements + under a particular route-map"; } leaf route_operation { type srpolsets:routing-policy-action-type; + description "permit/deny operation"; } leaf match_interface{ type route-map-intf; + description "Match based on interface"; } leaf match_prefix_set{ @@ -169,12 +175,14 @@ module sonic-route-map { leaf match_protocol { type string; + description "Match based on IP protocols bgp, connected, ospf, ospf3 and static"; } leaf match_next_hop_set { type leafref { path "/srpolsets:sonic-routing-policy-sets/srpolsets:PREFIX_SET/srpolsets:PREFIX_SET_LIST/srpolsets:name"; } + description "Match based on nexthop"; } leaf match_src_vrf { @@ -186,6 +194,7 @@ module sonic-route-map { path "/svrf:sonic-vrf/svrf:VRF/svrf:VRF_LIST/svrf:vrf_name"; } } + description "Match based on source VRF"; } leaf-list match_neighbor { @@ -203,71 +212,76 @@ module sonic-route-map { } description "IP addresse or interface for match operation."; - must "(/cmn:operation/cmn:operation = 'DELETE') or (count(current()) = 1)" { - error-app-tag "max-allowed-neighbor-reached"; - error-message "Only one neighbor or interface can be configured."; - } + max-elements 1; } leaf-list match_tag { type uint32; description "Value of the tag match member"; - must "(/cmn:operation/cmn:operation = 'DELETE') or (count(current()) = 1)" { - error-app-tag "max-allowed-tag-reached"; - error-message "Only one tag value can be configured."; - } + max-elements 1; } leaf match_med{ type uint32; + description "Match based on MED value"; } leaf match_origin{ type string; + description "Match based on BGP route origin egp, igp and incomplete"; } leaf match_local_pref{ type uint32; + description "Match based on BGP local preference value"; } leaf match_community{ type leafref { path "/srpolsets:sonic-routing-policy-sets/srpolsets:COMMUNITY_SET/srpolsets:COMMUNITY_SET_LIST/srpolsets:name"; } + description "Match based on community value"; } leaf match_ext_community{ type leafref { path "/srpolsets:sonic-routing-policy-sets/srpolsets:EXTENDED_COMMUNITY_SET/srpolsets:EXTENDED_COMMUNITY_SET_LIST/srpolsets:name"; } + description "Match based on extended community value"; } leaf match_as_path{ type leafref { path "/srpolsets:sonic-routing-policy-sets/srpolsets:AS_PATH_SET/srpolsets:AS_PATH_SET_LIST/srpolsets:name"; } + description "Match based on BGP AS-PATH"; } leaf call_route_map { type leafref { path "../../../ROUTE_MAP_SET/ROUTE_MAP_SET_LIST/name"; } + description "Invoke another route-map"; } leaf set_origin{ type string; + description "Set BGP origin value"; } leaf set_local_pref{ type uint32; + description "Set BGP local preference value"; } leaf set_med { type uint32; + description "Set BGP MED value"; } leaf set_metric_action { type metric-action-type; + description "Set metric action"; } leaf set_metric { @@ -277,50 +291,61 @@ module sonic-route-map { "or ../set_metric_action = 'METRIC_SUBTRACT_VALUE'"; */ type uint32; + description "Set metric value"; } leaf set_next_hop{ type string; + description "Set IP nexthop"; } leaf set_ipv6_next_hop_global { type string; + description "Set IPv6 global next hop"; } leaf set_ipv6_next_hop_prefer_global { type boolean; + description "Set to prefer IPv6 nexthop global address"; } leaf set_repeat_asn{ type uint8; + description "Indicates number of times the ASN value to be repeated"; } leaf set_asn{ type uint32; + description "Set ASN value"; } leaf set_asn_list{ type string; + description "Set list of ASN values"; } leaf-list set_community_inline { type string; + description "Set community string"; } leaf set_community_ref { type leafref { path "/srpolsets:sonic-routing-policy-sets/srpolsets:COMMUNITY_SET/srpolsets:COMMUNITY_SET_LIST/srpolsets:name"; } + description "Refer community from community list"; } leaf-list set_ext_community_inline { type string; + description "Set extended community string"; } leaf set_ext_community_ref { type leafref { path "/srpolsets:sonic-routing-policy-sets/srpolsets:EXTENDED_COMMUNITY_SET/srpolsets:EXTENDED_COMMUNITY_SET_LIST/srpolsets:name"; } + description "Refer extended community from extended community list"; } leaf set_tag { @@ -328,11 +353,6 @@ module sonic-route-map { description "Value of the tag set member"; } - - leaf set_weight{ - type uint32; - } - } } } diff --git a/src/sonic-yang-models/yang-models/sonic-routing-policy-sets.yang b/src/sonic-yang-models/yang-models/sonic-routing-policy-sets.yang index f87e780a2a77..94c9ae5ffee7 100644 --- a/src/sonic-yang-models/yang-models/sonic-routing-policy-sets.yang +++ b/src/sonic-yang-models/yang-models/sonic-routing-policy-sets.yang @@ -47,6 +47,7 @@ module sonic-routing-policy-sets { leaf name { type string; + description "Prefix name"; } leaf mode { @@ -54,6 +55,7 @@ module sonic-routing-policy-sets { enum IPv4; enum IPv6; } + description "Address family of the prefix"; } } } @@ -61,13 +63,14 @@ module sonic-routing-policy-sets { container PREFIX { list PREFIX_LIST { - key "set_name sequence_number ip_prefix masklength_range"; + key "name sequence_number ip_prefix masklength_range"; sonic-ext:custom-validation ValidateIpPrefixListCfg; - leaf set_name { + leaf name { type leafref { path "../../../PREFIX_SET/PREFIX_SET_LIST/name"; } + description "Prefix name"; } leaf sequence_number { @@ -120,6 +123,7 @@ module sonic-routing-policy-sets { leaf name { type string; + description "Community name"; } leaf set_type { @@ -127,6 +131,7 @@ module sonic-routing-policy-sets { enum STANDARD; enum EXPANDED; } + description "Community type"; } leaf match_action { @@ -134,6 +139,7 @@ module sonic-routing-policy-sets { enum ANY; enum ALL; } + description "Match action any/all"; } leaf action { @@ -157,6 +163,7 @@ module sonic-routing-policy-sets { leaf name { type string; + description "Extended community name"; } leaf set_type { @@ -164,6 +171,7 @@ module sonic-routing-policy-sets { enum STANDARD; enum EXPANDED; } + description "Extended community type"; } leaf match_action { @@ -171,6 +179,7 @@ module sonic-routing-policy-sets { enum ANY; enum ALL; } + description "Match action any/all"; } leaf action { @@ -194,6 +203,7 @@ module sonic-routing-policy-sets { leaf name { type string; + description "AS PATH name"; } leaf action { From 68cabce7b05d429527c5bb6d50587c203340796a Mon Sep 17 00:00:00 2001 From: Venkatesan Mahalingam Date: Mon, 19 Apr 2021 18:33:43 +0000 Subject: [PATCH 12/28] Updated the leaf references for VRF table key name change. Signed-off-by: Venkatesan Mahalingam --- .../tests/yang_model_tests/tests_config/bgp.json | 8 ++++---- src/sonic-yang-models/yang-models/sonic-bgp-global.yang | 2 +- src/sonic-yang-models/yang-models/sonic-route-common.yang | 2 +- src/sonic-yang-models/yang-models/sonic-route-map.yang | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json index a3263fac84af..baa06aa819a5 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json @@ -4,7 +4,7 @@ "sonic-vrf:VRF": { "VRF_LIST": [ { - "vrf_name":"Vrf1" + "name":"Vrf1" } ] } @@ -16,7 +16,7 @@ "sonic-vrf:VRF": { "VRF_LIST": [ { - "vrf_name":"Vrf1" + "name":"Vrf1" } ] } @@ -123,7 +123,7 @@ "sonic-vrf:VRF": { "VRF_LIST": [ { - "vrf_name":"Vrf1" + "name":"Vrf1" } ] } @@ -267,7 +267,7 @@ "sonic-vrf:VRF": { "VRF_LIST": [ { - "vrf_name":"Vrf1" + "name":"Vrf1" } ] } diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-global.yang b/src/sonic-yang-models/yang-models/sonic-bgp-global.yang index 3ebd363ecf9b..683f6314b727 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-global.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-global.yang @@ -52,7 +52,7 @@ module sonic-bgp-global { pattern "default"; } type leafref { - path "/svrf:sonic-vrf/svrf:VRF/svrf:VRF_LIST/svrf:vrf_name"; + path "/svrf:sonic-vrf/svrf:VRF/svrf:VRF_LIST/svrf:name"; } } description "VRF name"; diff --git a/src/sonic-yang-models/yang-models/sonic-route-common.yang b/src/sonic-yang-models/yang-models/sonic-route-common.yang index 558c1ea0a26b..631e8a89b5d0 100644 --- a/src/sonic-yang-models/yang-models/sonic-route-common.yang +++ b/src/sonic-yang-models/yang-models/sonic-route-common.yang @@ -40,7 +40,7 @@ module sonic-route-common { pattern "default"; } type leafref { - path "/svrf:sonic-vrf/svrf:VRF/svrf:VRF_LIST/svrf:vrf_name"; + path "/svrf:sonic-vrf/svrf:VRF/svrf:VRF_LIST/svrf:name"; } } description "VRF name"; diff --git a/src/sonic-yang-models/yang-models/sonic-route-map.yang b/src/sonic-yang-models/yang-models/sonic-route-map.yang index b0530bf93d27..453541c83fc4 100644 --- a/src/sonic-yang-models/yang-models/sonic-route-map.yang +++ b/src/sonic-yang-models/yang-models/sonic-route-map.yang @@ -191,7 +191,7 @@ module sonic-route-map { pattern "default"; } type leafref { - path "/svrf:sonic-vrf/svrf:VRF/svrf:VRF_LIST/svrf:vrf_name"; + path "/svrf:sonic-vrf/svrf:VRF/svrf:VRF_LIST/svrf:name"; } } description "Match based on source VRF"; From aed0a1610742a402483ea27c918d85b5a0f4573d Mon Sep 17 00:00:00 2001 From: Venkatesan Mahalingam Date: Tue, 20 Apr 2021 04:29:02 +0000 Subject: [PATCH 13/28] Fixed the build error. Signed-off-by: Venkatesan Mahalingam --- src/sonic-yang-models/tests/files/sample_config_db.json | 4 ---- 1 file changed, 4 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 3f8bf5fb4fc6..5d38bafb8715 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -695,10 +695,6 @@ "polling_interval": "0" } }, - "VRF": { - "Vrf1": { - } - }, "BGP_GLOBALS": { "default": { "router_id": "5.5.5.5", From e87037b23534dc15341d57aed7b6774a236302ce Mon Sep 17 00:00:00 2001 From: Venkatesan Mahalingam Date: Wed, 21 Apr 2021 03:55:19 +0000 Subject: [PATCH 14/28] Comment addressed. Signed-off-by: Venkatesan Mahalingam --- src/sonic-yang-models/yang-models/sonic-bgp-common.yang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-common.yang b/src/sonic-yang-models/yang-models/sonic-bgp-common.yang index cfe775463afc..3354f9e9120d 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-common.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-common.yang @@ -349,7 +349,7 @@ module sonic-bgp-common { leaf admin_status { type boolean; - description "Enabled status"; + description "Indicates address family active/inactive status"; } leaf send_default_route { From 075d7603e20c13446e18d551195f4f2134e921e8 Mon Sep 17 00:00:00 2001 From: Venkatesan Mahalingam Date: Thu, 6 May 2021 16:43:41 +0000 Subject: [PATCH 15/28] Added UT fix and updated bgp common YANG to avoid build errors. Signed-off-by: Venkatesan Mahalingam --- src/sonic-yang-models/tests/test_sonic_yang_models.py | 5 ++++- src/sonic-yang-models/yang-models/sonic-bgp-common.yang | 3 --- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sonic-yang-models/tests/test_sonic_yang_models.py b/src/sonic-yang-models/tests/test_sonic_yang_models.py index e5b801a94cb5..6db0c1b5678a 100644 --- a/src/sonic-yang-models/tests/test_sonic_yang_models.py +++ b/src/sonic-yang-models/tests/test_sonic_yang_models.py @@ -24,9 +24,12 @@ def test_content(response): def test_generate_yang_tree(): # Generate YANG Tree, see no error in it. - pyang_tree_cmd = "pyang -f tree ./yang-models/*.yang > ./yang-models/sonic_yang_tree" + pyang_tree_cmd = "pyang -Vf tree -p /usr/local/share/yang/modules/ietf ./yang-models/*.yang > ./yang-models/sonic_yang_tree" if (system(pyang_tree_cmd)): print("Failed: {}".format(pyang_tree_cmd)) + system("pyang --version") + system("env") + system("ls -l /usr/local/share/yang/modules/ietf/") exit(1) else: print("Passed: {}".format(pyang_tree_cmd)) diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-common.yang b/src/sonic-yang-models/yang-models/sonic-bgp-common.yang index 3354f9e9120d..340f87b89ddf 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-common.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-common.yang @@ -269,9 +269,6 @@ module sonic-bgp-common { type uint8 { range 1..254; } - must "((current() = 1 and (starts-with(current()/../neighbor, 'Eth') or starts-with(current()/../neighbor, 'Po') or starts-with(current()/../neighbor, 'Vlan'))) or (not(starts-with(current()/../neighbor, 'Eth') or starts-with(current()/../neighbor, 'Po') or starts-with(current()/../neighbor, 'Vlan'))))" { - error-message "Hops for connected neighbor cannot exceed 1"; - } description "TTL"; } From b52b0b84b05f524c1f7a26bb1accdc7e5fd9a2ff Mon Sep 17 00:00:00 2001 From: Venkatesan Mahalingam Date: Fri, 7 May 2021 03:20:57 +0000 Subject: [PATCH 16/28] Fixed the build errors. Signed-off-by: Venkatesan Mahalingam --- src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json | 2 +- .../tests/yang_model_tests/tests_config/bgp.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json b/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json index 97f04161ab5e..2fb315752965 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json @@ -135,7 +135,7 @@ }, "BGP_NEIGHBOR_NEG_INVALID_HOPS": { "desc": "Invalid TTL hops for unnumbered interface neigbhor.", - "eStr" : "Hops for connected neighbor cannot exceed 1" + "eStrKey" : "Pattern" } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json index baa06aa819a5..1b586ed83767 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json @@ -554,6 +554,7 @@ { "admin_status": "up", "alias": "eth0", + "lanes": "65", "name": "Ethernet0" } ] @@ -578,7 +579,7 @@ "local_asn": 1, "name": "BGP nbr 1", "asn": 65003, - "ttl_security_hops": 2 + "ttl_security_hops": 255 } ] } From 6e9ea10a5f12fc34f0c657fda661294512527d7f Mon Sep 17 00:00:00 2001 From: Venkatesan Mahalingam Date: Thu, 13 May 2021 00:39:10 +0000 Subject: [PATCH 17/28] Comments addressed. Signed-off-by: Venkatesan Mahalingam --- .../tests/yang_model_tests/tests/bgp.json | 3 --- .../yang_model_tests/tests_config/bgp.json | 12 ---------- .../yang-models/sonic-bgp-common.yang | 12 +++++----- .../yang-models/sonic-bgp-global.yang | 4 ++-- .../yang-models/sonic-bgp-neighbor.yang | 12 +++++----- .../yang-models/sonic-route-common.yang | 4 ++-- .../yang-models/sonic-route-map.yang | 22 +++++++++---------- 7 files changed, 27 insertions(+), 42 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json b/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json index 2fb315752965..596a3343e53d 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json @@ -1,7 +1,4 @@ { - "VRF_VALID": { - "desc": "Configure VRF table." - }, "BGP_GLOBAL_VALID": { "desc": "Configure BGP global table." }, diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json index 1b586ed83767..d537c97c9c53 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json @@ -1,16 +1,4 @@ { - "VRF_VALID": { - "sonic-vrf:sonic-vrf":{ - "sonic-vrf:VRF": { - "VRF_LIST": [ - { - "name":"Vrf1" - } - ] - } - } - }, - "BGP_GLOBAL_VALID": { "sonic-vrf:sonic-vrf":{ "sonic-vrf:VRF": { diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-common.yang b/src/sonic-yang-models/yang-models/sonic-bgp-common.yang index 340f87b89ddf..fb3e3c6b7852 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-common.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-common.yang @@ -8,15 +8,15 @@ module sonic-bgp-common { } import sonic-port { - prefix prt; + prefix port; } import sonic-portchannel { - prefix spc; + prefix lag; } import sonic-vlan { - prefix svlan; + prefix vlan; } import sonic-loopback-interface { @@ -224,13 +224,13 @@ module sonic-bgp-common { type union { type inet:ip-address; type leafref { - path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:name"; + path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name"; } type leafref { - path "/spc:sonic-portchannel/spc:PORTCHANNEL/spc:PORTCHANNEL_LIST/spc:name"; + path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; } type leafref { - path "/svlan:sonic-vlan/svlan:VLAN/svlan:VLAN_LIST/svlan:name"; + path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; } type leafref { path "/lo:sonic-loopback-interface/lo:LOOPBACK_INTERFACE/lo:LOOPBACK_INTERFACE_LIST/lo:name"; diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-global.yang b/src/sonic-yang-models/yang-models/sonic-bgp-global.yang index 683f6314b727..df0a442af5c9 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-global.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-global.yang @@ -4,7 +4,7 @@ module sonic-bgp-global { yang-version 1.1; import sonic-vrf { - prefix svrf; + prefix vrf; } import ietf-inet-types { @@ -52,7 +52,7 @@ module sonic-bgp-global { pattern "default"; } type leafref { - path "/svrf:sonic-vrf/svrf:VRF/svrf:VRF_LIST/svrf:name"; + path "/vrf:sonic-vrf/vrf:VRF/vrf:VRF_LIST/vrf:name"; } } description "VRF name"; diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang b/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang index ad82d2b7cd5e..c9357b1fb30a 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang @@ -12,15 +12,15 @@ module sonic-bgp-neighbor { } import sonic-port { - prefix prt; + prefix port; } import sonic-portchannel { - prefix spc; + prefix lag; } import sonic-vlan { - prefix svlan; + prefix vlan; } import sonic-bgp-global { @@ -61,13 +61,13 @@ module sonic-bgp-neighbor { type union { type inet:ip-address; type leafref { - path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:name"; + path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name"; } type leafref { - path "/spc:sonic-portchannel/spc:PORTCHANNEL/spc:PORTCHANNEL_LIST/spc:name"; + path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; } type leafref { - path "/svlan:sonic-vlan/svlan:VLAN/svlan:VLAN_LIST/svlan:name"; + path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; } } description "BGP Neighbor, it will be neighbor address or interface name"; diff --git a/src/sonic-yang-models/yang-models/sonic-route-common.yang b/src/sonic-yang-models/yang-models/sonic-route-common.yang index 631e8a89b5d0..174dfd3e1bb2 100644 --- a/src/sonic-yang-models/yang-models/sonic-route-common.yang +++ b/src/sonic-yang-models/yang-models/sonic-route-common.yang @@ -4,7 +4,7 @@ module sonic-route-common { yang-version 1.1; import sonic-vrf { - prefix svrf; + prefix vrf; } import sonic-route-map { @@ -40,7 +40,7 @@ module sonic-route-common { pattern "default"; } type leafref { - path "/svrf:sonic-vrf/svrf:VRF/svrf:VRF_LIST/svrf:name"; + path "/vrf:sonic-vrf/vrf:VRF/vrf:VRF_LIST/vrf:name"; } } description "VRF name"; diff --git a/src/sonic-yang-models/yang-models/sonic-route-map.yang b/src/sonic-yang-models/yang-models/sonic-route-map.yang index 453541c83fc4..031d60923a08 100644 --- a/src/sonic-yang-models/yang-models/sonic-route-map.yang +++ b/src/sonic-yang-models/yang-models/sonic-route-map.yang @@ -12,11 +12,11 @@ module sonic-route-map { } import sonic-port { - prefix prt; + prefix port; } import sonic-portchannel { - prefix spc; + prefix lag; } import sonic-routing-policy-sets { @@ -24,11 +24,11 @@ module sonic-route-map { } import sonic-vlan { - prefix svlan; + prefix vlan; } import sonic-vrf { - prefix svrf; + prefix vrf; } import sonic-interface { @@ -52,13 +52,13 @@ module sonic-route-map { typedef route-map-intf { type union { type leafref { - path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:name"; + path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name"; } type leafref { - path "/spc:sonic-portchannel/spc:PORTCHANNEL/spc:PORTCHANNEL_LIST/spc:name"; + path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; } type leafref { - path "/svlan:sonic-vlan/svlan:VLAN/svlan:VLAN_LIST/svlan:name"; + path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; } } } @@ -191,7 +191,7 @@ module sonic-route-map { pattern "default"; } type leafref { - path "/svrf:sonic-vrf/svrf:VRF/svrf:VRF_LIST/svrf:name"; + path "/vrf:sonic-vrf/vrf:VRF/vrf:VRF_LIST/vrf:name"; } } description "Match based on source VRF"; @@ -201,13 +201,13 @@ module sonic-route-map { type union { type inet:ip-address; type leafref { - path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:name"; + path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name"; } type leafref { - path "/spc:sonic-portchannel/spc:PORTCHANNEL/spc:PORTCHANNEL_LIST/spc:name"; + path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; } type leafref { - path "/svlan:sonic-vlan/svlan:VLAN/svlan:VLAN_LIST/svlan:name"; + path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; } } description From bf177226d68d267270c5b73e83c141d7aaab37c7 Mon Sep 17 00:00:00 2001 From: Venkatesan Mahalingam Date: Thu, 13 May 2021 02:12:53 +0000 Subject: [PATCH 18/28] Comments addressed. Signed-off-by: Venkatesan Mahalingam --- .../yang-models/sonic-bgp-common.yang | 44 +++++++------------ .../yang-models/sonic-bgp-global.yang | 26 ++++------- .../yang-models/sonic-bgp-neighbor.yang | 18 ++++---- .../yang-models/sonic-bgp-peergroup.yang | 14 +++--- .../yang-models/sonic-route-common.yang | 10 ++--- .../yang-models/sonic-route-map.yang | 30 +++++-------- .../sonic-routing-policy-sets.yang | 6 +-- 7 files changed, 58 insertions(+), 90 deletions(-) diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-common.yang b/src/sonic-yang-models/yang-models/sonic-bgp-common.yang index fb3e3c6b7852..112746bb2503 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-common.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-common.yang @@ -1,6 +1,6 @@ module sonic-bgp-common { namespace "http://github.com/Azure/sonic-bgp-common"; - prefix sbc; + prefix bgpcmn; yang-version 1.1; import ietf-inet-types { @@ -20,31 +20,19 @@ module sonic-bgp-common { } import sonic-loopback-interface { - prefix lo; + prefix lointf; } import sonic-routing-policy-sets { - prefix srpolsets; + prefix rpolsets; } import sonic-route-map { - prefix srmap; - } - - import sonic-types { - prefix cmn; - } - - import ietf-yang-types { - prefix ietf-yang; - } - - import sonic-interface { - prefix sintf; + prefix rmap; } import sonic-extension { - prefix sonic-ext; + prefix ext; } organization @@ -233,7 +221,7 @@ module sonic-bgp-common { path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; } type leafref { - path "/lo:sonic-loopback-interface/lo:LOOPBACK_INTERFACE/lo:LOOPBACK_INTERFACE_LIST/lo:name"; + path "/lointf:sonic-loopback-interface/lointf:LOOPBACK_INTERFACE/lointf:LOOPBACK_INTERFACE_LIST/lointf:name"; } } description "Local source address or interface name to use for connection."; @@ -252,7 +240,7 @@ module sonic-bgp-common { leaf disable_ebgp_connected_route_check { type boolean; description "Connected checked disabled"; - sonic-ext:custom-validation ValidateDisableConnectedCheck; + ext:custom-validation ValidateDisableConnectedCheck; } leaf enforce_first_as { @@ -316,7 +304,7 @@ module sonic-bgp-common { leaf strict_capability_match { type boolean; - sonic-ext:custom-validation ValidateStrictAndOverRideCapability; + ext:custom-validation ValidateStrictAndOverRideCapability; description "Strict capability negotiation match"; } @@ -356,7 +344,7 @@ module sonic-bgp-common { leaf default_rmap { type leafref { - path "/srmap:sonic-route-map/srmap:ROUTE_MAP_SET/srmap:ROUTE_MAP_SET_LIST/srmap:name"; + path "/rmap:sonic-route-map/rmap:ROUTE_MAP_SET/rmap:ROUTE_MAP_SET_LIST/rmap:name"; } description "Default route map to originate"; } @@ -387,7 +375,7 @@ module sonic-bgp-common { leaf-list route_map_in { type leafref { - path "/srmap:sonic-route-map/srmap:ROUTE_MAP_SET/srmap:ROUTE_MAP_SET_LIST/srmap:name"; + path "/rmap:sonic-route-map/rmap:ROUTE_MAP_SET/rmap:ROUTE_MAP_SET_LIST/rmap:name"; } description "Route-map filter for incoming routes"; max-elements 1; @@ -395,7 +383,7 @@ module sonic-bgp-common { leaf-list route_map_out { type leafref { - path "/srmap:sonic-route-map/srmap:ROUTE_MAP_SET/srmap:ROUTE_MAP_SET_LIST/srmap:name"; + path "/rmap:sonic-route-map/rmap:ROUTE_MAP_SET/rmap:ROUTE_MAP_SET_LIST/rmap:name"; } description "Route-map filter for outgoing routes"; max-elements 1; @@ -408,7 +396,7 @@ module sonic-bgp-common { leaf unsuppress_map_name { type leafref { - path "/srmap:sonic-route-map/srmap:ROUTE_MAP_SET/srmap:ROUTE_MAP_SET_LIST/srmap:name"; + path "/rmap:sonic-route-map/rmap:ROUTE_MAP_SET/rmap:ROUTE_MAP_SET_LIST/rmap:name"; } description "Route map"; } @@ -457,14 +445,14 @@ module sonic-bgp-common { leaf filter_list_in { type leafref { - path "/srpolsets:sonic-routing-policy-sets/srpolsets:AS_PATH_SET/srpolsets:AS_PATH_SET_LIST/srpolsets:name"; + path "/rpolsets:sonic-routing-policy-sets/rpolsets:AS_PATH_SET/rpolsets:AS_PATH_SET_LIST/rpolsets:name"; } description "Filter list name"; } leaf filter_list_out { type leafref { - path "/srpolsets:sonic-routing-policy-sets/srpolsets:AS_PATH_SET/srpolsets:AS_PATH_SET_LIST/srpolsets:name"; + path "/rpolsets:sonic-routing-policy-sets/rpolsets:AS_PATH_SET/rpolsets:AS_PATH_SET_LIST/rpolsets:name"; } description "Filter list name"; } @@ -481,14 +469,14 @@ module sonic-bgp-common { leaf prefix_list_in { type leafref { - path "/srpolsets:sonic-routing-policy-sets/srpolsets:PREFIX_SET/srpolsets:PREFIX_SET_LIST/srpolsets:name"; + path "/rpolsets:sonic-routing-policy-sets/rpolsets:PREFIX_SET/rpolsets:PREFIX_SET_LIST/rpolsets:name"; } description "Prefix list name"; } leaf prefix_list_out { type leafref { - path "/srpolsets:sonic-routing-policy-sets/srpolsets:PREFIX_SET/srpolsets:PREFIX_SET_LIST/srpolsets:name"; + path "/rpolsets:sonic-routing-policy-sets/rpolsets:PREFIX_SET/rpolsets:PREFIX_SET_LIST/rpolsets:name"; } description "Prefix list name"; } diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-global.yang b/src/sonic-yang-models/yang-models/sonic-bgp-global.yang index df0a442af5c9..ab47d2762050 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-global.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-global.yang @@ -1,6 +1,6 @@ module sonic-bgp-global { namespace "http://github.com/Azure/sonic-bgp-global"; - prefix sbgpg; + prefix bgpg; yang-version 1.1; import sonic-vrf { @@ -11,20 +11,12 @@ module sonic-bgp-global { prefix inet; } - import sonic-bgp-common { - prefix sbc; - } - import sonic-route-map { - prefix srmap; + prefix rmap; } import sonic-extension { - prefix sonic-ext; - } - - import sonic-types { - prefix cmn; + prefix ext; } organization @@ -295,7 +287,7 @@ module sonic-bgp-global { type uint16 { range 0..3600; } - sonic-ext:custom-validation ValidateMaxDelayAndEstWait; + ext:custom-validation ValidateMaxDelayAndEstWait; description "Maximum delay for updates."; } @@ -377,14 +369,14 @@ module sonic-bgp-global { leaf import_vrf_route_map { type leafref { - path "/srmap:sonic-route-map/srmap:ROUTE_MAP_SET/srmap:ROUTE_MAP_SET_LIST/srmap:name"; + path "/rmap:sonic-route-map/rmap:ROUTE_MAP_SET/rmap:ROUTE_MAP_SET_LIST/rmap:name"; } description "Import routes from VRF with route filter"; } leaf route_download_filter { type leafref { - path "/srmap:sonic-route-map/srmap:ROUTE_MAP_SET/srmap:ROUTE_MAP_SET_LIST/srmap:name"; + path "/rmap:sonic-route-map/rmap:ROUTE_MAP_SET/rmap:ROUTE_MAP_SET_LIST/rmap:name"; } description "Route download filter"; } @@ -489,7 +481,7 @@ module sonic-bgp-global { leaf policy { type leafref { - path "/srmap:sonic-route-map/srmap:ROUTE_MAP_SET/srmap:ROUTE_MAP_SET_LIST/srmap:name"; + path "/rmap:sonic-route-map/rmap:ROUTE_MAP_SET/rmap:ROUTE_MAP_SET_LIST/rmap:name"; } description "Apply route map to aggregate network"; } @@ -519,14 +511,14 @@ module sonic-bgp-global { leaf policy { type leafref { - path "/srmap:sonic-route-map/srmap:ROUTE_MAP_SET/srmap:ROUTE_MAP_SET_LIST/srmap:name"; + path "/rmap:sonic-route-map/rmap:ROUTE_MAP_SET/rmap:ROUTE_MAP_SET_LIST/rmap:name"; } description "Route-map to modify the attributes"; } leaf backdoor { type boolean; - sonic-ext:custom-validation ValidateAfisafiForBackdoor; + ext:custom-validation ValidateAfisafiForBackdoor; description "Indicates the backdoor route"; } } diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang b/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang index c9357b1fb30a..b1723a461514 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang @@ -1,6 +1,6 @@ module sonic-bgp-neighbor { namespace "http://github.com/Azure/sonic-bgp-neighbor"; - prefix sbnbr; + prefix bgpnbr; yang-version 1.1; import ietf-inet-types { @@ -8,7 +8,7 @@ module sonic-bgp-neighbor { } import sonic-bgp-common { - prefix sbc; + prefix bgpcmn; } import sonic-port { @@ -24,11 +24,11 @@ module sonic-bgp-neighbor { } import sonic-bgp-global { - prefix sbgpg; + prefix bgpg; } import sonic-bgp-peergroup { - prefix pg; + prefix bgppg; } organization @@ -52,7 +52,7 @@ module sonic-bgp-neighbor { leaf vrf_name { type leafref { - path "/sbgpg:sonic-bgp-global/sbgpg:BGP_GLOBALS/sbgpg:BGP_GLOBALS_LIST/sbgpg:vrf_name"; + path "/bgpg:sonic-bgp-global/bgpg:BGP_GLOBALS/bgpg:BGP_GLOBALS_LIST/bgpg:vrf_name"; } description "Network-instance/VRF name"; } @@ -75,12 +75,12 @@ module sonic-bgp-neighbor { leaf peer_group_name { type leafref { - path "/pg:sonic-bgp-peergroup/pg:BGP_PEER_GROUP/pg:BGP_PEER_GROUP_LIST[pg:vrf_name=current()/../vrf_name]/pg:peer_group_name"; + path "/bgppg:sonic-bgp-peergroup/bgppg:BGP_PEER_GROUP/bgppg:BGP_PEER_GROUP_LIST[bgppg:vrf_name=current()/../vrf_name]/bgppg:peer_group_name"; } description "Peer group name"; } - uses sbc:sonic-bgp-cmn; + uses bgpcmn:sonic-bgp-cmn; } } @@ -90,7 +90,7 @@ module sonic-bgp-neighbor { leaf vrf_name { type leafref { - path "/sbgpg:sonic-bgp-global/sbgpg:BGP_GLOBALS/sbgpg:BGP_GLOBALS_LIST/sbgpg:vrf_name"; + path "/bgpg:sonic-bgp-global/bgpg:BGP_GLOBALS/bgpg:BGP_GLOBALS_LIST/bgpg:vrf_name"; } description "Network-instance/VRF name"; } @@ -101,7 +101,7 @@ module sonic-bgp-neighbor { } description "BGP Neighbor, it will be neighbor address or interface name"; } - uses sbc:sonic-bgp-cmn-af; + uses bgpcmn:sonic-bgp-cmn-af; } } } diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-peergroup.yang b/src/sonic-yang-models/yang-models/sonic-bgp-peergroup.yang index 8abe69b1c53f..0cc9d5cb3f6a 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-peergroup.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-peergroup.yang @@ -8,11 +8,11 @@ module sonic-bgp-peergroup { } import sonic-bgp-common { - prefix sbc; + prefix bgpcmn; } import sonic-bgp-global { - prefix sbgpg; + prefix bgpg; } organization @@ -36,7 +36,7 @@ module sonic-bgp-peergroup { leaf vrf_name { type leafref { - path "/sbgpg:sonic-bgp-global/sbgpg:BGP_GLOBALS/sbgpg:BGP_GLOBALS_LIST/sbgpg:vrf_name"; + path "/bgpg:sonic-bgp-global/bgpg:BGP_GLOBALS/bgpg:BGP_GLOBALS_LIST/bgpg:vrf_name"; } description "Network-instance/VRF name"; } @@ -45,7 +45,7 @@ module sonic-bgp-peergroup { type string; description "Peer group name"; } - uses sbc:sonic-bgp-cmn; + uses bgpcmn:sonic-bgp-cmn; } } @@ -55,7 +55,7 @@ module sonic-bgp-peergroup { leaf vrf_name { type leafref { - path "/sbgpg:sonic-bgp-global/sbgpg:BGP_GLOBALS/sbgpg:BGP_GLOBALS_LIST/sbgpg:vrf_name"; + path "/bgpg:sonic-bgp-global/bgpg:BGP_GLOBALS/bgpg:BGP_GLOBALS_LIST/bgpg:vrf_name"; } description "Network-instance/VRF name"; } @@ -67,7 +67,7 @@ module sonic-bgp-peergroup { description "Peer group name"; } - uses sbc:sonic-bgp-cmn-af; + uses bgpcmn:sonic-bgp-cmn-af; } } @@ -77,7 +77,7 @@ module sonic-bgp-peergroup { leaf vrf_name { type leafref { - path "/sbgpg:sonic-bgp-global/sbgpg:BGP_GLOBALS/sbgpg:BGP_GLOBALS_LIST/sbgpg:vrf_name"; + path "/bgpg:sonic-bgp-global/bgpg:BGP_GLOBALS/bgpg:BGP_GLOBALS_LIST/bgpg:vrf_name"; } description "Network-instance/VRF name"; } diff --git a/src/sonic-yang-models/yang-models/sonic-route-common.yang b/src/sonic-yang-models/yang-models/sonic-route-common.yang index 174dfd3e1bb2..9579739bcdd7 100644 --- a/src/sonic-yang-models/yang-models/sonic-route-common.yang +++ b/src/sonic-yang-models/yang-models/sonic-route-common.yang @@ -1,6 +1,6 @@ module sonic-route-common { namespace "http://github.com/Azure/sonic-route-common"; - prefix srtcmn; + prefix rtcmn; yang-version 1.1; import sonic-vrf { @@ -8,11 +8,7 @@ module sonic-route-common { } import sonic-route-map { - prefix srmap; - } - - import sonic-types { - prefix cmn; + prefix rmap; } organization @@ -63,7 +59,7 @@ module sonic-route-common { leaf-list route_map { type leafref { - path "/srmap:sonic-route-map/srmap:ROUTE_MAP_SET/srmap:ROUTE_MAP_SET_LIST/srmap:name"; + path "/rmap:sonic-route-map/rmap:ROUTE_MAP_SET/rmap:ROUTE_MAP_SET_LIST/rmap:name"; } max-elements 1; description "Router filter to apply while redistributing the routes from another protocol."; diff --git a/src/sonic-yang-models/yang-models/sonic-route-map.yang b/src/sonic-yang-models/yang-models/sonic-route-map.yang index 031d60923a08..3fb61e9736be 100644 --- a/src/sonic-yang-models/yang-models/sonic-route-map.yang +++ b/src/sonic-yang-models/yang-models/sonic-route-map.yang @@ -1,16 +1,12 @@ module sonic-route-map { namespace "http://github.com/Azure/sonic-route-map"; - prefix srmap; + prefix rmap; yang-version 1.1; import ietf-inet-types { prefix inet; } - import sonic-types { - prefix cmn; - } - import sonic-port { prefix port; } @@ -20,7 +16,7 @@ module sonic-route-map { } import sonic-routing-policy-sets { - prefix srpolsets; + prefix rpolsets; } import sonic-vlan { @@ -31,10 +27,6 @@ module sonic-route-map { prefix vrf; } - import sonic-interface { - prefix sintf; - } - organization "SONiC"; @@ -148,7 +140,7 @@ module sonic-route-map { } leaf route_operation { - type srpolsets:routing-policy-action-type; + type rpolsets:routing-policy-action-type; description "permit/deny operation"; } @@ -159,7 +151,7 @@ module sonic-route-map { leaf match_prefix_set{ type leafref { - path "/srpolsets:sonic-routing-policy-sets/srpolsets:PREFIX_SET/srpolsets:PREFIX_SET_LIST/srpolsets:name"; + path "/rpolsets:sonic-routing-policy-sets/rpolsets:PREFIX_SET/rpolsets:PREFIX_SET_LIST/rpolsets:name"; } description "Match a prefix list name that contains IPv4 prefixes."; @@ -167,7 +159,7 @@ module sonic-route-map { leaf match_ipv6_prefix_set{ type leafref { - path "/srpolsets:sonic-routing-policy-sets/srpolsets:PREFIX_SET/srpolsets:PREFIX_SET_LIST/srpolsets:name"; + path "/rpolsets:sonic-routing-policy-sets/rpolsets:PREFIX_SET/rpolsets:PREFIX_SET_LIST/rpolsets:name"; } description "Match a prefix list name that contains IPv6 prefixes."; @@ -180,7 +172,7 @@ module sonic-route-map { leaf match_next_hop_set { type leafref { - path "/srpolsets:sonic-routing-policy-sets/srpolsets:PREFIX_SET/srpolsets:PREFIX_SET_LIST/srpolsets:name"; + path "/rpolsets:sonic-routing-policy-sets/rpolsets:PREFIX_SET/rpolsets:PREFIX_SET_LIST/rpolsets:name"; } description "Match based on nexthop"; } @@ -239,21 +231,21 @@ module sonic-route-map { leaf match_community{ type leafref { - path "/srpolsets:sonic-routing-policy-sets/srpolsets:COMMUNITY_SET/srpolsets:COMMUNITY_SET_LIST/srpolsets:name"; + path "/rpolsets:sonic-routing-policy-sets/rpolsets:COMMUNITY_SET/rpolsets:COMMUNITY_SET_LIST/rpolsets:name"; } description "Match based on community value"; } leaf match_ext_community{ type leafref { - path "/srpolsets:sonic-routing-policy-sets/srpolsets:EXTENDED_COMMUNITY_SET/srpolsets:EXTENDED_COMMUNITY_SET_LIST/srpolsets:name"; + path "/rpolsets:sonic-routing-policy-sets/rpolsets:EXTENDED_COMMUNITY_SET/rpolsets:EXTENDED_COMMUNITY_SET_LIST/rpolsets:name"; } description "Match based on extended community value"; } leaf match_as_path{ type leafref { - path "/srpolsets:sonic-routing-policy-sets/srpolsets:AS_PATH_SET/srpolsets:AS_PATH_SET_LIST/srpolsets:name"; + path "/rpolsets:sonic-routing-policy-sets/rpolsets:AS_PATH_SET/rpolsets:AS_PATH_SET_LIST/rpolsets:name"; } description "Match based on BGP AS-PATH"; } @@ -331,7 +323,7 @@ module sonic-route-map { leaf set_community_ref { type leafref { - path "/srpolsets:sonic-routing-policy-sets/srpolsets:COMMUNITY_SET/srpolsets:COMMUNITY_SET_LIST/srpolsets:name"; + path "/rpolsets:sonic-routing-policy-sets/rpolsets:COMMUNITY_SET/rpolsets:COMMUNITY_SET_LIST/rpolsets:name"; } description "Refer community from community list"; } @@ -343,7 +335,7 @@ module sonic-route-map { leaf set_ext_community_ref { type leafref { - path "/srpolsets:sonic-routing-policy-sets/srpolsets:EXTENDED_COMMUNITY_SET/srpolsets:EXTENDED_COMMUNITY_SET_LIST/srpolsets:name"; + path "/rpolsets:sonic-routing-policy-sets/rpolsets:EXTENDED_COMMUNITY_SET/rpolsets:EXTENDED_COMMUNITY_SET_LIST/rpolsets:name"; } description "Refer extended community from extended community list"; } diff --git a/src/sonic-yang-models/yang-models/sonic-routing-policy-sets.yang b/src/sonic-yang-models/yang-models/sonic-routing-policy-sets.yang index 94c9ae5ffee7..a4f6f78ac2a3 100644 --- a/src/sonic-yang-models/yang-models/sonic-routing-policy-sets.yang +++ b/src/sonic-yang-models/yang-models/sonic-routing-policy-sets.yang @@ -1,6 +1,6 @@ module sonic-routing-policy-sets { namespace "http://github.com/Azure/sonic-routing-policy-lists"; - prefix srpolsets; + prefix rpolsets; yang-version 1.1; import ietf-inet-types { @@ -8,7 +8,7 @@ module sonic-routing-policy-sets { } import sonic-extension { - prefix sonic-ext; + prefix ext; } organization @@ -64,7 +64,7 @@ module sonic-routing-policy-sets { list PREFIX_LIST { key "name sequence_number ip_prefix masklength_range"; - sonic-ext:custom-validation ValidateIpPrefixListCfg; + ext:custom-validation ValidateIpPrefixListCfg; leaf name { type leafref { From cf933a3885b9ac155d375e7833383817415e70e2 Mon Sep 17 00:00:00 2001 From: Venkatesan Mahalingam Date: Thu, 10 Jun 2021 23:20:28 +0000 Subject: [PATCH 19/28] Commented the VLAN leafref and used the VLAN pattern string as a workaround to overcome VLAN leafref issue.wq --- .../yang-models/sonic-bgp-common.yang | 9 ++++++--- .../yang-models/sonic-bgp-neighbor.yang | 7 +++++-- .../yang-models/sonic-route-map.yang | 14 ++++++++++---- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-common.yang b/src/sonic-yang-models/yang-models/sonic-bgp-common.yang index 112746bb2503..a0833deaee8f 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-common.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-common.yang @@ -217,12 +217,15 @@ module sonic-bgp-common { type leafref { path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; } - type leafref { - path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; - } + //type leafref { + // path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; + //} type leafref { path "/lointf:sonic-loopback-interface/lointf:LOOPBACK_INTERFACE/lointf:LOOPBACK_INTERFACE_LIST/lointf:name"; } + type string { + pattern 'Vlan([0-9]{1,3}|[1-3][0-9]{3}|[4][0][0-8][0-9]|[4][0][9][0-4])'; + } } description "Local source address or interface name to use for connection."; } diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang b/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang index b1723a461514..f8c53c754cc1 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang @@ -66,8 +66,11 @@ module sonic-bgp-neighbor { type leafref { path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; } - type leafref { - path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; + // type leafref { + // path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; + // } + type string { + pattern 'Vlan([0-9]{1,3}|[1-3][0-9]{3}|[4][0][0-8][0-9]|[4][0][9][0-4])'; } } description "BGP Neighbor, it will be neighbor address or interface name"; diff --git a/src/sonic-yang-models/yang-models/sonic-route-map.yang b/src/sonic-yang-models/yang-models/sonic-route-map.yang index 3fb61e9736be..56ee00e70726 100644 --- a/src/sonic-yang-models/yang-models/sonic-route-map.yang +++ b/src/sonic-yang-models/yang-models/sonic-route-map.yang @@ -49,8 +49,11 @@ module sonic-route-map { type leafref { path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; } - type leafref { - path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; + //type leafref { + // path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; + //} + type string { + pattern 'Vlan([0-9]{1,3}|[1-3][0-9]{3}|[4][0][0-8][0-9]|[4][0][9][0-4])'; } } } @@ -198,8 +201,11 @@ module sonic-route-map { type leafref { path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; } - type leafref { - path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; + //type leafref { + // path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; + //} + type string { + pattern 'Vlan([0-9]{1,3}|[1-3][0-9]{3}|[4][0][0-8][0-9]|[4][0][9][0-4])'; } } description From 969d9adbcae626fdcaaad20693d1189d6ebf9b76 Mon Sep 17 00:00:00 2001 From: Venkatesan Mahalingam Date: Thu, 10 Jun 2021 23:33:13 +0000 Subject: [PATCH 20/28] Commented the custom validation until the infra is ready. Signed-off-by: Venkatesan Mahalingam --- src/sonic-yang-models/yang-models/sonic-bgp-common.yang | 4 ++-- src/sonic-yang-models/yang-models/sonic-bgp-global.yang | 4 ++-- src/sonic-yang-models/yang-models/sonic-extension.yang | 5 ----- .../yang-models/sonic-routing-policy-sets.yang | 2 +- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-common.yang b/src/sonic-yang-models/yang-models/sonic-bgp-common.yang index a0833deaee8f..ece2dba4c990 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-common.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-common.yang @@ -243,7 +243,7 @@ module sonic-bgp-common { leaf disable_ebgp_connected_route_check { type boolean; description "Connected checked disabled"; - ext:custom-validation ValidateDisableConnectedCheck; + //ext:custom-validation ValidateDisableConnectedCheck; } leaf enforce_first_as { @@ -307,7 +307,7 @@ module sonic-bgp-common { leaf strict_capability_match { type boolean; - ext:custom-validation ValidateStrictAndOverRideCapability; + //ext:custom-validation ValidateStrictAndOverRideCapability; description "Strict capability negotiation match"; } diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-global.yang b/src/sonic-yang-models/yang-models/sonic-bgp-global.yang index ab47d2762050..a428635e6037 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-global.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-global.yang @@ -287,7 +287,7 @@ module sonic-bgp-global { type uint16 { range 0..3600; } - ext:custom-validation ValidateMaxDelayAndEstWait; + //ext:custom-validation ValidateMaxDelayAndEstWait; description "Maximum delay for updates."; } @@ -518,7 +518,7 @@ module sonic-bgp-global { leaf backdoor { type boolean; - ext:custom-validation ValidateAfisafiForBackdoor; + //ext:custom-validation ValidateAfisafiForBackdoor; description "Indicates the backdoor route"; } } diff --git a/src/sonic-yang-models/yang-models/sonic-extension.yang b/src/sonic-yang-models/yang-models/sonic-extension.yang index b8dbad46d9e4..6369b605173c 100644 --- a/src/sonic-yang-models/yang-models/sonic-extension.yang +++ b/src/sonic-yang-models/yang-models/sonic-extension.yang @@ -10,9 +10,4 @@ module sonic-extension { revision 2019-07-01 { description "First Revision"; } - - extension custom-validation { - description "Extension for registering custom validation handler."; - argument "handler"; - } } diff --git a/src/sonic-yang-models/yang-models/sonic-routing-policy-sets.yang b/src/sonic-yang-models/yang-models/sonic-routing-policy-sets.yang index a4f6f78ac2a3..5b178831fb8d 100644 --- a/src/sonic-yang-models/yang-models/sonic-routing-policy-sets.yang +++ b/src/sonic-yang-models/yang-models/sonic-routing-policy-sets.yang @@ -64,7 +64,7 @@ module sonic-routing-policy-sets { list PREFIX_LIST { key "name sequence_number ip_prefix masklength_range"; - ext:custom-validation ValidateIpPrefixListCfg; + //ext:custom-validation ValidateIpPrefixListCfg; leaf name { type leafref { From 71e4a376ca30d0e39d3ca9f8b80800898d163458 Mon Sep 17 00:00:00 2001 From: Venkatesan Mahalingam Date: Fri, 11 Jun 2021 00:26:05 +0000 Subject: [PATCH 21/28] Comments addressed. --- .../yang-models/sonic-bgp-common.yang | 8 +++++--- .../yang-models/sonic-bgp-neighbor.yang | 8 +++++--- src/sonic-yang-models/yang-models/sonic-route-map.yang | 10 ++++++---- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-common.yang b/src/sonic-yang-models/yang-models/sonic-bgp-common.yang index ece2dba4c990..feda9ac563ae 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-common.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-common.yang @@ -15,9 +15,10 @@ module sonic-bgp-common { prefix lag; } - import sonic-vlan { - prefix vlan; - } + // Comment sonic-vlan import here until libyang back-links issue is resolved for VLAN leaf reference. + // import sonic-vlan { + // prefix vlan; + // } import sonic-loopback-interface { prefix lointf; @@ -217,6 +218,7 @@ module sonic-bgp-common { type leafref { path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; } + // Comment VLAN leaf reference here until libyang back-links issue is resolved and use VLAN string pattern //type leafref { // path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; //} diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang b/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang index f8c53c754cc1..cbd94eefdacb 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang @@ -19,9 +19,10 @@ module sonic-bgp-neighbor { prefix lag; } - import sonic-vlan { - prefix vlan; - } + // Comment sonic-vlan import here until libyang back-links issue is resolved for VLAN leaf reference. + //import sonic-vlan { + // prefix vlan; + //} import sonic-bgp-global { prefix bgpg; @@ -66,6 +67,7 @@ module sonic-bgp-neighbor { type leafref { path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; } + // Comment VLAN leaf reference here until libyang back-links issue is resolved and use VLAN string pattern // type leafref { // path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; // } diff --git a/src/sonic-yang-models/yang-models/sonic-route-map.yang b/src/sonic-yang-models/yang-models/sonic-route-map.yang index 56ee00e70726..e4717cbc6288 100644 --- a/src/sonic-yang-models/yang-models/sonic-route-map.yang +++ b/src/sonic-yang-models/yang-models/sonic-route-map.yang @@ -18,10 +18,10 @@ module sonic-route-map { import sonic-routing-policy-sets { prefix rpolsets; } - - import sonic-vlan { - prefix vlan; - } +// Comment sonic-vlan import here until libyang back-links issue is resolved for VLAN leaf reference. +// import sonic-vlan { +// prefix vlan; +// } import sonic-vrf { prefix vrf; @@ -49,6 +49,7 @@ module sonic-route-map { type leafref { path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; } + // Comment VLAN leaf reference here until libyang back-links issue is resolved and use VLAN string pattern //type leafref { // path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; //} @@ -201,6 +202,7 @@ module sonic-route-map { type leafref { path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; } + // Comment VLAN leaf reference here until libyang back-links issue is resolved and use VLAN string pattern //type leafref { // path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; //} From b7adb38e31203a62297f15594bdd261a1c73ed6d Mon Sep 17 00:00:00 2001 From: Venkatesan Mahalingam Date: Thu, 17 Jun 2021 20:41:22 +0000 Subject: [PATCH 22/28] Removed the file. --- src/sonic-yang-mgmt/sonic_yang_ext.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/sonic-yang-mgmt/sonic_yang_ext.py b/src/sonic-yang-mgmt/sonic_yang_ext.py index 89343cac42d8..b01225277aa6 100644 --- a/src/sonic-yang-mgmt/sonic_yang_ext.py +++ b/src/sonic-yang-mgmt/sonic_yang_ext.py @@ -82,10 +82,6 @@ def _createDBTableToModuleMap(self): for j in self.yJson: # get module name moduleName = j['module']['@name'] - # Skip sonic-types and sonic-extensions modules - if moduleName.strip() == 'sonic-types': - continue - # get top level container topLevelContainer = j['module'].get('container') # if top level container is none, this is common yang files, which may From 45e526b942b848005811bad65f7d56bbf0e85b59 Mon Sep 17 00:00:00 2001 From: Venkatesan Mahalingam Date: Mon, 28 Jun 2021 04:43:10 +0000 Subject: [PATCH 23/28] Added BGP_NEIGHBOR list with just IP as the key to allow the current model being used in the community. Signed-off-by: Venkatesan Mahalingam --- .../tests/files/sample_config_db.json | 11 +++++ .../yang-models/sonic-bgp-neighbor.yang | 49 +++++++++++++++++++ 2 files changed, 60 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 2693c5c22164..db34368458a0 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -866,6 +866,17 @@ "default|ipv4_unicast|21.0.0.0/8": { } }, + "BGP_NEIGHBOR": { + "10.0.0.1": { + "asn": "65200", + "holdtime": "180", + "keepalive": "60", + "local_addr": "10.0.0.2", + "name":"PEER1", + "nhopself":"0", + "rrclient":"0" + } + }, "BGP_NEIGHBOR": { "default|192.168.1.1": { } diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang b/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang index cbd94eefdacb..ebd08f89f847 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang @@ -48,7 +48,56 @@ module sonic-bgp-neighbor { container sonic-bgp-neighbor { container BGP_NEIGHBOR { + list BGP_NEIGHBOR_TEMPLATE_LIST { + description "This list is to support template based BGP neighbor configuration handled by bgpcfgd"; + key "neighbor"; + + leaf neighbor { + type inet:ip-address; + description "BGP Neighbor address"; + } + + leaf asn { + type uint32 { + range "1..4294967295"; + } + description "Peer AS number"; + } + + leaf holdtime { + type uint16; + description "Hold time"; + } + + leaf keepalive { + type uint16; + description "Keepalive interval"; + } + + leaf local_addr { + type inet:ip-address; + description "Local source address or interface name to use for connection."; + } + + leaf name { + type string; + description "Peer description"; + } + + leaf nhopself { + type boolean; + description "Nexthop is self, no nexthop calculation"; + } + + leaf rrclient { + type boolean; + description "Route reflector client"; + } + } + list BGP_NEIGHBOR_LIST { + description "This list is to support generic BGP neighbor configuration handled by frrcfgd and + frr_mgmt_framework_config field should be set to true in DEVICE_METADATA talbe for accepting the generic BGP table configurations."; key "vrf_name neighbor"; leaf vrf_name { From d4df009f05338cdf45b919d11ab7177041ad8b93 Mon Sep 17 00:00:00 2001 From: Venkatesan Mahalingam Date: Tue, 29 Jun 2021 05:12:53 +0000 Subject: [PATCH 24/28] Comment addressed. Signed-off-by: Venkatesan Mahalingam --- .../tests/files/sample_config_db.json | 10 ++-------- 1 file changed, 2 insertions(+), 8 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 db34368458a0..8d73bc57e99a 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -867,18 +867,12 @@ } }, "BGP_NEIGHBOR": { - "10.0.0.1": { + "default|192.168.1.1": { "asn": "65200", "holdtime": "180", "keepalive": "60", "local_addr": "10.0.0.2", - "name":"PEER1", - "nhopself":"0", - "rrclient":"0" - } - }, - "BGP_NEIGHBOR": { - "default|192.168.1.1": { + "name":"PEER2" } }, "BGP_NEIGHBOR_AF": { From daace084024fef803c6dae053cd031c8845113a3 Mon Sep 17 00:00:00 2001 From: Venkatesan Mahalingam Date: Tue, 29 Jun 2021 17:41:56 +0000 Subject: [PATCH 25/28] Removed the fields present in the grouping as the infra is not ready. --- src/sonic-yang-models/tests/files/sample_config_db.json | 5 ----- 1 file changed, 5 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 8d73bc57e99a..2693c5c22164 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -868,11 +868,6 @@ }, "BGP_NEIGHBOR": { "default|192.168.1.1": { - "asn": "65200", - "holdtime": "180", - "keepalive": "60", - "local_addr": "10.0.0.2", - "name":"PEER2" } }, "BGP_NEIGHBOR_AF": { From d7eee7beb92073a5d6eaa231f79f0b54c832d5e0 Mon Sep 17 00:00:00 2001 From: Venkatesan Mahalingam Date: Tue, 6 Jul 2021 07:39:29 +0000 Subject: [PATCH 26/28] Comment addressed. --- .../tests/files/sample_config_db.json | 14 ++++++++++++++ 1 file changed, 14 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 2693c5c22164..98347d540815 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -867,7 +867,21 @@ } }, "BGP_NEIGHBOR": { + "10.0.0.1": { + "asn": "65200", + "holdtime": "180", + "keepalive": "60", + "local_addr": "10.0.0.2", + "name":"PEER1", + "nhopself":"0", + "rrclient":"0" + }, "default|192.168.1.1": { + "asn": "65200", + "holdtime": "180", + "keepalive": "60", + "local_addr": "10.0.0.2", + "name":"PEER2" } }, "BGP_NEIGHBOR_AF": { From 858b08f48f0df2d6ae193da912c21f70b4928d55 Mon Sep 17 00:00:00 2001 From: Venkatesan Mahalingam Date: Tue, 6 Jul 2021 17:00:32 +0000 Subject: [PATCH 27/28] Removed the sample config that depends on BGP_NEIGHBOR grouping fields. --- src/sonic-yang-models/tests/files/sample_config_db.json | 5 ----- 1 file changed, 5 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 98347d540815..803e5e7bee6e 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -877,11 +877,6 @@ "rrclient":"0" }, "default|192.168.1.1": { - "asn": "65200", - "holdtime": "180", - "keepalive": "60", - "local_addr": "10.0.0.2", - "name":"PEER2" } }, "BGP_NEIGHBOR_AF": { From e63af877783204a1d67ed9c244e5c085c8849e12 Mon Sep 17 00:00:00 2001 From: Venkatesan Mahalingam Date: Wed, 7 Jul 2021 03:45:14 +0000 Subject: [PATCH 28/28] Used the 0 and 1 for boolean. --- src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang b/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang index ebd08f89f847..8e0e3f4cc803 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang @@ -85,12 +85,16 @@ module sonic-bgp-neighbor { } leaf nhopself { - type boolean; + type uint8 { + range "0..1"; + } description "Nexthop is self, no nexthop calculation"; } leaf rrclient { - type boolean; + type uint8 { + range "0..1"; + } description "Route reflector client"; } }