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]>
(cherry picked from commit ad052b3995e6d4bf0bd7e1cf4814afe6ce9876d2)
Signed-off-by: Louis Scalbert <[email protected]>
  • Loading branch information
pguibert6WIND authored and louis-6wind committed Jan 25, 2024
1 parent 9b9abe1 commit f8c1cd4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f8c1cd4

Please sign in to comment.