Skip to content

Commit 16e5434

Browse files
[docker-frr]: Use egrep with regexp to match correct TSA rules (sonic-net#6403)
**- Why I did it** Earlier today we found a bug in the SONiC TSA implementation. TSC shows incorrect output (see below) in case we have a route-map which contains TSA route-map as a prefix. ``` admin@str-s6100-acs-1:~$ TSC Traffic Shift Check: System Mode: Not consistent ``` The reason is that TSC implementation has too loose regexps in TSA utilities, which match wrong route-map entries: For example, current TSC matches following ``` route-map TO_BGP_PEER_V4 permit 200 route-map TO_BGP_PEER_V6 permit 200 ``` But it should match only ``` route-map TO_BGP_PEER_V4 permit 20 route-map TO_BGP_PEER_V4 deny 30 route-map TO_BGP_PEER_V6 permit 20 route-map TO_BGP_PEER_V6 deny 30 ``` **- How I did it** I fixed it by using egrep with `^` and `$` regexp markers which match begin and end of the line. **- How to verify it** 1. Add follwing entry to FRR config: ``` str-s6100-acs-1# str-s6100-acs-1# conf t str-s6100-acs-1(config)# route-map TO_BGP_PEER_V4 permit 200 str-s6100-acs-1(config-route-map)# end ``` 2. Use the TSC command and check output. It should show normal. ``` admin@str-s6100-acs-1:~$ TSC Traffic Shift Check: System Mode: Normal```
1 parent 419c10b commit 16e5434

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

dockers/docker-fpm-frr/TSA

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ function check_not_installed()
66
config=$(vtysh -c "show run")
77
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p');
88
do
9-
echo "$config" | grep -q "route-map $route_map_name permit 20"
9+
echo "$config" | egrep -q "^route-map $route_map_name permit 20$"
1010
c=$((c+$?))
11-
echo "$config" | grep -q "route-map $route_map_name deny 30"
11+
echo "$config" | egrep -q "^route-map $route_map_name deny 30$"
1212
c=$((c+$?))
1313
done
1414
return $c

dockers/docker-fpm-frr/TSB

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ function check_installed()
77
config=$(vtysh -c "show run")
88
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p');
99
do
10-
echo "$config" | grep -q "route-map $route_map_name permit 20"
10+
echo "$config" | egrep -q "^route-map $route_map_name permit 20$"
1111
c=$((c+$?))
1212
e=$((e+1))
13-
echo "$config" | grep -q "route-map $route_map_name deny 30"
13+
echo "$config" | egrep -q "^route-map $route_map_name deny 30$"
1414
c=$((c+$?))
1515
e=$((e+1))
1616
done

dockers/docker-fpm-frr/TSC

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ function check_not_installed()
66
config=$(vtysh -c "show run")
77
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p' | egrep 'V4|V6');
88
do
9-
echo "$config" | grep -q "route-map $route_map_name permit 20"
9+
echo "$config" | egrep -q "^route-map $route_map_name permit 20$"
1010
c=$((c+$?))
11-
echo "$config" | grep -q "route-map $route_map_name deny 30"
11+
echo "$config" | egrep -q "^route-map $route_map_name deny 30$"
1212
c=$((c+$?))
1313
done
1414
return $c
@@ -21,10 +21,10 @@ function check_installed()
2121
config=$(vtysh -c "show run")
2222
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p' | egrep 'V4|V6');
2323
do
24-
echo "$config" | grep -q "route-map $route_map_name permit 20"
24+
echo "$config" | egrep -q "^route-map $route_map_name permit 20$"
2525
c=$((c+$?))
2626
e=$((e+1))
27-
echo "$config" | grep -q "route-map $route_map_name deny 30"
27+
echo "$config" | egrep -q "^route-map $route_map_name deny 30$"
2828
c=$((c+$?))
2929
e=$((e+1))
3030
done

0 commit comments

Comments
 (0)