From b380f68a7ae1ba89c4289c86ccc0ba0cf8aa2f87 Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Sat, 13 May 2017 16:37:13 -0400 Subject: [PATCH 1/5] bgpd: add epvn as labeled safi type (ISSUE #471) Signed-off-by: Lou Berger --- bgpd/bgp_label.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_label.h b/bgpd/bgp_label.h index 49a7b945ab..b45e791ce2 100644 --- a/bgpd/bgp_label.h +++ b/bgpd/bgp_label.h @@ -42,7 +42,8 @@ extern int bgp_nlri_parse_label (struct peer *peer, struct attr *attr, static inline int bgp_labeled_safi (safi_t safi) { - if ((safi == SAFI_LABELED_UNICAST) || (safi == SAFI_MPLS_VPN)) + if ((safi == SAFI_LABELED_UNICAST) || (safi == SAFI_MPLS_VPN) || + (safi == SAFI_EVPN)) return 1; return 0; } From 57907d6fe9f91131b7d5ed750d283399f1ca3a42 Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Sat, 13 May 2017 16:38:35 -0400 Subject: [PATCH 2/5] bgpd: fix VPN SAFI label distribution (Issue #473) Signed-off-by: Lou Berger --- bgpd/bgp_route.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 24a68778dc..2142719f49 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -1270,7 +1270,7 @@ subgroup_announce_check (struct bgp_node *rn, struct bgp_info *ri, } /* If it's labeled safi, make sure the route has a valid label. */ - if (bgp_labeled_safi(safi)) + if (safi == SAFI_LABELED_UNICAST) { u_char *tag = bgp_adv_label(rn, ri, peer, afi, safi); if (!bgp_is_valid_label(tag)) @@ -1942,7 +1942,7 @@ bgp_process_main (struct work_queue *wq, void *data) * to do this upon changes to best path except of the label index changes. */ bgp_table_lock (bgp_node_table (rn)); - if (bgp_labeled_safi (safi)) + if (safi == SAFI_LABELED_UNICAST) { if (new_select) { @@ -2848,7 +2848,7 @@ bgp_update (struct peer *peer, struct prefix *p, u_int32_t addpath_id, new = info_make(type, sub_type, 0, peer, attr_new, rn); /* Update MPLS tag. */ - if (bgp_labeled_safi(safi) || safi == SAFI_EVPN) + if (bgp_labeled_safi(safi)) memcpy ((bgp_info_extra_get (new))->tag, tag, 3); /* Update Overlay Index */ @@ -4462,6 +4462,8 @@ bgp_static_redo_import_check (struct bgp *bgp) afi_t afi; safi_t safi; struct bgp_node *rn; + struct bgp_node *rm; + struct bgp_table *table; struct bgp_static *bgp_static; /* Use this flag to force reprocessing of the route */ @@ -4471,8 +4473,21 @@ bgp_static_redo_import_check (struct bgp *bgp) for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) if (rn->info != NULL) { - bgp_static = rn->info; - bgp_static_update (bgp, &rn->p, bgp_static, afi, safi); + if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP) || (safi == SAFI_EVPN)) + { + table = rn->info; + + for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) + { + bgp_static = rm->info; + bgp_static_update_safi (bgp, &rm->p, bgp_static, afi, safi); + } + } + else + { + bgp_static = rn->info; + bgp_static_update (bgp, &rn->p, bgp_static, afi, safi); + } } bgp_flag_unset(bgp, BGP_FLAG_FORCE_STATIC_PROCESS); } From e5efc58be957eb3c52c03e3b9d80a2a7e8a869ad Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Sat, 13 May 2017 17:46:05 -0400 Subject: [PATCH 3/5] bgpd: fix rfapi label origination (Issue #473) Signed-off-by: Lou Berger --- bgpd/rfapi/rfapi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c index 99d26cf13c..fee6d745ee 100644 --- a/bgpd/rfapi/rfapi.c +++ b/bgpd/rfapi/rfapi.c @@ -1198,6 +1198,7 @@ add_vnc_route ( bgp, prd, table, p, new); } bgp_unlock_node (prn); + encode_label (label_val, bn->local_label); } bgp_unlock_node (bn); From 20aeb9709ee03c6331265c6e0bc287f0c3628e56 Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Sun, 14 May 2017 11:10:42 -0400 Subject: [PATCH 4/5] bgpd: fix v6 encap safi config - more labeled unicast breakage (Issue #473) Signed-off-by: Lou Berger --- bgpd/bgp_vty.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 4d983c3876..f2fa8a0643 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -60,16 +60,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA static struct peer_group * listen_range_exists (struct bgp *bgp, struct prefix *range, int exact); -#if 0 -#define INSTALL_CMD_ON_AF_NODES(cmd) \ - install_element(BGP_IPV4_NODE, cmd); \ - install_element(BGP_IPV4M_NODE, cmd); \ - install_element(BGP_IPV4L_NODE, cmd); \ - install_element(BGP_IPV6_NODE, cmd); \ - install_element(BGP_IPV6M_NODE, cmd); \ - install_element(BGP_IPV6L_NODE, cmd); \ - install_element(BGP_VPNV4_NODE, cmd); -#endif + static enum node_type bgp_node_type (afi_t afi, safi_t safi) { @@ -111,7 +102,7 @@ bgp_node_type (afi_t afi, safi_t safi) return BGP_VPNV6_NODE; break; case SAFI_ENCAP: - return BGP_ENCAP_NODE; + return BGP_ENCAPV6_NODE; break; } break; From 0918e873f241d5df4fa38da4a9e7bc414e805559 Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Sun, 14 May 2017 20:24:25 -0400 Subject: [PATCH 5/5] bgpd: fix table leak introduced in labeled unicast (Issue #473) Fix tested for vpn and encap ribs/safi. Labeled unicast may still leak as not tested. Signed-off-by: Lou Berger --- bgpd/bgp_route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 2142719f49..23fc4f8c36 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -1941,9 +1941,9 @@ bgp_process_main (struct work_queue *wq, void *data) * Right now, since we only deal with per-prefix labels, it is not necessary * to do this upon changes to best path except of the label index changes. */ - bgp_table_lock (bgp_node_table (rn)); if (safi == SAFI_LABELED_UNICAST) { + bgp_table_lock (bgp_node_table (rn)); if (new_select) { if (!old_select ||