Skip to content

Commit

Permalink
TSA/B/C scripts run only in BGP instances for front end ASICs.
Browse files Browse the repository at this point in the history
In addition skip enforcing it on route maps used between internal BGP sessions.
  • Loading branch information
judyjoseph committed Jan 26, 2021
1 parent b2fea23 commit 9505af0
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
8 changes: 8 additions & 0 deletions dockers/docker-fpm-frr/TSA
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
#!/bin/bash

# Check whether the routemap is for internal BGP sessions.
function is_internal_route_map()
{
[[ "$1" =~ .*"_INTERNAL_".* ]]
}

function check_not_installed()
{
c=0
config=$(vtysh -c "show run")
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p');
do
is_internal_route_map $route_map_name && continue
echo "$config" | egrep -q "^route-map $route_map_name permit 20$"
c=$((c+$?))
echo "$config" | egrep -q "^route-map $route_map_name deny 30$"
Expand All @@ -21,6 +28,7 @@ then
TSA_FILE=$(mktemp)
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p');
do
is_internal_route_map $route_map_name && continue
case "$route_map_name" in
*V4*)
ip_version=V4
Expand Down
8 changes: 8 additions & 0 deletions dockers/docker-fpm-frr/TSB
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
#!/bin/bash

# Check whether the routemap is for internal BGP sessions.
function is_internal_route_map()
{
[[ "$1" =~ .*"_INTERNAL_".* ]]
}

function check_installed()
{
c=0
e=0
config=$(vtysh -c "show run")
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p');
do
is_internal_route_map $route_map_name && continue
echo "$config" | egrep -q "^route-map $route_map_name permit 20$"
c=$((c+$?))
e=$((e+1))
Expand All @@ -24,6 +31,7 @@ then
TSB_FILE=$(mktemp)
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p');
do
is_internal_route_map $route_map_name && continue
case "$route_map_name" in
*V4*)
;;
Expand Down
8 changes: 8 additions & 0 deletions dockers/docker-fpm-frr/TSC
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
#!/bin/bash

# Check whether the routemap is for internal BGP sessions.
function is_internal_route_map()
{
[[ "$1" =~ .*"_INTERNAL_".* ]]
}

function check_not_installed()
{
c=0
config=$(vtysh -c "show run")
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p' | egrep 'V4|V6');
do
is_internal_route_map $route_map_name && continue
echo "$config" | egrep -q "^route-map $route_map_name permit 20$"
c=$((c+$?))
echo "$config" | egrep -q "^route-map $route_map_name deny 30$"
Expand All @@ -21,6 +28,7 @@ function check_installed()
config=$(vtysh -c "show run")
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p' | egrep 'V4|V6');
do
is_internal_route_map $route_map_name && continue
echo "$config" | egrep -q "^route-map $route_map_name permit 20$"
c=$((c+$?))
e=$((e+1))
Expand Down
11 changes: 9 additions & 2 deletions dockers/docker-fpm-frr/base_image_files/TS
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@ ASIC_CONF=/usr/share/sonic/device/$PLATFORM/asic.conf

if [[ ($NUM_ASIC -gt 1) ]]; then
asic=0
NAMESPACE_PREFIX='asic'

while [ $asic -lt $NUM_ASIC ]
do
echo -e "BGP"$asic" : \c"
docker exec -i bgp$asic /usr/bin/$1
# Run TSA/TSB/TSC scripts in BGP instance for frontend ASICs.
sub_role=`sonic-cfggen -d -v "DEVICE_METADATA['localhost']['sub_role']" -n $NAMESPACE_PREFIX$asic`
if [ $sub_role == 'FrontEnd' ]
then
echo -e "BGP"$asic" : \c"
docker exec -i bgp$asic /usr/bin/$1
fi
asic=$[$asic+1]
done
else
Expand Down

0 comments on commit 9505af0

Please sign in to comment.