sonic-buildimage/src/sonic-yang-models/yang-models/sonic-bgp-common.yang
ganglv dde5f37496
[yang]: Add Yang models for BGP monitor (#9752)
Why I did it
end2end test is blocked by Yang model for BGP monitor.

How I did it
Create new yang files for BGP monitor, and add UT.

How to verify it
Follow the steps in #9711.
Run UT for sonic-yang-models.

Signed-off-by: Gang Lv ganglv@microsoft.com
2022-01-20 08:51:12 +08:00

582 lines
15 KiB
YANG

module sonic-bgp-common {
namespace "http://github.com/Azure/sonic-bgp-common";
prefix bgpcmn;
yang-version 1.1;
import sonic-types {
prefix stypes;
}
import ietf-inet-types {
prefix inet;
}
import sonic-port {
prefix port;
}
import sonic-portchannel {
prefix lag;
}
// 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;
}
import sonic-routing-policy-sets {
prefix rpolsets;
}
import sonic-route-map {
prefix rmap;
}
import sonic-extension {
prefix ext;
}
organization
"SONiC";
contact
"SONiC";
description
"SONIC BGP common YANG attributes for Neighbors and Peer group";
revision 2021-02-26 {
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;
description "BGP peer type internal/external";
}
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 "/port:sonic-port/port:PORT/port:PORT_LIST/port:name";
}
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";
//}
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.";
}
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";
//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;
}
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;
//ext:custom-validation ValidateStrictAndOverRideCapability;
description "Strict capability negotiation match";
}
leaf admin_status {
type stypes:admin_status;
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 stypes:admin_status;
description "Indicates address family active/inactive status";
}
leaf send_default_route {
type boolean;
description "Send default route";
}
leaf default_rmap {
type leafref {
path "/rmap:sonic-route-map/rmap:ROUTE_MAP_SET/rmap:ROUTE_MAP_SET_LIST/rmap: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 "/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;
}
leaf-list route_map_out {
type leafref {
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;
}
leaf soft_reconfiguration_in {
type boolean;
description "Inbound soft reconfiguration";
}
leaf unsuppress_map_name {
type leafref {
path "/rmap:sonic-route-map/rmap:ROUTE_MAP_SET/rmap:ROUTE_MAP_SET_LIST/rmap:name";
}
description "Route map";
}
leaf rrclient {
type boolean;
description "Route reflector client";
}
leaf weight {
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 {
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 "/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 "/rpolsets:sonic-routing-policy-sets/rpolsets:AS_PATH_SET/rpolsets:AS_PATH_SET_LIST/rpolsets: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 "/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 "/rpolsets:sonic-routing-policy-sets/rpolsets:PREFIX_SET/rpolsets:PREFIX_SET_LIST/rpolsets: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";
}
}
grouping sonic-bgp-cmn-neigh {
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 uint8 {
range "0..1";
}
description "Nexthop is self, no nexthop calculation";
}
leaf rrclient {
type uint8 {
range "0..1";
}
description "Route reflector client";
}
leaf admin_status {
type stypes:admin_status;
description "Admin status of BGP peer";
}
}
}