Skip to content

Commit 6d767e5

Browse files
authored
[chassis] Support advertisement of Loopback0 of all LC's across all e-BGP peers in TSA mode (sonic-net#16714) (sonic-net#17837)
What I did: In Chassis TSA mode Loopback0 Ip's of each LC's should be advertise through e-BGP peers of each remote LC's How I did: - Route-map policy to Advertise own/self Loopback IP to other internal iBGP peers with a community internal_community as define in constants.yml - Route-map policy to match on above internal_community when route is received from internal iBGP peers and set a internal tag as define in constants.yml and also delete the internal_community so we don't send to any of e-BGP peers - In TSA new route-map match on above internal tag and permit the route (Loopback0 IP's of remote LC's) and set the community to traffic_shift_community. - In TSB delete the above new route-map. How I verify: Manual Verification UT updated. sonic-mgmt PR: sonic-net/sonic-mgmt#10239 Signed-off-by: Abhishek Dosi <[email protected]>
1 parent 898f126 commit 6d767e5

22 files changed

+214
-41
lines changed

dockers/docker-fpm-frr/TS

+7-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ function check_not_installed()
1616
is_internal_route_map $route_map_name && continue
1717
echo "$config" | egrep -q "^route-map $route_map_name permit 20$"
1818
c=$((c+$?))
19-
echo "$config" | egrep -q "^route-map $route_map_name deny 30$"
19+
echo "$config" | egrep -q "^route-map $route_map_name permit 30$"
20+
c=$((c+$?))
21+
echo "$config" | egrep -q "^route-map $route_map_name deny 40$"
2022
c=$((c+$?))
2123
done
2224
return $c
@@ -33,7 +35,10 @@ function check_installed()
3335
echo "$config" | egrep -q "^route-map $route_map_name permit 20$"
3436
c=$((c+$?))
3537
e=$((e+1))
36-
echo "$config" | egrep -q "^route-map $route_map_name deny 30$"
38+
echo "$config" | egrep -q "^route-map $route_map_name permit 30$"
39+
c=$((c+$?))
40+
e=$((e+1))
41+
echo "$config" | egrep -q "^route-map $route_map_name deny 40$"
3742
c=$((c+$?))
3843
e=$((e+1))
3944
done

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

+39-9
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,56 @@
44
!
55
{% from "common/functions.conf.j2" import get_ipv4_loopback_address %}
66
!
7-
route-map FROM_BGP_INTERNAL_PEER_V4 permit 100
7+
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
8+
route-map FROM_BGP_INTERNAL_PEER_V4 permit 1
9+
set originator-id {{ get_ipv4_loopback_address(CONFIG_DB__LOOPBACK_INTERFACE, "Loopback4096") | ip }}
810
!
9-
route-map TO_BGP_INTERNAL_PEER_V4 permit 100
11+
route-map FROM_BGP_INTERNAL_PEER_V6 permit 1
12+
set ipv6 next-hop prefer-global
13+
on-match next
1014
!
15+
route-map FROM_BGP_INTERNAL_PEER_V6 permit 2
16+
set originator-id {{ get_ipv4_loopback_address(CONFIG_DB__LOOPBACK_INTERFACE, "Loopback4096") | ip }}
17+
{% elif CONFIG_DB__DEVICE_METADATA['localhost']['switch_type'] == 'chassis-packet' %}
18+
bgp community-list standard DEVICE_INTERNAL_COMMUNITY permit {{ constants.bgp.internal_community }}
19+
!
20+
route-map FROM_BGP_INTERNAL_PEER_V4 permit 1
21+
match community DEVICE_INTERNAL_COMMUNITY
22+
set comm-list DEVICE_INTERNAL_COMMUNITY delete
23+
set tag {{ constants.bgp.internal_community_match_tag }}
1124
!
1225
route-map FROM_BGP_INTERNAL_PEER_V6 permit 1
1326
set ipv6 next-hop prefer-global
1427
on-match next
1528
!
16-
route-map FROM_BGP_INTERNAL_PEER_V6 permit 100
29+
route-map FROM_BGP_INTERNAL_PEER_V6 permit 2
30+
match community DEVICE_INTERNAL_COMMUNITY
31+
set comm-list DEVICE_INTERNAL_COMMUNITY delete
32+
set tag {{ constants.bgp.internal_community_match_tag }}
1733
!
18-
route-map TO_BGP_INTERNAL_PEER_V6 permit 100
34+
route-map TO_BGP_INTERNAL_PEER_V4 permit 1
35+
match ip address prefix-list PL_LoopbackV4
36+
set community {{ constants.bgp.internal_community }}
1937
!
20-
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
21-
route-map FROM_BGP_INTERNAL_PEER_V4 permit 2
22-
set originator-id {{ get_ipv4_loopback_address(CONFIG_DB__LOOPBACK_INTERFACE, "Loopback4096") | ip }}
38+
route-map TO_BGP_INTERNAL_PEER_V6 permit 2
39+
match ipv6 address prefix-list PL_LoopbackV6
40+
set community {{ constants.bgp.internal_community }}
41+
!
42+
{% else %}
43+
route-map FROM_BGP_INTERNAL_PEER_V6 permit 1
44+
set ipv6 next-hop prefer-global
45+
on-match next
2346
!
24-
route-map FROM_BGP_INTERNAL_PEER_V6 permit 2
25-
set originator-id {{ get_ipv4_loopback_address(CONFIG_DB__LOOPBACK_INTERFACE, "Loopback4096") | ip }}
2647
{% endif %}
2748
!
49+
route-map FROM_BGP_INTERNAL_PEER_V4 permit 100
50+
!
51+
route-map FROM_BGP_INTERNAL_PEER_V6 permit 100
52+
!
53+
route-map TO_BGP_INTERNAL_PEER_V4 permit 100
54+
!
55+
route-map TO_BGP_INTERNAL_PEER_V6 permit 100
56+
!
57+
!
2858
! end of template: bgpd/templates/internal/policies.conf.j2
2959
!

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

