Skip to content

Commit ad88700

Browse files
authored
[docker-fpm-frr]: TSA/B/C changes for multi-asic (#6510)
- Introduced TS common file in docker as well and moved common functions. - TSA/B/C scripts run only in BGP instances for front end ASICs. In addition skip enforcing it on route maps used between internal BGP sessions. admin@str--acs-1:~$ sudo /usr/bin/TSA System Mode: Normal -> Maintenance and in case of Multi-ASIC admin@str--acs-1:~$ sudo /usr/bin/TSA BGP0 : System Mode: Normal -> Maintenance BGP1 : System Mode: Normal -> Maintenance BGP2 : System Mode: Normal -> Maintenance
1 parent 0252425 commit ad88700

File tree

10 files changed

+82
-66
lines changed

10 files changed

+82
-66
lines changed

dockers/docker-fpm-frr/Dockerfile.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ COPY ["snmp.conf", "/etc/snmp/frr.conf"]
5353
COPY ["TSA", "/usr/bin/TSA"]
5454
COPY ["TSB", "/usr/bin/TSB"]
5555
COPY ["TSC", "/usr/bin/TSC"]
56+
COPY ["TS", "/usr/bin/TS"]
5657
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
5758
COPY ["zsocket.sh", "/usr/bin/"]
5859
RUN chmod a+x /usr/bin/TSA && \

dockers/docker-fpm-frr/TS

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
# Check whether the routemap is for internal BGP sessions.
4+
function is_internal_route_map()
5+
{
6+
[[ "$1" =~ .*"_INTERNAL_".* ]]
7+
}
8+
9+
function check_not_installed()
10+
{
11+
c=0
12+
config=$(vtysh -c "show run")
13+
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p' | egrep 'V4|V6');
14+
do
15+
is_internal_route_map $route_map_name && continue
16+
echo "$config" | egrep -q "^route-map $route_map_name permit 20$"
17+
c=$((c+$?))
18+
echo "$config" | egrep -q "^route-map $route_map_name deny 30$"
19+
c=$((c+$?))
20+
done
21+
return $c
22+
}
23+
24+
function check_installed()
25+
{
26+
c=0
27+
e=0
28+
config=$(vtysh -c "show run")
29+
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p' | egrep 'V4|V6');
30+
do
31+
is_internal_route_map $route_map_name && continue
32+
echo "$config" | egrep -q "^route-map $route_map_name permit 20$"
33+
c=$((c+$?))
34+
e=$((e+1))
35+
echo "$config" | egrep -q "^route-map $route_map_name deny 30$"
36+
c=$((c+$?))
37+
e=$((e+1))
38+
done
39+
return $((e-c))
40+
}

dockers/docker-fpm-frr/TSA

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
11
#!/bin/bash
22

3-
function check_not_installed()
4-
{
5-
c=0
6-
config=$(vtysh -c "show run")
7-
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p');
8-
do
9-
echo "$config" | egrep -q "^route-map $route_map_name permit 20$"
10-
c=$((c+$?))
11-
echo "$config" | egrep -q "^route-map $route_map_name deny 30$"
12-
c=$((c+$?))
13-
done
14-
return $c
15-
}
3+
# Load the common functions
4+
source /usr/bin/TS
165

176
check_not_installed
187
not_installed=$?
@@ -21,6 +10,7 @@ then
2110
TSA_FILE=$(mktemp)
2211
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p');
2312
do
13+
is_internal_route_map $route_map_name && continue
2414
case "$route_map_name" in
2515
*V4*)
2616
ip_version=V4

dockers/docker-fpm-frr/TSB

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,7 @@
11
#!/bin/bash
22

3-
function check_installed()
4-
{
5-
c=0
6-
e=0
7-
config=$(vtysh -c "show run")
8-
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p');
9-
do
10-
echo "$config" | egrep -q "^route-map $route_map_name permit 20$"
11-
c=$((c+$?))
12-
e=$((e+1))
13-
echo "$config" | egrep -q "^route-map $route_map_name deny 30$"
14-
c=$((c+$?))
15-
e=$((e+1))
16-
done
17-
return $((e-c))
18-
}
3+
# Load the common functions
4+
source /usr/bin/TS
195

