}
}
-static bool labels_same(struct bgp_path_info *bpi, mpls_label_t *label,
- uint32_t n)
-{
- if (!bpi->extra) {
- if (!n)
- return true;
- else
- return false;
- }
-
- return bgp_labels_same((const mpls_label_t *)bpi->extra->label,
- bpi->extra->num_labels,
- (const mpls_label_t *)label, n);
-}
-
/*
* make encoded route labels match specified encoded label set
*/
}
if (bpi) {
- bool labelssame = labels_same(bpi, label, num_labels);
+ bool labelssame = bgp_path_info_labels_same(bpi, label,
+ num_labels);
if (CHECK_FLAG(source_bpi->flags, BGP_PATH_REMOVED)
&& CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) {
return bgp_is_valid_label(&path->extra->label[0]);
}
+bool bgp_path_info_labels_same(const struct bgp_path_info *bpi,
+ const mpls_label_t *label, uint32_t n)
+{
+ uint32_t bpi_num_labels;
+ const mpls_label_t *bpi_label;
+
+ bpi_num_labels = bpi->extra ? bpi->extra->num_labels : 0;
+ bpi_label = bpi_num_labels ? bpi->extra->label : NULL;
+
+ return bgp_labels_same(bpi_label, bpi_num_labels,
+ (const mpls_label_t *)label, n);
+}
+
/* Free bgp route information. */
void bgp_path_info_free_with_caller(const char *name,
struct bgp_path_info *path)
/* Same attribute comes in. */
if (!CHECK_FLAG(pi->flags, BGP_PATH_REMOVED) && same_attr &&
(!has_valid_label ||
- (bgp_path_info_extra_get(pi) &&
- bgp_labels_same((const mpls_label_t *)pi->extra->label,
- pi->extra->num_labels, label,
- num_labels)))) {
+ bgp_path_info_labels_same(pi, label, num_labels))) {
if (get_active_bdc_from_pi(pi, afi, safi) &&
peer->sort == BGP_PEER_EBGP &&
CHECK_FLAG(pi->flags, BGP_PATH_HISTORY)) {
/* Update MPLS label */
if (has_valid_label) {
extra = bgp_path_info_extra_get(pi);
- if (!bgp_labels_same((const mpls_label_t *)extra->label,
- extra->num_labels, label,
- num_labels)) {
+ if (!bgp_path_info_labels_same(pi, label, num_labels)) {
memcpy(&extra->label, label,
num_labels * sizeof(mpls_label_t));
extra->num_labels = num_labels;
struct bgp_path_info *path, uint32_t flag);
extern void bgp_path_info_path_with_addpath_rx_str(struct bgp_path_info *pi,
char *buf, size_t buf_len);
+extern bool bgp_path_info_labels_same(const struct bgp_path_info *bpi,
+ const mpls_label_t *label, uint32_t n);
extern int bgp_nlri_parse_ip(struct peer *, struct attr *, struct bgp_nlri *);