diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-05 09:56:23 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-05 09:56:23 +0000 |
commit | c15d6efd40655f717841d00839a43df1ead5cb26 (patch) | |
tree | 35d579f9a19170e2b39085669ca92533c2d161b4 /bgpd/rfapi | |
parent | Adding upstream version 10.0.1. (diff) | |
download | frr-c15d6efd40655f717841d00839a43df1ead5cb26.tar.xz frr-c15d6efd40655f717841d00839a43df1ead5cb26.zip |
Adding upstream version 10.1.upstream/10.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'bgpd/rfapi')
-rw-r--r-- | bgpd/rfapi/rfapi.c | 14 | ||||
-rw-r--r-- | bgpd/rfapi/rfapi_import.c | 20 | ||||
-rw-r--r-- | bgpd/rfapi/rfapi_rib.c | 5 | ||||
-rw-r--r-- | bgpd/rfapi/rfapi_vty.c | 14 | ||||
-rw-r--r-- | bgpd/rfapi/vnc_import_bgp.c | 127 |
5 files changed, 117 insertions, 63 deletions
diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c index 382af05..23e3eb4 100644 --- a/bgpd/rfapi/rfapi.c +++ b/bgpd/rfapi/rfapi.c @@ -463,7 +463,7 @@ void del_vnc_route(struct rfapi_descriptor *rfd, bgp_aggregate_decrement(bgp, p, bpi, afi, safi); bgp_path_info_delete(bn, bpi); - bgp_process(bgp, bn, afi, safi); + bgp_process(bgp, bn, bpi, afi, safi); } else { vnc_zlog_debug_verbose( "%s: Couldn't find route (safi=%d) at prefix %pFX", @@ -549,6 +549,7 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */ int flags) { afi_t afi; /* of the VN address */ + struct bgp_labels bgp_labels = {}; struct bgp_path_info *new; struct bgp_path_info *bpi; struct bgp_dest *bn; @@ -592,7 +593,7 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */ } } - if (label) + if (label && *label != MPLS_INVALID_LABEL) label_val = *label; else label_val = MPLS_LABEL_IMPLICIT_NULL; @@ -1001,7 +1002,7 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */ /* Process change. */ bgp_aggregate_increment(bgp, p, bpi, afi, safi); - bgp_process(bgp, bn, afi, safi); + bgp_process(bgp, bn, bpi, afi, safi); bgp_dest_unlock_node(bn); vnc_zlog_debug_any( @@ -1020,7 +1021,10 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */ new->extra->vnc = XCALLOC(MTYPE_BGP_ROUTE_EXTRA_VNC, sizeof(struct bgp_path_info_extra_vnc)); new->extra->vnc->vnc.export.rfapi_handle = (void *)rfd; - encode_label(label_val, &new->extra->label[0]); + + encode_label(label_val, &bgp_labels.label[0]); + bgp_labels.num_labels = 1; + new->extra->labels = bgp_labels_intern(&bgp_labels); /* debug */ @@ -1046,7 +1050,7 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */ } bgp_dest_unlock_node(bn); - bgp_process(bgp, bn, afi, safi); + bgp_process(bgp, bn, new, afi, safi); vnc_zlog_debug_any( "%s: Added route (safi=%s) at prefix %s (bn=%p, prd=%pRDP)", diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index 168b8e4..2afcb2f 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -442,6 +442,7 @@ static struct bgp_path_info *rfapiBgpInfoCreate(struct attr *attr, uint32_t *label) { struct bgp_path_info *new; + struct bgp_labels bgp_labels = {}; new = info_make(type, sub_type, 0, peer, attr, NULL); @@ -454,8 +455,11 @@ static struct bgp_path_info *rfapiBgpInfoCreate(struct attr *attr, new->extra->vnc->vnc.import.rd = *prd; new->extra->vnc->vnc.import.create_time = monotime(NULL); } - if (label) - encode_label(*label, &new->extra->label[0]); + if (label && *label != MPLS_INVALID_LABEL) { + encode_label(*label, &bgp_labels.label[0]); + bgp_labels.num_labels = 1; + new->extra->labels = bgp_labels_intern(&bgp_labels); + } peer_lock(peer); @@ -1267,7 +1271,10 @@ rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix, bpi->extra->vnc->vnc.import.rd.val[1]; /* label comes from MP_REACH_NLRI label */ - vo->v.l2addr.label = decode_label(&bpi->extra->label[0]); + vo->v.l2addr.label = + bgp_path_info_num_labels(bpi) + ? decode_label(&bpi->extra->labels->label[0]) + : MPLS_INVALID_LABEL; new->vn_options = vo; @@ -4154,15 +4161,16 @@ static void rfapiBgpTableFilteredImport(struct bgp *bgp, for (bpi = bgp_dest_get_bgp_path_info(dest2); bpi; bpi = bpi->next) { - uint32_t label = 0; + uint32_t label = MPLS_INVALID_LABEL; if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) continue; - if (bpi->extra) + if (bgp_path_info_num_labels(bpi)) label = decode_label( - &bpi->extra->label[0]); + &bpi->extra->labels + ->label[0]); (*rfapiBgpInfoFilteredImportFunction( safi))( it, /* which import table */ diff --git a/bgpd/rfapi/rfapi_rib.c b/bgpd/rfapi/rfapi_rib.c index 316904e..a0bdf49 100644 --- a/bgpd/rfapi/rfapi_rib.c +++ b/bgpd/rfapi/rfapi_rib.c @@ -691,7 +691,10 @@ static void rfapiRibBi2Ri(struct bgp_path_info *bpi, struct rfapi_info *ri, bpi->extra->vnc->vnc.import.rd.val[1]; /* label comes from MP_REACH_NLRI label */ - vo->v.l2addr.label = decode_label(&bpi->extra->label[0]); + vo->v.l2addr.label = + bgp_path_info_num_labels(bpi) + ? decode_label(&bpi->extra->labels->label[0]) + : MPLS_INVALID_LABEL; rfapi_vn_options_free( ri->vn_options); /* maybe free old version */ diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c index 5da99db..9bfb6c4 100644 --- a/bgpd/rfapi/rfapi_vty.c +++ b/bgpd/rfapi/rfapi_vty.c @@ -413,12 +413,12 @@ void rfapi_vty_out_vncinfo(struct vty *vty, const struct prefix *p, XFREE(MTYPE_ECOMMUNITY_STR, s); } - if (bpi->extra != NULL) { - if (bpi->extra->label[0] == BGP_PREVENT_VRF_2_VRF_LEAK) + if (bgp_path_info_num_labels(bpi)) { + if (bpi->extra->labels->label[0] == BGP_PREVENT_VRF_2_VRF_LEAK) vty_out(vty, " label=VRF2VRF"); else vty_out(vty, " label=%u", - decode_label(&bpi->extra->label[0])); + decode_label(&bpi->extra->labels->label[0])); } if (bpi->attr->srv6_l3vpn || bpi->attr->srv6_vpn) { @@ -1052,8 +1052,8 @@ static int rfapiPrintRemoteRegBi(struct bgp *bgp, void *stream, snprintf(buf_un, sizeof(buf_un), "%s", inet_ntop(pfx_vn.family, &pfx_vn.u.prefix, buf_ntop, sizeof(buf_ntop))); - if (bpi->extra) { - uint32_t l = decode_label(&bpi->extra->label[0]); + if (bgp_path_info_num_labels(bpi)) { + uint32_t l = decode_label(&bpi->extra->labels->label[0]); snprintf(buf_vn, sizeof(buf_vn), "Label: %d", l); } else /* should never happen */ { @@ -1161,8 +1161,8 @@ static int rfapiPrintRemoteRegBi(struct bgp *bgp, void *stream, } } } - if (tun_type != BGP_ENCAP_TYPE_MPLS && bpi->extra) { - uint32_t l = decode_label(&bpi->extra->label[0]); + if (tun_type != BGP_ENCAP_TYPE_MPLS && bgp_path_info_num_labels(bpi)) { + uint32_t l = decode_label(&bpi->extra->labels->label[0]); if (!MPLS_LABEL_IS_NULL(l)) { fp(out, " Label: %d", l); diff --git a/bgpd/rfapi/vnc_import_bgp.c b/bgpd/rfapi/vnc_import_bgp.c index c067b7a..2bb7c1b 100644 --- a/bgpd/rfapi/vnc_import_bgp.c +++ b/bgpd/rfapi/vnc_import_bgp.c @@ -414,7 +414,7 @@ static void vnc_import_bgp_add_route_mode_resolve_nve_one_bi( uint32_t lifetime; uint32_t *plifetime; struct bgp_attr_encap_subtlv *encaptlvs; - uint32_t label = 0; + uint32_t label; struct rfapi_un_option optary[3]; struct rfapi_un_option *opt = NULL; @@ -470,16 +470,19 @@ static void vnc_import_bgp_add_route_mode_resolve_nve_one_bi( if (bgp_attr_get_ecommunity(bpi->attr)) ecommunity_merge(new_ecom, bgp_attr_get_ecommunity(bpi->attr)); - if (bpi->extra) - label = decode_label(&bpi->extra->label[0]); + if (bgp_path_info_num_labels(bpi)) + label = decode_label(&bpi->extra->labels->label[0]); + else + label = MPLS_INVALID_LABEL; add_vnc_route(&vncHDResolveNve, bgp, SAFI_MPLS_VPN, - prefix, /* unicast route prefix */ + prefix, /* unicast route prefix */ prd, &nexthop_h, /* new nexthop */ local_pref, plifetime, (struct bgp_tea_options *)encaptlvs, /* RFP options */ opt, NULL, new_ecom, med, /* NULL => don't set med */ - (label ? &label : NULL), /* NULL= default */ + ((label != MPLS_INVALID_LABEL) ? &label + : NULL), /* NULL= default */ ZEBRA_ROUTE_BGP_DIRECT, BGP_ROUTE_REDISTRIBUTE, RFAPI_AHR_RFPOPT_IS_VNCTLV); /* flags */ @@ -1678,7 +1681,7 @@ static void vnc_import_bgp_exterior_add_route_it( bpi_interior = bpi_interior->next) { struct prefix_rd *prd; struct attr new_attr; - uint32_t label = 0; + uint32_t label; if (!is_usable_interior_route(bpi_interior)) continue; @@ -1695,14 +1698,19 @@ static void vnc_import_bgp_exterior_add_route_it( */ have_usable_route = 1; - if (bpi_interior->extra) { + if (bpi_interior->extra) prd = &bpi_interior->extra->vnc->vnc .import.rd; - label = decode_label( - &bpi_interior->extra->label[0]); - } else + else prd = NULL; + if (bgp_path_info_num_labels(bpi_interior)) + label = decode_label( + &bpi_interior->extra->labels + ->label[0]); + else + label = MPLS_INVALID_LABEL; + /* use local_pref from unicast route */ memset(&new_attr, 0, sizeof(new_attr)); new_attr = *bpi_interior->attr; @@ -1851,7 +1859,7 @@ void vnc_import_bgp_exterior_del_route( for (bpi_interior = rn->info; bpi_interior; bpi_interior = bpi_interior->next) { struct prefix_rd *prd; - uint32_t label = 0; + uint32_t label; if (!is_usable_interior_route(bpi_interior)) continue; @@ -1864,14 +1872,19 @@ void vnc_import_bgp_exterior_del_route( */ have_usable_route = 1; - if (bpi_interior->extra) { + if (bpi_interior->extra) prd = &bpi_interior->extra->vnc->vnc .import.rd; - label = decode_label( - &bpi_interior->extra->label[0]); - } else + else prd = NULL; + if (bgp_path_info_num_labels(bpi_interior)) + label = decode_label( + &bpi_interior->extra->labels + ->label[0]); + else + label = MPLS_INVALID_LABEL; + rfapiBgpInfoFilteredImportVPN( it, FIF_ACTION_KILL, bpi_interior->peer, NULL, /* rfd */ @@ -2007,18 +2020,22 @@ void vnc_import_bgp_exterior_add_route_interior( struct prefix_rd *prd; struct attr new_attr; - uint32_t label = 0; + uint32_t label; assert(bpi_exterior); assert(pfx_exterior); - if (bpi_interior->extra) { + if (bpi_interior->extra) prd = &bpi_interior->extra->vnc->vnc.import.rd; - label = decode_label( - &bpi_interior->extra->label[0]); - } else + else prd = NULL; + if (bgp_path_info_num_labels(bpi_interior)) + label = decode_label( + &bpi_interior->extra->labels->label[0]); + else + label = MPLS_INVALID_LABEL; + /* use local_pref from unicast route */ memset(&new_attr, 0, sizeof(struct attr)); new_attr = *bpi_interior->attr; @@ -2097,7 +2114,7 @@ void vnc_import_bgp_exterior_add_route_interior( struct bgp_path_info *bpi; struct prefix_rd *prd; struct attr new_attr; - uint32_t label = 0; + uint32_t label; /* do pull-down */ @@ -2124,15 +2141,19 @@ void vnc_import_bgp_exterior_add_route_interior( * parent routes. */ for (bpi = par->info; bpi; bpi = bpi->next) { - - if (bpi->extra) { + if (bpi->extra) prd = &bpi->extra->vnc->vnc .import.rd; - label = decode_label( - &bpi->extra->label[0]); - } else + else prd = NULL; + if (bgp_path_info_num_labels(bpi)) + label = decode_label( + &bpi->extra->labels + ->label[0]); + else + label = MPLS_INVALID_LABEL; + rfapiBgpInfoFilteredImportVPN( it, FIF_ACTION_KILL, bpi->peer, NULL, /* rfd */ @@ -2147,14 +2168,19 @@ void vnc_import_bgp_exterior_add_route_interior( * Add constructed exterior routes based on * the new interior route at longer prefix. */ - if (bpi_interior->extra) { + if (bpi_interior->extra) prd = &bpi_interior->extra->vnc->vnc .import.rd; - label = decode_label( - &bpi_interior->extra->label[0]); - } else + else prd = NULL; + if (bgp_path_info_num_labels(bpi_interior)) + label = decode_label( + &bpi_interior->extra->labels + ->label[0]); + else + label = MPLS_INVALID_LABEL; + /* use local_pref from unicast route */ memset(&new_attr, 0, sizeof(struct attr)); new_attr = *bpi_interior->attr; @@ -2237,7 +2263,7 @@ void vnc_import_bgp_exterior_add_route_interior( struct prefix_rd *prd; struct attr new_attr; - uint32_t label = 0; + uint32_t label; /* do pull-down */ @@ -2266,13 +2292,17 @@ void vnc_import_bgp_exterior_add_route_interior( * Add constructed exterior routes based on the * new interior route at the longer prefix. */ - if (bpi_interior->extra) { + if (bpi_interior->extra) prd = &bpi_interior->extra->vnc->vnc.import.rd; - label = decode_label( - &bpi_interior->extra->label[0]); - } else + else prd = NULL; + if (bgp_path_info_num_labels(bpi_interior)) + label = decode_label( + &bpi_interior->extra->labels->label[0]); + else + label = MPLS_INVALID_LABEL; + /* use local_pref from unicast route */ memset(&new_attr, 0, sizeof(struct attr)); new_attr = *bpi_interior->attr; @@ -2372,14 +2402,19 @@ void vnc_import_bgp_exterior_del_route_interior( &cursor)) { struct prefix_rd *prd; - uint32_t label = 0; + uint32_t label; - if (bpi_interior->extra) { + if (bpi_interior->extra) prd = &bpi_interior->extra->vnc->vnc.import.rd; - label = decode_label(&bpi_interior->extra->label[0]); - } else + else prd = NULL; + if (bgp_path_info_num_labels(bpi_interior)) + label = decode_label( + &bpi_interior->extra->labels->label[0]); + else + label = MPLS_INVALID_LABEL; + rfapiBgpInfoFilteredImportVPN( it, FIF_ACTION_KILL, bpi_interior->peer, NULL, /* rfd */ pfx_exterior, NULL, afi, prd, bpi_interior->attr, @@ -2446,18 +2481,22 @@ void vnc_import_bgp_exterior_del_route_interior( struct prefix_rd *prd; struct attr new_attr; - uint32_t label = 0; + uint32_t label; if (bpi->type == ZEBRA_ROUTE_BGP_DIRECT_EXT) continue; - if (bpi->extra) { + if (bpi->extra) prd = &bpi->extra->vnc->vnc.import.rd; - label = decode_label( - &bpi->extra->label[0]); - } else + else prd = NULL; + if (bgp_path_info_num_labels(bpi)) + label = decode_label( + &bpi->extra->labels->label[0]); + else + label = MPLS_INVALID_LABEL; + /* use local_pref from unicast route */ memset(&new_attr, 0, sizeof(new_attr)); new_attr = *bpi->attr; |