206
check_installed
217
installed=$?
@@ -24,6 +10,7 @@ then
2410
TSB_FILE=$(mktemp)
2511
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p');
2612
do
13+
is_internal_route_map $route_map_name && continue
2714
case "$route_map_name" in
2815
*V4*)
2916
;;

dockers/docker-fpm-frr/TSC

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,7 @@
11
#!/bin/bash
22

3-
function check_not_installed()
4-
{
5-
c=0
6-
config=$(vtysh -c "show run")
7-
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p' | egrep 'V4|V6');
8-
do
9-
echo "$config" | egrep -q "^route-map $route_map_name permit 20$"
10-
c=$((c+$?))
11-
echo "$config" | egrep -q "^route-map $route_map_name deny 30$"
12-
c=$((c+$?))
13-
done
14-
return $c
15-
}
16-
17-
function check_installed()
18-
{
19-
c=0
20-
e=0
21-
config=$(vtysh -c "show run")
22-
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p' | egrep 'V4|V6');
23-
do
24-
echo "$config" | egrep -q "^route-map $route_map_name permit 20$"
25-
c=$((c+$?))
26-
e=$((e+1))
27-
echo "$config" | egrep -q "^route-map $route_map_name deny 30$"
28-
c=$((c+$?))
29-
e=$((e+1))
30-
done
31-
return $((e-c))
32-
}
33-
34-
echo "Traffic Shift Check:"
3+
# Load the common functions
4+
source /usr/bin/TS
355

366
check_not_installed
377
not_installed=$?
@@ -48,5 +18,3 @@ then
4818
else
4919
echo "System Mode: Not consistent"
5020
fi
51-
52-
echo
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
# read SONiC immutable variables
4+
[ -f /etc/sonic/sonic-environment ] && . /etc/sonic/sonic-environment
5+
6+
PLATFORM=${PLATFORM:-`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`}
7+
8+
# Parse the device specific asic conf file, if it exists
9+
ASIC_CONF=/usr/share/sonic/device/$PLATFORM/asic.conf
10+
[ -f $ASIC_CONF ] && . $ASIC_CONF
11+
12+
if [[ ($NUM_ASIC -gt 1) ]]; then
13+
asic=0
14+
NAMESPACE_PREFIX='asic'
15+
16+
while [ $asic -lt $NUM_ASIC ]
17+
do
18+
# Run TSA/TSB/TSC scripts in BGP instance for frontend ASICs.
19+
sub_role=`sonic-cfggen -d -v "DEVICE_METADATA['localhost']['sub_role']" -n $NAMESPACE_PREFIX$asic`
20+
if [ $sub_role == 'FrontEnd' ]
21+
then
22+
echo -e "BGP"$asic" : \c"
23+
docker exec -i bgp$asic /usr/bin/$1
24+
fi
25+
asic=$[$asic+1]
26+
done
27+
else
28+
docker exec -i bgp /usr/bin/$1
29+
fi
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
docker exec -i bgp /usr/bin/TSA
3+
/usr/bin/TS TSA
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
docker exec -i bgp /usr/bin/TSB
3+
/usr/bin/TS TSB
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
22

3-
docker exec -i bgp /usr/bin/TSC
3+
/usr/bin/TS TSC
44

55
portstat -p 5

rules/docker-fpm-frr.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ $(DOCKER_FPM_FRR)_BASE_IMAGE_FILES += vtysh:/usr/bin/vtysh
3030
$(DOCKER_FPM_FRR)_BASE_IMAGE_FILES += TSA:/usr/bin/TSA
3131
$(DOCKER_FPM_FRR)_BASE_IMAGE_FILES += TSB:/usr/bin/TSB
3232
$(DOCKER_FPM_FRR)_BASE_IMAGE_FILES += TSC:/usr/bin/TSC
33+
$(DOCKER_FPM_FRR)_BASE_IMAGE_FILES += TS:/usr/bin/TS
3334
$(DOCKER_FPM_FRR)_BASE_IMAGE_FILES += monit_bgp:/etc/monit/conf.d

0 commit comments

Comments
 (0)