-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bgp] Add support to explicitly specify bgp router id for single asic…
…e device (#18727) HLD: sonic-net/SONiC#1643 Add support to explictly specify bgp router id for single asic device Microsoft ADO (number only): 27674485 How I did it 1. When bgp_router_id configured in DEVICE_METADATA, use it as bgp router-id. 2. Remove the hard dependency on loopback0 ipv4 address when adding bgp peer. 3. Add UTs. Behavior of set bgp router-id To be clarified that when bgp router-id hasn't been explicitly set, bgp actions would totally like previous Loopback0 IPv4 address exists Loopback0 IPv4 address doesn't exist bgp_router_id configured Honor bgp_router_id Honor bgp_router_id bgp_router_id not confgd Honor Loopback0 IPv4 address FRR default router ID value is selected as the largest IP address of the device. When router zebra is not enabled bgpd can’t get interface information, so router-id is set to 0.0.0.0 Behavior of add bgp peer To be clarified that when bgp router-id hasn't been explicitly set, bgp actions would totally like previous Loopback0 IPv4 address exists Loopback0 IPv4 address doesn't exist bgp_router_id configured Add BGP peer Add BGP peer bgp_router_id not configured Add BGP peer Do not add BGP peer
- Loading branch information
Showing
13 changed files
with
425 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/sonic-bgpcfgd/tests/data/monitors/peer-group.conf/param_without_lo0_ipv4.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"CONFIG_DB__DEVICE_METADATA": { | ||
"localhost": { | ||
"type": "LeafRouter" | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/sonic-bgpcfgd/tests/data/monitors/peer-group.conf/result_without_lo0_ipv4.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
! | ||
! template: bgpd/templates/BGPMON/peer-group.conf.j2 | ||
! | ||
neighbor BGPMON peer-group | ||
address-family ipv4 | ||
neighbor BGPMON activate | ||
neighbor BGPMON route-map FROM_BGPMON in | ||
neighbor BGPMON route-map TO_BGPMON out | ||
neighbor BGPMON send-community | ||
neighbor BGPMON maximum-prefix 1 | ||
exit-address-family | ||
! | ||
! end of template: bgpd/templates/BGPMON/peer-group.conf.j2 | ||
! | ||
|
80 changes: 80 additions & 0 deletions
80
src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/defaults_router_id.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
! | ||
! template: bgpd/bgpd.main.conf.j2 | ||
! | ||
! bgp multiple-instance | ||
! | ||
! BGP configuration | ||
! | ||
! TSA configuration | ||
! | ||
ip prefix-list PL_LoopbackV4 permit 55.55.55.55/32 | ||
! | ||
ipv6 prefix-list PL_LoopbackV6 permit fc00::/64 | ||
! | ||
ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 5 permit 10.10.10.0/24 | ||
! | ||
ipv6 prefix-list LOCAL_VLAN_IPV6_PREFIX seq 10 permit fc01::/64 | ||
! | ||
ip prefix-list V4_P2P_IP permit 0.0.0.0/0 ge 31 le 31 | ||
! | ||
ipv6 prefix-list V6_P2P_IP permit ::/0 ge 126 le 126 | ||
! | ||
route-map V4_CONNECTED_ROUTES permit 10 | ||
match ip address prefix-list V4_P2P_IP | ||
call HIDE_INTERNAL | ||
! | ||
route-map V6_CONNECTED_ROUTES permit 10 | ||
match ipv6 address prefix-list V6_P2P_IP | ||
call HIDE_INTERNAL | ||
! | ||
route-map HIDE_INTERNAL permit 10 | ||
set community no-export | ||
! | ||
! | ||
router bgp 55555 | ||
! | ||
bgp log-neighbor-changes | ||
bgp suppress-fib-pending | ||
no bgp default ipv4-unicast | ||
no bgp ebgp-requires-policy | ||
! | ||
bgp bestpath as-path multipath-relax | ||
! | ||
bgp graceful-restart restart-time 240 | ||
bgp graceful-restart | ||
bgp graceful-restart preserve-fw-state | ||
bgp graceful-restart select-defer-time 45 | ||
! | ||
bgp router-id 8.8.8.8 | ||
! | ||
network 55.55.55.55/32 | ||
network 55.55.55.56/32 route-map HIDE_INTERNAL | ||
! | ||
address-family ipv6 | ||
network fc00::1/64 | ||
exit-address-family | ||
address-family ipv6 | ||
network fc00::2/128 route-map HIDE_INTERNAL | ||
exit-address-family | ||
! | ||
network 10.10.10.1/24 | ||
address-family ipv6 | ||
network fc01::1/64 | ||
exit-address-family | ||
! | ||
address-family ipv4 | ||
redistribute connected route-map V4_CONNECTED_ROUTES | ||
exit-address-family | ||
address-family ipv6 | ||
redistribute connected route-map V6_CONNECTED_ROUTES | ||
exit-address-family | ||
! | ||
address-family ipv4 | ||
maximum-paths 64 | ||
exit-address-family | ||
address-family ipv6 | ||
maximum-paths 64 | ||
exit-address-family | ||
! | ||
! end of template: bgpd/bgpd.main.conf.j2 | ||
! |
36 changes: 36 additions & 0 deletions
36
src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/defaults_router_id.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"DEVICE_METADATA": { | ||
"localhost": { | ||
"bgp_asn": "55555", | ||
"sub_role": "FrontEnd", | ||
"type": "ToRRouter", | ||
"bgp_router_id": "8.8.8.8" | ||
} | ||
}, | ||
"LOOPBACK_INTERFACE": { | ||
"Loopback0|55.55.55.55/32": {}, | ||
"Loopback0|fc00::1/128": {}, | ||
"Loopback4096|55.55.55.56/32": {}, | ||
"Loopback4096|fc00::2/128": {} | ||
}, | ||
"VLAN_INTERFACE": { | ||
"Vlan10|10.10.10.1/24": {}, | ||
"Vlan10|fc01::1/64": {}, | ||
"Vlan20": {"vnet_name": "Vnet1"}, | ||
"Vlan20|20.20.20.1/24": {}, | ||
"Vlan20|fd01::1/64": {} | ||
}, | ||
"constants": { | ||
"bgp": { | ||
"multipath_relax": { | ||
"enabled": true | ||
}, | ||
"graceful_restart": { | ||
"enabled": true | ||
}, | ||
"maximum_paths": { | ||
"enabled": true | ||
} | ||
} | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/lo0_ipv6_only.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
! | ||
! template: bgpd/bgpd.main.conf.j2 | ||
! | ||
! bgp multiple-instance | ||
! | ||
! BGP configuration | ||
! | ||
! TSA configuration | ||
! | ||
ipv6 prefix-list PL_LoopbackV6 permit fc00::/64 | ||
! | ||
ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 5 permit 10.10.10.0/24 | ||
! | ||
ipv6 prefix-list LOCAL_VLAN_IPV6_PREFIX seq 10 permit fc01::/64 | ||
! | ||
ip prefix-list V4_P2P_IP permit 0.0.0.0/0 ge 31 le 31 | ||
! | ||
ipv6 prefix-list V6_P2P_IP permit ::/0 ge 126 le 126 | ||
! | ||
route-map V4_CONNECTED_ROUTES permit 10 | ||
match ip address prefix-list V4_P2P_IP | ||
call HIDE_INTERNAL | ||
! | ||
route-map V6_CONNECTED_ROUTES permit 10 | ||
match ipv6 address prefix-list V6_P2P_IP | ||
call HIDE_INTERNAL | ||
! | ||
route-map HIDE_INTERNAL permit 10 | ||
set community no-export | ||
! | ||
! | ||
router bgp 55555 | ||
! | ||
bgp log-neighbor-changes | ||
bgp suppress-fib-pending | ||
no bgp default ipv4-unicast | ||
no bgp ebgp-requires-policy | ||
! | ||
bgp bestpath as-path multipath-relax | ||
! | ||
bgp graceful-restart restart-time 480 | ||
bgp graceful-restart | ||
bgp graceful-restart preserve-fw-state | ||
bgp graceful-restart select-defer-time 45 | ||
! | ||
network 55.55.55.56/32 route-map HIDE_INTERNAL | ||
! | ||
address-family ipv6 | ||
network fc00::1/64 | ||
exit-address-family | ||
address-family ipv6 | ||
network fc00::2/128 route-map HIDE_INTERNAL | ||
exit-address-family | ||
! | ||
network 10.10.10.1/24 | ||
address-family ipv6 | ||
network fc01::1/64 | ||
exit-address-family | ||
! | ||
address-family ipv4 | ||
redistribute connected route-map V4_CONNECTED_ROUTES | ||
exit-address-family | ||
address-family ipv6 | ||
redistribute connected route-map V6_CONNECTED_ROUTES | ||
exit-address-family | ||
! | ||
address-family ipv4 | ||
maximum-paths 32 | ||
exit-address-family | ||
address-family ipv6 | ||
maximum-paths 32 | ||
exit-address-family | ||
! | ||
! end of template: bgpd/bgpd.main.conf.j2 | ||
! |
37 changes: 37 additions & 0 deletions
37
src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/lo0_ipv6_only.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"DEVICE_METADATA": { | ||
"localhost": { | ||
"bgp_asn": "55555", | ||
"sub_role": "FrontEnd", | ||
"type": "ToRRouter" | ||
} | ||
}, | ||
"LOOPBACK_INTERFACE": { | ||
"Loopback0|fc00::1/128": {}, | ||
"Loopback4096|55.55.55.56/32": {}, | ||
"Loopback4096|fc00::2/128": {} | ||
}, | ||
"VLAN_INTERFACE": { | ||
"Vlan10|10.10.10.1/24": {}, | ||
"Vlan10|fc01::1/64": {}, | ||
"Vlan20": {"vnet_name": "Vnet1"}, | ||
"Vlan20|20.20.20.1/24": {}, | ||
"Vlan20|fd01::1/64": {} | ||
}, | ||
"constants": { | ||
"bgp": { | ||
"multipath_relax": { | ||
"enabled": true | ||
}, | ||
"graceful_restart": { | ||
"enabled": true, | ||
"restart_time": 480 | ||
}, | ||
"maximum_paths": { | ||
"enabled": true, | ||
"ipv4": 32, | ||
"ipv6": 32 | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.