Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FRR] Switch to dplane_fpm_nl plugin instead of fpm #12852

Merged
merged 19 commits into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions dockers/docker-fpm-frr/docker_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ update_default_gw()
fi
}

write_default_zebra_config()
{
FILE_NAME=${1}

grep -q '^no fpm use-next-hop-groups' $FILE_NAME || {
sed -i '1i no fpm use-next-hop-groups\nfpm address 127.0.0.1' $FILE_NAME
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why adding this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please refer to the comment by @dgsudharsan #12852 (comment).
SONiC supports split mode FRR configuration. That is, user provides own zebra.conf, bgp.conf, etc. in /etc/sonic/frr folder, instead of generated from templates by SONiC.
In case user upgrades from older version to image with these changes he will not have mandatory configuration in his zebra.conf copied from the old image. I added this line to insert this configuration in case user does not have it.

}
}

if [[ ! -z "$NAMESPACE_ID" ]]; then
update_default_gw 4
update_default_gw 6
Expand Down Expand Up @@ -69,9 +78,11 @@ if [ -z "$CONFIG_TYPE" ] || [ "$CONFIG_TYPE" == "separated" ]; then
elif [ "$CONFIG_TYPE" == "split" ]; then
echo "no service integrated-vtysh-config" > /etc/frr/vtysh.conf
rm -f /etc/frr/frr.conf
write_default_zebra_config /etc/frr/zebra.conf
elif [ "$CONFIG_TYPE" == "split-unified" ]; then
echo "service integrated-vtysh-config" > /etc/frr/vtysh.conf
rm -f /etc/frr/bgpd.conf /etc/frr/zebra.conf /etc/frr/staticd.conf
write_default_zebra_config /etc/frr/frr.conf
elif [ "$CONFIG_TYPE" == "unified" ]; then
CFGGEN_PARAMS=" \
-d \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ stderr_logfile=syslog
dependent_startup=true

[program:zebra]
command=/usr/lib/frr/zebra -A 127.0.0.1 -s 90000000 -M fpm -M snmp
command=/usr/lib/frr/zebra -A 127.0.0.1 -s 90000000 -M dplane_fpm_nl -M snmp
priority=4
autostart=false
autorestart=false
Expand Down
7 changes: 7 additions & 0 deletions dockers/docker-fpm-frr/frr/zebra/zebra.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
!
{% endblock banner %}
!
{% block fpm %}
! Uses the old known FPM behavior of including next hop information in the route (e.g. RTM_NEWROUTE) messages
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the behavior if the user has split mode and performs an upgrade?

Copy link
Collaborator Author

@stepanblyschak stepanblyschak Jan 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fpmsyncd will get RTN_NEWROUTE without next hops and routes won't be programmed. User needs to update his own configs

no fpm use-next-hop-groups
!
fpm address 127.0.0.1
{% endblock fpm %}
!
{% include "common/daemons.common.conf.j2" %}
!
{% include "zebra.interfaces.conf.j2" %}
Expand Down
2 changes: 2 additions & 0 deletions platform/vs/docker-sonic-vs/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ RUN touch /etc/quagga/zebra.conf
# disable integrated vtysh config
RUN rm /etc/frr/frr.conf

COPY ["frr/zebra.conf", "/etc/frr/"]

# Create /var/warmboot/teamd folder for teammgrd
RUN mkdir -p /var/warmboot/teamd

Expand Down
4 changes: 4 additions & 0 deletions platform/vs/docker-sonic-vs/frr/zebra.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
no fpm use-next-hop-groups

fpm address 127.0.0.1

2 changes: 1 addition & 1 deletion platform/vs/docker-sonic-vs/supervisord.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ environment=ASAN_OPTIONS="log_path=/var/log/asan/teammgrd-asan.log{{ asan_extra_
{% endif %}

