Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TSA]: Add community to the loopback prefix, when isolated #3708

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions dockers/docker-fpm-frr/TSA
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
c=0
config=$(vtysh -c "show run")
echo "$config" | grep -q "route-map TO_BGP_PEER_V4 permit 2"
c=$(($c+$?))
c=$((c+$?))
echo "$config" | grep -q "route-map TO_BGP_PEER_V4 deny 3"
c=$(($c+$?))
c=$((c+$?))
echo "$config" | grep -q "route-map TO_BGP_PEER_V6 permit 2"
c=$(($c+$?))
c=$((c+$?))
echo "$config" | grep -q "route-map TO_BGP_PEER_V6 deny 3"
c=$(($c+$?))
c=$((c+$?))

if [[ $c -eq 4 ]];
then
vtysh -c "configure terminal" -c "route-map TO_BGP_PEER_V4 permit 2" -c "match ip address prefix-list PL_LoopbackV4"
vtysh -c "configure terminal" -c "route-map TO_BGP_PEER_V4 deny 3"
vtysh -c "configure terminal" -c "route-map TO_BGP_PEER_V6 permit 2" -c "match ipv6 address prefix-list PL_LoopbackV6"
vtysh -c "configure terminal" -c "route-map TO_BGP_PEER_V6 deny 3"
TSA_FILE=$(mktemp)
sonic-cfggen -d -y /etc/sonic/constants.yml -t /usr/share/sonic/templates/bgpd.tsa.isolate.conf.j2 > "$TSA_FILE"
vtysh -f "$TSA_FILE"
rm -f "$TSA_FILE"
echo "System Mode: Normal -> Maintenance"
else
echo "System is already in Maintenance mode"
Expand Down
17 changes: 8 additions & 9 deletions dockers/docker-fpm-frr/TSB
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,20 @@
c=0
config=$(vtysh -c "show run")
echo "$config" | grep -q "route-map TO_BGP_PEER_V4 permit 2"
c=$(($c+$?))
c=$((c+$?))
echo "$config" | grep -q "route-map TO_BGP_PEER_V4 deny 3"
c=$(($c+$?))
c=$((c+$?))
echo "$config" | grep -q "route-map TO_BGP_PEER_V6 permit 2"
c=$(($c+$?))
c=$((c+$?))
echo "$config" | grep -q "route-map TO_BGP_PEER_V6 deny 3"
c=$(($c+$?))
c=$((c+$?))

if [[ $c -eq 0 ]];
then
vtysh -c "configure terminal" -c "no route-map TO_BGP_PEER_V4 deny 3"
vtysh -c "configure terminal" -c "no route-map TO_BGP_PEER_V4 permit 2"
vtysh -c "configure terminal" -c "no route-map TO_BGP_PEER_V6 deny 3"
vtysh -c "configure terminal" -c "no route-map TO_BGP_PEER_V6 permit 2"

TSB_FILE=$(mktemp)
sonic-cfggen -d -y /etc/sonic/constants.yml -t /usr/share/sonic/templates/bgpd.tsa.unisolate.conf.j2 > "$TSB_FILE"
vtysh -f "$TSB_FILE"
rm -f "$TSB_FILE"
echo "System Mode: Maintenance -> Normal"
else
echo "System is already in Normal mode"
Expand Down
8 changes: 4 additions & 4 deletions dockers/docker-fpm-frr/TSC
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ echo "Traffic Shift Check:"
c=0
config=$(vtysh -c "show run")
echo "$config" | grep -q "route-map TO_BGP_PEER_V4 permit 2"
c=$(($c+$?))
c=$((c+$?))
echo "$config" | grep -q "route-map TO_BGP_PEER_V4 deny 3"
c=$(($c+$?))
c=$((c+$?))
echo "$config" | grep -q "route-map TO_BGP_PEER_V6 permit 2"
c=$(($c+$?))
c=$((c+$?))
echo "$config" | grep -q "route-map TO_BGP_PEER_V6 deny 3"
c=$(($c+$?))
c=$((c+$?))

if [[ $c -eq 4 ]];
then
Expand Down
2 changes: 1 addition & 1 deletion dockers/docker-fpm-frr/bgpd.conf.default.j2
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
{% if bgp_peer['peer_asn'] is defined %}
neighbor {{ bgp_peer['name'] }} remote-as {{ bgp_peer['peer_asn'] }}
{% else %}
neighbor {{ bgp_peer['name'] }} remote-as {{ deployment_id_asn_map[DEVICE_METADATA['localhost']['deployment_id']] }}
neighbor {{ bgp_peer['name'] }} remote-as {{ constants.deployment_id_asn_map[DEVICE_METADATA['localhost']['deployment_id']] }}
{% endif %}
neighbor {{ bgp_peer['name'] }} ebgp-multihop 255
neighbor {{ bgp_peer['name'] }} soft-reconfiguration inbound
Expand Down
10 changes: 10 additions & 0 deletions dockers/docker-fpm-frr/bgpd.tsa.isolate.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
route-map TO_BGP_PEER_V4 permit 2
match ip address prefix-list PL_LoopbackV4
set community {{ constants.traffic_shift_community }}
route-map TO_BGP_PEER_V4 deny 3
!
route-map TO_BGP_PEER_V6 permit 2
match ipv6 address prefix-list PL_LoopbackV6
set community {{ constants.traffic_shift_community }}
route-map TO_BGP_PEER_V6 deny 3
!
6 changes: 6 additions & 0 deletions dockers/docker-fpm-frr/bgpd.tsa.unisolate.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
no route-map TO_BGP_PEER_V4 permit 2
no route-map TO_BGP_PEER_V4 deny 3
!
no route-map TO_BGP_PEER_V6 permit 2
no route-map TO_BGP_PEER_V6 deny 3
!
4 changes: 2 additions & 2 deletions dockers/docker-fpm-frr/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ mkdir -p /etc/frr
CONFIG_TYPE=`sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["docker_routing_config_mode"]'`