+20
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,37 @@
11
!
22
! template: bgpd/templates/voq_chassis/policies.conf.j2
33
!
4+
bgp community-list standard DEVICE_INTERNAL_COMMUNITY permit {{ constants.bgp.internal_community }}
5+
!
6+
route-map FROM_VOQ_CHASSIS_V4_PEER permit 1
7+
match community DEVICE_INTERNAL_COMMUNITY
8+
set comm-list DEVICE_INTERNAL_COMMUNITY delete
9+
set tag {{ constants.bgp.internal_community_match_tag }}
10+
!
411
route-map FROM_VOQ_CHASSIS_V4_PEER permit 100
512
!
13+
route-map TO_VOQ_CHASSIS_V4_PEER permit 1
14+
match ip address prefix-list PL_LoopbackV4
15+
set community {{ constants.bgp.internal_community }}
16+
!
617
route-map TO_VOQ_CHASSIS_V4_PEER permit 100
718
!
819
!
920
route-map FROM_VOQ_CHASSIS_V6_PEER permit 1
1021
set ipv6 next-hop prefer-global
1122
on-match next
1223
!
24+
route-map FROM_VOQ_CHASSIS_V6_PEER permit 2
25+
match community DEVICE_INTERNAL_COMMUNITY
26+
set comm-list DEVICE_INTERNAL_COMMUNITY delete
27+
set tag {{ constants.bgp.internal_community_match_tag }}
28+
!
1329
route-map FROM_VOQ_CHASSIS_V6_PEER permit 100
1430
!
31+
route-map TO_VOQ_CHASSIS_V6_PEER permit 1
32+
match ipv6 address prefix-list PL_LoopbackV6
33+
set community {{ constants.bgp.internal_community }}
34+
!
1535
route-map TO_VOQ_CHASSIS_V6_PEER permit 100
1636
!
1737
! end of template: bgpd/templates/voq_chassis/policies.conf.j2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
route-map {{ route_map_name }} permit 20
22
match {{ ip_protocol }} address prefix-list PL_Loopback{{ ip_version }}
33
set community {{ constants.bgp.traffic_shift_community }}
4-
route-map {{ route_map_name }} deny 30
4+
route-map {{ route_map_name }} permit 30
5+
match tag {{ constants.bgp.internal_community_match_tag }}
6+
set community {{ constants.bgp.traffic_shift_community }}
7+
route-map {{ route_map_name }} deny 40
58
!
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
no route-map {{ route_map_name }} permit 20
2-
no route-map {{ route_map_name }} deny 30
2+
no route-map {{ route_map_name }} permit 30
3+
no route-map {{ route_map_name }} deny 40
34
!

files/image_config/constants/constants.yml

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ constants:
44
"2" : 65433
55
bgp:
66
traffic_shift_community: 12345:12345
7+
internal_community: 11111:11111
8+
internal_community_match_tag: 1002
79
families:
810
- ipv4
911
- ipv6

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

