if (label == MPLS_INVALID_LABEL)
bgp_unset_valid_label(&dest->local_label);
else {
- label_ntop(label, 1, &dest->local_label);
+ dest->local_label = mpls_lse_encode(label, 0, 0, 1);
bgp_set_valid_label(&dest->local_label);
}
SET_FLAG(dest->flags, BGP_NODE_LABEL_CHANGED);
uint16_t flags = 0;
size_t flags_pos = 0;
mpls_label_t *local_label = &(dest->local_label);
- bool have_label_to_reg =
- bgp_is_valid_label(local_label)
- && label_pton(local_label) != MPLS_LABEL_IMPLICIT_NULL;
+ uint32_t ttl = 0;
+ uint32_t bos = 0;
+ uint32_t exp = 0;
+ mpls_label_t label = MPLS_INVALID_LABEL;
+ bool have_label_to_reg;
+
+ mpls_lse_decode(*local_label, &label, &ttl, &exp, &bos);
+
+ have_label_to_reg = bgp_is_valid_label(local_label) &&
+ label != MPLS_LABEL_IMPLICIT_NULL;
p = bgp_dest_get_prefix(dest);
if (BGP_DEBUG(labelpool, LABELPOOL))
zlog_debug("%s: FEC %sregister %pRN label_index=%u label=%u",
__func__, reg ? "" : "un", bgp_dest_to_rnode(dest),
- label_index, label_pton(local_label));
+ label_index, label);
/* If the route node has a local_label assigned or the
* path node has an MPLS SR label index allowing zebra to
* derive the label, proceed with registration. */
stream_putl(s, label_index);
} else if (have_label_to_reg) {
flags |= ZEBRA_FEC_REGISTER_LABEL;
- stream_putl(s, label_pton(local_label));
+ stream_putl(s, label);
}
SET_FLAG(dest->flags, BGP_NODE_REGISTERED_FOR_LABEL);
} else
*/
if (CHECK_FLAG(dest->flags, BGP_NODE_REGISTERED_FOR_LABEL)) {
UNSET_FLAG(dest->flags, BGP_NODE_LABEL_REQUESTED);
- label_ntop(MPLS_LABEL_IMPLICIT_NULL, 1,
- &dest->local_label);
+ dest->local_label = mpls_lse_encode(
+ MPLS_LABEL_IMPLICIT_NULL, 0, 0, 1);
bgp_set_valid_label(&dest->local_label);
}
}
- label_ntop(new_label, 1, &dest->local_label);
+ dest->local_label = mpls_lse_encode(new_label, 0, 0, 1);
bgp_set_valid_label(&dest->local_label);
/*
{
bool with_label_index = false;
const struct prefix *p;
- bool have_label_to_reg =
- bgp_is_valid_label(&dest->local_label)
- && label_pton(&dest->local_label) != MPLS_LABEL_IMPLICIT_NULL;
+ bool have_label_to_reg;
+ uint32_t ttl = 0;
+ uint32_t bos = 0;
+ uint32_t exp = 0;
+ mpls_label_t label = MPLS_INVALID_LABEL;
+
+ mpls_lse_decode(dest->local_label, &label, &ttl, &exp, &bos);
+
+ have_label_to_reg = bgp_is_valid_label(&dest->local_label) &&
+ label != MPLS_LABEL_IMPLICIT_NULL;
p = bgp_dest_get_prefix(dest);
}
} else {
UNSET_FLAG(dest->flags, BGP_NODE_LABEL_REQUESTED);
- bgp_lp_release(LP_TYPE_BGP_LU, dest,
- label_pton(&dest->local_label));
+ bgp_lp_release(LP_TYPE_BGP_LU, dest, label);
}
bgp_send_fec_register_label_msg(
bgp_reg_dereg_for_label(dest, NULL, false);
}
-/* Label stream to value */
-static inline uint32_t label_pton(const mpls_label_t *label)
-{
- uint8_t *t = (uint8_t *)label;
- return ((((unsigned int)t[0]) << 12) | (((unsigned int)t[1]) << 4)
- | ((unsigned int)((t[2] & 0xF0) >> 4)));
-}
-
-/* Encode label values */
-static inline void label_ntop(uint32_t l, int bos, mpls_label_t *label)
-{
- uint8_t *t = (uint8_t *)label;
- t[0] = ((l & 0x000FF000) >> 12);
- t[1] = ((l & 0x00000FF0) >> 4);
- t[2] = ((l & 0x0000000F) << 4);
- if (bos)
- t[2] |= 0x01;
-}
-
/* Return BOS value of label stream */
static inline uint8_t label_bos(mpls_label_t *label)
{
dest->flags,
BGP_NODE_LABEL_REQUESTED))
bgp_unregister_for_label(dest);
- label_ntop(MPLS_LABEL_IMPLICIT_NULL, 1,
- &dest->local_label);
+ dest->local_label = mpls_lse_encode(
+ MPLS_LABEL_IMPLICIT_NULL, 0, 0,
+ 1);
bgp_set_valid_label(&dest->local_label);
} else
bgp_register_for_label(dest,
int i;
char *nexthop_hostname =
bgp_nexthop_hostname(path->peer, path->nexthop);
+ uint32_t ttl = 0;
+ uint32_t bos = 0;
+ uint32_t exp = 0;
+ mpls_label_t label = MPLS_INVALID_LABEL;
if (json_paths) {
json_path = json_object_new_object();
/* Remote Label */
if (path->extra && bgp_is_valid_label(&path->extra->label[0])
&& (safi != SAFI_EVPN && !is_route_parent_evpn(path))) {
- mpls_label_t label = label_pton(&path->extra->label[0]);
+ mpls_lse_decode(path->extra->label[0], &label, &ttl, &exp,
+ &bos);
if (json_paths)
json_object_int_add(json_path, "remoteLabel", label);
int has_valid_label = 0;
mpls_label_t label = 0;
json_object *json_adv_to = NULL;
+ uint32_t ttl = 0;
+ uint32_t bos = 0;
+ uint32_t exp = 0;
- p = bgp_dest_get_prefix(dest);
- has_valid_label = bgp_is_valid_label(&dest->local_label);
+ mpls_lse_decode(dest->local_label, &label, &ttl, &exp, &bos);
- if (has_valid_label)
- label = label_pton(&dest->local_label);
+ p = bgp_dest_get_prefix(dest);
+ has_valid_label = bgp_is_valid_label(&label);
if (safi == SAFI_EVPN) {
uint64_t cum_bw = 0;
uint32_t nhg_id = 0;
bool is_add;
+ uint32_t ttl = 0;
+ uint32_t bos = 0;
+ uint32_t exp = 0;
/* Don't try to install if we're not connected to Zebra or Zebra doesn't
* know of this instance.
if (mpinfo->extra
&& bgp_is_valid_label(&mpinfo->extra->label[0])
&& !CHECK_FLAG(api.flags, ZEBRA_FLAG_EVPN_ROUTE)) {
- label = label_pton(&mpinfo->extra->label[0]);
+ mpls_lse_decode(mpinfo->extra->label[0], &label, &ttl,
+ &exp, &bos);
SET_FLAG(api_nh->flags, ZAPI_NEXTHOP_FLAG_LABEL);
&mpinfo->extra->label[0]))
continue;
- label = label_pton(&mpinfo->extra->label[0]);
+ mpls_lse_decode(mpinfo->extra->label[0], &label,
+ &ttl, &exp, &bos);
transpose_sid(&api_nh->seg6_segs, label,
sid_info->transposition_offset,
sid_info->transposition_len);