summaryrefslogtreecommitdiff
path: root/lib/zclient.c
diff options
context:
space:
mode:
authorHiroki Shirokura <slank.dev@gmail.com>2020-12-17 22:45:58 +0900
committerMark Stapp <mjs@voltanet.io>2021-06-02 10:24:47 -0400
commit2aa01034f3c437e076cf12f1ea4e4b7b5b6b9075 (patch)
tree98533279860fb8dd44b502adb78aae3e5c698a81 /lib/zclient.c
parent4c6f9934e4d0cb824e0383e9435bd957ea54bcb0 (diff)
lib: add new nexthop's attributes seg6 (step3)
This commit add new nexthop's addional object for SRv6 routing about seg6 route. Before this commit, we can add MPLS info as additional object on nexthop. This commit make it add more support about seg6 routes. seg6 routes are ones of the LWT routing mechanism, so configuration of seg6local routes is performed by ZEBRA_ROUTE_SEND, it's same as MPLS configuration. Real configuration implementation isn't implemented at this commit. later commit add that. This commit add only nexthop additional object and some misc functions. Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
Diffstat (limited to 'lib/zclient.c')
-rw-r--r--lib/zclient.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/zclient.c b/lib/zclient.c
index c8bb720591..8520fd769d 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -810,6 +810,13 @@ 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)
{
@@ -914,6 +921,10 @@ static int zapi_nexthop_cmp(const void *item1, const void *item2)
return ret;
ret = zapi_nexthop_seg6local_cmp(next1, next2);
+ if (ret != 0)
+ return ret;
+
+ ret = zapi_nexthop_seg6_cmp(next1, next2);
return ret;
}
@@ -1016,6 +1027,10 @@ int zapi_nexthop_encode(struct stream *s, const struct zapi_nexthop *api_nh,
sizeof(struct seg6local_context));
}
+ if (CHECK_FLAG(api_flags, ZEBRA_FLAG_SEG6_ROUTE))
+ stream_write(s, &api_nh->seg6_segs,
+ sizeof(struct in6_addr));
+
done:
return ret;
}
@@ -1303,6 +1318,10 @@ int zapi_nexthop_decode(struct stream *s, struct zapi_nexthop *api_nh,
sizeof(struct seg6local_context));
}
+ if (CHECK_FLAG(api_flags, ZEBRA_FLAG_SEG6_ROUTE))
+ STREAM_GET(&api_nh->seg6_segs, s,
+ sizeof(struct in6_addr));
+
/* Success */
ret = 0;
@@ -1645,6 +1664,7 @@ stream_failure:
struct nexthop *nexthop_from_zapi_nexthop(const struct zapi_nexthop *znh)
{
+ uint8_t zero[16] = {0};
struct nexthop *n = nexthop_new();
n->type = znh->type;
@@ -1671,6 +1691,9 @@ struct nexthop *nexthop_from_zapi_nexthop(const struct zapi_nexthop *znh)
nexthop_add_seg6local(n, znh->seg6local_action,
&znh->seg6local_ctx);
+ if (memcmp(&znh->seg6_segs, zero, sizeof(struct in6_addr)) != 0)
+ nexthop_add_seg6(n, &znh->seg6_segs);
+
return n;
}
@@ -1721,6 +1744,10 @@ int zapi_nexthop_from_nexthop(struct zapi_nexthop *znh,
sizeof(struct seg6local_context));
}
+ if (nh->nh_seg6_segs != NULL)
+ memcpy(&znh->seg6_segs, nh->nh_seg6_segs,
+ sizeof(struct in6_addr));
+
return 0;
}