Skip to content

Commit

Permalink
support BGP_ALLOWED_PREFIXES (#10142)
Browse files Browse the repository at this point in the history
  • Loading branch information
StormLiangMS authored Mar 5, 2022
1 parent c40f04f commit 55a0722
Show file tree
Hide file tree
Showing 5 changed files with 323 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/sonic-yang-models/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def run(self):
'./yang-models/sonic-bgp-neighbor.yang',
'./yang-models/sonic-bgp-peergroup.yang',
'./yang-models/sonic-bgp-peerrange.yang',
'./yang-models/sonic-bgp-allowed-prefix.yang',
'./yang-models/sonic-breakout_cfg.yang',
'./yang-models/sonic-buffer-pg.yang',
'./yang-models/sonic-buffer-pool.yang',
Expand Down Expand Up @@ -126,11 +127,8 @@ def run(self):
'./yang-models/sonic-versions.yang',
'./yang-models/sonic-vlan.yang',
'./yang-models/sonic-vrf.yang',

'./yang-models/sonic-mclag.yang',

'./yang-models/sonic-vlan-sub-interface.yang',

'./yang-models/sonic-warm-restart.yang',
'./yang-models/sonic-lldp.yang',
'./yang-models/sonic-scheduler.yang',
Expand All @@ -153,6 +151,7 @@ def run(self):
'./cvlyang-models/sonic-bgp-neighbor.yang',
'./cvlyang-models/sonic-bgp-peergroup.yang',
'./cvlyang-models/sonic-bgp-peerrange.yang',
'./cvlyang-models/sonic-bgp-allowed-prefix.yang',
'./cvlyang-models/sonic-breakout_cfg.yang',
'./cvlyang-models/sonic-copp.yang',
'./cvlyang-models/sonic-crm.yang',
Expand Down
8 changes: 8 additions & 0 deletions src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,14 @@
"peer_group": "PG1"
}
},
"BGP_ALLOWED_PREFIXES" :{
"DEPLOYMENT_ID|4|123:123": {
"default_action": "permit"
},
"DEPLOYMENT_ID|5": {
"default_action": "permit"
}
},
"ROUTE_MAP_SET": {
"map1": {
}
Expand Down
41 changes: 40 additions & 1 deletion src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,46 @@
},
"BGP_PEERRANGE_ALL_VALID": {
"desc": "Configure BGP peer range table."
},
"BGP_ALLOWED_PREFIXES_COM_LIST_ALL_VALID": {
"desc": "Configue BGP allowed prefix list."
},
"BGP_ALLOWED_PREFIXES_COM_LIST_INVALID_DEPLOYMENT": {
"desc": "Invalid default action.",
"eStrKey" : "Pattern"
},
"BGP_ALLOWED_PREFIXES_COM_LIST_INVALID_DEFAULT_ACTION": {
"desc": "Invalid default action.",
"eStrKey" : "InvalidValue",
"eStr" : ["default_action"]
},
"BGP_ALLOWED_PREFIXES_COM_LIST_INVALID_PREFIXES_IPV4": {
"desc": "Invalid IPv4 prefix.",
"eStrKey" : "Pattern"
},
"BGP_ALLOWED_PREFIXES_COM_LIST_INVALID_PREFIXES_IPV6": {
"desc": "Invalid IPv6 prefix.",
"eStrKey" : "Pattern"
},
"BGP_ALLOWED_PREFIXES_LIST_ALL_VALID": {
"desc": "Configue BGP allowed prefix list."
},
"BGP_ALLOWED_PREFIXES_LIST_INVALID_DEPLOYMENT": {
"desc": "Invalid default action.",
"eStrKey" : "Pattern"
},
"BGP_ALLOWED_PREFIXES_LIST_INVALID_DEFAULT_ACTION": {
"desc": "Invalid default action.",
"eStrKey" : "InvalidValue",
"eStr" : ["default_action"]
},
"BGP_ALLOWED_PREFIXES_LIST_INVALID_PREFIXES_IPV4": {
"desc": "Invalid IPv4 prefix.",
"eStrKey" : "Pattern"
},
"BGP_ALLOWED_PREFIXES_LIST_INVALID_PREFIXES_IPV6": {
"desc": "Invalid IPv6 prefix.",
"eStrKey" : "Pattern"
}

}

171 changes: 171 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json
Original file line number Diff line number Diff line change
Expand Up @@ -1420,6 +1420,177 @@
]
}
}
},