if [ -z "$CONFIG_TYPE" ] || [ "$CONFIG_TYPE" == "separated" ]; then
sonic-cfggen -d -y /etc/sonic/deployment_id_asn_map.yml -t /usr/share/sonic/templates/bgpd.conf.j2 > /etc/frr/bgpd.conf
sonic-cfggen -d -y /etc/sonic/constants.yml -t /usr/share/sonic/templates/bgpd.conf.j2 > /etc/frr/bgpd.conf
sonic-cfggen -d -t /usr/share/sonic/templates/zebra.conf.j2 > /etc/frr/zebra.conf
sonic-cfggen -d -t /usr/share/sonic/templates/staticd.conf.j2 > /etc/frr/staticd.conf
echo "no service integrated-vtysh-config" > /etc/frr/vtysh.conf
rm -f /etc/frr/frr.conf
elif [ "$CONFIG_TYPE" == "unified" ]; then
sonic-cfggen -d -y /etc/sonic/deployment_id_asn_map.yml -t /usr/share/sonic/templates/frr.conf.j2 >/etc/frr/frr.conf
sonic-cfggen -d -y /etc/sonic/constants.yml -t /usr/share/sonic/templates/frr.conf.j2 >/etc/frr/frr.conf
echo "service integrated-vtysh-config" > /etc/frr/vtysh.conf
rm -f /etc/frr/bgpd.conf /etc/frr/zebra.conf /etc/frr/staticd.conf
fi
Expand Down
2 changes: 1 addition & 1 deletion dockers/docker-fpm-quagga/bgpd.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
{% if bgp_peer['peer_asn'] is defined %}
neighbor {{ bgp_peer['name'] }} remote-as {{ bgp_peer['peer_asn'] }}
{% else %}
neighbor {{ bgp_peer['name'] }} remote-as {{ deployment_id_asn_map[DEVICE_METADATA['localhost']['deployment_id']] }}
neighbor {{ bgp_peer['name'] }} remote-as {{ constants.deployment_id_asn_map[DEVICE_METADATA['localhost']['deployment_id']] }}
{% endif %}
neighbor {{ bgp_peer['name'] }} ebgp-multihop 255
neighbor {{ bgp_peer['name'] }} soft-reconfiguration inbound
Expand Down
2 changes: 1 addition & 1 deletion dockers/docker-fpm-quagga/start.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

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

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

Expand Down
2 changes: 1 addition & 1 deletion files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ sudo bash -c "echo '{ \"DEVICE_METADATA\": { \"localhost\": { \"default_bgp_stat
sudo cp $IMAGE_CONFIGS/snmp/snmp.yml $FILESYSTEM_ROOT/etc/sonic/

# Copy ASN configuration files
sudo cp $IMAGE_CONFIGS/asn/deployment_id_asn_map.yml $FILESYSTEM_ROOT/etc/sonic/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @pavel-shirshov
I think this change breaks bgp_speaker TCs.

TASK [test : fetch bgp speaker asn number from DUT] ****************************
Monday 11 November 2019  12:07:39 +0000 (0:00:00.110)       0:00:12.550 ******* 
�[0;31mfatal: [cab18-2-dut]: FAILED! => {"changed": true, "cmd": "sonic-cfggen -m -d -y /etc/sonic/deployment_id_asn_map.yml -v \"deployment_id_asn_map[DEVICE_METADATA['localhost']['deployment_id']]\"", "delta": "0:00:00.166444", "end": "2019-11-11 12:07:39.972509", "failed": true, "rc": 1, "start": "2019-11-11 12:07:39.806065", "stderr": "Traceback (most recent call last):\n  File \"/usr/local/bin/sonic-cfggen\", line 318, in <module>\n    main()\n  File \"/usr/local/bin/sonic-cfggen\", line 250, in main\n    with open(yaml_file, 'r') as stream:\nIOError: [Errno 2] No such file or directory: '/etc/sonic/deployment_id_asn_map.yml'", "stdout": "", "stdout_lines": [], "warnings": []}�[0m

Could you please check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @akokhan
Thank you for your report. Can you please check the fix? sonic-net/sonic-mgmt#1204 ?

sudo cp $IMAGE_CONFIGS/constants/constants.yml $FILESYSTEM_ROOT/etc/sonic/

# Copy sudoers configuration file
sudo cp $IMAGE_CONFIGS/sudoers/sudoers $FILESYSTEM_ROOT/etc/
Expand Down
2 changes: 0 additions & 2 deletions files/image_config/asn/deployment_id_asn_map.yml

This file was deleted.

4 changes: 4 additions & 0 deletions files/image_config/constants/constants.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
constants:
deployment_id_asn_map:
"1" : 65432
traffic_shift_community: 12345:12345