Skip to content

Commit 6088bd5

Browse files
authored
[multi-ASIC] BGP internal neighbor table support (#5520)
* Initial commit for BGP internal neighbor table support. > Add new template named "internal" for the internal BGP sessions > Add a new table in database "BGP_INTERNAL_NEIGHBOR" > The internal BGP sessions will be stored in this new table "BGP_INTERNAL_NEIGHBOR" * Changes in template generation tests with the introduction of internal neighbor template files.
1 parent 09d5a62 commit 6088bd5

40 files changed

+404
-173
lines changed

dockers/docker-fpm-frr/frr/bgpd/templates/general/instance.conf.j2

-19
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,12 @@
1515
!
1616
{% if neighbor_addr | ipv4 %}
1717
address-family ipv4
18-
{% if 'ASIC' in bgp_session['name'] %}
19-
neighbor {{ neighbor_addr }} peer-group PEER_V4_INT
20-
{% else %}
2118
neighbor {{ neighbor_addr }} peer-group PEER_V4
22-
{% endif %}
23-
!
24-
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
25-
neighbor {{ neighbor_addr }} route-map FROM_BGP_PEER_V4_INT in
26-
{% endif %}
2719
!
2820
{% elif neighbor_addr | ipv6 %}
2921
address-family ipv6
30-
{% if 'ASIC' in bgp_session['name'] %}
31-
neighbor {{ neighbor_addr }} peer-group PEER_V6_INT
32-
{% else %}
3322
neighbor {{ neighbor_addr }} peer-group PEER_V6
34-
{% endif %}
3523
!
36-
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
37-
neighbor {{ neighbor_addr }} route-map FROM_BGP_PEER_V6_INT in
38-
{% endif %}
3924
{% endif %}
4025
!
4126
{% if bgp_session.has_key('rrclient') and bgp_session['rrclient'] | int != 0 %}
@@ -45,10 +30,6 @@
4530
{% if bgp_session.has_key('nhopself') and bgp_session['nhopself'] | int != 0 %}
4631
neighbor {{ neighbor_addr }} next-hop-self
4732
{% endif %}
48-
!
49-
{% if 'ASIC' in bgp_session['name'] %}
50-
neighbor {{ neighbor_addr }} next-hop-self force
51-
{% endif %}
5233
!
5334
neighbor {{ neighbor_addr }} activate
5435
exit-address-family

dockers/docker-fpm-frr/frr/bgpd/templates/general/peer-group.conf.j2

-16
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,30 @@
22
! template: bgpd/templates/general/peer-group.conf.j2
33
!
44
neighbor PEER_V4 peer-group
5-
neighbor PEER_V4_INT peer-group
65
neighbor PEER_V6 peer-group
7-
neighbor PEER_V6_INT peer-group
86
address-family ipv4
97
{% if CONFIG_DB__DEVICE_METADATA['localhost']['type'] == 'ToRRouter' %}
108
neighbor PEER_V4 allowas-in 1
11-
neighbor PEER_V4_INT allowas-in 1
129
{% elif CONFIG_DB__DEVICE_METADATA['localhost']['type'] == 'LeafRouter' %}
1310
{% if CONFIG_DB__BGP_BBR['status'] == 'enabled' %}
1411
neighbor PEER_V4 allowas-in 1
1512
{% endif %}
16-
{% endif %}
17-
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
18-
neighbor PEER_V4_INT route-reflector-client
1913
{% endif %}
2014
neighbor PEER_V4 soft-reconfiguration inbound
2115
neighbor PEER_V4 route-map FROM_BGP_PEER_V4 in
2216
neighbor PEER_V4 route-map TO_BGP_PEER_V4 out
23-
neighbor PEER_V4_INT soft-reconfiguration inbound
24-
neighbor PEER_V4_INT route-map FROM_BGP_PEER_V4 in
25-
neighbor PEER_V4_INT route-map TO_BGP_PEER_V4 out
2617
exit-address-family
2718
address-family ipv6
2819
{% if CONFIG_DB__DEVICE_METADATA['localhost']['type'] == 'ToRRouter' %}
2920
neighbor PEER_V6 allowas-in 1
30-
neighbor PEER_V6_INT allowas-in 1
3121
{% elif CONFIG_DB__DEVICE_METADATA['localhost']['type'] == 'LeafRouter' %}
3222
{% if CONFIG_DB__BGP_BBR['status'] == 'enabled' %}
3323
neighbor PEER_V6 allowas-in 1
3424
{% endif %}
35-
{% endif %}
36-
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
37-
neighbor PEER_V6_INT route-reflector-client
3825
{% endif %}
3926
neighbor PEER_V6 soft-reconfiguration inbound
4027
neighbor PEER_V6 route-map FROM_BGP_PEER_V6 in
4128
neighbor PEER_V6 route-map TO_BGP_PEER_V6 out
42-
neighbor PEER_V6_INT soft-reconfiguration inbound
43-
neighbor PEER_V6_INT route-map FROM_BGP_PEER_V6 in
44-
neighbor PEER_V6_INT route-map TO_BGP_PEER_V6 out
4529
exit-address-family
4630
!
4731
! end of template: bgpd/templates/general/peer-group.conf.j2

dockers/docker-fpm-frr/frr/bgpd/templates/general/policies.conf.j2

-11
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,5 @@ route-map FROM_BGP_PEER_V6 permit 100
4242
!
4343
route-map TO_BGP_PEER_V6 permit 100
4444
!
45-
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
46-
route-map FROM_BGP_PEER_V4_INT permit 2
47-
set originator-id {{ loopback0_ipv4 | ip }}
48-
!
49-
route-map FROM_BGP_PEER_V6_INT permit 1
50-
set ipv6 next-hop prefer-global
51-
!
52-
route-map FROM_BGP_PEER_V6_INT permit 2
53-
set originator-id {{ loopback0_ipv4 | ip }}
54-
{% endif %}
55-
!
5645
! end of template: bgpd/templates/general/policies.conf.j2
5746
!
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
!
2+
! template: bgpd/templates/internal/instance.conf.j2
3+
!
4+
neighbor {{ neighbor_addr }} remote-as {{ bgp_session['asn'] }}
5+
neighbor {{ neighbor_addr }} description {{ bgp_session['name'] }}
6+
!
7+
{% if neighbor_addr | ipv4 %}
8+
address-family ipv4
9+
neighbor {{ neighbor_addr }} peer-group INTERNAL_PEER_V4
10+
!
11+
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
12+
neighbor {{ neighbor_addr }} route-map FROM_BGP_INTERNAL_PEER_V4 in
13+
{% endif %}
14+
!
15+
{% elif neighbor_addr | ipv6 %}
16+
address-family ipv6
17+
neighbor {{ neighbor_addr }} peer-group INTERNAL_PEER_V6
18+
!
19+
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
20+
neighbor {{ neighbor_addr }} route-map FROM_BGP_INTERNAL_PEER_V6 in
21+
{% endif %}
22+
{% endif %}
23+
!
24+
{% if bgp_session.has_key('rrclient') and bgp_session['rrclient'] | int != 0 %}
25+
neighbor {{ neighbor_addr }} route-reflector-client
26+
{% endif %}
27+
!
28+
neighbor {{ neighbor_addr }} next-hop-self force
29+
!
30+
neighbor {{ neighbor_addr }} activate
31+
exit-address-family
32+
!
33+
! end of template: bgpd/templates/internal/instance.conf.j2
34+
!
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
!
2+
! template: bgpd/templates/internal/peer-group.conf.j2
3+
!
4+
neighbor INTERNAL_PEER_V4 peer-group
5+
neighbor INTERNAL_PEER_V6 peer-group
6+
address-family ipv4
7+
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
8+
neighbor INTERNAL_PEER_V4 route-reflector-client
9+
{% endif %}
10+
neighbor INTERNAL_PEER_V4 soft-reconfiguration inbound
11+
neighbor INTERNAL_PEER_V4 route-map FROM_BGP_INTERNAL_PEER_V4 in
12+
neighbor INTERNAL_PEER_V4 route-map TO_BGP_INTERNAL_PEER_V4 out
13+
exit-address-family
14+
address-family ipv6
15+
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
16+
neighbor INTERNAL_PEER_V6 route-reflector-client
17+
{% endif %}
18+
neighbor INTERNAL_PEER_V6 soft-reconfiguration inbound
19+
neighbor INTERNAL_PEER_V6 route-map FROM_BGP_INTERNAL_PEER_V6 in
20+
neighbor INTERNAL_PEER_V6 route-map TO_BGP_INTERNAL_PEER_V6 out
21+
exit-address-family
22+
!
23+
! end of template: bgpd/templates/internal/peer-group.conf.j2
24+
!
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
!
2+
! template: bgpd/templates/internal/policies.conf.j2
3+
!
4+
!
5+
!
6+
route-map FROM_BGP_INTERNAL_PEER_V4 permit 100
7+
!
8+
route-map TO_BGP_INTERNAL_PEER_V4 permit 100
9+
!
10+
!
11+
route-map FROM_BGP_INTERNAL_PEER_V6 permit 1
12+
set ipv6 next-hop prefer-global
13+
!
14+
route-map FROM_BGP_INTERNAL_PEER_V6 permit 100
15+
!
16+
route-map TO_BGP_INTERNAL_PEER_V6 permit 100
17+
!
18+
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
19+
route-map FROM_BGP_INTERNAL_PEER_V4 permit 2
20+
set originator-id {{ loopback0_ipv4 | ip }}
21+
!
22+
route-map FROM_BGP_INTERNAL_PEER_V6 permit 2
23+
set originator-id {{ loopback0_ipv4 | ip }}
24+
{% endif %}
25+
!
26+
! end of template: bgpd/templates/internal/policies.conf.j2
27+
!

files/image_config/constants/constants.yml

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ constants:
4040
- ipv4
4141
PEER_V6:
4242
- ipv6
43+
internal: # peer_type
44+
db_table: "BGP_INTERNAL_NEIGHBOR"
45+
template_dir: "internal"
4346
monitors: # peer_type
4447
enabled: true
4548
db_table: "BGP_MONITORS"

src/sonic-bgpcfgd/bgpcfgd/main.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def do_work():
4444
ZebraSetSrc(common_objs, "STATE_DB", swsscommon.STATE_INTERFACE_TABLE_NAME),
4545
# Peer Managers
4646
BGPPeerMgrBase(common_objs, "CONFIG_DB", swsscommon.CFG_BGP_NEIGHBOR_TABLE_NAME, "general", True),
47+
BGPPeerMgrBase(common_objs, "CONFIG_DB", swsscommon.CFG_BGP_INTERNAL_NEIGHBOR_TABLE_NAME, "internal", False),
4748
BGPPeerMgrBase(common_objs, "CONFIG_DB", "BGP_MONITORS", "monitors", False),
4849
BGPPeerMgrBase(common_objs, "CONFIG_DB", "BGP_PEER_RANGE", "dynamic", False),
4950
# AllowList Managers
@@ -81,4 +82,4 @@ def main():
8182
try:
8283
sys.exit(rc)
8384
except SystemExit:
84-
os._exit(rc)
85+
os._exit(rc)

src/sonic-bgpcfgd/tests/data/general/instance.conf/param_ASIC_v6.json

-15
This file was deleted.

src/sonic-bgpcfgd/tests/data/general/instance.conf/param_all_v4.json

-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
{
2-
"CONFIG_DB__DEVICE_METADATA": {
3-
"localhost": {
4-
"sub_role": "BackEnd"
5-
}
6-
},
72
"neighbor_addr": "10.10.10.10",
83
"bgp_session": {
94
"asn": "555",

src/sonic-bgpcfgd/tests/data/general/instance.conf/param_all_v6.json

-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
{
2-
"CONFIG_DB__DEVICE_METADATA": {
3-
"localhost": {
4-
"sub_role": "BackEnd"
5-
}
6-
},
72
"neighbor_addr": "fc::10",
83
"bgp_session": {
94
"asn": "555",

src/sonic-bgpcfgd/tests/data/general/instance.conf/result_ASIC_v6.conf

-13
This file was deleted.

src/sonic-bgpcfgd/tests/data/general/instance.conf/result_all_v4.conf

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
neighbor 10.10.10.10 shutdown
88
address-family ipv4
99
neighbor 10.10.10.10 peer-group PEER_V4
10-
neighbor 10.10.10.10 route-map FROM_BGP_PEER_V4_INT in
1110
neighbor 10.10.10.10 route-reflector-client
1211
neighbor 10.10.10.10 next-hop-self
1312
neighbor 10.10.10.10 activate

src/sonic-bgpcfgd/tests/data/general/instance.conf/result_all_v6.conf

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
neighbor fc::10 shutdown
88
address-family ipv6
99
neighbor fc::10 peer-group PEER_V6
10-
neighbor fc::10 route-map FROM_BGP_PEER_V6_INT in
1110
neighbor fc::10 route-reflector-client
1211
neighbor fc::10 next-hop-self
1312
neighbor fc::10 activate

src/sonic-bgpcfgd/tests/data/general/peer-group.conf/param_base.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"CONFIG_DB__DEVICE_METADATA": {
33
"localhost": {
4-
"type": "LeafRouter",
5-
"sub_role": "BackEnd"
4+
"type": "LeafRouter"
65
}
76
},
87
"CONFIG_DB__BGP_BBR": {

src/sonic-bgpcfgd/tests/data/general/peer-group.conf/result_all.conf

-10
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,18 @@
22
! template: bgpd/templates/general/peer-group.conf.j2
33
!
44
neighbor PEER_V4 peer-group
5-
neighbor PEER_V4_INT peer-group
65
neighbor PEER_V6 peer-group
7-
neighbor PEER_V6_INT peer-group
86
address-family ipv4
97
neighbor PEER_V4 allowas-in 1
10-
neighbor PEER_V4_INT allowas-in 1
118
neighbor PEER_V4 soft-reconfiguration inbound
129
neighbor PEER_V4 route-map FROM_BGP_PEER_V4 in
1310
neighbor PEER_V4 route-map TO_BGP_PEER_V4 out
14-
neighbor PEER_V4_INT soft-reconfiguration inbound
15-
neighbor PEER_V4_INT route-map FROM_BGP_PEER_V4 in
16-
neighbor PEER_V4_INT route-map TO_BGP_PEER_V4 out
1711
exit-address-family
1812
address-family ipv6
1913
neighbor PEER_V6 allowas-in 1
20-
neighbor PEER_V6_INT allowas-in 1
2114
neighbor PEER_V6 soft-reconfiguration inbound
2215
neighbor PEER_V6 route-map FROM_BGP_PEER_V6 in
2316
neighbor PEER_V6 route-map TO_BGP_PEER_V6 out
24-
neighbor PEER_V6_INT soft-reconfiguration inbound
25-
neighbor PEER_V6_INT route-map FROM_BGP_PEER_V6 in
26-
neighbor PEER_V6_INT route-map TO_BGP_PEER_V6 out
2717
exit-address-family
2818
!
2919
! end of template: bgpd/templates/general/peer-group.conf.j2

src/sonic-bgpcfgd/tests/data/general/peer-group.conf/result_base.conf

-10
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,16 @@
22
! template: bgpd/templates/general/peer-group.conf.j2
33
!
44
neighbor PEER_V4 peer-group
5-
neighbor PEER_V4_INT peer-group
65
neighbor PEER_V6 peer-group
7-
neighbor PEER_V6_INT peer-group
86
address-family ipv4
9-
neighbor PEER_V4_INT route-reflector-client
107
neighbor PEER_V4 soft-reconfiguration inbound
118
neighbor PEER_V4 route-map FROM_BGP_PEER_V4 in
129
neighbor PEER_V4 route-map TO_BGP_PEER_V4 out
13-
neighbor PEER_V4_INT soft-reconfiguration inbound
14-
neighbor PEER_V4_INT route-map FROM_BGP_PEER_V4 in
15-
neighbor PEER_V4_INT route-map TO_BGP_PEER_V4 out
1610
exit-address-family
1711
address-family ipv6
18-
neighbor PEER_V6_INT route-reflector-client
1912
neighbor PEER_V6 soft-reconfiguration inbound
2013
neighbor PEER_V6 route-map FROM_BGP_PEER_V6 in
2114
neighbor PEER_V6 route-map TO_BGP_PEER_V6 out
22-
neighbor PEER_V6_INT soft-reconfiguration inbound
23-
neighbor PEER_V6_INT route-map FROM_BGP_PEER_V6 in
24-
neighbor PEER_V6_INT route-map TO_BGP_PEER_V6 out
2515
exit-address-family
2616
!
2717
! end of template: bgpd/templates/general/peer-group.conf.j2

src/sonic-bgpcfgd/tests/data/general/policies.conf/param_all.json

-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
{
2-
"CONFIG_DB__DEVICE_METADATA": {
3-
"localhost": {
4-
"sub_role": "BackEnd"
5-
}
6-
},
72
"loopback0_ipv4": "10.10.10.10/32",
83
"constants": {
94
"bgp": {

src/sonic-bgpcfgd/tests/data/general/policies.conf/param_base.json

-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
{
2-
"CONFIG_DB__DEVICE_METADATA": {
3-
"localhost": {
4-
"sub_role": "NotBackEnd"
5-
}
6-
},
72
"loopback0_ipv4": "10.10.10.10/32",
83
"constants": {
94
"bgp": {

src/sonic-bgpcfgd/tests/data/general/policies.conf/param_deny.json

-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
{
2-
"CONFIG_DB__DEVICE_METADATA": {
3-
"localhost": {
4-
"sub_role": "BackEnd"
5-
}
6-
},
72
"loopback0_ipv4": "10.10.10.10/32",
83
"constants": {
94
"bgp": {

src/sonic-bgpcfgd/tests/data/general/policies.conf/result_all.conf

-9
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,5 @@ route-map FROM_BGP_PEER_V6 permit 100
2626
!
2727
route-map TO_BGP_PEER_V6 permit 100
2828
!
29-
route-map FROM_BGP_PEER_V4_INT permit 2
30-
set originator-id 10.10.10.10
31-
!
32-
route-map FROM_BGP_PEER_V6_INT permit 1
33-
set ipv6 next-hop prefer-global
34-
!
35-
route-map FROM_BGP_PEER_V6_INT permit 2
36-
set originator-id 10.10.10.10
37-
!
3829
! end of template: bgpd/templates/general/policies.conf.j2
3930
!

0 commit comments

Comments
 (0)