]> git.proxmox.com Git - mirror_frr.git/blame_incremental - isisd/isis_zebra.c
isisd: uninstall local routes that don't have any valid nexthop
[mirror_frr.git] / isisd / isis_zebra.c
... / ...
CommitLineData
1/*
2 * IS-IS Rout(e)ing protocol - isis_zebra.c
3 *
4 * Copyright (C) 2001,2002 Sampo Saaristo
5 * Tampere University of Technology
6 * Institute of Communications Engineering
7 * Copyright (C) 2013-2015 Christian Franke <chris@opensourcerouting.org>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public Licenseas published by the Free
11 * Software Foundation; either version 2 of the License, or (at your option)
12 * any later version.
13 *
14 * This program is distributed in the hope that it will be useful,but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; see the file COPYING; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#include <zebra.h>
25
26#include "thread.h"
27#include "command.h"
28#include "memory.h"
29#include "log.h"
30#include "lib_errors.h"
31#include "if.h"
32#include "network.h"
33#include "prefix.h"
34#include "zclient.h"
35#include "stream.h"
36#include "linklist.h"
37#include "nexthop.h"
38#include "vrf.h"
39#include "libfrr.h"
40
41#include "isisd/isis_constants.h"
42#include "isisd/isis_common.h"
43#include "isisd/isis_flags.h"
44#include "isisd/isis_misc.h"
45#include "isisd/isis_circuit.h"
46#include "isisd/isisd.h"
47#include "isisd/isis_circuit.h"
48#include "isisd/isis_csm.h"
49#include "isisd/isis_lsp.h"
50#include "isisd/isis_route.h"
51#include "isisd/isis_zebra.h"
52#include "isisd/isis_adjacency.h"
53#include "isisd/isis_te.h"
54#include "isisd/isis_sr.h"
55#include "isisd/isis_ldp_sync.h"
56
57struct zclient *zclient;
58static struct zclient *zclient_sync;
59
60/* Router-id update message from zebra. */
61static int isis_router_id_update_zebra(ZAPI_CALLBACK_ARGS)
62{
63 struct isis_area *area;
64 struct listnode *node;
65 struct prefix router_id;
66 struct isis *isis = NULL;
67
68 isis = isis_lookup_by_vrfid(vrf_id);
69
70 if (isis == NULL) {
71 return -1;
72 }
73
74 zebra_router_id_update_read(zclient->ibuf, &router_id);
75 if (isis->router_id == router_id.u.prefix4.s_addr)
76 return 0;
77
78 isis->router_id = router_id.u.prefix4.s_addr;
79 for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area))
80 if (listcount(area->area_addrs) > 0)
81 lsp_regenerate_schedule(area, area->is_type, 0);
82
83 return 0;
84}
85
86static int isis_zebra_if_address_add(ZAPI_CALLBACK_ARGS)
87{
88 struct isis_circuit *circuit;
89 struct connected *c;
90
91 c = zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_ADD,
92 zclient->ibuf, vrf_id);
93
94 if (c == NULL)
95 return 0;
96
97#ifdef EXTREME_DEBUG
98 if (c->address->family == AF_INET)
99 zlog_debug("connected IP address %pFX", c->address);
100 if (c->address->family == AF_INET6)
101 zlog_debug("connected IPv6 address %pFX", c->address);
102#endif /* EXTREME_DEBUG */
103
104 if (if_is_operative(c->ifp)) {
105 circuit = circuit_scan_by_ifp(c->ifp);
106 if (circuit)
107 isis_circuit_add_addr(circuit, c);
108 }
109
110 return 0;
111}
112
113static int isis_zebra_if_address_del(ZAPI_CALLBACK_ARGS)
114{
115 struct isis_circuit *circuit;
116 struct connected *c;
117
118 c = zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_DELETE,
119 zclient->ibuf, vrf_id);
120
121 if (c == NULL)
122 return 0;
123
124#ifdef EXTREME_DEBUG
125 if (c->address->family == AF_INET)
126 zlog_debug("disconnected IP address %pFX", c->address);
127 if (c->address->family == AF_INET6)
128 zlog_debug("disconnected IPv6 address %pFX", c->address);
129#endif /* EXTREME_DEBUG */
130
131 if (if_is_operative(c->ifp)) {
132 circuit = circuit_scan_by_ifp(c->ifp);
133 if (circuit)
134 isis_circuit_del_addr(circuit, c);
135 }
136
137 connected_free(&c);
138
139 return 0;
140}
141
142static int isis_zebra_link_params(ZAPI_CALLBACK_ARGS)
143{
144 struct interface *ifp;
145
146 ifp = zebra_interface_link_params_read(zclient->ibuf, vrf_id);
147
148 if (ifp == NULL)
149 return 0;
150
151 /* Update TE TLV */
152 isis_mpls_te_update(ifp);
153
154 return 0;
155}
156
157enum isis_zebra_nexthop_type {
158 ISIS_NEXTHOP_MAIN = 0,
159 ISIS_NEXTHOP_BACKUP,
160};
161
162static int isis_zebra_add_nexthops(struct isis *isis, struct list *nexthops,
163 struct zapi_nexthop zapi_nexthops[],
164 enum isis_zebra_nexthop_type type,
165 bool mpls_lsp, uint8_t backup_nhs)
166{
167 struct isis_nexthop *nexthop;
168 struct listnode *node;
169 int count = 0;
170
171 /* Nexthops */
172 for (ALL_LIST_ELEMENTS_RO(nexthops, node, nexthop)) {
173 struct zapi_nexthop *api_nh;
174
175 if (count >= MULTIPATH_NUM)
176 break;
177 api_nh = &zapi_nexthops[count];
178 if (fabricd)
179 SET_FLAG(api_nh->flags, ZAPI_NEXTHOP_FLAG_ONLINK);
180 api_nh->vrf_id = isis->vrf_id;
181
182 switch (nexthop->family) {
183 case AF_INET:
184 /* FIXME: can it be ? */
185 if (nexthop->ip.ipv4.s_addr != INADDR_ANY) {
186 api_nh->type = NEXTHOP_TYPE_IPV4_IFINDEX;
187 api_nh->gate.ipv4 = nexthop->ip.ipv4;
188 } else {
189 api_nh->type = NEXTHOP_TYPE_IFINDEX;
190 }
191 break;
192 case AF_INET6:
193 if (!IN6_IS_ADDR_LINKLOCAL(&nexthop->ip.ipv6)
194 && !IN6_IS_ADDR_UNSPECIFIED(&nexthop->ip.ipv6)) {
195 continue;
196 }
197 api_nh->gate.ipv6 = nexthop->ip.ipv6;
198 api_nh->type = NEXTHOP_TYPE_IPV6_IFINDEX;
199 break;
200 default:
201 flog_err(EC_LIB_DEVELOPMENT,
202 "%s: unknown address family [%d]", __func__,
203 nexthop->family);
204 exit(1);
205 }
206
207 api_nh->ifindex = nexthop->ifindex;
208
209 /* Add MPLS label(s). */
210 switch (type) {
211 case ISIS_NEXTHOP_MAIN:
212 if (nexthop->sr.present) {
213 api_nh->label_num = 1;
214 api_nh->labels[0] = nexthop->sr.label;
215 } else if (mpls_lsp)
216 /*
217 * Do not use non-SR enabled nexthops to prevent
218 * broken LSPs from being formed.
219 */
220 continue;
221 break;
222 case ISIS_NEXTHOP_BACKUP:
223 if (nexthop->label_stack) {
224 api_nh->label_num =
225 nexthop->label_stack->num_labels;
226 memcpy(api_nh->labels,
227 nexthop->label_stack->label,
228 sizeof(mpls_label_t)
229 * api_nh->label_num);
230 } else if (mpls_lsp) {
231 /*
232 * This is necessary because zebra requires
233 * the nexthops of MPLS LSPs to be labeled.
234 */
235 api_nh->label_num = 1;
236 api_nh->labels[0] = MPLS_LABEL_IMPLICIT_NULL;
237 }
238 break;
239 }
240
241 /* Backup nexthop handling. */
242 if (backup_nhs) {
243 SET_FLAG(api_nh->flags, ZAPI_NEXTHOP_FLAG_HAS_BACKUP);
244 /*
245 * If the backup has multiple nexthops, all of them
246 * protect the same primary nexthop since ECMP routes
247 * have no backups.
248 */
249 api_nh->backup_num = backup_nhs;
250 for (int i = 0; i < backup_nhs; i++)
251 api_nh->backup_idx[i] = i;
252 }
253 count++;
254 }
255
256 return count;
257}
258
259void isis_zebra_route_add_route(struct isis *isis, struct prefix *prefix,
260 struct prefix_ipv6 *src_p,
261 struct isis_route_info *route_info)
262{
263 struct zapi_route api;
264 int count = 0;
265
266 if (zclient->sock < 0)
267 return;
268
269 /* Uninstall the route if it doesn't have any valid nexthop. */
270 if (list_isempty(route_info->nexthops)) {
271 isis_zebra_route_del_route(isis, prefix, src_p, route_info);
272 return;
273 }
274
275 memset(&api, 0, sizeof(api));
276 api.vrf_id = isis->vrf_id;
277 api.type = PROTO_TYPE;
278 api.safi = SAFI_UNICAST;
279 api.prefix = *prefix;
280 if (src_p && src_p->prefixlen) {
281 api.src_prefix = *src_p;
282 SET_FLAG(api.message, ZAPI_MESSAGE_SRCPFX);
283 }
284 SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
285 SET_FLAG(api.message, ZAPI_MESSAGE_METRIC);
286 api.metric = route_info->cost;
287
288 /* Add backup nexthops first. */
289 if (route_info->backup) {
290 count = isis_zebra_add_nexthops(
291 isis, route_info->backup->nexthops, api.backup_nexthops,
292 ISIS_NEXTHOP_BACKUP, false, 0);
293 if (count > 0) {
294 SET_FLAG(api.message, ZAPI_MESSAGE_BACKUP_NEXTHOPS);
295 api.backup_nexthop_num = count;
296 }
297 }
298
299 /* Add primary nexthops. */
300 count = isis_zebra_add_nexthops(isis, route_info->nexthops,
301 api.nexthops, ISIS_NEXTHOP_MAIN, false,
302 count);
303 if (!count)
304 return;
305 api.nexthop_num = count;
306
307 zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api);
308}
309
310void isis_zebra_route_del_route(struct isis *isis,
311 struct prefix *prefix,
312 struct prefix_ipv6 *src_p,
313 struct isis_route_info *route_info)
314{
315 struct zapi_route api;
316
317 if (zclient->sock < 0)
318 return;
319
320 memset(&api, 0, sizeof(api));
321 api.vrf_id = isis->vrf_id;
322 api.type = PROTO_TYPE;
323 api.safi = SAFI_UNICAST;
324 api.prefix = *prefix;
325 if (src_p && src_p->prefixlen) {
326 api.src_prefix = *src_p;
327 SET_FLAG(api.message, ZAPI_MESSAGE_SRCPFX);
328 }
329
330 zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api);
331}
332
333/**
334 * Install Prefix-SID label entry in the forwarding plane through Zebra.
335 *
336 * @param area IS-IS area
337 * @param prefix Route prefix
338 * @param rinfo Route information
339 * @param psid Prefix-SID information
340 */
341void isis_zebra_prefix_sid_install(struct isis_area *area,
342 struct prefix *prefix,
343 struct isis_route_info *rinfo,
344 struct isis_sr_psid_info *psid)
345{
346 struct zapi_labels zl;
347 int count = 0;
348
349 sr_debug("ISIS-Sr (%s): update label %u for prefix %pFX",
350 area->area_tag, psid->label, prefix);
351
352 /* Prepare message. */
353 memset(&zl, 0, sizeof(zl));
354 zl.type = ZEBRA_LSP_ISIS_SR;
355 zl.local_label = psid->label;
356
357 /* Local routes don't have any nexthop and require special handling. */
358 if (list_isempty(rinfo->nexthops)) {
359 struct zapi_nexthop *znh;
360 struct interface *ifp;
361
362 ifp = if_lookup_by_name("lo", VRF_DEFAULT);
363 if (!ifp) {
364 zlog_warn(
365 "%s: couldn't install Prefix-SID %pFX: loopback interface not found",
366 __func__, prefix);
367 return;
368 }
369
370 znh = &zl.nexthops[zl.nexthop_num++];
371 znh->type = NEXTHOP_TYPE_IFINDEX;
372 znh->ifindex = ifp->ifindex;
373 znh->label_num = 1;
374 znh->labels[0] = MPLS_LABEL_IMPLICIT_NULL;
375 } else {
376 /* Add backup nexthops first. */
377 if (rinfo->backup) {
378 count = isis_zebra_add_nexthops(
379 area->isis, rinfo->backup->nexthops,
380 zl.backup_nexthops, ISIS_NEXTHOP_BACKUP, true,
381 0);
382 if (count > 0) {
383 SET_FLAG(zl.message, ZAPI_LABELS_HAS_BACKUPS);
384 zl.backup_nexthop_num = count;
385 }
386 }
387
388 /* Add primary nexthops. */
389 count = isis_zebra_add_nexthops(area->isis, rinfo->nexthops,
390 zl.nexthops, ISIS_NEXTHOP_MAIN,
391 true, count);
392 if (!count)
393 return;
394 zl.nexthop_num = count;
395 }
396
397 /* Send message to zebra. */
398 (void)zebra_send_mpls_labels(zclient, ZEBRA_MPLS_LABELS_REPLACE, &zl);
399}
400
401/**
402 * Uninstall Prefix-SID label entry from the forwarding plane through Zebra.
403 *
404 * @param area IS-IS area
405 * @param prefix Route prefix
406 * @param rinfo Route information
407 * @param psid Prefix-SID information
408 */
409void isis_zebra_prefix_sid_uninstall(struct isis_area *area,
410 struct prefix *prefix,
411 struct isis_route_info *rinfo,
412 struct isis_sr_psid_info *psid)
413{
414 struct zapi_labels zl;
415
416 sr_debug("ISIS-Sr (%s): delete label %u for prefix %pFX",
417 area->area_tag, psid->label, prefix);
418
419 /* Prepare message. */
420 memset(&zl, 0, sizeof(zl));
421 zl.type = ZEBRA_LSP_ISIS_SR;
422 zl.local_label = psid->label;
423
424 /* Send message to zebra. */
425 (void)zebra_send_mpls_labels(zclient, ZEBRA_MPLS_LABELS_DELETE, &zl);
426}
427
428/**
429 * Send (LAN)-Adjacency-SID to ZEBRA for installation or deletion.
430 *
431 * @param cmd ZEBRA_MPLS_LABELS_ADD or ZEBRA_ROUTE_DELETE
432 * @param sra Segment Routing Adjacency-SID
433 */
434void isis_zebra_send_adjacency_sid(int cmd, const struct sr_adjacency *sra)
435{
436 struct isis *isis = sra->adj->circuit->area->isis;
437 struct zapi_labels zl;
438 struct zapi_nexthop *znh;
439
440 if (cmd != ZEBRA_MPLS_LABELS_ADD && cmd != ZEBRA_MPLS_LABELS_DELETE) {
441 flog_warn(EC_LIB_DEVELOPMENT, "%s: wrong ZEBRA command",
442 __func__);
443 return;
444 }
445
446 sr_debug(" |- %s label %u for interface %s",
447 cmd == ZEBRA_MPLS_LABELS_ADD ? "Add" : "Delete",
448 sra->input_label, sra->adj->circuit->interface->name);
449
450 memset(&zl, 0, sizeof(zl));
451 zl.type = ZEBRA_LSP_ISIS_SR;
452 zl.local_label = sra->input_label;
453 zl.nexthop_num = 1;
454 znh = &zl.nexthops[0];
455 znh->gate = sra->nexthop.address;
456 znh->type = (sra->nexthop.family == AF_INET)
457 ? NEXTHOP_TYPE_IPV4_IFINDEX
458 : NEXTHOP_TYPE_IPV6_IFINDEX;
459 znh->ifindex = sra->adj->circuit->interface->ifindex;
460 znh->label_num = 1;
461 znh->labels[0] = MPLS_LABEL_IMPLICIT_NULL;
462
463 /* Set backup nexthops. */
464 if (sra->type == ISIS_SR_LAN_BACKUP) {
465 int count;
466
467 count = isis_zebra_add_nexthops(isis, sra->backup_nexthops,
468 zl.backup_nexthops,
469 ISIS_NEXTHOP_BACKUP, true, 0);
470 if (count > 0) {
471 SET_FLAG(zl.message, ZAPI_LABELS_HAS_BACKUPS);
472 zl.backup_nexthop_num = count;
473
474 SET_FLAG(znh->flags, ZAPI_NEXTHOP_FLAG_HAS_BACKUP);
475 znh->backup_num = count;
476 for (int i = 0; i < count; i++)
477 znh->backup_idx[i] = i;
478 }
479 }
480
481 (void)zebra_send_mpls_labels(zclient, cmd, &zl);
482}
483
484static int isis_zebra_read(ZAPI_CALLBACK_ARGS)
485{
486 struct zapi_route api;
487 struct isis *isis = NULL;
488
489 isis = isis_lookup_by_vrfid(vrf_id);
490
491 if (isis == NULL)
492 return -1;
493
494 if (zapi_route_decode(zclient->ibuf, &api) < 0)
495 return -1;
496
497 if (api.prefix.family == AF_INET6
498 && IN6_IS_ADDR_LINKLOCAL(&api.prefix.u.prefix6))
499 return 0;
500
501 /*
502 * Avoid advertising a false default reachability. (A default
503 * route installed by IS-IS gets redistributed from zebra back
504 * into IS-IS causing us to start advertising default reachabity
505 * without this check)
506 */
507 if (api.prefix.prefixlen == 0
508 && api.src_prefix.prefixlen == 0
509 && api.type == PROTO_TYPE) {
510 cmd = ZEBRA_REDISTRIBUTE_ROUTE_DEL;
511 }
512
513 if (cmd == ZEBRA_REDISTRIBUTE_ROUTE_ADD)
514 isis_redist_add(isis, api.type, &api.prefix, &api.src_prefix,
515 api.distance, api.metric);
516 else
517 isis_redist_delete(isis, api.type, &api.prefix,
518 &api.src_prefix);
519
520 return 0;
521}
522
523int isis_distribute_list_update(int routetype)
524{
525 return 0;
526}
527
528void isis_zebra_redistribute_set(afi_t afi, int type)
529{
530 if (type == DEFAULT_ROUTE)
531 zclient_redistribute_default(ZEBRA_REDISTRIBUTE_DEFAULT_ADD,
532 zclient, afi, VRF_DEFAULT);
533 else
534 zclient_redistribute(ZEBRA_REDISTRIBUTE_ADD, zclient, afi, type,
535 0, VRF_DEFAULT);
536}
537
538void isis_zebra_redistribute_unset(afi_t afi, int type)
539{
540 if (type == DEFAULT_ROUTE)
541 zclient_redistribute_default(ZEBRA_REDISTRIBUTE_DEFAULT_DELETE,
542 zclient, afi, VRF_DEFAULT);
543 else
544 zclient_redistribute(ZEBRA_REDISTRIBUTE_DELETE, zclient, afi,
545 type, 0, VRF_DEFAULT);
546}
547
548/* Label Manager Functions */
549
550/**
551 * Check if Label Manager is Ready or not.
552 *
553 * @return True if Label Manager is ready, False otherwise
554 */
555bool isis_zebra_label_manager_ready(void)
556{
557 return (zclient_sync->sock > 0);
558}
559
560/**
561 * Request Label Range to the Label Manager.
562 *
563 * @param base base label of the label range to request
564 * @param chunk_size size of the label range to request
565 *
566 * @return 0 on success, -1 on failure
567 */
568int isis_zebra_request_label_range(uint32_t base, uint32_t chunk_size)
569{
570 int ret;
571 uint32_t start, end;
572
573 if (zclient_sync->sock < 0)
574 return -1;
575
576 ret = lm_get_label_chunk(zclient_sync, 0, base, chunk_size, &start,
577 &end);
578 if (ret < 0) {
579 zlog_warn("%s: error getting label range!", __func__);
580 return -1;
581 }
582
583 return 0;
584}
585
586/**
587 * Release Label Range to the Label Manager.
588 *
589 * @param start start of label range to release
590 * @param end end of label range to release
591 *
592 * @return 0 on success, -1 otherwise
593 */
594int isis_zebra_release_label_range(uint32_t start, uint32_t end)
595{
596 int ret;
597
598 if (zclient_sync->sock < 0)
599 return -1;
600
601 ret = lm_release_label_chunk(zclient_sync, start, end);
602 if (ret < 0) {
603 zlog_warn("%s: error releasing label range!", __func__);
604 return -1;
605 }
606
607 return 0;
608}
609
610/**
611 * Connect to the Label Manager.
612 *
613 * @return 0 on success, -1 otherwise
614 */
615int isis_zebra_label_manager_connect(void)
616{
617 /* Connect to label manager. */
618 if (zclient_socket_connect(zclient_sync) < 0) {
619 zlog_warn("%s: failed connecting synchronous zclient!",
620 __func__);
621 return -1;
622 }
623 /* make socket non-blocking */
624 set_nonblocking(zclient_sync->sock);
625
626 /* Send hello to notify zebra this is a synchronous client */
627 if (zclient_send_hello(zclient_sync) == ZCLIENT_SEND_FAILURE) {
628 zlog_warn("%s: failed sending hello for synchronous zclient!",
629 __func__);
630 close(zclient_sync->sock);
631 zclient_sync->sock = -1;
632 return -1;
633 }
634
635 /* Connect to label manager */
636 if (lm_label_manager_connect(zclient_sync, 0) != 0) {
637 zlog_warn("%s: failed connecting to label manager!", __func__);
638 if (zclient_sync->sock > 0) {
639 close(zclient_sync->sock);
640 zclient_sync->sock = -1;
641 }
642 return -1;
643 }
644
645 sr_debug("ISIS-Sr: Successfully connected to the Label Manager");
646
647 return 0;
648}
649
650void isis_zebra_vrf_register(struct isis *isis)
651{
652 if (!zclient || zclient->sock < 0 || !isis)
653 return;
654
655 if (isis->vrf_id != VRF_UNKNOWN) {
656 if (IS_DEBUG_EVENTS)
657 zlog_debug("%s: Register VRF %s id %u", __func__,
658 isis->name, isis->vrf_id);
659 zclient_send_reg_requests(zclient, isis->vrf_id);
660 }
661}
662
663
664static void isis_zebra_connected(struct zclient *zclient)
665{
666 zclient_send_reg_requests(zclient, VRF_DEFAULT);
667}
668
669/*
670 * opaque messages between processes
671 */
672static int isis_opaque_msg_handler(ZAPI_CALLBACK_ARGS)
673{
674 struct stream *s;
675 struct zapi_opaque_msg info;
676 struct ldp_igp_sync_if_state state;
677 struct ldp_igp_sync_announce announce;
678 struct ldp_igp_sync_hello hello;
679 int ret = 0;
680
681 s = zclient->ibuf;
682 if (zclient_opaque_decode(s, &info) != 0)
683 return -1;
684
685 switch (info.type) {
686 case LDP_IGP_SYNC_IF_STATE_UPDATE:
687 STREAM_GET(&state, s, sizeof(state));
688 ret = isis_ldp_sync_state_update(state);
689 break;
690 case LDP_IGP_SYNC_ANNOUNCE_UPDATE:
691 STREAM_GET(&announce, s, sizeof(announce));
692 ret = isis_ldp_sync_announce_update(announce);
693 break;
694 case LDP_IGP_SYNC_HELLO_UPDATE:
695 STREAM_GET(&hello, s, sizeof(hello));
696 ret = isis_ldp_sync_hello_update(hello);
697 break;
698 default:
699 break;
700 }
701
702stream_failure:
703
704 return ret;
705}
706
707void isis_zebra_init(struct thread_master *master, int instance)
708{
709 /* Initialize asynchronous zclient. */
710 zclient = zclient_new(master, &zclient_options_default);
711 zclient_init(zclient, PROTO_TYPE, 0, &isisd_privs);
712 zclient->zebra_connected = isis_zebra_connected;
713 zclient->router_id_update = isis_router_id_update_zebra;
714 zclient->interface_address_add = isis_zebra_if_address_add;
715 zclient->interface_address_delete = isis_zebra_if_address_del;
716 zclient->interface_link_params = isis_zebra_link_params;
717 zclient->redistribute_route_add = isis_zebra_read;
718 zclient->redistribute_route_del = isis_zebra_read;
719
720 /* Initialize special zclient for synchronous message exchanges. */
721 struct zclient_options options = zclient_options_default;
722 options.synchronous = true;
723 zclient_sync = zclient_new(master, &options);
724 zclient_sync->sock = -1;
725 zclient_sync->redist_default = ZEBRA_ROUTE_ISIS;
726 zclient_sync->instance = instance;
727 /*
728 * session_id must be different from default value (0) to distinguish
729 * the asynchronous socket from the synchronous one
730 */
731 zclient_sync->session_id = 1;
732 zclient_sync->privs = &isisd_privs;
733
734 zclient->opaque_msg_handler = isis_opaque_msg_handler;
735}
736
737void isis_zebra_stop(void)
738{
739 zclient_stop(zclient_sync);
740 zclient_free(zclient_sync);
741 zclient_stop(zclient);
742 zclient_free(zclient);
743 frr_fini();
744}