sonic-buildimage/dockers
pavel-shirshov c94f93f046
[bgpcfgd]: Dynamic BBR support (#5626)
**- Why I did it**
To introduce dynamic support of BBR functionality into bgpcfgd.
BBR is adding  `neighbor PEER_GROUP allowas-in 1' for all BGP peer-groups which points to T0
Now we can add and remove this configuration based on CONFIG_DB entry 

**- How I did it**
I introduced a new CONFIG_DB entry:
 - table name: "BGP_BBR"
 - key value: "all". Currently only "all" is supported, which means that all peer-groups which points to T0s will be updated
 - data value: a dictionary: {"status": "status_value"}, where status_value could be either "enabled" or "disabled"

Initially, when bgpcfgd starts, it reads initial BBR status values from the [constants.yml](https://github.com/Azure/sonic-buildimage/pull/5626/files#diff-e6f2fe13a6c276dc2f3b27a5bef79886f9c103194be4fcb28ce57375edf2c23cR34). Then you can control BBR status by changing "BGP_BBR" table in the CONFIG_DB (see examples below).

bgpcfgd knows what peer-groups to change fron [constants.yml](https://github.com/Azure/sonic-buildimage/pull/5626/files#diff-e6f2fe13a6c276dc2f3b27a5bef79886f9c103194be4fcb28ce57375edf2c23cR39). The dictionary contains peer-group names as keys, and a list of address-families as values. So when bgpcfgd got a request to change the BBR state, it changes the state only for peer-groups listed in the constants.yml dictionary (and only for address families from the peer-group value).

**- How to verify it**
Initially, when we start SONiC FRR has BBR enabled for PEER_V4 and PEER_V6:
```
admin@str-s6100-acs-1:~$ vtysh -c 'show run' | egrep 'PEER_V.? allowas'
  neighbor PEER_V4 allowas-in 1
  neighbor PEER_V6 allowas-in 1
```

Then we apply following configuration to the db:
```
admin@str-s6100-acs-1:~$ cat disable.json                
{
        "BGP_BBR": {
            "all": {
                "status": "disabled"
            }
        }
}


admin@str-s6100-acs-1:~$ sonic-cfggen -j disable.json -w 
```
The log output are:
```
Oct 14 18:40:22.450322 str-s6100-acs-1 DEBUG bgp#bgpcfgd: Received message : '('all', 'SET', (('status', 'disabled'),))'
Oct 14 18:40:22.450620 str-s6100-acs-1 DEBUG bgp#bgpcfgd: execute command '['vtysh', '-f', '/tmp/tmpmWTiuq']'.
Oct 14 18:40:22.681084 str-s6100-acs-1 DEBUG bgp#bgpcfgd: execute command '['vtysh', '-c', 'clear bgp peer-group PEER_V4 soft in']'.
Oct 14 18:40:22.904626 str-s6100-acs-1 DEBUG bgp#bgpcfgd: execute command '['vtysh', '-c', 'clear bgp peer-group PEER_V6 soft in']'.
```

Check FRR configuraiton and see that no allowas parameters are there:
```
admin@str-s6100-acs-1:~$ vtysh -c 'show run' | egrep 'PEER_V.? allowas' 
admin@str-s6100-acs-1:~$
```

Then we apply enabling configuration back:
```
admin@str-s6100-acs-1:~$ cat enable.json 
{
        "BGP_BBR": {
            "all": {
                "status": "enabled"
            }
        }
}

admin@str-s6100-acs-1:~$ sonic-cfggen -j enable.json -w 
```
The log output:
```
Oct 14 18:40:41.074720 str-s6100-acs-1 DEBUG bgp#bgpcfgd: Received message : '('all', 'SET', (('status', 'enabled'),))'
Oct 14 18:40:41.074720 str-s6100-acs-1 DEBUG bgp#bgpcfgd: execute command '['vtysh', '-f', '/tmp/tmpDD6SKv']'.
Oct 14 18:40:41.587257 str-s6100-acs-1 DEBUG bgp#bgpcfgd: execute command '['vtysh', '-c', 'clear bgp peer-group PEER_V4 soft in']'.
Oct 14 18:40:42.042967 str-s6100-acs-1 DEBUG bgp#bgpcfgd: execute command '['vtysh', '-c', 'clear bgp peer-group PEER_V6 soft in']'.
```


Check FRR configuraiton and see that the BBR configuration is back:
```
admin@str-s6100-acs-1:~$ vtysh -c 'show run' | egrep 'PEER_V.? allowas'
  neighbor PEER_V4 allowas-in 1
  neighbor PEER_V6 allowas-in 1
```

*** The test coverage ***
Below is the test coverage
```
---------- coverage: platform linux2, python 2.7.12-final-0 ----------
Name                             Stmts   Miss  Cover
----------------------------------------------------
bgpcfgd/__init__.py                  0      0   100%
bgpcfgd/__main__.py                  3      3     0%
bgpcfgd/config.py                   78     41    47%
bgpcfgd/directory.py                63     34    46%
bgpcfgd/log.py                      15      3    80%
bgpcfgd/main.py                     51     51     0%
bgpcfgd/manager.py                  41     23    44%
bgpcfgd/managers_allow_list.py     385     21    95%
bgpcfgd/managers_bbr.py             76      0   100%
bgpcfgd/managers_bgp.py            193    193     0%
bgpcfgd/managers_db.py               9      9     0%
bgpcfgd/managers_intf.py            33     33     0%
bgpcfgd/managers_setsrc.py          45     45     0%
bgpcfgd/runner.py                   39     39     0%
bgpcfgd/template.py                 64     11    83%
bgpcfgd/utils.py                    32     24    25%
bgpcfgd/vars.py                      1      0   100%
----------------------------------------------------
TOTAL                             1128    530    53%
```

**- Which release branch to backport (provide reason below if selected)**

- [ ] 201811
- [x] 201911
- [x] 202006
2020-10-22 11:04:21 -07:00
..
docker-base [docker-base]: Rate limit priority INFO and lower in syslog (#5666) 2020-10-20 11:52:46 -07:00
docker-base-buster [docker-base]: Rate limit priority INFO and lower in syslog (#5666) 2020-10-20 11:52:46 -07:00
docker-base-stretch [docker-base]: Rate limit priority INFO and lower in syslog (#5666) 2020-10-20 11:52:46 -07:00
docker-basic_router Remove extra trailing newlines at EOF (#804) 2017-07-12 20:54:37 -07:00
docker-config-engine [python-click] No longer build our own package, let pip/setuptools install vanilla (#5549) 2020-10-14 10:16:35 -07:00
docker-config-engine-buster [python-click] No longer build our own package, let pip/setuptools install vanilla (#5549) 2020-10-14 10:16:35 -07:00
docker-config-engine-stretch [python-click] No longer build our own package, let pip/setuptools install vanilla (#5549) 2020-10-14 10:16:35 -07:00
docker-database [chassis]: Use correct path for chassisdb.conf file (#5632) 2020-10-21 01:40:04 -07:00
docker-dhcp-relay [dhcpmon] Print Both Snapshot And Current Counters (#5374) 2020-09-15 15:27:36 -07:00
docker-fpm-frr [bgpcfgd]: Dynamic BBR support (#5626) 2020-10-22 11:04:21 -07:00
docker-fpm-gobgp [frr] Reduce Calls to SONiC Cfggen (#5176) 2020-08-17 15:47:42 -07:00
docker-fpm-quagga [cfggen] Make Jinja2 Template Python 3 Compatible 2020-09-30 07:07:43 -07:00
docker-iccpd [docker-iccpd]: Upgrade docker-iccpd to buster (#4984) 2020-07-18 00:12:59 -07:00
docker-lldp [cfggen] Make Jinja2 Template Python 3 Compatible 2020-09-30 07:07:43 -07:00
docker-nat [dockers][supervisor] Increase event buffer size for dependent-startup (#5247) 2020-09-08 23:36:38 -07:00
docker-orchagent [ECMP][Multi-ASIC] Have different ECMP seed value on each ASIC (#5357) 2020-10-08 09:05:37 -07:00
docker-platform-monitor [sonic-platform-common] Install Python 3 package in host OS and PMon container (#5461) 2020-09-29 13:57:54 -07:00
docker-ptf [docker-ptf] add gnmi python client (#4928) 2020-07-12 18:08:52 +00:00
docker-ptf-saithrift [docker-ptf-*]: Use buildimage infrastructure to build docker-ptf-* (#638) 2017-05-26 17:18:11 -07:00
docker-router-advertiser [dockers][supervisor] Increase event buffer size for dependent-startup (#5247) 2020-09-08 23:36:38 -07:00
docker-sflow [Monit] Unmonitor the processes in containers which are disabled. (#5153) 2020-09-25 00:28:28 -07:00
docker-snmp [monit]: Fix process checker. (#5480) 2020-09-29 17:23:09 -07:00
docker-sonic-mgmt [mgmt] Install dhclient in sonic-mgmt docker (#5447) 2020-09-23 20:01:58 -07:00
docker-sonic-mgmt-framework [dockers][supervisor] Increase event buffer size for dependent-startup (#5247) 2020-09-08 23:36:38 -07:00
docker-sonic-restapi Update conf DB with CA cert & rename ca_crt field (#5448) 2020-09-25 09:20:09 -07:00
docker-sonic-telemetry [Monit] Unmonitor the processes in containers which are disabled. (#5153) 2020-09-25 00:28:28 -07:00
docker-teamd [Monit] Unmonitor the processes in containers which are disabled. (#5153) 2020-09-25 00:28:28 -07:00
dockerfile-macros.j2 [sonic-platform-common] Install Python 3 package in host OS and PMon container (#5461) 2020-09-29 13:57:54 -07:00