summaryrefslogtreecommitdiff
path: root/lib/nexthop.c
diff options
context:
space:
mode:
authorMark Stapp <mjs@voltanet.io>2019-04-02 12:33:06 -0400
committerMark Stapp <mjs@voltanet.io>2019-04-03 04:25:21 -0400
commit55f93d4b0d5f14136b2b29307b3ee55363669aa4 (patch)
tree2da0467f3aaec37344cb529352d240f8d9cf8eb3 /lib/nexthop.c
parent09310979549d06725619fc80fdcb3c2f914a4549 (diff)
libs: nexthop comparison includes labels if present
Adjust the nexthop comparison api so that it calls the label- comparison api. Adjust the label-comp api so that "no labels" is "equal". Signed-off-by: Mark Stapp <mjs@voltanet.io>
Diffstat (limited to 'lib/nexthop.c')
-rw-r--r--lib/nexthop.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/nexthop.c b/lib/nexthop.c
index d25b470277..474abee309 100644
--- a/lib/nexthop.c
+++ b/lib/nexthop.c
@@ -121,12 +121,17 @@ 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(struct nexthop *nh1, struct nexthop *nh2)
+int nexthop_labels_match(const struct nexthop *nh1, const struct nexthop *nh2)
{
- struct mpls_label_stack *nhl1, *nhl2;
+ 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;
@@ -212,7 +217,8 @@ bool nexthop_same(const struct nexthop *nh1, const struct nexthop *nh2)
break;
}
- return true;
+ /* Compare labels too (if present) */
+ return (!!nexthop_labels_match(nh1, nh2));
}
/* Update nexthop with label information. */