]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib: integrate srv6-nexthop-cmp functions
authorHiroki Shirokura <slank.dev@gmail.com>
Mon, 22 Mar 2021 00:52:11 +0000 (00:52 +0000)
committerMark Stapp <mjs@voltanet.io>
Wed, 2 Jun 2021 14:24:48 +0000 (10:24 -0400)
I agree with the PR review from mstap and merged
the following two functions into one.

- zapi_nexthop_seg6_cmp
- zapi_nexthop_seg6local_cmp

[note]
If both of them have more complex extensions in the future,
I think it will be less confusing to remove the integration
of these functions and make them as separate functions as
before.

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
lib/zclient.c

index 158a20eb58e9ae260cc26c7df8cdb4486c0428b8..27cc095f12dfd780b9d9217559089c53a7af2d4a 100644 (file)
@@ -833,9 +833,16 @@ static int zapi_nexthop_labels_cmp(const struct zapi_nexthop *next1,
        return memcmp(next1->labels, next2->labels, next1->label_num);
 }
 
-static int zapi_nexthop_seg6local_cmp(const struct zapi_nexthop *next1,
-                                     const struct zapi_nexthop *next2)
+static int zapi_nexthop_srv6_cmp(const struct zapi_nexthop *next1,
+                                const struct zapi_nexthop *next2)
 {
+       int ret = 0;
+
+       ret = memcmp(&next1->seg6_segs, &next2->seg6_segs,
+                    sizeof(struct in6_addr));
+       if (ret != 0)
+               return ret;
+
        if (next1->seg6local_action > next2->seg6local_action)
                return 1;
 
@@ -846,13 +853,6 @@ static int zapi_nexthop_seg6local_cmp(const struct zapi_nexthop *next1,
                      sizeof(struct seg6local_context));
 }
 
-static int zapi_nexthop_seg6_cmp(const struct zapi_nexthop *next1,
-                                const struct zapi_nexthop *next2)
-{
-       return memcmp(&next1->seg6_segs, &next2->seg6_segs,
-                     sizeof(struct in6_addr));
-}
-
 static int zapi_nexthop_cmp_no_labels(const struct zapi_nexthop *next1,
                                      const struct zapi_nexthop *next2)
 {
@@ -956,11 +956,7 @@ static int zapi_nexthop_cmp(const void *item1, const void *item2)
        if (ret != 0)
                return ret;
 
-       ret = zapi_nexthop_seg6local_cmp(next1, next2);
-       if (ret != 0)
-               return ret;
-
-       ret = zapi_nexthop_seg6_cmp(next1, next2);
+       ret = zapi_nexthop_srv6_cmp(next1, next2);
 
        return ret;
 }