"BGP_ALLOWED_PREFIXES_COM_LIST_ALL_VALID": {
"sonic-bgp-allowed-prefix:sonic-bgp-allowed-prefix": {
"sonic-bgp-allowed-prefix:BGP_ALLOWED_PREFIXES": {
"BGP_ALLOWED_PREFIXES_COM_LIST": [
{
"deployment": "DEPLOYMENT_ID",
"id": "4",
"community": "123:123",
"default_action": "permit",
"prefixes_v4": ["10.0.0.0/24", "10.1.0.0/24"],
"prefixes_v6": ["fc00:f0::/64", "fc00:a0::/64"]
},
{
"deployment": "DEPLOYMENT_ID",
"id": "5",
"community": "456:456",
"default_action": "permit",
"prefixes_v4": ["10.10.0.0/24", "10.11.0.0/24"],
"prefixes_v6": ["fc00:f1::/64", "fc00:a1::/64"]
}
]
}
}
},
"BGP_ALLOWED_PREFIXES_COM_LIST_INVALID_DEPLOYMENT": {
"sonic-bgp-allowed-prefix:sonic-bgp-allowed-prefix": {
"sonic-bgp-allowed-prefix:BGP_ALLOWED_PREFIXES": {
"BGP_ALLOWED_PREFIXES_COM_LIST": [
{
"deployment": "DEPLOYMENTID",
"id": "4",
"community": "123:123",
"default_action": "permitall",
"prefixes_v4": ["10.0.0.0/24", "10.1.0.0/24"],
"prefixes_v6": ["fc00:f0::/64", "fc00:a0::/64"]
}
]
}
}
},
"BGP_ALLOWED_PREFIXES_COM_LIST_INVALID_DEFAULT_ACTION": {
"sonic-bgp-allowed-prefix:sonic-bgp-allowed-prefix": {
"sonic-bgp-allowed-prefix:BGP_ALLOWED_PREFIXES": {
"BGP_ALLOWED_PREFIXES_COM_LIST": [
{
"deployment": "DEPLOYMENT_ID",
"id": "4",
"community": "123:123",
"default_action": "permitall",
"prefixes_v4": ["10.0.0.0/24", "10.1.0.0/24"],
"prefixes_v6": ["fc00:f0::/64", "fc00:a0::/64"]
}
]
}
}
},
"BGP_ALLOWED_PREFIXES_COM_LIST_INVALID_PREFIXES_IPV4": {
"sonic-bgp-allowed-prefix:sonic-bgp-allowed-prefix": {
"sonic-bgp-allowed-prefix:BGP_ALLOWED_PREFIXES": {
"BGP_ALLOWED_PREFIXES_COM_LIST": [
{
"deployment": "DEPLOYMENT_ID",
"id": "4",
"community": "123:123",
"default_action": "permit",
"prefixes_v4": ["10.0.0.0/48", "10.1.0.0/24"],
"prefixes_v6": ["fc00:f0::/64", "fc00:a0::/64"]
}
]
}
}
},
"BGP_ALLOWED_PREFIXES_COM_LIST_INVALID_PREFIXES_IPV6": {
"sonic-bgp-allowed-prefix:sonic-bgp-allowed-prefix": {
"sonic-bgp-allowed-prefix:BGP_ALLOWED_PREFIXES": {
"BGP_ALLOWED_PREFIXES_COM_LIST": [
{
"deployment": "DEPLOYMENT_ID",
"id": "4",
"community": "123:123",
"default_action": "permit",
"prefixes_v4": ["10.0.0.0/24", "10.1.0.0./24"],
"prefixes_v6": ["fc00:f0::/129", "fc00:a0::/64"]
}
]
}
}
},
"BGP_ALLOWED_PREFIXES_LIST_ALL_VALID": {
"sonic-bgp-allowed-prefix:sonic-bgp-allowed-prefix": {
"sonic-bgp-allowed-prefix:BGP_ALLOWED_PREFIXES": {
"BGP_ALLOWED_PREFIXES_LIST": [
{
"deployment": "DEPLOYMENT_ID",
"id": "4",
"default_action": "permit",
"prefixes_v4": ["10.0.0.0/24", "10.1.0.0/24"],
"prefixes_v6": ["fc00:f0::/64", "fc00:a0::/64"]
},
{
"deployment": "DEPLOYMENT_ID",
"id": "5",
"default_action": "permit",
"prefixes_v4": ["10.10.0.0/24", "10.11.0.0/24"],
"prefixes_v6": ["fc00:f1::/64", "fc00:a1::/64"]
}
]
}
}
},
"BGP_ALLOWED_PREFIXES_LIST_INVALID_DEPLOYMENT": {
"sonic-bgp-allowed-prefix:sonic-bgp-allowed-prefix": {
"sonic-bgp-allowed-prefix:BGP_ALLOWED_PREFIXES": {
"BGP_ALLOWED_PREFIXES_LIST": [
{
"deployment": "DEPLOYMENTID",
"id": "4",
"default_action": "permitall",
"prefixes_v4": ["10.0.0.0/24", "10.1.0.0/24"],
"prefixes_v6": ["fc00:f0::/64", "fc00:a0::/64"]
}
]
}
}
},
"BGP_ALLOWED_PREFIXES_LIST_INVALID_DEFAULT_ACTION": {
"sonic-bgp-allowed-prefix:sonic-bgp-allowed-prefix": {
"sonic-bgp-allowed-prefix:BGP_ALLOWED_PREFIXES": {
"BGP_ALLOWED_PREFIXES_LIST": [
{
"deployment": "DEPLOYMENT_ID",
"id": "4",
"default_action": "permitall",
"prefixes_v4": ["10.0.0.0/24", "10.1.0.0/24"],
"prefixes_v6": ["fc00:f0::/64", "fc00:a0::/64"]
}
]
}
}
},
"BGP_ALLOWED_PREFIXES_LIST_INVALID_PREFIXES_IPV4": {
"sonic-bgp-allowed-prefix:sonic-bgp-allowed-prefix": {
"sonic-bgp-allowed-prefix:BGP_ALLOWED_PREFIXES": {
"BGP_ALLOWED_PREFIXES_LIST": [
{
"deployment": "DEPLOYMENT_ID",
"id": "4",
"default_action": "permit",
"prefixes_v4": ["10.0.0.0/48", "10.1.0.0/24"],
"prefixes_v6": ["fc00:f0::/64", "fc00:a0::/64"]
}
]
}
}
},
"BGP_ALLOWED_PREFIXES_LIST_INVALID_PREFIXES_IPV6": {
"sonic-bgp-allowed-prefix:sonic-bgp-allowed-prefix": {
"sonic-bgp-allowed-prefix:BGP_ALLOWED_PREFIXES": {
"BGP_ALLOWED_PREFIXES_LIST": [
{
"deployment": "DEPLOYMENT_ID",
"id": "4",
"default_action": "permit",
"prefixes_v4": ["10.0.0.0/24", "10.1.0.0./24"],
"prefixes_v6": ["fc00:f0::/129", "fc00:a0::/64"]
}
]
}
}
}
}