+8-2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,17 @@
2323
route-map TO_BGP_PEER_V4 permit 20
2424
match ip address prefix-list PL_LoopbackV4
2525
set community 12345:12345
26-
route-map TO_BGP_PEER_V4 deny 30
26+
route-map TO_BGP_PEER_V4 permit 30
27+
match tag 1001
28+
set community 12345:12345
29+
route-map TO_BGP_PEER_V4 deny 40
2730
!
2831
route-map TO_BGP_PEER_V6 permit 20
2932
match ipv6 address prefix-list PL_LoopbackV6
3033
set community 12345:12345
31-
route-map TO_BGP_PEER_V6 deny 30
34+
route-map TO_BGP_PEER_V6 permit 30
35+
match tag 1001
36+
set community 12345:12345
37+
route-map TO_BGP_PEER_V6 deny 40
3238
!
3339

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121

2222

2323
no route-map TO_BGP_PEER_V4 permit 20
24-
no route-map TO_BGP_PEER_V4 deny 30
24+
no route-map TO_BGP_PEER_V4 permit 30
25+
no route-map TO_BGP_PEER_V4 deny 40
2526
!
2627
no route-map TO_BGP_PEER_V6 permit 20
27-
no route-map TO_BGP_PEER_V6 deny 30
28+
no route-map TO_BGP_PEER_V6 permit 30
29+
no route-map TO_BGP_PEER_V6 deny 40
2830
!
2931

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

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@
22
route-map TO_BGP_PEER_V4 permit 20
33
match ip address prefix-list PL_LoopbackV4
44
set community 12345:12345
5-
route-map TO_BGP_PEER_V4 deny 30
5+
route-map TO_BGP_PEER_V4 permit 30
6+
match tag 1001
7+
set community 12345:12345
8+
route-map TO_BGP_PEER_V4 deny 40
69
!
710
route-map TO_BGP_PEER_V6 permit 20
811
match ipv6 address prefix-list PL_LoopbackV6
912
set community 12345:12345
10-
route-map TO_BGP_PEER_V6 deny 30
13+
route-map TO_BGP_PEER_V6 permit 30
14+
match tag 1001
15+
set community 12345:12345
16+
route-map TO_BGP_PEER_V6 deny 40
1117
!
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11

22
no route-map TO_BGP_PEER_V4 permit 20
3-
no route-map TO_BGP_PEER_V4 deny 30
3+
no route-map TO_BGP_PEER_V4 permit 30
4+
no route-map TO_BGP_PEER_V4 deny 40
45
!
56
no route-map TO_BGP_PEER_V6 permit 20
6-
no route-map TO_BGP_PEER_V6 deny 30
7+
no route-map TO_BGP_PEER_V6 permit 30
8+
no route-map TO_BGP_PEER_V6 deny 40
79
!

src/sonic-bgpcfgd/tests/data/internal/policies.conf/param_back.json

+6
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,11 @@
66
},
77
"CONFIG_DB__LOOPBACK_INTERFACE": {
88
"Loopback4096|10.10.10.10/32": {}
9+
},
10+
"constants": {
11+
"bgp": {
12+
"internal_community": "12345:556",
13+
"internal_community_match_tag": "101"
14+
}
915
}
1016
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"CONFIG_DB__DEVICE_METADATA": {
3+
"localhost": {
4+
"type": "SpineRouter",
5+
"sub_role": "FrontEnd",
6+
"switch_type": "chassis-packet"
7+
}
8+
},
9+
"constants": {
10+
"bgp": {
11+
"internal_community": "12345:556",
12+
"internal_community_match_tag": "101"
13+
}
14+
},
15+
"loopback0_ipv4": "10.10.10.10/32"
16+
}

