[YANG] Add to support BGP and route-map YANG models (#6917)

Why I did it
SONiC YANG model support for BGP & route-map features.

How I did it
Defined various BGP and route-map YANG containers and lists based on config-DB schema.

How to verify it
Built the following successfully with various BGP & route-map unit test cases.
make target/python-wheels/sonic_yang_models-1.0-py3-none-any.whl
make target/python-wheels/sonic_yang_mgmt-1.0-py3-none-any.whl
This commit is contained in:
Venkatesan Mahalingam 2021-06-18 10:31:19 -07:00 committed by GitHub
parent a069cb0b11
commit a3e144b16d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 4111 additions and 3 deletions

View File

@ -292,11 +292,11 @@ class Test_SonicYang(object):
'''
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
# 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.
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)

View File

@ -42,6 +42,10 @@ setup(
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',
@ -53,6 +57,9 @@ setup(
'./yang-models/sonic-nat.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',

View File

@ -749,6 +749,7 @@
"polling_interval": "0"
}
},
"NAT_BINDINGS": {
"bind1": {
"nat_pool": "pool1",
@ -780,6 +781,73 @@
"125.56.90.8": {
"local_ip": "12.12.0.2"
}
},
"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": {
}
}
},

View File

@ -0,0 +1,139 @@
{
"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_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"
},
"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"
},
"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.",
"eStrKey" : "Pattern"
}
}

View File

@ -42,5 +42,9 @@
"DEVICE_METADATA_INCORRECT_BUFFER_MODEL_PATTERN": {
"desc": "DEVICE_METADATA wrong value for BUFFER_MODEL field.",
"eStr": ["pattern", "does not satisfy"]
},
"DEVICE_METADATA_FRR_MGMT_FWK_CONFIG": {
"desc": "Verifying FRR MGMT framework configuration."
}
}

View File

@ -0,0 +1,107 @@
{
"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"
},
"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_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"
},
"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."
},
"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"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -117,5 +117,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"
}
}
}
}
}

View File

@ -0,0 +1,539 @@
{
"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_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": [
{
"name": "map1"
}
]
}
},
"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": [
{
"name": "map1",
"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,
"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
}
]
}
}
},
"ROUTE_MAP_INVALID_STMT": {
"sonic-route-map:sonic-route-map":{
"sonic-route-map:ROUTE_MAP": {
"ROUTE_MAP_LIST": [
{
"name": "map2",
"stmt_name": 10000000
}
]
}
}
},
"ROUTE_MAP_INVALID_OPERATION_TYPE": {
"sonic-route-map:sonic-route-map":{
"sonic-route-map:ROUTE_MAP": {
"ROUTE_MAP_LIST": [
{
"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": [
{
"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": [
{
"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": [
{
"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": [
{
"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": [
{
"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": [
{
"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": [
{
"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": [
{
"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": [
{
"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": [
{
"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": [
{
"name": "map14",
"stmt_name": 14,
"set_ext_community_ref": "null"
}
]
}
}
},
"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": [
{
"name": "prefix1",
"sequence_number": 10,
"ip_prefix": "20.0.0.0/8",
"masklength_range": "8..16",
"action": "permit"
},
{
"name": "prefix1",
"sequence_number": 11,
"ip_prefix": "21.0.0.0/8",
"masklength_range": "exact",
"action": "permit"
}
]
}
}
},
"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": [
{
"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": [
{
"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": {
"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_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": {
"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"]
}
]
}
}
}
}

View File

@ -0,0 +1,530 @@
module sonic-bgp-common {
namespace "http://github.com/Azure/sonic-bgp-common";
prefix bgpcmn;
yang-version 1.1;
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 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 "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";
}
}
}

View File

@ -0,0 +1,527 @@
module sonic-bgp-global {
namespace "http://github.com/Azure/sonic-bgp-global";
prefix bgpg;
yang-version 1.1;
import sonic-vrf {
prefix vrf;
}
import ietf-inet-types {
prefix inet;
}
import sonic-route-map {
prefix rmap;
}
import sonic-extension {
prefix ext;
}
organization
"SONiC";
contact
"SONiC";
description
"SONIC BGP Global YANG";
revision 2021-02-26 {
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 "/vrf:sonic-vrf/vrf:VRF/vrf:VRF_LIST/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 {
type boolean;
description
"Set F-bit indication that FIB is preserved while doing Graceful Restart.";
}
leaf gr_restart_time {
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 {
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;
}
//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";
}
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 {
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!";
}
description "Import routes from particular VRF";
}
leaf import_vrf_route_map {
type leafref {
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 "/rmap:sonic-route-map/rmap:ROUTE_MAP_SET/rmap:ROUTE_MAP_SET_LIST/rmap: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 {
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;
description "Enable route-flap dampening";
}
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";
}
description "Half-life time for the penalty";
}
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";
}
description "Value to start reusing a route";
}
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";
}
description "Value to start suppressing a route";
}
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";
}
description "Maximum duration to suppress a stable route";
}
}
}
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";
}
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 "/rmap:sonic-route-map/rmap:ROUTE_MAP_SET/rmap:ROUTE_MAP_SET_LIST/rmap:name";
}
description "Apply route map to aggregate network";
}
}
}
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";
}
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 "/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;
//ext:custom-validation ValidateAfisafiForBackdoor;
description "Indicates the backdoor route";
}
}
}
}
}

View File

@ -0,0 +1,113 @@
module sonic-bgp-neighbor {
namespace "http://github.com/Azure/sonic-bgp-neighbor";
prefix bgpnbr;
yang-version 1.1;
import ietf-inet-types {
prefix inet;
}
import sonic-bgp-common {
prefix bgpcmn;
}
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-bgp-global {
prefix bgpg;
}
import sonic-bgp-peergroup {
prefix bgppg;
}
organization
"SONiC";
contact
"SONiC";
description
"SONIC BGP Neighbor";
revision 2021-02-26 {
description
"Initial revision.";
}
container sonic-bgp-neighbor {
container BGP_NEIGHBOR {
list BGP_NEIGHBOR_LIST {
key "vrf_name neighbor";
leaf vrf_name {
type leafref {
path "/bgpg:sonic-bgp-global/bgpg:BGP_GLOBALS/bgpg:BGP_GLOBALS_LIST/bgpg:vrf_name";
}
description "Network-instance/VRF name";
}
leaf neighbor {
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 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";
}
leaf peer_group_name {
type leafref {
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 bgpcmn:sonic-bgp-cmn;
}
}
container BGP_NEIGHBOR_AF {
list BGP_NEIGHBOR_AF_LIST {
key "vrf_name neighbor afi_safi";
leaf vrf_name {
type leafref {
path "/bgpg:sonic-bgp-global/bgpg:BGP_GLOBALS/bgpg:BGP_GLOBALS_LIST/bgpg:vrf_name";
}
description "Network-instance/VRF name";
}
leaf 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 bgpcmn:sonic-bgp-cmn-af;
}
}
}
}

View File

@ -0,0 +1,100 @@
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 bgpcmn;
}
import sonic-bgp-global {
prefix bgpg;
}
organization
"SONiC";
contact
"SONiC";
description
"SONIC BGP Peer Group YANG";
revision 2021-02-26 {
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 "/bgpg:sonic-bgp-global/bgpg:BGP_GLOBALS/bgpg:BGP_GLOBALS_LIST/bgpg:vrf_name";
}
description "Network-instance/VRF name";
}
leaf peer_group_name {
type string;
description "Peer group name";
}
uses bgpcmn: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 "/bgpg:sonic-bgp-global/bgpg:BGP_GLOBALS/bgpg:BGP_GLOBALS_LIST/bgpg: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";
}
description "Peer group name";
}
uses bgpcmn: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 "/bgpg:sonic-bgp-global/bgpg:BGP_GLOBALS/bgpg:BGP_GLOBALS_LIST/bgpg:vrf_name";
}
description "Network-instance/VRF name";
}
leaf ip_prefix {
type inet:ip-prefix;
description "Configure BGP dynamic neighbors listen range";
}
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";
}
}
}
}
}

View File

@ -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";
@ -101,6 +106,13 @@ module sonic-device_metadata {
pattern "dynamic|traditional";
}
}
leaf frr_mgmt_framework_config {
type boolean;
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";
}
}
/* end of container localhost */
}

View File

@ -0,0 +1,76 @@
module sonic-route-common {
namespace "http://github.com/Azure/sonic-route-common";
prefix rtcmn;
yang-version 1.1;
import sonic-vrf {
prefix vrf;
}
import sonic-route-map {
prefix rmap;
}
organization
"SONiC";
contact
"SONiC";
description
"SONIC ROUTE common YANG";
revision 2021-02-26 {
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 "/vrf:sonic-vrf/vrf:VRF/vrf:VRF_LIST/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 "/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.";
}
leaf metric {
type uint32;
description "Metric for redistributed routes";
}
}
}
}
}

View File

@ -0,0 +1,359 @@
module sonic-route-map {
namespace "http://github.com/Azure/sonic-route-map";
prefix rmap;
yang-version 1.1;
import ietf-inet-types {
prefix inet;
}
import sonic-port {
prefix port;
}
import sonic-portchannel {
prefix lag;
}
import sonic-routing-policy-sets {
prefix rpolsets;
}
// 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;
}
organization
"SONiC";
contact
"SONiC";
description
"SONIC Route map YANG";
revision 2021-02-26 {
description
"Initial revision.";
}
typedef route-map-intf {
type union {
type leafref {
path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name";
}
type leafref {
path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name";
}
// 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 string {
pattern 'Vlan([0-9]{1,3}|[1-3][0-9]{3}|[4][0][0-8][0-9]|[4][0][9][0-4])';
}
}
}
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;
description "Route map name";
}
}
}
container ROUTE_MAP {
list ROUTE_MAP_LIST {
key "name stmt_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 rpolsets:routing-policy-action-type;
description "permit/deny operation";
}
leaf match_interface{
type route-map-intf;
description "Match based on interface";
}
leaf match_prefix_set{
type leafref {
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.";
}
leaf match_ipv6_prefix_set{
type leafref {
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.";
}
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 "/rpolsets:sonic-routing-policy-sets/rpolsets:PREFIX_SET/rpolsets:PREFIX_SET_LIST/rpolsets:name";
}
description "Match based on nexthop";
}
leaf match_src_vrf {
type union {
type string {
pattern "default";
}
type leafref {
path "/vrf:sonic-vrf/vrf:VRF/vrf:VRF_LIST/vrf:name";
}
}
description "Match based on source VRF";
}
leaf-list match_neighbor {
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 string {
pattern 'Vlan([0-9]{1,3}|[1-3][0-9]{3}|[4][0][0-8][0-9]|[4][0][9][0-4])';
}
}
description
"IP addresse or interface for match operation.";
max-elements 1;
}
leaf-list match_tag {
type uint32;
description
"Value of the tag match member";
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 "/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 "/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 "/rpolsets:sonic-routing-policy-sets/rpolsets:AS_PATH_SET/rpolsets:AS_PATH_SET_LIST/rpolsets: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 {
/*
when "../set_metric_action = 'METRIC_SET_VALUE' " +
"or ../set_metric_action = 'METRIC_ADD_VALUE' " +
"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 "/rpolsets:sonic-routing-policy-sets/rpolsets:COMMUNITY_SET/rpolsets:COMMUNITY_SET_LIST/rpolsets: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 "/rpolsets:sonic-routing-policy-sets/rpolsets:EXTENDED_COMMUNITY_SET/rpolsets:EXTENDED_COMMUNITY_SET_LIST/rpolsets:name";
}
description "Refer extended community from extended community list";
}
leaf set_tag {
type uint32;
description
"Value of the tag set member";
}
}
}
}
}

View File

@ -0,0 +1,223 @@
module sonic-routing-policy-sets {
namespace "http://github.com/Azure/sonic-routing-policy-lists";
prefix rpolsets;
yang-version 1.1;
import ietf-inet-types {
prefix inet;
}
import sonic-extension {
prefix ext;
}
organization
"SONiC";
contact
"SONiC";
description
"SONiC ROUTING POLICY SETS";
revision 2021-02-26 {
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;
description "Prefix name";
}
leaf mode {
type enumeration {
enum IPv4;
enum IPv6;
}
description "Address family of the prefix";
}
}
}
container PREFIX {
list PREFIX_LIST {
key "name sequence_number ip_prefix masklength_range";
//ext:custom-validation ValidateIpPrefixListCfg;
leaf name {
type leafref {
path "../../../PREFIX_SET/PREFIX_SET_LIST/name";
}
description "Prefix 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;
description "Community name";
}
leaf set_type {
type enumeration {
enum STANDARD;
enum EXPANDED;
}
description "Community type";
}
leaf match_action {
type enumeration {
enum ANY;
enum ALL;
}
description "Match action any/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;
description "Extended community name";
}
leaf set_type {
type enumeration {
enum STANDARD;
enum EXPANDED;
}
description "Extended community type";
}
leaf match_action {
type enumeration {
enum ANY;
enum ALL;
}
description "Match action any/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;
description "AS PATH name";
}
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";
}
}
}
}
}