[program:zebra]
command=/usr/lib/frr/zebra -A 127.0.0.1 -s 90000000 -M fpm
command=/usr/lib/frr/zebra -A 127.0.0.1 -s 90000000 -M dplane_fpm_nl
priority=13
autostart=false
autorestart=false
Expand Down
6 changes: 6 additions & 0 deletions src/sonic-bgpcfgd/tests/data/sonic-cfggen/zebra/zebra.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
! generated by templates/zebra/zebra.conf.j2 using config DB data
! file: zebra.conf
!
!
! Uses the old known FPM behavior of including next hop information in the route (e.g. RTM_NEWROUTE) messages
no fpm use-next-hop-groups
!
fpm address 127.0.0.1
!
! template: common/daemons.common.conf.j2
!
hostname new_hostname
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
! file: zebra.conf
!
!
! Uses the old known FPM behavior of including next hop information in the route (e.g. RTM_NEWROUTE) messages
no fpm use-next-hop-groups
!
fpm address 127.0.0.1
!
! template: common/daemons.common.conf.j2
!
hostname SpineFront01
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
! file: zebra.conf
!
!
! Uses the old known FPM behavior of including next hop information in the route (e.g. RTM_NEWROUTE) messages
no fpm use-next-hop-groups
!
fpm address 127.0.0.1
!
! template: common/daemons.common.conf.j2
!
hostname SpineFront01
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
! file: zebra.conf
!
!
! Uses the old known FPM behavior of including next hop information in the route (e.g. RTM_NEWROUTE) messages
no fpm use-next-hop-groups
!
fpm address 127.0.0.1
!
! template: common/daemons.common.conf.j2
!
hostname switch-t0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
! file: zebra.conf
!
!
! Uses the old known FPM behavior of including next hop information in the route (e.g. RTM_NEWROUTE) messages
no fpm use-next-hop-groups
!
fpm address 127.0.0.1
!
! template: common/daemons.common.conf.j2
!
hostname SpineFront01
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
! file: zebra.conf
!
!
! Uses the old known FPM behavior of including next hop information in the route (e.g. RTM_NEWROUTE) messages
no fpm use-next-hop-groups
!
fpm address 127.0.0.1
!
! template: common/daemons.common.conf.j2
!
hostname SpineFront01
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
! file: zebra.conf
!
!
! Uses the old known FPM behavior of including next hop information in the route (e.g. RTM_NEWROUTE) messages
no fpm use-next-hop-groups
!
fpm address 127.0.0.1
!
! template: common/daemons.common.conf.j2
!
hostname switch-t0
Expand Down
61 changes: 42 additions & 19 deletions src/sonic-frr/patch/0003-Use-vrf_id-for-vrf-not-tabled_id.patch
Original file line number Diff line number Diff line change
@@ -1,25 +1,48 @@
From 39bb40dc4bad4462e4ae9c98580d75fa2c92e032 Mon Sep 17 00:00:00 2001
From: Pavel Shirshov <pavelsh@microsoft.com>
Date: Mon, 16 Nov 2020 18:29:46 -0800
Subject: [PATCH 3/8] Use vrf_id for vrf, not tabled_id
From 5dba497fb3810f9e5cb4b23bec151ec44d8dcec4 Mon Sep 17 00:00:00 2001
From: Stepan Blyschak <stepanb@nvidia.com>
Date: Mon, 16 Jan 2023 11:24:16 +0000
Subject: [PATCH] Use vrf_id for vrf, not tabled_id

Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
---
zebra/zebra_fpm_netlink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
zebra/rt_netlink.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/zebra/zebra_fpm_netlink.c b/zebra/zebra_fpm_netlink.c
index ec22c5dd4..aad0156b3 100644
--- a/zebra/zebra_fpm_netlink.c
+++ b/zebra/zebra_fpm_netlink.c
@@ -287,7 +287,7 @@ static int netlink_route_info_fill(struct netlink_route_info *ri, int cmd,
ri->nlmsg_pid = zvrf->zns->netlink_dplane_out.snl.nl_pid;
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index 24c01b7f5..d4567990e 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -1969,12 +1969,24 @@ ssize_t netlink_route_multipath_msg_encode(int cmd,
#endif
/* Table corresponding to this route. */
table_id = dplane_ctx_get_table(ctx);
- if (table_id < 256)
- req->r.rtm_table = table_id;
- else {
- req->r.rtm_table = RT_TABLE_UNSPEC;
- if (!nl_attr_put32(&req->n, datalen, RTA_TABLE, table_id))
- return 0;
+ if (!fpm) {
+ if (table_id < 256)
+ req->r.rtm_table = table_id;
+ else {
+ req->r.rtm_table = RT_TABLE_UNSPEC;
+ if (!nl_attr_put32(&req->n, datalen, RTA_TABLE, table_id))
+ return 0;
+ }
+ } else {
+ /* Put vrf if_index instead of table id */
+ vrf_id_t vrf = dplane_ctx_get_vrf(ctx);
+ if (vrf < 256)
+ req->r.rtm_table = vrf;
+ else {
+ req->r.rtm_table = RT_TABLE_UNSPEC;
+ if (!nl_attr_put32(&req->n, datalen, RTA_TABLE, vrf))
+ return 0;
+ }
}

ri->nlmsg_type = cmd;
- ri->rtm_table = table_info->table_id;
+ ri->rtm_table = zvrf_id(rib_dest_vrf(dest));
ri->rtm_protocol = RTPROT_UNSPEC;

/*
if (IS_ZEBRA_DEBUG_KERNEL)
--
2.12.2
2.30.2

Loading