Expand Down
102 changes: 102 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-bgp-allowed-prefix.yang
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
module sonic-bgp-allowed-prefix {
namespace "http://github.com/Azure/sonic-bgp-allowed-prefix";
prefix bgppre;
yang-version 1.1;

import sonic-bgp-common {
prefix bgpcmn;
}

import ietf-inet-types {
prefix inet;
}

import sonic-routing-policy-sets {
prefix rpolsets;
}

organization
"SONiC";

contact
"SONiC";

description
"SONIC BGP Allowed Prefix";

revision 2022-02-26 {
description
"Initial revision.";
}

container sonic-bgp-allowed-prefix {
container BGP_ALLOWED_PREFIXES {
list BGP_ALLOWED_PREFIXES_COM_LIST {
key "deployment id community";

leaf deployment {
type string {
pattern "DEPLOYMENT_ID";
}
description "BGP allowed prefix list key type";
}

leaf id {
type uint32;
description "BGP allowed prefix list deployment id";
}

leaf community {
type string;
description "BGP allowed prefix list deployment community";
}

leaf default_action {
type rpolsets:routing-policy-action-type;
description "Permit/Deny action for BGP allow prefix list";
}

leaf-list prefixes_v4 {
type inet:ipv4-prefix;
description "BGP V4 allowed prefix list";
}

leaf-list prefixes_v6 {
type inet:ipv6-prefix;
description "BGP V6 allowed prefix list";
}
}

list BGP_ALLOWED_PREFIXES_LIST {
key "deployment id";

leaf deployment {
type string {
pattern "DEPLOYMENT_ID";
}
description "BGP allowed prefix list key type";
}

leaf id {
type uint32;
description "BGP allowed prefix list deployment id";
}

leaf default_action {
type rpolsets:routing-policy-action-type;
description "Permit/Deny action for BGP allow prefix list";
}

leaf-list prefixes_v4 {
type inet:ipv4-prefix;
description "BGP V4 allowed prefix list";
}

leaf-list prefixes_v6 {
type inet:ipv6-prefix;
description "BGP V6 allowed prefix list";
}
}
}
}
}

0 comments on commit 55a0722

Please sign in to comment.