Skip to content

Commit 24b792d

Browse files
author
Rodny Molina
committed
[build]: Adding support for Free-Range-Routing stack.
- Extending SONiC building infrastructure to provide users with greater flexibility, by allowing them to elect a routing-stack different than the default one (quagga). The desired routing-stack will be defined in rules/config file. - As part of these changes I'm adding support for Free-Range-Routing (FRR) stack. Quagga will continue to be the default routing-stack. Signed-off-by: Rodny Molina <[email protected]>
1 parent fae53f7 commit 24b792d

36 files changed

+511
-22
lines changed

dockers/docker-fpm-frr/Dockerfile.j2

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM docker-config-engine
2+
3+
## Make apt-get non-interactive
4+
ENV DEBIAN_FRONTEND=noninteractive
5+
6+
RUN apt-get update
7+
8+
RUN apt-get install -y libdbus-1-3 libdaemon0 libjansson4 libc-ares2 iproute
9+
10+
COPY \
11+
{% for deb in docker_fpm_frr_debs.split(' ') -%}
12+
debs/{{ deb }}{{' '}}
13+
{%- endfor -%}
14+
debs/
15+
16+
RUN dpkg -i \
17+
{% for deb in docker_fpm_frr_debs.split(' ') -%}
18+
debs/{{ deb }}{{' '}}
19+
{%- endfor %}
20+
21+
## Clean up
22+
RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y
23+
RUN rm -rf /debs
24+
25+
COPY ["*.j2", "/usr/share/sonic/templates/"]
26+
COPY ["start.sh", "config.sh", "/usr/bin/"]
27+
COPY ["daemons", "/etc/frr/"]
28+
COPY ["debian.conf", "/etc/frr/"]
29+
30+
ENTRYPOINT /usr/bin/config.sh \
31+
&& /usr/bin/start.sh \
32+
&& /bin/bash

