From 32fc26cbe0f76bdea0e1305322bde824ced36818 Mon Sep 17 00:00:00 2001 From: Tore Anderson Date: Thu, 9 Mar 2023 12:42:59 +0100 Subject: [PATCH] frrcfgd: fix incorrect rendering of route-map references A reference to a route-maps under a BGP address family is a single-value string, not a multi-value list. Looping over it yields incorrect configuration being rendered, for example: ``` neighbor peergroup route-map R in neighbor peergroup route-map M in neighbor peergroup route-map A in neighbor peergroup route-map P in ``` These overwrite each other as the configuration is loaded, making the effective FRR contain only the last one listed. This route-map (in this case called `P`) does most likely not exist, leading to an effective configuration which rejects all routes. The correct and expected rendered configuration would be: ``` neighbor peergroup route-map RMAP in ``` Signed-off-by: Tore Anderson --- .../templates/bgpd/bgpd.conf.db.addr_family.j2 | 4 +--- .../templates/bgpd/bgpd.conf.db.nbr_af.j2 | 8 ++------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.addr_family.j2 b/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.addr_family.j2 index 9bf005518cc3..4caa1d7dcd19 100644 --- a/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.addr_family.j2 +++ b/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.addr_family.j2 @@ -65,9 +65,7 @@ {% for rr_key, rr_val in ROUTE_REDISTRIBUTE.items() %} {% if vrf == rr_key[0] and af_str == rr_key[3] %} {% if 'route_map' in rr_val %} -{% for rmap in rr_val['route_map'] %} - redistribute {{rr_key[1]}} route-map {{rmap}} -{% endfor %} + redistribute {{rr_key[1]}} route-map {{rr_val['route_map']}} {% else %} redistribute {{rr_key[1]}} {% endif %} diff --git a/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.nbr_af.j2 b/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.nbr_af.j2 index 8afb64e991cc..f936bfb0132a 100644 --- a/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.nbr_af.j2 +++ b/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.nbr_af.j2 @@ -112,16 +112,12 @@ {% endif %} {# ------- route-map in --------------------------- #} {% if 'route_map_in' in n_af_val %} -{% for map in n_af_val['route_map_in'] %} - neighbor {{nbr_name}} route-map {{map}} in -{% endfor %} + neighbor {{nbr_name}} route-map {{n_af_val['route_map_in']}} in {% endif %} {# ------- route-map in end --------------------------- #} {# ------- route-map out --------------------------- #} {% if 'route_map_out' in n_af_val %} -{% for map in n_af_val['route_map_out'] %} - neighbor {{nbr_name}} route-map {{map}} out -{% endfor %} + neighbor {{nbr_name}} route-map {{n_af_val['route_map_out']}} out {% endif %} {# ------- route-map out end --------------------------- #} {% if 'unsuppress_map_name' in n_af_val %}