Skip to content

Commit

Permalink
[build_templates]: add multi-namespace spport to bgp
Browse files Browse the repository at this point in the history
* add bgp service template
* create /etc/sonic/frr* for multiple instances of bgp docker container

[frr docker]: add multi-ASIC support to bgpd.conf
* add `redistribute connected` option to advertise routes to local interfaces
* add `all` option to next-hop-self
* add route-map to hide internal routes
* add route-map to allow duplicate frontend router id

Signed-off-by: Lawrence Lee <[email protected]>
  • Loading branch information
Lawrence Lee committed Aug 2, 2019
1 parent 845778e commit 4ea01b7
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 4 deletions.
24 changes: 22 additions & 2 deletions dockers/docker-fpm-frr/bgpd.conf.default.j2
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,24 @@ route-map TO_BGP_PEER_V4 permit 100
!
route-map TO_BGP_PEER_V6 permit 100
!
{% if DEVICE_METADATA['localhost']['type'] == 'InternalFrontend' %}
route-map HIDE_INTERNAL permit 10
set community local-AS
!
{% endif %}
{% if DEVICE_METADATA['localhost']['type'] == 'InternalBackend' %}
route-map OVERRIDE_ORIGINATOR_ID permit 10
{% for (name, prefix) in LOOPBACK_INTERFACE|pfx_filter %}
{% if prefix | ipv4 and name == 'Loopback0' %}
set originator-id {{ prefix | ip }}
{% endif %}
{% endfor %}
!
{% endif %}
router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
{% if DEVICE_METADATA['localhost']['type'] == 'InternalFrontend' %}
redistribute connected route-map HIDE_INTERNAL
{% endif %}
bgp log-neighbor-changes
bgp bestpath as-path multipath-relax
no bgp default ipv4-unicast
Expand Down Expand Up @@ -64,6 +81,9 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
{% if bgp_session['asn'] | int != 0 %}
neighbor {{ neighbor_addr }} remote-as {{ bgp_session['asn'] }}
neighbor {{ neighbor_addr }} description {{ bgp_session['name'] }}
{% if DEVICE_METADATA['localhost']['type'] == 'InternalBackend' %}
neighbor {{ neighbor_addr }} route-map OVERRIDE_ORIGINATOR_ID in
{% endif %}
{# set the bgp neighbor timers if they have not default values #}
{% if (bgp_session['keepalive'] is defined and bgp_session['keepalive'] | int != 60)
or (bgp_session['holdtime'] is defined and bgp_session['holdtime'] | int != 180) %}
Expand All @@ -87,7 +107,7 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
neighbor {{ neighbor_addr }} route-reflector-client
{% endif %}
{% if bgp_session['nhopself'] | int != 0 %}
neighbor {{ neighbor_addr }} next-hop-self
neighbor {{ neighbor_addr }} next-hop-self all
{% endif %}
maximum-paths 64
exit-address-family
Expand All @@ -103,7 +123,7 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
neighbor {{ neighbor_addr }} route-reflector-client
{% endif %}
{% if bgp_session['nhopself'] | int != 0 %}
neighbor {{ neighbor_addr }} next-hop-self
neighbor {{ neighbor_addr }} next-hop-self all
{% endif %}
{% if bgp_session['asn'] != DEVICE_METADATA['localhost']['bgp_asn'] %}
neighbor {{ neighbor_addr }} route-map set-next-hop-global-v6 in
Expand Down
5 changes: 4 additions & 1 deletion files/build_templates/docker_image_ctl.j2
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ start() {
--tmpfs /tmp \
{%- endif %}
{%- endif %}
-v /var/run/redis$DEV:/var/run/redis:rw\
{%- if docker_container_name == "bgp" %}
-v /etc/sonic/frr$DEV:/etc/frr:rw \
{%- endif %}
-v /var/run/redis$DEV:/var/run/redis:rw \
-v /usr/share/sonic/device/$PLATFORM:/usr/share/sonic/platform:ro \
{%- if docker_container_name != "database" %}
-v /usr/share/sonic/device/$PLATFORM/$HWSKU:/usr/share/sonic/hwsku:ro \
Expand Down
17 changes: 17 additions & 0 deletions files/build_templates/multi_instance/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Unit]
Description=BGP container
#Requires=updategraph.service
#After=updategraph.service
After=database@%i.service
Requires=database@%i.service
Before=ntp-config.service
PartOf=namespace@%i.target

[Service]
User=root
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start %i
ExecStart=/usr/bin/{{docker_container_name}}.sh wait %i
ExecStop=/usr/bin/{{docker_container_name}}.sh stop %i

[Install]
RequiredBy=namespace@%i.target
8 changes: 8 additions & 0 deletions files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,14 @@ sudo chmod 755 $FILESYSTEM_ROOT/usr/bin/mlnx-fw-upgrade.sh
{% endif %}

{%- if SONIC_ROUTING_STACK == "frr" %}
{% for i in range(6) %}
sudo mkdir $FILESYSTEM_ROOT/etc/sonic/frr{{i}}
sudo touch $FILESYSTEM_ROOT/etc/sonic/frr{{i}}/frr.conf
sudo touch $FILESYSTEM_ROOT/etc/sonic/frr{{i}}/vtysh.conf
sudo chown -R $FRR_USER_UID:$FRR_USER_GID $FILESYSTEM_ROOT/etc/sonic/frr{{i}}
sudo chmod -R 640 $FILESYSTEM_ROOT/etc/sonic/frr{{i}}/
sudo chmod 750 $FILESYSTEM_ROOT/etc/sonic/frr{{i}}
{%- endfor %}
sudo mkdir $FILESYSTEM_ROOT/etc/sonic/frr
sudo touch $FILESYSTEM_ROOT/etc/sonic/frr/frr.conf
sudo touch $FILESYSTEM_ROOT/etc/sonic/frr/vtysh.conf
Expand Down
1 change: 0 additions & 1 deletion rules/docker-fpm-frr.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ SONIC_STRETCH_DBG_DOCKERS += $(DOCKER_FPM_FRR_DBG)
$(DOCKER_FPM_FRR)_CONTAINER_NAME = bgp
$(DOCKER_FPM_FRR)_RUN_OPT += --net=host --privileged -t
$(DOCKER_FPM_FRR)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro
$(DOCKER_FPM_FRR)_RUN_OPT += -v /etc/sonic/frr:/etc/frr:rw

$(DOCKER_FPM_FRR)_BASE_IMAGE_FILES += vtysh:/usr/bin/vtysh
$(DOCKER_FPM_FRR)_BASE_IMAGE_FILES += TSA:/usr/bin/TSA
Expand Down

0 comments on commit 4ea01b7

Please sign in to comment.