Skip to content

Commit 3cd68d0

Browse files
pavel-shirshovzhenggen-xu
authored andcommitted
[TSA]: Add community to the loopback prefix, when isolated (sonic-net#3708)
* Rename asn/deployment_id_asn_map.yaml to constants/constants.yaml * Fix bgp templates * Add community for loopback when bgpd is isolated * Use correct community value
1 parent 3ab1ebb commit 3cd68d0

File tree

12 files changed

+46
-29
lines changed

12 files changed

+46
-29
lines changed

dockers/docker-fpm-frr/TSA

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
c=0
44
config=$(vtysh -c "show run")
55
echo "$config" | grep -q "route-map TO_BGP_PEER_V4 permit 2"
6-
c=$(($c+$?))
6+
c=$((c+$?))
77
echo "$config" | grep -q "route-map TO_BGP_PEER_V4 deny 3"
8-
c=$(($c+$?))
8+
c=$((c+$?))
99
echo "$config" | grep -q "route-map TO_BGP_PEER_V6 permit 2"
10-
c=$(($c+$?))
10+
c=$((c+$?))
1111
echo "$config" | grep -q "route-map TO_BGP_PEER_V6 deny 3"
12-
c=$(($c+$?))
12+
c=$((c+$?))
1313

1414
if [[ $c -eq 4 ]];
1515
then
16-
vtysh -c "configure terminal" -c "route-map TO_BGP_PEER_V4 permit 2" -c "match ip address prefix-list PL_LoopbackV4"
17-
vtysh -c "configure terminal" -c "route-map TO_BGP_PEER_V4 deny 3"
18-
vtysh -c "configure terminal" -c "route-map TO_BGP_PEER_V6 permit 2" -c "match ipv6 address prefix-list PL_LoopbackV6"
19-
vtysh -c "configure terminal" -c "route-map TO_BGP_PEER_V6 deny 3"
16+
TSA_FILE=$(mktemp)
17+
sonic-cfggen -d -y /etc/sonic/constants.yml -t /usr/share/sonic/templates/bgpd.tsa.isolate.conf.j2 > "$TSA_FILE"
18+
vtysh -f "$TSA_FILE"
19+
rm -f "$TSA_FILE"
2020
echo "System Mode: Normal -> Maintenance"
2121
else
2222
echo "System is already in Maintenance mode"

dockers/docker-fpm-frr/TSB

+8-9
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,20 @@
33
c=0
44
config=$(vtysh -c "show run")
55
echo "$config" | grep -q "route-map TO_BGP_PEER_V4 permit 2"
6-
c=$(($c+$?))
6+
c=$((c+$?))
77
echo "$config" | grep -q "route-map TO_BGP_PEER_V4 deny 3"
8-
c=$(($c+$?))
8+
c=$((c+$?))
99
echo "$config" | grep -q "route-map TO_BGP_PEER_V6 permit 2"
10-
c=$(($c+$?))
10+
c=$((c+$?))
1111
echo "$config" | grep -q "route-map TO_BGP_PEER_V6 deny 3"
12-
c=$(($c+$?))
12+
c=$((c+$?))
1313

1414
if [[ $c -eq 0 ]];
1515
then
16-
vtysh -c "configure terminal" -c "no route-map TO_BGP_PEER_V4 deny 3"
17-
vtysh -c "configure terminal" -c "no route-map TO_BGP_PEER_V4 permit 2"
18-
vtysh -c "configure terminal" -c "no route-map TO_BGP_PEER_V6 deny 3"
19-
vtysh -c "configure terminal" -c "no route-map TO_BGP_PEER_V6 permit 2"
20-
16+
TSB_FILE=$(mktemp)
17+
sonic-cfggen -d -y /etc/sonic/constants.yml -t /usr/share/sonic/templates/bgpd.tsa.unisolate.conf.j2 > "$TSB_FILE"
18+
vtysh -f "$TSB_FILE"
19+
rm -f "$TSB_FILE"
2120
echo "System Mode: Maintenance -> Normal"
2221
else
2322
echo "System is already in Normal mode"

dockers/docker-fpm-frr/TSC

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ echo "Traffic Shift Check:"
44
c=0
55
config=$(vtysh -c "show run")
66
echo "$config" | grep -q "route-map TO_BGP_PEER_V4 permit 2"
7-
c=$(($c+$?))
7+
c=$((c+$?))
88
echo "$config" | grep -q "route-map TO_BGP_PEER_V4 deny 3"
9-
c=$(($c+$?))
9+
c=$((c+$?))
1010
echo "$config" | grep -q "route-map TO_BGP_PEER_V6 permit 2"
11-
c=$(($c+$?))
11+
c=$((c+$?))
1212
echo "$config" | grep -q "route-map TO_BGP_PEER_V6 deny 3"
13-
c=$(($c+$?))
13+
c=$((c+$?))
1414

1515
if [[ $c -eq 4 ]];
1616
then

dockers/docker-fpm-frr/bgpd.conf.default.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
107107
{% if bgp_peer['peer_asn'] is defined %}
108108
neighbor {{ bgp_peer['name'] }} remote-as {{ bgp_peer['peer_asn'] }}
109109
{% else %}
110-
neighbor {{ bgp_peer['name'] }} remote-as {{ deployment_id_asn_map[DEVICE_METADATA['localhost']['deployment_id']] }}
110+
neighbor {{ bgp_peer['name'] }} remote-as {{ constants.deployment_id_asn_map[DEVICE_METADATA['localhost']['deployment_id']] }}
111111
{% endif %}
112112
neighbor {{ bgp_peer['name'] }} ebgp-multihop 255
113113
neighbor {{ bgp_peer['name'] }} soft-reconfiguration inbound
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
route-map TO_BGP_PEER_V4 permit 2
2+
match ip address prefix-list PL_LoopbackV4
3+
set community {{ constants.traffic_shift_community }}
4+
route-map TO_BGP_PEER_V4 deny 3
5+
!
6+
route-map TO_BGP_PEER_V6 permit 2
7+
match ipv6 address prefix-list PL_LoopbackV6
8+
set community {{ constants.traffic_shift_community }}
9+
route-map TO_BGP_PEER_V6 deny 3
10+
!
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
no route-map TO_BGP_PEER_V4 permit 2
2+
no route-map TO_BGP_PEER_V4 deny 3
3+
!
4+
no route-map TO_BGP_PEER_V6 permit 2
5+
no route-map TO_BGP_PEER_V6 deny 3
6+
!

dockers/docker-fpm-frr/start.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ mkdir -p /etc/frr
55
CONFIG_TYPE=`sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["docker_routing_config_mode"]'`
66

77
if [ -z "$CONFIG_TYPE" ] || [ "$CONFIG_TYPE" == "separated" ]; then
8-
sonic-cfggen -d -y /etc/sonic/deployment_id_asn_map.yml -t /usr/share/sonic/templates/bgpd.conf.j2 > /etc/frr/bgpd.conf
8+
sonic-cfggen -d -y /etc/sonic/constants.yml -t /usr/share/sonic/templates/bgpd.conf.j2 > /etc/frr/bgpd.conf
99
sonic-cfggen -d -t /usr/share/sonic/templates/zebra.conf.j2 > /etc/frr/zebra.conf
1010
sonic-cfggen -d -t /usr/share/sonic/templates/staticd.conf.j2 > /etc/frr/staticd.conf
1111
echo "no service integrated-vtysh-config" > /etc/frr/vtysh.conf
1212
rm -f /etc/frr/frr.conf
1313
elif [ "$CONFIG_TYPE" == "unified" ]; then
14-
sonic-cfggen -d -y /etc/sonic/deployment_id_asn_map.yml -t /usr/share/sonic/templates/frr.conf.j2 >/etc/frr/frr.conf
14+
sonic-cfggen -d -y /etc/sonic/constants.yml -t /usr/share/sonic/templates/frr.conf.j2 >/etc/frr/frr.conf
1515
echo "service integrated-vtysh-config" > /etc/frr/vtysh.conf
1616
rm -f /etc/frr/bgpd.conf /etc/frr/zebra.conf /etc/frr/staticd.conf
1717
fi

dockers/docker-fpm-quagga/bgpd.conf.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
101101
{% if bgp_peer['peer_asn'] is defined %}
102102
neighbor {{ bgp_peer['name'] }} remote-as {{ bgp_peer['peer_asn'] }}
103103
{% else %}
104-
neighbor {{ bgp_peer['name'] }} remote-as {{ deployment_id_asn_map[DEVICE_METADATA['localhost']['deployment_id']] }}
104+
neighbor {{ bgp_peer['name'] }} remote-as {{ constants.deployment_id_asn_map[DEVICE_METADATA['localhost']['deployment_id']] }}
105105
{% endif %}
106106
neighbor {{ bgp_peer['name'] }} ebgp-multihop 255
107107
neighbor {{ bgp_peer['name'] }} soft-reconfiguration inbound

dockers/docker-fpm-quagga/start.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

33
mkdir -p /etc/quagga
4-
sonic-cfggen -d -y /etc/sonic/deployment_id_asn_map.yml -t /usr/share/sonic/templates/bgpd.conf.j2 > /etc/quagga/bgpd.conf
4+
sonic-cfggen -d -y /etc/sonic/constants.yml -t /usr/share/sonic/templates/bgpd.conf.j2 > /etc/quagga/bgpd.conf
55

66
sonic-cfggen -d -t /usr/share/sonic/templates/zebra.conf.j2 > /etc/quagga/zebra.conf
77

files/build_templates/sonic_debian_extension.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ sudo bash -c "echo '{ \"DEVICE_METADATA\": { \"localhost\": { \"default_bgp_stat
235235
sudo cp $IMAGE_CONFIGS/snmp/snmp.yml $FILESYSTEM_ROOT/etc/sonic/
236236

237237
# Copy ASN configuration files
238-
sudo cp $IMAGE_CONFIGS/asn/deployment_id_asn_map.yml $FILESYSTEM_ROOT/etc/sonic/
238+
sudo cp $IMAGE_CONFIGS/constants/constants.yml $FILESYSTEM_ROOT/etc/sonic/
239239

240240
# Copy sudoers configuration file
241241
sudo cp $IMAGE_CONFIGS/sudoers/sudoers $FILESYSTEM_ROOT/etc/

files/image_config/asn/deployment_id_asn_map.yml

-2
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
constants:
2+
deployment_id_asn_map:
3+
"1" : 65432
4+
traffic_shift_community: 12345:12345

0 commit comments

Comments
 (0)