Skip to content

Commit

Permalink
[docker-frr]: Use egrep with regexp to match correct TSA rules (#6403)
Browse files Browse the repository at this point in the history
**- 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```
  • Loading branch information
pavel-shirshov authored and abdosi committed Jan 20, 2021
1 parent c9e9110 commit beaaf33
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions dockers/docker-fpm-frr/TSA
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ function check_not_installed()
config=$(vtysh -c "show run")
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p');
do
echo "$config" | grep -q "route-map $route_map_name permit 20"
echo "$config" | egrep -q "^route-map $route_map_name permit 20$"
c=$((c+$?))
echo "$config" | grep -q "route-map $route_map_name deny 30"
echo "$config" | egrep -q "^route-map $route_map_name deny 30$"
c=$((c+$?))
done
return $c
Expand Down
4 changes: 2 additions & 2 deletions dockers/docker-fpm-frr/TSB
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ 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');
do
echo "$config" | grep -q "route-map $route_map_name permit 20"
echo "$config" | egrep -q "^route-map $route_map_name permit 20$"
c=$((c+$?))
e=$((e+1))
echo "$config" | grep -q "route-map $route_map_name deny 30"
echo "$config" | egrep -q "^route-map $route_map_name deny 30$"
c=$((c+$?))
e=$((e+1))
done
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 @@ -6,9 +6,9 @@ function check_not_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
echo "$config" | grep -q "route-map $route_map_name permit 20"
echo "$config" | egrep -q "^route-map $route_map_name permit 20$"
c=$((c+$?))
echo "$config" | grep -q "route-map $route_map_name deny 30"
echo "$config" | egrep -q "^route-map $route_map_name deny 30$"
c=$((c+$?))
done
return $c
Expand All @@ -21,10 +21,10 @@ 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
echo "$config" | grep -q "route-map $route_map_name permit 20"
echo "$config" | egrep -q "^route-map $route_map_name permit 20$"
c=$((c+$?))
e=$((e+1))
echo "$config" | grep -q "route-map $route_map_name deny 30"
echo "$config" | egrep -q "^route-map $route_map_name deny 30$"
c=$((c+$?))
e=$((e+1))
done
Expand Down

0 comments on commit beaaf33

Please sign in to comment.