]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib: Make labels_match function use labels_cmp
authorStephen Worley <sworley@cumulusnetworks.com>
Tue, 14 May 2019 17:26:22 +0000 (10:26 -0700)
committerStephen Worley <sworley@cumulusnetworks.com>
Thu, 23 May 2019 16:21:15 +0000 (12:21 -0400)
Update the nexthop_labels_match() function to use
nexthop_labels_cmp().

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
lib/nexthop.c
lib/nexthop.h

index c616ea857e1c5a80e66e7d75c365259c9562cfe7..120968f43662c50639b41a702efea6c993a136da 100644 (file)
@@ -206,27 +206,12 @@ const char *nexthop_type_to_str(enum nexthop_types_t nh_type)
 /*
  * Check if the labels match for the 2 nexthops specified.
  */
-int nexthop_labels_match(const struct nexthop *nh1, const struct nexthop *nh2)
+bool nexthop_labels_match(const struct nexthop *nh1, const struct nexthop *nh2)
 {
-       const struct mpls_label_stack *nhl1, *nhl2;
-
-       nhl1 = nh1->nh_label;
-       nhl2 = nh2->nh_label;
-
-       /* No labels is a match */
-       if (!nhl1 && !nhl2)
-               return 1;
-
-       if (!nhl1 || !nhl2)
-               return 0;
-
-       if (nhl1->num_labels != nhl2->num_labels)
-               return 0;
-
-       if (memcmp(nhl1->label, nhl2->label, nhl1->num_labels))
-               return 0;
+       if (nexthop_labels_cmp(nh1, nh2) != 0)
+               return false;
 
-       return 1;
+       return true;
 }
 
 struct nexthop *nexthop_new(void)
index 58e8e0ebb60fa862b281060f9dbc99a7703557dd..1bc3055835336d5c07e7018e69b6690a1b66ce33 100644 (file)
@@ -144,8 +144,8 @@ extern int nexthop_cmp(const struct nexthop *nh1, const struct nexthop *nh2);
 extern const char *nexthop_type_to_str(enum nexthop_types_t nh_type);
 extern int nexthop_same_no_recurse(const struct nexthop *next1,
                                   const struct nexthop *next2);
-extern int nexthop_labels_match(const struct nexthop *nh1,
-                               const struct nexthop *nh2);
+extern bool nexthop_labels_match(const struct nexthop *nh1,
+                                const struct nexthop *nh2);
 extern int nexthop_same_firsthop(struct nexthop *next1, struct nexthop *next2);
 
 extern const char *nexthop2str(const struct nexthop *nexthop,