Skip to content

Commit 116b86f

Browse files
committed
FRR 4.0 integration with SONiC
-- Uses SONiC FRR repo frr/4.0 (which has SONiC support) to build image -- Makefile changes to make frr4.0 builtable. -- Updated/Added FRR configuration files -- bgpd jinja template fixes To build SONiC images with FRR4.0, simply edit rules/config file and change routing stack to following: SONIC_ROUTING_STACK = frr and then build images as usual.
1 parent 018b589 commit 116b86f

File tree

14 files changed

+127
-158
lines changed

14 files changed

+127
-158
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
url = https://github.com/Azure/sonic-platform-daemons
4747
[submodule "src/sonic-frr/frr"]
4848
path = src/sonic-frr/frr
49-
url = https://github.com/FRRouting/frr.git
49+
url = https://github.com/Azure/sonic-frr.git
5050
[submodule "platform/p4/p4-hlir/p4-hlir-v1.1"]
5151
path = platform/p4/p4-hlir/p4-hlir-v1.1
5252
url = https://github.com/p4lang/p4-hlir.git

dockers/docker-fpm-frr/Dockerfile.j2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ RUN rm -rf /debs ~/.cache
3333
COPY ["*.j2", "/usr/share/sonic/templates/"]
3434
COPY ["start.sh", "config.sh", "/usr/bin/"]
3535
COPY ["daemons", "/etc/frr/"]
36-
COPY ["debian.conf", "/etc/frr/"]
36+
COPY ["daemons.conf", "/etc/frr/"]
37+
COPY ["vtysh.conf", "/etc/frr/"]
3738

