diff --git a/lib/nexthop.c b/lib/nexthop.c index 73c2de0cd80e..b15e738db47d 100644 --- a/lib/nexthop.c +++ b/lib/nexthop.c @@ -105,12 +105,6 @@ static int _nexthop_cmp_no_labels(const struct nexthop *next1, { int ret = 0; - if (next1->vrf_id < next2->vrf_id) - return -1; - - if (next1->vrf_id > next2->vrf_id) - return 1; - if (next1->type < next2->type) return -1; @@ -120,6 +114,12 @@ static int _nexthop_cmp_no_labels(const struct nexthop *next1, switch (next1->type) { case NEXTHOP_TYPE_IPV4: case NEXTHOP_TYPE_IPV6: + if (next1->vrf_id < next2->vrf_id) + return -1; + + if (next1->vrf_id > next2->vrf_id) + return 1; + ret = _nexthop_gateway_cmp(next1, next2); if (ret != 0) return ret; diff --git a/lib/zclient.c b/lib/zclient.c index a135d1874400..3d84c34b8909 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -790,12 +790,6 @@ static int zapi_nexthop_cmp_no_labels(const struct zapi_nexthop *next1, { int ret = 0; - if (next1->vrf_id < next2->vrf_id) - return -1; - - if (next1->vrf_id > next2->vrf_id) - return 1; - if (next1->type < next2->type) return -1; @@ -805,6 +799,12 @@ static int zapi_nexthop_cmp_no_labels(const struct zapi_nexthop *next1, switch (next1->type) { case NEXTHOP_TYPE_IPV4: case NEXTHOP_TYPE_IPV6: + if (next1->vrf_id < next2->vrf_id) + return -1; + + if (next1->vrf_id > next2->vrf_id) + return 1; + ret = nexthop_g_addr_cmp(next1->type, &next1->gate, &next2->gate); if (ret != 0)