diff options
author | Louis Scalbert <louis.scalbert@6wind.com> | 2024-02-26 12:10:16 +0100 |
---|---|---|
committer | Louis Scalbert <louis.scalbert@6wind.com> | 2024-06-05 11:08:46 +0200 |
commit | 04748e36a5d5e6dd22979bac0c81b96158a7e8f1 (patch) | |
tree | 82551b0f30f6eed2969983fb1bd48b5fa701c628 /bgpd | |
parent | bgpd: optimize label copy for new path_info (diff) | |
download | frr-04748e36a5d5e6dd22979bac0c81b96158a7e8f1.tar.xz frr-04748e36a5d5e6dd22979bac0c81b96158a7e8f1.zip |
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>
Diffstat (limited to 'bgpd')
-rw-r--r-- | bgpd/bgp_mplsvpn.c | 18 | ||||
-rw-r--r-- | bgpd/bgp_route.c | 22 | ||||
-rw-r--r-- | bgpd/bgp_route.h | 2 |
3 files changed, 19 insertions, 23 deletions
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index c58c67e6a..6e4f93f1e 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -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 */ @@ -1129,7 +1114,8 @@ leak_update(struct bgp *to_bgp, struct bgp_dest *bn, } 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)) { diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 8da30e789..bf3ffaedf 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -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]); } +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) @@ -4851,10 +4864,7 @@ void bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id, /* 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)) { @@ -5038,9 +5048,7 @@ void bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id, /* 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; diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h index 7afd77cf6..2aa721a3b 100644 --- a/bgpd/bgp_route.h +++ b/bgpd/bgp_route.h @@ -760,6 +760,8 @@ extern void bgp_path_info_unset_flag(struct bgp_dest *dest, 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 *); |