diff options
| author | Hiroki Shirokura <slank.dev@gmail.com> | 2020-12-19 09:28:38 +0900 |
|---|---|---|
| committer | Mark Stapp <mjs@voltanet.io> | 2021-06-02 10:24:48 -0400 |
| commit | 618538f8ab65eeee12323a460336dffb08cd36e8 (patch) | |
| tree | a4b84d101ffd7950ea21e256d0664e2c72391918 /lib/zclient.c | |
| parent | bfaab44d1e6ffa23cfc983ccd72d98e6082e38df (diff) | |
lib: add usual func to install SRv6 localsid (step4)
This commit add usuful function to configure SRv6 localsid
which is represented with seg6local lwt route.
Now, it can support only NEXTHOP_TYPE_IFINDEX route.
Actual configurationof SRv6 localsid is performed with
ZEBRA_ROUTE_ADD. So this is just a wrapper function
for route-install.
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
Diffstat (limited to 'lib/zclient.c')
| -rw-r--r-- | lib/zclient.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/zclient.c b/lib/zclient.c index 7eb365c305..1acf7f20d5 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -436,6 +436,45 @@ enum zclient_send_status zclient_send_vrf_label(struct zclient *zclient, return zclient_send_message(zclient); } +enum zclient_send_status zclient_send_localsid(struct zclient *zclient, + const struct in6_addr *sid, ifindex_t oif, + enum seg6local_action_t action, + const struct seg6local_context *context) +{ + struct prefix_ipv6 p; + struct zapi_route api; + struct nexthop nh; + + memset(&p, 0, sizeof(p)); + p.family = AF_INET6; + p.prefixlen = 128; + p.prefix = *sid; + + memset(&api, 0, sizeof(api)); + api.vrf_id = VRF_DEFAULT; + api.type = ZEBRA_ROUTE_BGP; + api.instance = 0; + api.safi = SAFI_UNICAST; + memcpy(&api.prefix, &p, sizeof(p)); + + if (action == ZEBRA_SEG6_LOCAL_ACTION_UNSPEC) + return zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api); + + SET_FLAG(api.flags, ZEBRA_FLAG_ALLOW_RECURSION); + SET_FLAG(api.flags, ZEBRA_FLAG_SEG6LOCAL_ROUTE); + SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP); + + memset(&nh, 0, sizeof(nh)); + nh.type = NEXTHOP_TYPE_IFINDEX; + nh.ifindex = oif; + nexthop_add_seg6local(&nh, action, context); + + zapi_nexthop_from_nexthop(&api.nexthops[0], &nh); + api.nexthop_num = 1; + + return zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api); +} + /* Send register requests to zebra daemon for the information in a VRF. */ void zclient_send_reg_requests(struct zclient *zclient, vrf_id_t vrf_id) { |