dockers/docker-fpm-frr/bgpd.conf.j2

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
!
2+
{% block banner %}
3+
! =========== Managed by sonic-cfggen DO NOT edit manually! ====================
4+
! generated by templates/quagga/bgpd.conf.j2 using minigraph_facts.py
5+
! file: bgpd.conf
6+
!
7+
{% endblock banner %}
8+
!
9+
{% block system_init %}
10+
hostname {{ inventory_hostname }}
11+
password zebra
12+
log syslog informational
13+
log facility local4
14+
! enable password {# {{ en_passwd }} TODO: param needed #}
15+
{% endblock system_init %}
16+
!
17+
{% block bgp_init %}
18+
!
19+
! bgp multiple-instance
20+
!
21+
router bgp {{ minigraph_bgp_asn }}
22+
bgp log-neighbor-changes
23+
bgp bestpath as-path multipath-relax
24+
{# TODO: use lo[0] for backward compatibility, will revisit the case with multiple lo interfaces #}
25+
bgp router-id {{ minigraph_lo_interfaces[0]['addr'] }}
26+
{# advertise loopback #}
27+
{% for lo in minigraph_lo_interfaces %}
28+
{% if lo['addr'] | ipv4 %}
29+
network {{ lo['addr'] }}/32
30+
{% elif lo['addr'] | ipv6 %}
31+
address-family ipv6
32+
network {{ lo['addr'] }}/128
33+
exit-address-family
34+
{% endif %}
35+
{% endfor %}
36+
{% endblock bgp_init %}
37+
{% block vlan_advertisement %}
38+
{% for vlan_interface in minigraph_vlan_interfaces %}
39+
network {{ vlan_interface['subnet'] }}
40+
{% endfor %}
41+
{% endblock vlan_advertisement %}
42+
{% block bgp_sessions %}
43+
{% for bgp_session in minigraph_bgp %}
44+
{% if bgp_session['asn'] != 0 %}
45+
neighbor {{ bgp_session['addr'] }} remote-as {{ bgp_session['asn'] }}
46+
neighbor {{ bgp_session['addr'] }} description {{ bgp_session['name'] }}
47+
{% if minigraph_devices[inventory_hostname]['type'] == 'ToRRouter' %}
48+
neighbor {{ bgp_session['addr'] }} allowas-in 1
49+
{% endif %}
50+
{% if bgp_session['addr'] | ipv6 %}
51+
address-family ipv6
52+
neighbor {{ bgp_session['addr'] }} activate
53+
maximum-paths 64
54+
exit-address-family
55+
{% endif %}
56+
{% endif %}
57+
{% endfor %}
58+
{% endblock bgp_sessions %}
59+
!
60+
maximum-paths 64
61+
!
62+
route-map ISOLATE permit 10
63+
set as-path prepend {{ minigraph_bgp_asn }}
64+
!

dockers/docker-fpm-frr/config.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
mkdir -p /etc/frr
4+
sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/bgpd.conf.j2 >/etc/frr/bgpd.conf
5+
sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/zebra.conf.j2 >/etc/frr/zebra.conf
6+
7+
sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/isolate.j2 >/usr/sbin/bgp-isolate
8+
chown root:root /usr/sbin/bgp-isolate
9+
chmod 0755 /usr/sbin/bgp-isolate
10+
11+
sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/unisolate.j2 >/usr/sbin/bgp-unisolate
12+
chown root:root /usr/sbin/bgp-unisolate
13+
chmod 0755 /usr/sbin/bgp-unisolate
14+
15+
mkdir -p /var/sonic
16+
echo "# Config files managed by sonic-config-engine" >/var/sonic/config_status
17+
File renamed without changes.

dockers/docker-fpm-frr/debian.conf

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#
2+
# If this option is set the /etc/init.d/frr script automatically loads
3+
# the config via "vtysh -b" when the servers are started.
4+
# Check /etc/pam.d/frr if you intend to use "vtysh"!
5+
#
6+
vtysh_enable=yes
7+
zebra_options=" -s 90000000 --daemon -A 127.0.0.1 -M fpm"
8+
bgpd_options=" --daemon -A 127.0.0.1"
9+
ospfd_options=" --daemon -A 127.0.0.1"
10+
ospf6d_options=" --daemon -A ::1"
11+
ripd_options=" --daemon -A 127.0.0.1"
12+
ripngd_options=" --daemon -A ::1"
13+
isisd_options=" --daemon -A 127.0.0.1"
14+
pimd_options=" --daemon -A 127.0.0.1"
15+
ldpd_options=" --daemon -A 127.0.0.1"
16+
nhrpd_options=" --daemon -A 127.0.0.1"
17+
18+
# The list of daemons to watch is automatically generated by the init script.
19+
watchfrr_enable=yes
20+
watchfrr_options=(-adz -r /usr/sbin/servicebBfrrbBrestartbB%s -s /usr/sbin/servicebBfrrbBstartbB%s -k /usr/sbin/servicebBfrrbBstopbB%s -b bB -t 30)
File renamed without changes.

dockers/docker-fpm-frr/start.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
rm -f /var/run/rsyslogd.pid
4+
service rsyslog start
5+
service frr start
6+
fpmsyncd &
File renamed without changes.

dockers/docker-fpm-frr/zebra.conf.j2

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
!
2+
{% block banner %}
3+
! =========== Managed by sonic-cfggen DO NOT edit manually! ====================
4+
! generated by templates/quagga/zebra.conf.j2 using minigraph_facts.py
5+
! file: zebra.conf
6+
!
7+
{% endblock banner %}
8+
!
9+
{% block sys_init %}
10+
hostname {{ inventory_hostname }}
11+
password zebra
12+
enable password zebra
13+
{% endblock sys_init %}
14+
!
15+
{% block interfaces %}
16+
! Enable link-detect (default disabled)
17+
{% for interface in minigraph_interfaces %}
18+
interface {{ interface['alias'] }}
19+
link-detect
20+
!
21+
{% endfor %}
22+
{% for interface in minigraph_portchannel_interfaces %}
23+
interface {{ interface['name'] }}
24+
link-detect
25+
!
26+
{% endfor %}
27+
{% endblock interfaces %}
28+
!
29+
{% block default_route %}
30+
! set static default route to mgmt gateway as a backup to learned default
31+
ip route 0.0.0.0/0 {{ minigraph_mgmt_interface['gwaddr'] }} 200
32+
{% endblock default_route %}
33+
!
34+
{% block source_loopback %}
35+
! Set ip source to loopback for bgp learned routes
36+
route-map RM_SET_SRC permit 10
37+
set src {{ minigraph_lo_interfaces[0]['addr'] }}
38+
!
39+
{% set lo_ipv6_addrs = [] %}
40+
{% if minigraph_lo_interfaces is defined %}
41+
{% for interface in minigraph_lo_interfaces %}
42+
{% if interface['addr'] is defined and interface['addr']|ipv6 %}
43+
{% if lo_ipv6_addrs.append(interface['addr']) %}
44+
{% endif %}
45+
{% endif %}
46+
{% endfor %}
47+
{% endif %}
48+
{% if lo_ipv6_addrs|length > 0 %}
49+
route-map RM_SET_SRC6 permit 10
50+
set src {{ lo_ipv6_addrs[0] }}
51+
!
52+
{% endif %}
53+
ip protocol bgp route-map RM_SET_SRC
54+
!
55+
{% if lo_ipv6_addrs|length > 0 %}
56+
ipv6 protocol bgp route-map RM_SET_SRC6
57+
!
58+
{% endif %}
59+
{% endblock source_loopback %}
60+
!
61+
{% block logging %}
62+
log syslog informational
63+
log facility local4
64+
{% endblock logging %}
65+
!
66+

dockers/docker-fpm-gobgp/Dockerfile.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM docker-fpm
1+
FROM docker-fpm-quagga
22

33
## Make apt-get non-interactive
44
ENV DEBIAN_FRONTEND=noninteractive

dockers/docker-fpm/Dockerfile.j2 renamed to dockers/docker-fpm-quagga/Dockerfile.j2

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ RUN apt-get update
88
RUN apt-get install -y libdbus-1-3 libdaemon0 libjansson4
99

1010
COPY \
11-
{% for deb in docker_fpm_debs.split(' ') -%}
11+
{% for deb in docker_fpm_quagga_debs.split(' ') -%}
1212
debs/{{ deb }}{{' '}}
1313
{%- endfor -%}
1414
debs/
1515

1616
RUN dpkg -i \
17-
{% for deb in docker_fpm_debs.split(' ') -%}
17+
{% for deb in docker_fpm_quagga_debs.split(' ') -%}
1818
debs/{{ deb }}{{' '}}
1919
{%- endfor %}
2020

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
docker exec -i bgp vtysh "$@"
File renamed without changes.

dockers/docker-fpm-quagga/daemons

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This file tells the quagga package which daemons to start.
2+
#
3+
# Entries are in the format: <daemon>=(yes|no|priority)
4+
# 0, "no" = disabled
5+
# 1, "yes" = highest priority
6+
# 2 .. 10 = lower priorities
7+
# Read /usr/share/doc/quagga/README.Debian for details.
8+
#
9+
# Sample configurations for these daemons can be found in
10+
# /usr/share/doc/quagga/examples/.
11+
#
12+
# ATTENTION:
13+
#
14+
# When activation a daemon at the first time, a config file, even if it is
15+
# empty, has to be present *and* be owned by the user and group "quagga", else
16+
# the daemon will not be started by /etc/init.d/quagga. The permissions should
17+
# be u=rw,g=r,o=.
18+
# When using "vtysh" such a config file is also needed. It should be owned by
19+
# group "quaggavty" and set to ug=rw,o= though. Check /etc/pam.d/quagga, too.
20+
#
21+
# The watchquagga daemon is always started. Per default in monitoring-only but
22+
# that can be changed via /etc/quagga/debian.conf.
23+
#
24+
zebra=yes
25+
bgpd=yes
26+
ospfd=no
27+
ospf6d=no
28+
ripd=no
29+
ripngd=no
30+
isisd=no
31+
babeld=no

dockers/docker-fpm-quagga/isolate.j2

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
## vtysh only accepts script in stdin, so cannot be directly used in shebang
3+
## Cut the tail of this script and feed vtysh stdin
4+
sed -n -e '9,$p' < "$0" | vtysh "$@"
5+
## Exit with vtysh return code
6+
exit $?
7+
8+
## vtysh script start from next line, which line number MUST eqaul in 'sed' command above
9+
10+
configure terminal
11+
router bgp {{ minigraph_bgp_asn }}
12+
{% for bgp_session in minigraph_bgp %}
13+
neighbor {{ bgp_session['addr'] }} route-map ISOLATE out
14+
{% endfor %}
15+
exit
16+
exit
17+
18+
{% for bgp_session in minigraph_bgp %}
19+
clear ip bgp {{ bgp_session['addr'] }} soft out
20+
{% endfor %}
File renamed without changes.
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
## vtysh only accepts script in stdin, so cannot be directly used in shebang
3+
## Cut the tail of this script and feed vtysh stdin
4+
sed -n -e '9,$p' < "$0" | vtysh "$@"
5+
## Exit with vtysh return code
6+
exit $?
7+
8+
## vtysh script start from next line, which line number MUST eqaul in 'sed' command above
9+
10+
configure terminal
11+
router bgp {{ minigraph_bgp_asn }}
12+
{% for bgp_session in minigraph_bgp %}
13+
no neighbor {{ bgp_session['addr'] }} route-map ISOLATE out
14+
{% endfor %}
15+
exit
16+
exit
17+
18+
{% for bgp_session in minigraph_bgp %}
19+
clear ip bgp {{ bgp_session['addr'] }} soft out
20+
{% endfor %}

platform/broadcom/rules.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ $(DSSERVE)_URL = "https://sonicstorage.blob.core.windows.net/packages/dsserve?sv
2121
SONIC_ONLINE_FILES += $(BCMCMD) $(DSSERVE)
2222

2323
SONIC_ALL += $(SONIC_ONE_IMAGE) $(SONIC_ONE_ABOOT_IMAGE) \
24-
$(DOCKER_FPM_GOBGP) \
24+
$(DOCKER_FPM) \
2525
$(DOCKER_SYNCD_BRCM_RPC)
2626

2727
# Inject brcm sai into sairedis

platform/cavium/rules.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ include $(PLATFORM_PATH)/libsaithrift-dev.mk
88
include $(PLATFORM_PATH)/python-saithrift.mk
99

1010
SONIC_ALL += $(SONIC_ONE_IMAGE) \
11-
$(DOCKER_FPM_GOBGP)
11+
$(DOCKER_FPM)
1212

1313
# Inject cavium sai into sairedis
1414
$(LIBSAIREDIS)_DEPENDS += $(CAVM_SAI) $(CAVM_LIBSAI)

platform/mellanox/rules.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ include $(PLATFORM_PATH)/libsaithrift-dev.mk
1111
include $(PLATFORM_PATH)/python-saithrift.mk
1212

1313
SONIC_ALL += $(SONIC_ONE_IMAGE) \
14-
$(DOCKER_FPM_GOBGP) \
14+
$(DOCKER_FPM) \
1515
$(DOCKER_SYNCD_MLNX_RPC)
1616

1717
# Inject mlnx sai into sairedis

platform/p4/docker-sonic-p4.mk

+10-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
DOCKER_SONIC_P4 = docker-sonic-p4.gz
44
$(DOCKER_SONIC_P4)_PATH = $(PLATFORM_PATH)/docker-sonic-p4
5-
$(DOCKER_SONIC_P4)_DEPENDS += $(SWSS) $(SYNCD) $(P4_SWITCH) $(REDIS_SERVER) $(REDIS_TOOLS) $(QUAGGA) $(LIBTEAMDCT) $(LIBTEAM_UTILS)
5+
$(DOCKER_SONIC_P4)_DEPENDS += $(SWSS) $(SYNCD) $(P4_SWITCH) $(REDIS_SERVER) $(REDIS_TOOLS) $(LIBTEAMDCT) $(LIBTEAM_UTILS)
6+
7+
ifeq ($(ROUTING_STACK), quagga)
8+
$(DOCKER_SONIC_P4)_DEPENDS += $(QUAGGA)
9+
else ifeq ($(ROUTING_STACK), frr)
10+
$(DOCKER_SONIC_P4)_DEPENDS += $(FRR)
11+
else
12+
$(DOCKER_SONIC_P4)_DEPENDS += $(GOBGP)
13+
endif
14+
615
$(DOCKER_SONIC_P4)_LOAD_DOCKERS += $(DOCKER_BASE)
716
SONIC_DOCKER_IMAGES += $(DOCKER_SONIC_P4)

platform/p4/docker-sonic-p4/Dockerfile.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ENV DEBIAN_FRONTEND=noninteractive
55

66
RUN apt-get update
77

8-
RUN apt-get install -y net-tools ethtool tcpdump ifupdown bridge-utils python-ply libqt5core5a libqt5network5 libboost-program-options1.55.0 libboost-system1.55.0 libboost-thread1.55.0 libgmp10 libjudydebian1 libnanomsg0 libdaemon0 libjansson4 libjemalloc1 openssh-client openssh-server
8+
RUN apt-get install -y net-tools ethtool tcpdump ifupdown bridge-utils python-ply libqt5core5a libqt5network5 libboost-program-options1.55.0 libboost-system1.55.0 libboost-thread1.55.0 libgmp10 libjudydebian1 libnanomsg0 libdaemon0 libjansson4 libjemalloc1 openssh-client openssh-server libc-ares2 iproute
99

1010
COPY \
1111
{% for deb in docker_sonic_p4_debs.split(' ') -%}

rules/config

+5
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,8 @@ DEFAULT_PASSWORD = YourPaSsWoRd
4141
# SONIC_CONFIG_DEBUG - install debug packages
4242
# Uncomment next line to enable:
4343
# SONIC_CONFIG_DEBUG = y
44+
45+
# SONIC_ROUTING_STACK - specify the routing-stack being elected to drive SONiC's control-plane.
46+
# Quagga will be the default routing-stack for all the SONiC platforms. Other supported
47+
# routing-stacks: frr, gobgp.
48+
SONIC_ROUTING_STACK = quagga

rules/docker-fpm-frr.mk

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# docker image for fpm-frr
2+
3+
DOCKER_FPM_FRR = docker-fpm-frr.gz
4+
$(DOCKER_FPM_FRR)_PATH = $(DOCKERS_PATH)/docker-fpm-frr
5+
$(DOCKER_FPM_FRR)_DEPENDS += $(FRR) $(SWSS)
6+
$(DOCKER_FPM_FRR)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE)
7+
SONIC_DOCKER_IMAGES += $(DOCKER_FPM_FRR)
8+
9+
$(DOCKER_FPM_FRR)_CONTAINER_NAME = bgp
10+
$(DOCKER_FPM_FRR)_RUN_OPT += --net=host --privileged -t
11+
$(DOCKER_FPM_FRR)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro
12+
13+
$(DOCKER_FPM_FRR)_BASE_IMAGE_FILES += vtysh:/usr/bin/vtysh
14+

rules/docker-fpm-gobgp.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
DOCKER_FPM_GOBGP = docker-fpm-gobgp.gz
44
$(DOCKER_FPM_GOBGP)_PATH = $(DOCKERS_PATH)/docker-fpm-gobgp
55
$(DOCKER_FPM_GOBGP)_DEPENDS += $(GOBGP)
6-
$(DOCKER_FPM_GOBGP)_LOAD_DOCKERS += $(DOCKER_FPM)
6+
$(DOCKER_FPM_GOBGP)_LOAD_DOCKERS += $(DOCKER_FPM_QUAGGA)
77
SONIC_DOCKER_IMAGES += $(DOCKER_FPM_GOBGP)
88

99
$(DOCKER_FPM_GOBGP)_CONTAINER_NAME = bgp

0 commit comments

Comments
 (0)