From 618538f8ab65eeee12323a460336dffb08cd36e8 Mon Sep 17 00:00:00 2001 From: Hiroki Shirokura Date: Sat, 19 Dec 2020 09:28:38 +0900 Subject: 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 --- lib/zclient.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'lib/zclient.c') 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) { -- cgit v1.2.3