if (!dest || !pi || !to)
return MPLS_INVALID_LABEL;
- remote_label = pi->extra ? pi->extra->label[0] : MPLS_INVALID_LABEL;
+ remote_label = (pi->extra && pi->extra->num_labels)
+ ? pi->extra->label[0]
+ : MPLS_INVALID_LABEL;
from = pi->peer;
reflect =
((from->sort == BGP_PEER_IBGP) && (to->sort == BGP_PEER_IBGP));
/* prefix_sid attribute */
return false;
- if (!pi->extra || !bgp_is_valid_label(&pi->extra->label[0]))
+ if (!pi->extra || !pi->extra->num_labels ||
+ !bgp_is_valid_label(&pi->extra->label[0]))
/* invalid MPLS label */
return false;
return true;
{
struct bgp_mplsvpn_nh_label_bind_cache *bmnc;
struct bgp_mplsvpn_nh_label_bind_cache_head *tree;
+ mpls_label_t label;
+
+ label = pi->extra->num_labels ? decode_label(&pi->extra->label[0])
+ : MPLS_INVALID_LABEL;
tree = &bgp->mplsvpn_nh_label_bind;
- bmnc = bgp_mplsvpn_nh_label_bind_find(
- tree, &pi->nexthop->prefix, decode_label(&pi->extra->label[0]));
+ bmnc = bgp_mplsvpn_nh_label_bind_find(tree, &pi->nexthop->prefix, label);
if (!bmnc) {
- bmnc = bgp_mplsvpn_nh_label_bind_new(
- tree, &pi->nexthop->prefix,
- decode_label(&pi->extra->label[0]));
+ bmnc = bgp_mplsvpn_nh_label_bind_new(tree, &pi->nexthop->prefix,
+ label);
bmnc->bgp_vpn = bgp;
bmnc->allocation_in_progress = true;
bgp_lp_get(LP_TYPE_BGP_L3VPN_BIND, bmnc,
/* If one path has a label but the other does not, do not treat
* them as equals for multipath
*/
- int newl, existl;
-
- newl = existl = 0;
-
- if (new->extra)
- newl = new->extra->num_labels;
- if (exist->extra)
- existl = exist->extra->num_labels;
- if (((new->extra &&bgp_is_valid_label(&new->extra->label[0])) !=
- (exist->extra &&
- bgp_is_valid_label(&exist->extra->label[0]))) ||
- (newl != existl)) {
+ bool new_label_valid, exist_label_valid;
+
+ new_label_valid = new->extra && new->extra->num_labels &&
+ bgp_is_valid_label(&new->extra->label[0]);
+ exist_label_valid = exist->extra && exist->extra->num_labels &&
+ bgp_is_valid_label(&exist->extra->label[0]);
+
+ if (new_label_valid != exist_label_valid) {
if (debug)
zlog_debug(
"%s: %s and %s cannot be multipath, one has a label while the other does not",
pfx_buf, new_buf, exist_buf);
} else if (CHECK_FLAG(bgp->flags,
BGP_FLAG_ASPATH_MULTIPATH_RELAX)) {
-
/*
* For the two paths, all comparison steps till IGP
* metric
|| new_select->sub_type == BGP_ROUTE_AGGREGATE
|| new_select->sub_type == BGP_ROUTE_REDISTRIBUTE)
goto need_null_label;
- else if (new_select->extra &&
+ else if (new_select->extra && new_select->extra->num_labels &&
bgp_is_valid_label(&new_select->extra->label[0]))
return false;
need_null_label:
route_map_result_t ret;
#ifdef ENABLE_BGP_VNC
int vnc_implicit_withdraw = 0;
- mpls_label_t label = 0;
+ mpls_label_t label = MPLS_INVALID_LABEL;
#endif
uint32_t num_labels = 0;
struct bgp *bgp_nexthop = bgp;
bgp, p, pi);
}
} else {
- if (pi->extra)
+ if (pi->extra && pi->extra->num_labels)
label = decode_label(
&pi->extra->label[0]);
}
}
}
- if (bgp_is_valid_label(&path->extra->label[0])) {
+ if (path->extra->num_labels &&
+ bgp_is_valid_label(&path->extra->label[0])) {
label = decode_label(&path->extra->label[0]);
if (json) {
json_object_int_add(json_out, "notag", label);
api_nh->srte_color = bgp_attr_get_color(info->attr);
if (bgp_debug_zebra(&api->prefix)) {
- if (mpinfo->extra) {
+ if (mpinfo->extra && mpinfo->extra->num_labels) {
zlog_debug("%s: p=%pFX, bgp_is_valid_label: %d",
__func__, p,
bgp_is_valid_label(
&mpinfo->extra->label[0]));
} else {
- zlog_debug(
- "%s: p=%pFX, extra is NULL, no label",
- __func__, p);
+ zlog_debug("%s: p=%pFX, no label", __func__, p);
}
}
}
}
- if (label)
+ if (label && *label != MPLS_INVALID_LABEL)
label_val = *label;
else
label_val = MPLS_LABEL_IMPLICIT_NULL;
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]);
+ new->extra->num_labels = 1;
/* debug */
bgp, prd, table, p, new);
bgp_dest_unlock_node(pdest);
encode_label(label_val, &bn->local_label);
+ new->extra->num_labels = 1;
}
bgp_dest_unlock_node(bn);
new->extra->vnc->vnc.import.rd = *prd;
new->extra->vnc->vnc.import.create_time = monotime(NULL);
}
- if (label)
+ if (label && *label != MPLS_INVALID_LABEL) {
encode_label(*label, &new->extra->label[0]);
+ new->extra->num_labels = 1;
+ } else
+ new->extra->num_labels = 0;
peer_lock(peer);
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 =
+ bpi->extra->num_labels
+ ? decode_label(&bpi->extra->label[0])
+ : MPLS_INVALID_LABEL;
new->vn_options = vo;
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 (bpi->extra && bpi->extra->num_labels)
label = decode_label(
&bpi->extra->label[0]);
(*rfapiBgpInfoFilteredImportFunction(
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 =
+ bpi->extra->num_labels
+ ? decode_label(&bpi->extra->label[0])
+ : MPLS_INVALID_LABEL;
rfapi_vn_options_free(
ri->vn_options); /* maybe free old version */
XFREE(MTYPE_ECOMMUNITY_STR, s);
}
- if (bpi->extra != NULL) {
+ if (bpi->extra != NULL && bpi->extra->num_labels) {
if (bpi->extra->label[0] == BGP_PREVENT_VRF_2_VRF_LEAK)
vty_out(vty, " label=VRF2VRF");
else
snprintf(buf_un, sizeof(buf_un), "%s",
inet_ntop(pfx_vn.family, &pfx_vn.u.prefix, buf_ntop,
sizeof(buf_ntop)));
- if (bpi->extra) {
+ if (bpi->extra && bpi->extra->num_labels) {
uint32_t l = decode_label(&bpi->extra->label[0]);
snprintf(buf_vn, sizeof(buf_vn), "Label: %d", l);
} else /* should never happen */
}
}
}
- if (tun_type != BGP_ENCAP_TYPE_MPLS && bpi->extra) {
+ if (tun_type != BGP_ENCAP_TYPE_MPLS && bpi->extra &&
+ bpi->extra->num_labels) {
uint32_t l = decode_label(&bpi->extra->label[0]);
if (!MPLS_LABEL_IS_NULL(l)) {
uint32_t lifetime;
uint32_t *plifetime;
struct bgp_attr_encap_subtlv *encaptlvs;
- uint32_t label = 0;
+ uint32_t label = MPLS_INVALID_LABEL;
struct rfapi_un_option optary[3];
struct rfapi_un_option *opt = NULL;
if (bgp_attr_get_ecommunity(bpi->attr))
ecommunity_merge(new_ecom, bgp_attr_get_ecommunity(bpi->attr));
- if (bpi->extra)
+ if (bpi->extra && bpi->extra->num_labels)
label = decode_label(&bpi->extra->label[0]);
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 */
bpi_interior = bpi_interior->next) {
struct prefix_rd *prd;
struct attr new_attr;
- uint32_t label = 0;
+ uint32_t label = MPLS_INVALID_LABEL;
if (!is_usable_interior_route(bpi_interior))
continue;
if (bpi_interior->extra) {
prd = &bpi_interior->extra->vnc->vnc
.import.rd;
- label = decode_label(
- &bpi_interior->extra->label[0]);
+ if (bpi_interior->extra->num_labels)
+ label = decode_label(
+ &bpi_interior->extra
+ ->label[0]);
} else
prd = NULL;
for (bpi_interior = rn->info; bpi_interior;
bpi_interior = bpi_interior->next) {
struct prefix_rd *prd;
- uint32_t label = 0;
+ uint32_t label = MPLS_INVALID_LABEL;
if (!is_usable_interior_route(bpi_interior))
continue;
if (bpi_interior->extra) {
prd = &bpi_interior->extra->vnc->vnc
.import.rd;
- label = decode_label(
- &bpi_interior->extra->label[0]);
+ if (bpi_interior->extra->num_labels)
+ label = decode_label(
+ &bpi_interior->extra
+ ->label[0]);
} else
prd = NULL;
struct prefix_rd *prd;
struct attr new_attr;
- uint32_t label = 0;
+ uint32_t label = MPLS_INVALID_LABEL;
assert(bpi_exterior);
assert(pfx_exterior);
if (bpi_interior->extra) {
prd = &bpi_interior->extra->vnc->vnc.import.rd;
- label = decode_label(
- &bpi_interior->extra->label[0]);
+ if (bpi_interior->extra->num_labels)
+ label = decode_label(
+ &bpi_interior->extra->label[0]);
} else
prd = NULL;
struct bgp_path_info *bpi;
struct prefix_rd *prd;
struct attr new_attr;
- uint32_t label = 0;
+ uint32_t label = MPLS_INVALID_LABEL;
/* do pull-down */
if (bpi->extra) {
prd = &bpi->extra->vnc->vnc
.import.rd;
- label = decode_label(
- &bpi->extra->label[0]);
+ if (bpi->extra->num_labels)
+ label = decode_label(
+ &bpi->extra->label
+ [0]);
} else
prd = NULL;
if (bpi_interior->extra) {
prd = &bpi_interior->extra->vnc->vnc
.import.rd;
- label = decode_label(
- &bpi_interior->extra->label[0]);
+ if (bpi_interior->extra->num_labels)
+ label = decode_label(
+ &bpi_interior->extra
+ ->label[0]);
} else
prd = NULL;
struct prefix_rd *prd;
struct attr new_attr;
- uint32_t label = 0;
+ uint32_t label = MPLS_INVALID_LABEL;
/* do pull-down */
*/
if (bpi_interior->extra) {
prd = &bpi_interior->extra->vnc->vnc.import.rd;
- label = decode_label(
- &bpi_interior->extra->label[0]);
+ if (bpi_interior->extra->num_labels)
+ label = decode_label(
+ &bpi_interior->extra->label[0]);
} else
prd = NULL;
&cursor)) {
struct prefix_rd *prd;
- uint32_t label = 0;
+ uint32_t label = MPLS_INVALID_LABEL;
if (bpi_interior->extra) {
prd = &bpi_interior->extra->vnc->vnc.import.rd;
- label = decode_label(&bpi_interior->extra->label[0]);
+ if (bpi_interior->extra->num_labels)
+ label = decode_label(
+ &bpi_interior->extra->label[0]);
} else
prd = NULL;
struct prefix_rd *prd;
struct attr new_attr;
- uint32_t label = 0;
+ uint32_t label = MPLS_INVALID_LABEL;
if (bpi->type == ZEBRA_ROUTE_BGP_DIRECT_EXT)
continue;
if (bpi->extra) {
prd = &bpi->extra->vnc->vnc.import.rd;
- label = decode_label(
- &bpi->extra->label[0]);
+ if (bpi->extra->num_labels)
+ label = decode_label(
+ &bpi->extra->label[0]);
} else
prd = NULL;