From ecfeeb32b609e0f8c1e8bc4925d3357dcb01a133 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Wed, 15 Feb 2023 14:37:45 +0100 Subject: [PATCH] bgpd: fix mpls label pointer comparison Comparing pointers is not the appropriate way to know if the label values are the same or not. Perform a memcmp call instead is better. Fixes: 8ba710505735 ("bgpd: fix valgrind flagged errors") Signed-off-by: Philippe Guibert Signed-off-by: Louis Scalbert --- bgpd/bgp_route.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index ae3a88ddcc2c..4d6f2796f6da 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -4710,7 +4710,8 @@ 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 (extra->label != label) { + if (memcmp(&extra->label[0], &label[0], + num_labels * sizeof(mpls_label_t))) { memcpy(&extra->label, label, num_labels * sizeof(mpls_label_t)); extra->num_labels = num_labels; @@ -4909,7 +4910,8 @@ 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(new); - if (extra->label != label) { + if (memcmp(&extra->label[0], &label[0], + num_labels * sizeof(mpls_label_t))) { memcpy(&extra->label, label, num_labels * sizeof(mpls_label_t)); extra->num_labels = num_labels;