3839
ENTRYPOINT /usr/bin/config.sh \
3940
&& /usr/bin/start.sh \

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

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,40 @@ log facility local4
1414
! enable password {# {{ en_passwd }} TODO: param needed #}
1515
{% endblock system_init %}
1616
!
17+
{% if DEVICE_METADATA['localhost'].has_key('bgp_asn') %}
1718
{% block bgp_init %}
1819
!
1920
! bgp multiple-instance
2021
!
22+
route-map FROM_BGP_SPEAKER_V4 permit 10
23+
!
24+
route-map TO_BGP_SPEAKER_V4 deny 10
25+
!
2126
router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
2227
bgp log-neighbor-changes
2328
bgp bestpath as-path multipath-relax
2429
no bgp default ipv4-unicast
25-
{# TODO: use lo[0] for backward compatibility, will revisit the case with multiple lo interfaces #}
30+
{# Advertise graceful restart capability for ToR #}
31+
{% if DEVICE_METADATA['localhost']['type'] == 'ToRRouter' %}
32+
bgp graceful-restart
33+
{% endif %}
2634
{% for (name, prefix) in LOOPBACK_INTERFACE %}
2735
{% if prefix | ipv4 and name == 'Loopback0' %}
2836
bgp router-id {{ prefix | ip }}
2937
{% endif %}
3038
{% endfor %}
3139
{# advertise loopback #}
32-
3340
{% for (name, prefix) in LOOPBACK_INTERFACE %}
34-
{% if prefix | ipv4 %}
41+
{% if prefix | ipv4 and name == 'Loopback0' %}
3542
network {{ prefix | ip }}/32
36-
{% elif prefix | ipv6 %}
43+
{% elif prefix | ipv6 and name == 'Loopback0' %}
3744
address-family ipv6
3845
network {{ prefix | ip }}/128
3946
exit-address-family
4047
{% endif %}
4148
{% endfor %}
4249
{% endblock bgp_init %}
50+
{% endif %}
4351
{% block vlan_advertisement %}
4452
{% for (name, prefix) in VLAN_INTERFACE %}
4553
{% if prefix | ipv4 %}
@@ -56,13 +64,21 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
5664
{% if bgp_session['asn'] | int != 0 %}
5765
neighbor {{ neighbor_addr }} remote-as {{ bgp_session['asn'] }}
5866
neighbor {{ neighbor_addr }} description {{ bgp_session['name'] }}
67+
{# set the bgp neighbor timers if they have not default values #}
68+
{% if (bgp_session['keepalive'] is defined and bgp_session['keepalive'] | int != 60)
69+
or (bgp_session['holdtime'] is defined and bgp_session['holdtime'] | int != 180) %}
5970
neighbor {{ neighbor_addr }} timers {{ bgp_session['keepalive'] }} {{ bgp_session['holdtime'] }}
60-
{% if DEVICE_METADATA['localhost']['type'] == 'ToRRouter' %}
61-
neighbor {{ neighbor_addr }} allowas-in 1
71+
{% endif %}
72+
{% if bgp_session.has_key('admin_status') and bgp_session['admin_status'] == 'down' or not bgp_session.has_key('admin_status') and DEVICE_METADATA['localhost'].has_key('default_bgp_status') and DEVICE_METADATA['localhost']['default_bgp_status'] == 'down' %}
73+
neighbor {{ neighbor_addr }} shutdown
6274
{% endif %}
6375
{% if neighbor_addr | ipv4 %}
6476
address-family ipv4
77+
{% if DEVICE_METADATA['localhost']['type'] == 'ToRRouter' %}
78+
neighbor {{ neighbor_addr }} allowas-in 1
79+
{% endif %}
6580
neighbor {{ neighbor_addr }} activate
81+
neighbor {{ neighbor_addr }} soft-reconfiguration inbound
6682
{% if bgp_session['rrclient'] | int != 0 %}
6783
neighbor {{ neighbor_addr }} route-reflector-client
6884
{% endif %}
@@ -74,7 +90,11 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
7490
{% endif %}
7591
{% if neighbor_addr | ipv6 %}
7692
address-family ipv6
93+
{% if DEVICE_METADATA['localhost']['type'] == 'ToRRouter' %}
94+
neighbor {{ neighbor_addr }} allowas-in 1
95+
{% endif %}
7796
neighbor {{ neighbor_addr }} activate
97+
neighbor {{ neighbor_addr }} soft-reconfiguration inbound
7898
{% if bgp_session['rrclient'] | int != 0 %}
7999
neighbor {{ neighbor_addr }} route-reflector-client
80100
{% endif %}
@@ -90,11 +110,43 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
90110
{% endif %}
91111
{% endfor %}
92112
{% endblock bgp_sessions %}
113+
{% block bgp_peers_with_range %}
114+
{% if BGP_PEER_RANGE %}
115+
{% for bgp_peer in BGP_PEER_RANGE.values() %}
116+
neighbor {{ bgp_peer['name'] }} peer-group
117+
neighbor {{ bgp_peer['name'] }} passive
118+
neighbor {{ bgp_peer['name'] }} remote-as {{ deployment_id_asn_map[DEVICE_METADATA['localhost']['deployment_id']] }}
119+
neighbor {{ bgp_peer['name'] }} ebgp-multihop 255
120+
{% for (name, prefix) in LOOPBACK_INTERFACE %}
121+
{% if name == 'Loopback1' %}
122+
neighbor {{ bgp_peer['name'] }} update-source {{ prefix | ip }}
123+
{% endif %}
124+
{% endfor %}
125+
{% for ip_range in bgp_peer['ip_range'] %}
126+
bgp listen range {{ip_range}} peer-group {{ bgp_peer['name'] }}
127+
{% endfor %}
128+
address-family ipv4
129+
neighbor {{ bgp_peer['name'] }} activate
130+
neighbor {{ bgp_peer['name'] }} soft-reconfiguration inbound
131+
neighbor {{ bgp_peer['name'] }} route-map FROM_BGP_SPEAKER_V4 in
132+
neighbor {{ bgp_peer['name'] }} route-map TO_BGP_SPEAKER_V4 out
133+
maximum-paths 64
134+
exit-address-family
135+
address-family ipv6
136+
neighbor {{ bgp_peer['name'] }} activate
137+
neighbor {{ bgp_peer['name'] }} soft-reconfiguration inbound
138+
maximum-paths 64
139+
exit-address-family
140+
{% endfor %}
141+
{% endif %}
142+
{% endblock bgp_peers_with_range %}
93143
!
144+
{% if DEVICE_METADATA['localhost'].has_key('bgp_asn') %}
94145
maximum-paths 64
95146
!
96147
route-map ISOLATE permit 10
97148
set as-path prepend {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
149+
{% endif %}
98150
!
99151
route-map set-next-hop-global-v6 permit 10
100152
set ipv6 next-hop prefer-global

dockers/docker-fpm-frr/daemons

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
# This file tells the quagga package which daemons to start.
1+
# This file tells the frr package which daemons to start.
22
#
33
# Entries are in the format: <daemon>=(yes|no|priority)
44
# 0, "no" = disabled
55
# 1, "yes" = highest priority
66
# 2 .. 10 = lower priorities
7-
# Read /usr/share/doc/quagga/README.Debian for details.
7+
# Read /usr/share/doc/frr/README.Debian for details.
88
#
99
# Sample configurations for these daemons can be found in
10-
# /usr/share/doc/quagga/examples/.
10+
# /usr/share/doc/frr/examples/.
1111
#
12-
# ATTENTION:
12+
# ATTENTION:
1313
#
1414
# 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
15+
# empty, has to be present *and* be owned by the user and group "frr", else
16+
# the daemon will not be started by /etc/init.d/frr. The permissions should
1717
# be u=rw,g=r,o=.
1818
# 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.
19+
# group "frrvty" and set to ug=rw,o= though. Check /etc/pam.d/frr, too.
2020
#
21-
# The watchquagga daemon is always started. Per default in monitoring-only but
22-
# that can be changed via /etc/quagga/debian.conf.
21+
# The watchfrr daemon is always started. Per default in monitoring-only but
22+
# that can be changed via /etc/frr/daemons.conf.
2323
#
2424
zebra=yes
2525
bgpd=yes
@@ -28,4 +28,9 @@ ospf6d=no
2828
ripd=no
2929
ripngd=no
3030
isisd=no
31+
pimd=no
32+
ldpd=no
33+
nhrpd=no
34+
eigrpd=no
3135
babeld=no
36+
sharpd=no

dockers/docker-fpm-frr/debian.conf renamed to dockers/docker-fpm-frr/daemons.conf

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ isisd_options=" --daemon -A 127.0.0.1"
1414
pimd_options=" --daemon -A 127.0.0.1"
1515
ldpd_options=" --daemon -A 127.0.0.1"
1616
nhrpd_options=" --daemon -A 127.0.0.1"
17+
eigrpd_options=" --daemon -A 127.0.0.1"
18+
babeld_options=" --daemon -A 127.0.0.1"
19+
sharpd_options=" --daemon -A 127.0.0.1"
1720

1821
# The list of daemons to watch is automatically generated by the init script.
1922
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)
23+
watchfrr_options=(-d -r /usr/sbin/servicebBfrrbBrestartbB%s -s /usr/sbin/servicebBfrrbBstartbB%s -k /usr/sbin/servicebBfrrbBstopbB%s -b bB -t 30)
24+
25+
# If valgrind_enable is 'yes' the frr daemons will be started via valgrind.
26+
# The use case for doing so is tracking down memory leaks, etc in frr.
27+
valgrind_enable=no
28+
valgrind=/usr/bin/valgrind

dockers/docker-fpm-frr/vtysh.conf

Whitespace-only changes.

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ ip route 0.0.0.0/0 {{ MGMT_INTERFACE[(name, prefix)]['gwaddr'] }} 200
4040
{% set lo_ipv6_addrs = [] %}
4141
{% if LOOPBACK_INTERFACE %}
4242
{% for (name, prefix) in LOOPBACK_INTERFACE %}
43-
{% if prefix | ipv6 %}
44-
{% if lo_ipv6_addrs.append(prefix) %}
45-
{% endif %}
46-
{% else %}
47-
{% if lo_ipv4_addrs.append(prefix) %}
43+
{% if name == 'Loopback0' %}
44+
{% if prefix | ipv6 %}
45+
{% if lo_ipv6_addrs.append(prefix) %}
46+
{% endif %}
47+
{% else %}
48+
{% if lo_ipv4_addrs.append(prefix) %}
49+
{% endif %}
4850
{% endif %}
4951
{% endif %}
5052
{% endfor %}

rules/config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ DEFAULT_PASSWORD = YourPaSsWoRd
4545
# SONIC_INSTALL_DEBUG_TOOLS = y
4646

4747
# SONIC_ROUTING_STACK - specify the routing-stack being elected to drive SONiC's control-plane.
48-
# Quagga will be the default routing-stack for all the SONiC platforms. Other supported
49-
# routing-stacks: frr, gobgp.
48+
# Supported routing stacks on SONiC are:
49+
# routing-stacks: quagga, frr.
5050
SONIC_ROUTING_STACK = quagga
5151

5252
# ENABLE_SYNCD_RPC - build docker-syncd with rpc packages for testing purposes.

rules/frr.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# FRRouting (frr) package
22

3-
FRR_VERSION = 3.0
3+
FRR_VERSION = 4.0
44
export FRR_VERSION
55

6-
FRR = frr_$(FRR_VERSION)_amd64.deb
6+
FRR = frr_$(FRR_VERSION)-1~sonic.debian8+1_amd64.deb
77
$(FRR)_DEPENDS += $(LIBSNMP_DEV)
88
$(FRR)_SRC_PATH = $(SRC_PATH)/sonic-frr
99
SONIC_MAKE_DEBS += $(FRR)

sonic-slave/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ RUN apt-get update && apt-get install -y \
6363
libjson0-dev \
6464
libsystemd-dev \
6565
python-ipaddr \
66+
install-info \
6667
# For libnl3 (local) build
6768
cdbs \
6869
# For SAI meta build

src/sonic-frr/Makefile

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,40 @@
22
SHELL = /bin/bash
33
.SHELLFLAGS += -e
44

5-
MAIN_TARGET = frr_$(FRR_VERSION)_amd64.deb
5+
MAIN_TARGET = frr_$(FRR_VERSION)-1~sonic.debian8+1_amd64.deb
66

77
$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% :
8-
# Replacing frr's rules/install files with SONiC's own versions to activate
9-
# specific knobs and adjust install process to address SONiC's needs.
10-
cp sonic_frr.rules frr/debian/rules
11-
cp sonic_frr.install frr/debian/frr.install
128

13-
# Build the package
9+
# Build the package
1410
pushd ./frr
15-
rm -f debian/*.debhelper.log
11+
12+
# clean up the previous build
13+
rm -rf debian
14+
rm frr*.tar.gz
15+
rm frr*.tar.xz
16+
rm frr*.dsc
17+
18+
# make a dist tarball
19+
./bootstrap.sh
20+
./configure
21+
make dist
22+
23+
# Create backports debian sources
24+
cp -a debianpkg debian
25+
make -f debian/rules backports
26+
27+
# new directory to build the package
28+
rm -rf frrpkg
29+
mkdir frrpkg
30+
cd frrpkg
31+
tar xf ../frr_*.orig.tar.gz
32+
cd frr*
33+
tar xf ../../frr_*sonic.debian8*.debian.tar.xz
34+
35+
# build package
1636
dpkg-buildpackage -rfakeroot -b -us -uc
37+
cd ..
38+
mv $* $(DEST)/
39+
1740
popd
1841

19-
mv $* $(DEST)/

src/sonic-frr/frr

Submodule frr updated from 5424c62 to aaf54fd

src/sonic-frr/sonic_frr.install

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)