src/sonic-bgpcfgd/tests/data/internal/policies.conf/param_front.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
{
22
"CONFIG_DB__DEVICE_METADATA": {
33
"localhost": {
4-
"sub_role": "FrontkEnd"
4+
"sub_role": "FrontEnd"
5+
}
6+
},
7+
"constants": {
8+
"bgp": {
9+
"internal_community": "12345:556",
10+
"internal_community_match_tag": "101"
511
}
612
},
713
"loopback0_ipv4": "10.10.10.10/32"
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
!
22
! template: bgpd/templates/internal/policies.conf.j2
33
!
4-
route-map FROM_BGP_INTERNAL_PEER_V4 permit 100
5-
!
6-
route-map TO_BGP_INTERNAL_PEER_V4 permit 100
4+
route-map FROM_BGP_INTERNAL_PEER_V4 permit 1
5+
set originator-id 10.10.10.10
76
!
87
route-map FROM_BGP_INTERNAL_PEER_V6 permit 1
98
set ipv6 next-hop prefer-global
109
on-match next
1110
!
12-
route-map FROM_BGP_INTERNAL_PEER_V6 permit 100
11+
route-map FROM_BGP_INTERNAL_PEER_V6 permit 2
12+
set originator-id 10.10.10.10
1313
!
14-
route-map TO_BGP_INTERNAL_PEER_V6 permit 100
14+
route-map FROM_BGP_INTERNAL_PEER_V4 permit 100
1515
!
16-
route-map FROM_BGP_INTERNAL_PEER_V4 permit 2
17-
set originator-id 10.10.10.10
16+
route-map FROM_BGP_INTERNAL_PEER_V6 permit 100
1817
!
19-
route-map FROM_BGP_INTERNAL_PEER_V6 permit 2
20-
set originator-id 10.10.10.10
18+
route-map TO_BGP_INTERNAL_PEER_V4 permit 100
19+
!
20+
route-map TO_BGP_INTERNAL_PEER_V6 permit 100
2121
!
2222
! end of template: bgpd/templates/internal/policies.conf.j2
2323
!
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
!
2+
! template: bgpd/templates/internal/policies.conf.j2
3+
!
4+
bgp community-list standard DEVICE_INTERNAL_COMMUNITY permit 12345:556
5+
!
6+
route-map FROM_BGP_INTERNAL_PEER_V4 permit 1
7+
match community DEVICE_INTERNAL_COMMUNITY
8+
set comm-list DEVICE_INTERNAL_COMMUNITY delete
9+
set tag 101
10+
!
11+
route-map FROM_BGP_INTERNAL_PEER_V6 permit 1
12+
set ipv6 next-hop prefer-global
13+
on-match next
14+
!
15+
route-map FROM_BGP_INTERNAL_PEER_V6 permit 2
16+
match community DEVICE_INTERNAL_COMMUNITY
17+
set comm-list DEVICE_INTERNAL_COMMUNITY delete
18+
set tag 101
19+
!
20+
route-map TO_BGP_INTERNAL_PEER_V4 permit 1
21+
match ip address prefix-list PL_LoopbackV4
22+
set community 12345:556
23+
!
24+
route-map TO_BGP_INTERNAL_PEER_V6 permit 2
25+
match ipv6 address prefix-list PL_LoopbackV6
26+
set community 12345:556
27+
!
28+
route-map FROM_BGP_INTERNAL_PEER_V4 permit 100
29+
!
30+
route-map FROM_BGP_INTERNAL_PEER_V6 permit 100
31+
!
32+
route-map TO_BGP_INTERNAL_PEER_V4 permit 100
33+
!
34+
route-map TO_BGP_INTERNAL_PEER_V6 permit 100
35+
!
36+
! end of template: bgpd/templates/internal/policies.conf.j2
37+
!

src/sonic-bgpcfgd/tests/data/internal/policies.conf/result_front.conf

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
!
22
! template: bgpd/templates/internal/policies.conf.j2
33
!
4-
route-map FROM_BGP_INTERNAL_PEER_V4 permit 100
5-
!
6-
route-map TO_BGP_INTERNAL_PEER_V4 permit 100
7-
!
84
route-map FROM_BGP_INTERNAL_PEER_V6 permit 1
95
set ipv6 next-hop prefer-global
106
on-match next
117
!
8+
route-map FROM_BGP_INTERNAL_PEER_V4 permit 100
9+
!
1210
route-map FROM_BGP_INTERNAL_PEER_V6 permit 100
1311
!
12+
route-map TO_BGP_INTERNAL_PEER_V4 permit 100
13+
!
1414
route-map TO_BGP_INTERNAL_PEER_V6 permit 100
1515
!
1616
! end of template: bgpd/templates/internal/policies.conf.j2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
route-map test_rm_name permit 20
22
match ip address prefix-list PL_LoopbackV4
33
set community 12345:555
4-
route-map test_rm_name deny 30
4+
route-map test_rm_name permit 30
5+
match tag 1002
6+
set community 12345:555
7+
route-map test_rm_name deny 40
58
!
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"constants": {
33
"bgp": {
4-
"traffic_shift_community": "12345:555"
4+
"traffic_shift_community": "12345:555",
5+
"internal_community_match_tag": "1002"
56
}
67
},
78
"route_map_name": "test_rm_name",
89
"ip_version": "V4",
910
"ip_protocol": "ip"
10-
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
no route-map test_rm permit 20
2-
no route-map test_rm deny 30
2+
no route-map test_rm permit 30
3+
no route-map test_rm deny 40
34
!
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
{
22
"CONFIG_DB__DEVICE_METADATA": {
33
"localhost": {}
4+
},
5+
"constants": {
6+
"bgp": {
7+
"internal_community": "12345:556",
8+
"internal_community_match_tag": "101"
9+
}
410
}
511
}

0 commit comments

Comments
 (0)