mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-08 11:18:43 +00:00
bgpd: add bgp_path_info_labels_same()
Add bgp_path_info_labels_same() to compare labels with labels from path_info. Remove labels_same() that was used for mplsvpn only. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
This commit is contained in:
parent
9771f1a03e
commit
04748e36a5
@ -964,21 +964,6 @@ void transpose_sid(struct in6_addr *sid, uint32_t label, uint8_t offset,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
* make encoded route labels match specified encoded label set
|
||||||
*/
|
*/
|
||||||
@ -1129,7 +1114,8 @@ leak_update(struct bgp *to_bgp, struct bgp_dest *bn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bpi) {
|
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)
|
if (CHECK_FLAG(source_bpi->flags, BGP_PATH_REMOVED)
|
||||||
&& CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) {
|
&& CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) {
|
||||||
|
@ -332,6 +332,19 @@ bool bgp_path_info_has_valid_label(const struct bgp_path_info *path)
|
|||||||
return bgp_is_valid_label(&path->extra->label[0]);
|
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. */
|
/* Free bgp route information. */
|
||||||
void bgp_path_info_free_with_caller(const char *name,
|
void bgp_path_info_free_with_caller(const char *name,
|
||||||
struct bgp_path_info *path)
|
struct bgp_path_info *path)
|
||||||
@ -4851,10 +4864,7 @@ void bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
|
|||||||
/* Same attribute comes in. */
|
/* Same attribute comes in. */
|
||||||
if (!CHECK_FLAG(pi->flags, BGP_PATH_REMOVED) && same_attr &&
|
if (!CHECK_FLAG(pi->flags, BGP_PATH_REMOVED) && same_attr &&
|
||||||
(!has_valid_label ||
|
(!has_valid_label ||
|
||||||
(bgp_path_info_extra_get(pi) &&
|
bgp_path_info_labels_same(pi, label, num_labels))) {
|
||||||
bgp_labels_same((const mpls_label_t *)pi->extra->label,
|
|
||||||
pi->extra->num_labels, label,
|
|
||||||
num_labels)))) {
|
|
||||||
if (get_active_bdc_from_pi(pi, afi, safi) &&
|
if (get_active_bdc_from_pi(pi, afi, safi) &&
|
||||||
peer->sort == BGP_PEER_EBGP &&
|
peer->sort == BGP_PEER_EBGP &&
|
||||||
CHECK_FLAG(pi->flags, BGP_PATH_HISTORY)) {
|
CHECK_FLAG(pi->flags, BGP_PATH_HISTORY)) {
|
||||||
@ -5038,9 +5048,7 @@ void bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
|
|||||||
/* Update MPLS label */
|
/* Update MPLS label */
|
||||||
if (has_valid_label) {
|
if (has_valid_label) {
|
||||||
extra = bgp_path_info_extra_get(pi);
|
extra = bgp_path_info_extra_get(pi);
|
||||||
if (!bgp_labels_same((const mpls_label_t *)extra->label,
|
if (!bgp_path_info_labels_same(pi, label, num_labels)) {
|
||||||
extra->num_labels, label,
|
|
||||||
num_labels)) {
|
|
||||||
memcpy(&extra->label, label,
|
memcpy(&extra->label, label,
|
||||||
num_labels * sizeof(mpls_label_t));
|
num_labels * sizeof(mpls_label_t));
|
||||||
extra->num_labels = num_labels;
|
extra->num_labels = num_labels;
|
||||||
|
@ -760,6 +760,8 @@ extern void bgp_path_info_unset_flag(struct bgp_dest *dest,
|
|||||||
struct bgp_path_info *path, uint32_t flag);
|
struct bgp_path_info *path, uint32_t flag);
|
||||||
extern void bgp_path_info_path_with_addpath_rx_str(struct bgp_path_info *pi,
|
extern void bgp_path_info_path_with_addpath_rx_str(struct bgp_path_info *pi,
|
||||||
char *buf, size_t buf_len);
|
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 *);
|
extern int bgp_nlri_parse_ip(struct peer *, struct attr *, struct bgp_nlri *);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user