summaryrefslogtreecommitdiffstats
path: root/lib/nexthop.c
diff options
context:
space:
mode:
authorStephen Worley <sworley@cumulusnetworks.com>2019-05-14 19:41:40 +0200
committerStephen Worley <sworley@cumulusnetworks.com>2019-05-23 18:21:15 +0200
commit2ed74b933dbf980422cc5d4da76b168297e133e6 (patch)
tree0cbc8320fa7e6d242b6c6019aab5ece34b883a7f /lib/nexthop.c
parentlib: Add labels_cmp to nexthop_cmp (diff)
downloadfrr-2ed74b933dbf980422cc5d4da76b168297e133e6.tar.xz
frr-2ed74b933dbf980422cc5d4da76b168297e133e6.zip
lib: Update nexthop_same to use nexthop_cmp
Simplify the code a bit by making nexthop_same() just use nexthop_cmp() internally. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
Diffstat (limited to '')
-rw-r--r--lib/nexthop.c41
1 files changed, 3 insertions, 38 deletions
diff --git a/lib/nexthop.c b/lib/nexthop.c
index 0153fef3f..7cc77a767 100644
--- a/lib/nexthop.c
+++ b/lib/nexthop.c
@@ -68,7 +68,7 @@ int nexthop_cmp(const struct nexthop *next1, const struct nexthop *next2)
{
int ret = 0;
uint32_t n1 = 0;
- uint32_2 n2 = 0;
+ uint32_t n2 = 0;
if (next1->vrf_id < next2->vrf_id)
return -1;
@@ -255,45 +255,10 @@ bool nexthop_same(const struct nexthop *nh1, const struct nexthop *nh2)
if (nh1 == nh2)
return true;
- if (nh1->vrf_id != nh2->vrf_id)
+ if (nexthop_cmp(nh1, nh2) != 0)
return false;
- if (nh1->type != nh2->type)
- return false;
-
- switch (nh1->type) {
- case NEXTHOP_TYPE_IFINDEX:
- if (nh1->ifindex != nh2->ifindex)
- return false;
- break;
- case NEXTHOP_TYPE_IPV4:
- if (nh1->gate.ipv4.s_addr != nh2->gate.ipv4.s_addr)
- return false;
- break;
- case NEXTHOP_TYPE_IPV4_IFINDEX:
- if (nh1->gate.ipv4.s_addr != nh2->gate.ipv4.s_addr)
- return false;
- if (nh1->ifindex != nh2->ifindex)
- return false;
- break;
- case NEXTHOP_TYPE_IPV6:
- if (memcmp(&nh1->gate.ipv6, &nh2->gate.ipv6, 16))
- return false;
- break;
- case NEXTHOP_TYPE_IPV6_IFINDEX:
- if (memcmp(&nh1->gate.ipv6, &nh2->gate.ipv6, 16))
- return false;
- if (nh1->ifindex != nh2->ifindex)
- return false;
- break;
- case NEXTHOP_TYPE_BLACKHOLE:
- if (nh1->bh_type != nh2->bh_type)
- return false;
- break;
- }
-
- /* Compare labels too (if present) */
- return (!!nexthop_labels_match(nh1, nh2));
+ return true;
}
/* Update nexthop with label information. */