Skip to content

Commit

Permalink
bgpd: fix mpls label pointer comparison
Browse files Browse the repository at this point in the history
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: 8ba7105 ("bgpd: fix valgrind flagged errors")
Signed-off-by: Philippe Guibert <[email protected]>
Signed-off-by: Louis Scalbert <[email protected]>
  • Loading branch information
pguibert6WIND authored and louis-6wind committed Jan 26, 2024
1 parent 9b9abe1 commit f254f4b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -4710,7 +4710,9 @@ 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 (!bgp_labels_same((const mpls_label_t *)extra->label,
extra->num_labels, label,
num_labels)) {
memcpy(&extra->label, label,
num_labels * sizeof(mpls_label_t));
extra->num_labels = num_labels;
Expand Down Expand Up @@ -4909,7 +4911,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 (!bgp_labels_same((const mpls_label_t *)extra->label,
extra->num_labels, label, num_labels)) {
memcpy(&extra->label, label,
num_labels * sizeof(mpls_label_t));
extra->num_labels = num_labels;
Expand Down

0 comments on commit f254f4b

Please sign in to comment.