diff options
| author | Mark Stapp <mjs@voltanet.io> | 2020-05-26 11:08:42 -0400 |
|---|---|---|
| committer | Mark Stapp <mjs@voltanet.io> | 2020-07-07 13:14:01 -0400 |
| commit | 0e8542eef3f287d249d0ae09d8a4dbb873ac981c (patch) | |
| tree | 5d6fdc64d92b15b09ff727d2ed9cc33d92682539 /lib/nexthop.c | |
| parent | 65d413f4a052a91ce89ae60ead875b44741ef0b2 (diff) | |
lib: test vrfs in nexthop_same_firsthop()
Test the two nexthops' vrfs, and convert api to 'bool' return.
Signed-off-by: Mark Stapp <mjs@voltanet.io>
Diffstat (limited to 'lib/nexthop.c')
| -rw-r--r-- | lib/nexthop.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/nexthop.c b/lib/nexthop.c index 0d239e091b..3496081d47 100644 --- a/lib/nexthop.c +++ b/lib/nexthop.c @@ -187,35 +187,41 @@ int nexthop_cmp(const struct nexthop *next1, const struct nexthop *next2) return ret; } -int nexthop_same_firsthop(struct nexthop *next1, struct nexthop *next2) +bool nexthop_same_firsthop(const struct nexthop *next1, + const struct nexthop *next2) { + /* Map the TYPE_IPx types to TYPE_IPx_IFINDEX */ int type1 = NEXTHOP_FIRSTHOPTYPE(next1->type); int type2 = NEXTHOP_FIRSTHOPTYPE(next2->type); if (type1 != type2) - return 0; + return false; + + if (next1->vrf_id != next2->vrf_id) + return false; + switch (type1) { case NEXTHOP_TYPE_IPV4_IFINDEX: if (!IPV4_ADDR_SAME(&next1->gate.ipv4, &next2->gate.ipv4)) - return 0; + return false; if (next1->ifindex != next2->ifindex) - return 0; + return false; break; case NEXTHOP_TYPE_IFINDEX: if (next1->ifindex != next2->ifindex) - return 0; + return false; break; case NEXTHOP_TYPE_IPV6_IFINDEX: if (!IPV6_ADDR_SAME(&next1->gate.ipv6, &next2->gate.ipv6)) - return 0; + return false; if (next1->ifindex != next2->ifindex) - return 0; + return false; break; default: /* do nothing */ break; } - return 1; + return true; } /* |
