module openconfig-bgp-policy { yang-version "1.1"; // namespace namespace "http://openconfig.net/yang/bgp-policy"; prefix "bgp-pol"; // import some basic types import ietf-inet-types { prefix inet; } import openconfig-routing-policy {prefix rpol; } import openconfig-policy-types { prefix pt; } import openconfig-bgp-types { prefix bgp-types; } import openconfig-extensions { prefix oc-ext; } import bgp-types { prefix bgp-t; revision-date 2020-01-20; } // meta organization "OpenConfig working group"; contact "OpenConfig working group netopenconfig@googlegroups.com"; description "This module contains data definitions for BGP routing policy. It augments the base routing-policy module with BGP-specific options for conditions and actions."; oc-ext:openconfig-version "1.1.0"; revision "2015-10-09" { description "Initial OpenConfig public release"; reference "1.1.0"; } revision "2015-05-15" { description "Updated model to augment base routing-policy module"; reference "Pre-release"; } // extension statements // feature statements // identity statements // typedef statements typedef bgp-as-path-prepend-repeat { type uint8; description "Option for the BGP as-prepend policy action. Prepends the local AS number repeated n times"; } typedef bgp-set-community-option-type { type enumeration { enum ADD { description "add the specified communities to the existing community attribute"; } enum REMOVE { description "remove the specified communities from the existing community attribute"; } enum REPLACE { description "replace the existing community attribute with the specified communities. If an empty set is specified, this removes the community attribute from the route."; } } description "Type definition for options when setting the community attribute in a policy action"; } typedef bgp-next-hop-type { type union { type inet:ip-address; type enumeration { enum SELF { description "special designation for local router's own address, i.e., next-hop-self"; } } } description "type definition for specifying next-hop in policy actions"; } typedef bgp-set-med-type { type union { type uint32; type string { pattern "^[+-][0-9]+"; } type enumeration { enum IGP { description "set the MED value to the IGP cost toward the next hop for the route"; } } } description "Type definition for specifying how the BGP MED can be set in BGP policy actions. The three choices are to set the MED directly, increment/decrement using +/- notation, and setting it to the IGP cost (predefined value)."; } // grouping statements grouping bgp-match-conditions { description "Condition statement definitions for checking membership in a defined set"; container match-community-set { presence "The presence of this container indicates that the routes should match the referenced community-set"; description "Match a referenced community-set according to the logic defined in the match-set-options leaf"; leaf community-set { type leafref { path "/rpol:routing-policy/rpol:defined-sets/" + "bgp-pol:bgp-defined-sets/bgp-pol:community-sets/" + "bgp-pol:community-set/bgp-pol:community-set-name"; require-instance true; } description "References a defined community set"; } uses rpol:match-set-options-group; } container match-ext-community-set { presence "The presence of this container indicates that the routes should match the referenced extended community set"; description "Match a referenced extended community-set according to the logic defined in the match-set-options leaf"; leaf ext-community-set { type leafref { path "/rpol:routing-policy/rpol:defined-sets/" + "bgp-pol:bgp-defined-sets/bgp-pol:ext-community-sets/" + "bgp-pol:ext-community-set/" + "bgp-pol:ext-community-set-name"; require-instance true; } description "References a defined extended community set"; } uses rpol:match-set-options-group; } container match-as-path-set { presence "The presence of this container indicates that the route should match the referenced as-path set"; description "Match a referenced as-path set according to the logic defined in the match-set-options leaf"; leaf as-path-set { type leafref { path "/rpol:routing-policy/rpol:defined-sets/" + "bgp-pol:bgp-defined-sets/bgp-pol:as-path-sets/" + "bgp-pol:as-path-set/bgp-pol:as-path-set-name"; require-instance true; } description "References a defined AS path set"; } uses rpol:match-set-options-group; } } grouping bgp-attribute-conditions { description "Condition statement definitions for comparing a BGP route attribute to a specified value"; leaf med-eq { type uint32; description "Condition to check if the received MED value is equal to the specified value"; } leaf origin-eq { type bgp-types:bgp-origin-attr-type; description "Condition to check if the route origin is equal to the specified value"; } leaf-list next-hop-in { type inet:ip-address; description "List of next hop addresses to check for in the route update"; } leaf-list afi-safi-in { type identityref { base "bgp-types:afi-safi-type"; } description "List of address families which the NLRI may be within"; } leaf local-pref-eq { type uint32; // TODO: add support for other comparisons if needed description "Condition to check if the local pref attribute is equal to the specified value"; } container community-count { presence "node is present in the config data to indicate a community-count condition"; description "Value and comparison operations for conditions based on the number of communities in the route update"; uses pt:attribute-compare-operators; } container as-path-length { presence "node is present in the config data to indicate a as-path-length condition"; description "Value and comparison operations for conditions based on the length of the AS path in the route update"; uses pt:attribute-compare-operators; } leaf route-type { // TODO: verify extent of vendor support for this comparison type enumeration { enum INTERNAL { description "route type is internal"; } enum EXTERNAL { description "route type is external"; } } description "Condition to check the route type in the route update"; } } // augment statements augment "/rpol:routing-policy/rpol:defined-sets" { description "adds BGP defined sets container to routing policy model"; container bgp-defined-sets { description "BGP-related set definitions for policy match conditions"; container community-sets { description "Enclosing container for community sets"; list community-set { key community-set-name; description "Definitions for community sets"; leaf community-set-name { type string; mandatory true; description "name / label of the community set -- this is used to reference the set in match conditions"; } list communities { uses bgp-t:community; description "members of the community set"; } } } container ext-community-sets { description "Enclosing container for extended community sets"; list ext-community-set { key ext-community-set-name; description "Definitions for extended community sets"; leaf ext-community-set-name { type string; description "name / label of the extended community set -- this is used to reference the set in match conditions"; } list ext-community-member { uses bgp-t:extended-community; description "members of the extended community set"; } } } container as-path-sets { description "Enclosing container for AS path sets"; list as-path-set { key as-path-set-name; description "Definitions for AS path sets"; leaf as-path-set-name { type string; description "name of the AS path set -- this is used to reference the set in match conditions"; } leaf-list as-path-set-member { type inet:as-number; description "AS path expression -- list of ASes in the set"; } } } } } augment "/rpol:routing-policy/rpol:policy-definitions/" + "rpol:policy-definition/rpol:statements/rpol:statement/" + "rpol:conditions" { description "BGP policy conditions added to routing policy module"; container bgp-conditions { description "Policy conditions for matching BGP-specific defined sets or comparing BGP-specific attributes"; uses bgp-match-conditions; uses bgp-attribute-conditions; } } augment "/rpol:routing-policy/rpol:policy-definitions/" + "rpol:policy-definition/rpol:statements/rpol:statement/" + "rpol:actions" { description "BGP policy actions added to routing policy module"; container bgp-actions { description "Definitions for policy action statements that change BGP-specific attributes of the route"; container set-as-path-prepend { presence "node is present in the config data to use the AS prepend action"; description "action to prepend local AS number to the AS-path a specified number of times"; leaf repeat-n { type uint8; description "number of times to prepend the local AS number"; } } container set-community { presence "node is present in the config data when set-community action is used"; description "action to set the community attributes of the route, along with options to modify how the community is modified"; choice set-community-method { description "Option to set communities using an inline list or reference to an existing defined set."; case inline { list communities { uses bgp-t:community; description "Set the community values for the update inline with a list."; } } case reference { leaf community-set-ref { type leafref { path "/rpol:routing-policy/rpol:defined-sets/" + "bgp-pol:bgp-defined-sets/" + "bgp-pol:community-sets/bgp-pol:community-set/" + "bgp-pol:community-set-name"; require-instance true; } description "References a defined community set by name"; } } } leaf options { type bgp-set-community-option-type; description "Options for modifying the community attribute with the specified values. These options apply to both methods of setting the community attribute."; } } container set-ext-community { presence "node is present in the config data when set-community action is used"; description "Action to set the extended community attributes of the route, along with options to modify how the community is modified"; choice set-ext-community-method { description "Option to set communities using an inline list or reference to an existing defined set."; case inline { list ext-community-member { uses bgp-t:extended-community; description "Set the community values for the update inline with a list."; } } case reference { leaf ext-community-set-ref { type leafref { path "/rpol:routing-policy/rpol:defined-sets/" + "bgp-pol:bgp-defined-sets/" + "bgp-pol:ext-community-sets/" + "bgp-pol:ext-community-set/" + "bgp-pol:ext-community-set-name"; require-instance true; } description "References a defined extended community set by name"; } } } leaf options { type bgp-set-community-option-type; description "options for modifying the extended community attribute with the specified values. These options apply to both methods of setting the community attribute."; } } leaf set-route-origin { type bgp-types:bgp-origin-attr-type; description "set the origin attribute to the specified value"; } leaf set-local-pref { type uint32; description "set the local pref attribute on the route update"; } leaf set-next-hop { type bgp-next-hop-type; description "set the next-hop attribute in the route update"; } leaf set-med { type bgp-set-med-type; description "set the med metric attribute in the route update"; } } } // rpc statements // notification statements }