]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_zebra.c
3b128a689d78e3015aff0be025108132156de7d6
[mirror_frr.git] / isisd / isis_zebra.c
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; if not, write to the Free Software Foundation, Inc.,
21 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 "if.h"
31 #include "network.h"
32 #include "prefix.h"
33 #include "zclient.h"
34 #include "stream.h"
35 #include "linklist.h"
36 #include "nexthop.h"
37 #include "vrf.h"
38
39 #include "isisd/dict.h"
40 #include "isisd/isis_constants.h"
41 #include "isisd/isis_common.h"
42 #include "isisd/isis_flags.h"
43 #include "isisd/isis_misc.h"
44 #include "isisd/isis_circuit.h"
45 #include "isisd/isis_tlv.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_te.h"
53
54 struct zclient *zclient = NULL;
55
56 /* Router-id update message from zebra. */
57 static int
58 isis_router_id_update_zebra (int command, struct zclient *zclient,
59 zebra_size_t length, vrf_id_t vrf_id)
60 {
61 struct isis_area *area;
62 struct listnode *node;
63 struct prefix router_id;
64
65 /*
66 * If ISIS TE is enable, TE Router ID is set through specific command.
67 * See mpls_te_router_addr() command in isis_te.c
68 */
69 if (IS_MPLS_TE(isisMplsTE))
70 return 0;
71
72 zebra_router_id_update_read (zclient->ibuf, &router_id);
73 if (isis->router_id == router_id.u.prefix4.s_addr)
74 return 0;
75
76 isis->router_id = router_id.u.prefix4.s_addr;
77 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
78 if (listcount (area->area_addrs) > 0)
79 lsp_regenerate_schedule (area, area->is_type, 0);
80
81 return 0;
82 }
83
84 static int
85 isis_zebra_if_add (int command, struct zclient *zclient, zebra_size_t length,
86 vrf_id_t vrf_id)
87 {
88 struct interface *ifp;
89
90 ifp = zebra_interface_add_read (zclient->ibuf, vrf_id);
91
92 if (isis->debugs & DEBUG_ZEBRA)
93 zlog_debug ("Zebra I/F add: %s index %d flags %ld metric %d mtu %d",
94 ifp->name, ifp->ifindex, (long)ifp->flags, ifp->metric, ifp->mtu);
95
96 if (if_is_operative (ifp))
97 isis_csm_state_change (IF_UP_FROM_Z, circuit_scan_by_ifp (ifp), ifp);
98
99 return 0;
100 }
101
102 static int
103 isis_zebra_if_del (int command, struct zclient *zclient, zebra_size_t length,
104 vrf_id_t vrf_id)
105 {
106 struct interface *ifp;
107 struct stream *s;
108
109 s = zclient->ibuf;
110 ifp = zebra_interface_state_read (s, vrf_id);
111
112 if (!ifp)
113 return 0;
114
115 if (if_is_operative (ifp))
116 zlog_warn ("Zebra: got delete of %s, but interface is still up",
117 ifp->name);
118
119 if (isis->debugs & DEBUG_ZEBRA)
120 zlog_debug ("Zebra I/F delete: %s index %d flags %ld metric %d mtu %d",
121 ifp->name, ifp->ifindex, (long)ifp->flags, ifp->metric, ifp->mtu);
122
123 isis_csm_state_change (IF_DOWN_FROM_Z, circuit_scan_by_ifp (ifp), ifp);
124
125 /* Cannot call if_delete because we should retain the pseudo interface
126 in case there is configuration info attached to it. */
127 if_delete_retain(ifp);
128
129 ifp->ifindex = IFINDEX_DELETED;
130
131 return 0;
132 }
133
134 static int
135 isis_zebra_if_state_up (int command, struct zclient *zclient,
136 zebra_size_t length, vrf_id_t vrf_id)
137 {
138 struct interface *ifp;
139
140 ifp = zebra_interface_state_read (zclient->ibuf, vrf_id);
141
142 if (ifp == NULL)
143 return 0;
144
145 isis_csm_state_change (IF_UP_FROM_Z, circuit_scan_by_ifp (ifp), ifp);
146
147 return 0;
148 }
149
150 static int
151 isis_zebra_if_state_down (int command, struct zclient *zclient,
152 zebra_size_t length, vrf_id_t vrf_id)
153 {
154 struct interface *ifp;
155 struct isis_circuit *circuit;
156
157 ifp = zebra_interface_state_read (zclient->ibuf, vrf_id);
158
159 if (ifp == NULL)
160 return 0;
161
162 circuit = isis_csm_state_change (IF_DOWN_FROM_Z, circuit_scan_by_ifp (ifp),
163 ifp);
164 if (circuit)
165 SET_FLAG(circuit->flags, ISIS_CIRCUIT_FLAPPED_AFTER_SPF);
166
167 return 0;
168 }
169
170 static int
171 isis_zebra_if_address_add (int command, struct zclient *zclient,
172 zebra_size_t length, vrf_id_t vrf_id)
173 {
174 struct connected *c;
175 struct prefix *p;
176 char buf[PREFIX2STR_BUFFER];
177
178 c = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD,
179 zclient->ibuf, vrf_id);
180
181 if (c == NULL)
182 return 0;
183
184 p = c->address;
185
186 prefix2str (p, buf, sizeof (buf));
187 #ifdef EXTREME_DEBUG
188 if (p->family == AF_INET)
189 zlog_debug ("connected IP address %s", buf);
190 if (p->family == AF_INET6)
191 zlog_debug ("connected IPv6 address %s", buf);
192 #endif /* EXTREME_DEBUG */
193 if (if_is_operative (c->ifp))
194 isis_circuit_add_addr (circuit_scan_by_ifp (c->ifp), c);
195
196 return 0;
197 }
198
199 static int
200 isis_zebra_if_address_del (int command, struct zclient *client,
201 zebra_size_t length, vrf_id_t vrf_id)
202 {
203 struct connected *c;
204 struct interface *ifp;
205 #ifdef EXTREME_DEBUG
206 struct prefix *p;
207 char buf[PREFIX2STR_BUFFER];
208 #endif /* EXTREME_DEBUG */
209
210 c = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE,
211 zclient->ibuf, vrf_id);
212
213 if (c == NULL)
214 return 0;
215
216 ifp = c->ifp;
217
218 #ifdef EXTREME_DEBUG
219 p = c->address;
220 prefix2str (p, buf, sizeof (buf));
221
222 if (p->family == AF_INET)
223 zlog_debug ("disconnected IP address %s", buf);
224 if (p->family == AF_INET6)
225 zlog_debug ("disconnected IPv6 address %s", buf);
226 #endif /* EXTREME_DEBUG */
227
228 if (if_is_operative (ifp))
229 isis_circuit_del_addr (circuit_scan_by_ifp (ifp), c);
230 connected_free (c);
231
232 return 0;
233 }
234
235 static int
236 isis_zebra_link_params (int command, struct zclient *zclient,
237 zebra_size_t length)
238 {
239 struct interface *ifp;
240
241 ifp = zebra_interface_link_params_read (zclient->ibuf);
242
243 if (ifp == NULL)
244 return 0;
245
246 /* Update TE TLV */
247 isis_mpls_te_update(ifp);
248
249 return 0;
250 }
251
252 static void
253 isis_zebra_route_add_ipv4 (struct prefix *prefix,
254 struct isis_route_info *route_info)
255 {
256 u_char message;
257 u_int32_t flags;
258 int psize;
259 struct stream *stream;
260 struct isis_nexthop *nexthop;
261 struct listnode *node;
262
263 if (CHECK_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED))
264 return;
265
266 if (vrf_bitmap_check (zclient->redist[AFI_IP][ZEBRA_ROUTE_ISIS], VRF_DEFAULT))
267 {
268 message = 0;
269 flags = 0;
270
271 SET_FLAG (message, ZAPI_MESSAGE_NEXTHOP);
272 SET_FLAG (message, ZAPI_MESSAGE_METRIC);
273 #if 0
274 SET_FLAG (message, ZAPI_MESSAGE_DISTANCE);
275 #endif
276
277 stream = zclient->obuf;
278 stream_reset (stream);
279 zclient_create_header (stream, ZEBRA_IPV4_ROUTE_ADD, VRF_DEFAULT);
280 /* type */
281 stream_putc (stream, ZEBRA_ROUTE_ISIS);
282 /* instance */
283 stream_putw (stream, 0);
284 /* flags */
285 stream_putl (stream, flags);
286 /* message */
287 stream_putc (stream, message);
288 /* SAFI */
289 stream_putw (stream, SAFI_UNICAST);
290 /* prefix information */
291 psize = PSIZE (prefix->prefixlen);
292 stream_putc (stream, prefix->prefixlen);
293 stream_write (stream, (u_char *) & prefix->u.prefix4, psize);
294
295 stream_putc (stream, listcount (route_info->nexthops));
296
297 /* Nexthop, ifindex, distance and metric information */
298 for (ALL_LIST_ELEMENTS_RO (route_info->nexthops, node, nexthop))
299 {
300 /* FIXME: can it be ? */
301 if (nexthop->ip.s_addr != INADDR_ANY)
302 {
303 stream_putc (stream, NEXTHOP_TYPE_IPV4_IFINDEX);
304 stream_put_in_addr (stream, &nexthop->ip);
305 stream_putl (stream, nexthop->ifindex);
306 }
307 else
308 {
309 stream_putc (stream, NEXTHOP_TYPE_IFINDEX);
310 stream_putl (stream, nexthop->ifindex);
311 }
312 }
313 #if 0
314 if (CHECK_FLAG (message, ZAPI_MESSAGE_DISTANCE))
315 stream_putc (stream, route_info->depth);
316 #endif
317 if (CHECK_FLAG (message, ZAPI_MESSAGE_METRIC))
318 stream_putl (stream, route_info->cost);
319
320 stream_putw_at (stream, 0, stream_get_endp (stream));
321 zclient_send_message(zclient);
322 SET_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED);
323 UNSET_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_RESYNC);
324 }
325 }
326
327 static void
328 isis_zebra_route_del_ipv4 (struct prefix *prefix,
329 struct isis_route_info *route_info)
330 {
331 struct zapi_ipv4 api;
332 struct prefix_ipv4 prefix4;
333
334 if (vrf_bitmap_check (zclient->redist[AFI_IP][ZEBRA_ROUTE_ISIS], VRF_DEFAULT))
335 {
336 api.vrf_id = VRF_DEFAULT;
337 api.type = ZEBRA_ROUTE_ISIS;
338 api.instance = 0;
339 api.flags = 0;
340 api.message = 0;
341 api.safi = SAFI_UNICAST;
342 prefix4.family = AF_INET;
343 prefix4.prefixlen = prefix->prefixlen;
344 prefix4.prefix = prefix->u.prefix4;
345 zapi_ipv4_route (ZEBRA_IPV4_ROUTE_DELETE, zclient, &prefix4, &api);
346 }
347 UNSET_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED);
348
349 return;
350 }
351
352 static void
353 isis_zebra_route_add_ipv6 (struct prefix *prefix,
354 struct isis_route_info *route_info)
355 {
356 struct zapi_ipv6 api;
357 struct in6_addr **nexthop_list;
358 ifindex_t *ifindex_list;
359 struct isis_nexthop6 *nexthop6;
360 int i, size;
361 struct listnode *node;
362 struct prefix_ipv6 prefix6;
363
364 if (CHECK_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED))
365 return;
366
367 api.vrf_id = VRF_DEFAULT;
368 api.type = ZEBRA_ROUTE_ISIS;
369 api.instance = 0;
370 api.flags = 0;
371 api.message = 0;
372 api.safi = SAFI_UNICAST;
373 SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
374 SET_FLAG (api.message, ZAPI_MESSAGE_IFINDEX);
375 SET_FLAG (api.message, ZAPI_MESSAGE_METRIC);
376 api.metric = route_info->cost;
377 #if 0
378 SET_FLAG (api.message, ZAPI_MESSAGE_DISTANCE);
379 api.distance = route_info->depth;
380 #endif
381 api.nexthop_num = listcount (route_info->nexthops6);
382 api.ifindex_num = listcount (route_info->nexthops6);
383
384 /* allocate memory for nexthop_list */
385 size = sizeof (struct isis_nexthop6 *) * listcount (route_info->nexthops6);
386 nexthop_list = (struct in6_addr **) XMALLOC (MTYPE_ISIS_TMP, size);
387 if (!nexthop_list)
388 {
389 zlog_err ("isis_zebra_add_route_ipv6: out of memory!");
390 return;
391 }
392
393 /* allocate memory for ifindex_list */
394 size = sizeof (unsigned int) * listcount (route_info->nexthops6);
395 ifindex_list = (ifindex_t *) XMALLOC (MTYPE_ISIS_TMP, size);
396 if (!ifindex_list)
397 {
398 zlog_err ("isis_zebra_add_route_ipv6: out of memory!");
399 XFREE (MTYPE_ISIS_TMP, nexthop_list);
400 return;
401 }
402
403 /* for each nexthop */
404 i = 0;
405 for (ALL_LIST_ELEMENTS_RO (route_info->nexthops6, node, nexthop6))
406 {
407 if (!IN6_IS_ADDR_LINKLOCAL (&nexthop6->ip6) &&
408 !IN6_IS_ADDR_UNSPECIFIED (&nexthop6->ip6))
409 {
410 api.nexthop_num--;
411 api.ifindex_num--;
412 continue;
413 }
414
415 nexthop_list[i] = &nexthop6->ip6;
416 ifindex_list[i] = nexthop6->ifindex;
417 i++;
418 }
419
420 api.nexthop = nexthop_list;
421 api.ifindex = ifindex_list;
422
423 if (api.nexthop_num && api.ifindex_num)
424 {
425 prefix6.family = AF_INET6;
426 prefix6.prefixlen = prefix->prefixlen;
427 memcpy (&prefix6.prefix, &prefix->u.prefix6, sizeof (struct in6_addr));
428 zapi_ipv6_route (ZEBRA_IPV6_ROUTE_ADD, zclient, &prefix6, NULL, &api);
429 SET_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED);
430 UNSET_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_RESYNC);
431 }
432
433 XFREE (MTYPE_ISIS_TMP, nexthop_list);
434 XFREE (MTYPE_ISIS_TMP, ifindex_list);
435
436 return;
437 }
438
439 static void
440 isis_zebra_route_del_ipv6 (struct prefix *prefix,
441 struct isis_route_info *route_info)
442 {
443 struct zapi_ipv6 api;
444 struct in6_addr **nexthop_list;
445 ifindex_t *ifindex_list;
446 struct isis_nexthop6 *nexthop6;
447 int i, size;
448 struct listnode *node;
449 struct prefix_ipv6 prefix6;
450
451 if (!CHECK_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED))
452 return;
453
454 api.vrf_id = VRF_DEFAULT;
455 api.type = ZEBRA_ROUTE_ISIS;
456 api.instance = 0;
457 api.flags = 0;
458 api.message = 0;
459 api.safi = SAFI_UNICAST;
460 SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
461 SET_FLAG (api.message, ZAPI_MESSAGE_IFINDEX);
462 api.nexthop_num = listcount (route_info->nexthops6);
463 api.ifindex_num = listcount (route_info->nexthops6);
464
465 /* allocate memory for nexthop_list */
466 size = sizeof (struct isis_nexthop6 *) * listcount (route_info->nexthops6);
467 nexthop_list = (struct in6_addr **) XMALLOC (MTYPE_ISIS_TMP, size);
468 if (!nexthop_list)
469 {
470 zlog_err ("isis_zebra_route_del_ipv6: out of memory!");
471 return;
472 }
473
474 /* allocate memory for ifindex_list */
475 size = sizeof (unsigned int) * listcount (route_info->nexthops6);
476 ifindex_list = (ifindex_t *) XMALLOC (MTYPE_ISIS_TMP, size);
477 if (!ifindex_list)
478 {
479 zlog_err ("isis_zebra_route_del_ipv6: out of memory!");
480 XFREE (MTYPE_ISIS_TMP, nexthop_list);
481 return;
482 }
483
484 /* for each nexthop */
485 i = 0;
486 for (ALL_LIST_ELEMENTS_RO (route_info->nexthops6, node, nexthop6))
487 {
488 if (!IN6_IS_ADDR_LINKLOCAL (&nexthop6->ip6) &&
489 !IN6_IS_ADDR_UNSPECIFIED (&nexthop6->ip6))
490 {
491 api.nexthop_num--;
492 api.ifindex_num--;
493 continue;
494 }
495
496 nexthop_list[i] = &nexthop6->ip6;
497 ifindex_list[i] = nexthop6->ifindex;
498 i++;
499 }
500
501 api.nexthop = nexthop_list;
502 api.ifindex = ifindex_list;
503
504 if (api.nexthop_num && api.ifindex_num)
505 {
506 prefix6.family = AF_INET6;
507 prefix6.prefixlen = prefix->prefixlen;
508 memcpy (&prefix6.prefix, &prefix->u.prefix6, sizeof (struct in6_addr));
509 zapi_ipv6_route (ZEBRA_IPV6_ROUTE_DELETE, zclient, &prefix6, NULL, &api);
510 UNSET_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED);
511 }
512
513 XFREE (MTYPE_ISIS_TMP, nexthop_list);
514 XFREE (MTYPE_ISIS_TMP, ifindex_list);
515 }
516
517 void
518 isis_zebra_route_update (struct prefix *prefix,
519 struct isis_route_info *route_info)
520 {
521 if (zclient->sock < 0)
522 return;
523
524 if ((prefix->family == AF_INET && !vrf_bitmap_check (zclient->redist[AFI_IP][ZEBRA_ROUTE_ISIS], VRF_DEFAULT)) ||
525 (prefix->family == AF_INET6 && !vrf_bitmap_check (zclient->redist[AFI_IP6][ZEBRA_ROUTE_ISIS], VRF_DEFAULT)))
526 return;
527
528 if (CHECK_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ACTIVE))
529 {
530 if (prefix->family == AF_INET)
531 isis_zebra_route_add_ipv4 (prefix, route_info);
532 else if (prefix->family == AF_INET6)
533 isis_zebra_route_add_ipv6 (prefix, route_info);
534 }
535 else
536 {
537 if (prefix->family == AF_INET)
538 isis_zebra_route_del_ipv4 (prefix, route_info);
539 else if (prefix->family == AF_INET6)
540 isis_zebra_route_del_ipv6 (prefix, route_info);
541 }
542 return;
543 }
544
545 static int
546 isis_zebra_read_ipv4 (int command, struct zclient *zclient,
547 zebra_size_t length, vrf_id_t vrf_id)
548 {
549 struct stream *stream;
550 struct zapi_ipv4 api;
551 struct prefix_ipv4 p;
552 struct prefix *p_generic = (struct prefix*)&p;
553
554 stream = zclient->ibuf;
555 memset(&api, 0, sizeof(api));
556 memset (&p, 0, sizeof (struct prefix_ipv4));
557
558 api.type = stream_getc (stream);
559 api.instance = stream_getw (stream);
560 api.flags = stream_getl (stream);
561 api.message = stream_getc (stream);
562
563 p.family = AF_INET;
564 p.prefixlen = MIN(IPV4_MAX_PREFIXLEN, stream_getc (stream));
565 stream_get (&p.prefix, stream, PSIZE (p.prefixlen));
566
567 if (CHECK_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP))
568 {
569 api.nexthop_num = stream_getc (stream);
570 (void)stream_get_ipv4 (stream);
571 }
572 if (CHECK_FLAG (api.message, ZAPI_MESSAGE_IFINDEX))
573 {
574 api.ifindex_num = stream_getc (stream);
575 stream_getl (stream);
576 }
577 if (CHECK_FLAG (api.message, ZAPI_MESSAGE_DISTANCE))
578 api.distance = stream_getc (stream);
579 if (CHECK_FLAG (api.message, ZAPI_MESSAGE_METRIC))
580 api.metric = stream_getl (stream);
581
582 /*
583 * Avoid advertising a false default reachability. (A default
584 * route installed by IS-IS gets redistributed from zebra back
585 * into IS-IS causing us to start advertising default reachabity
586 * without this check)
587 */
588 if (p.prefixlen == 0 && api.type == ZEBRA_ROUTE_ISIS)
589 command = ZEBRA_IPV4_ROUTE_DELETE;
590
591 if (command == ZEBRA_REDISTRIBUTE_IPV4_ADD)
592 isis_redist_add(api.type, p_generic, api.distance, api.metric);
593 else
594 isis_redist_delete(api.type, p_generic);
595
596 return 0;
597 }
598
599 static int
600 isis_zebra_read_ipv6 (int command, struct zclient *zclient,
601 zebra_size_t length, vrf_id_t vrf_id)
602 {
603 struct stream *stream;
604 struct zapi_ipv6 api;
605 struct prefix_ipv6 p;
606 struct prefix *p_generic = (struct prefix*)&p;
607 struct in6_addr nexthop;
608 unsigned long ifindex __attribute__((unused));
609
610 stream = zclient->ibuf;
611 memset(&api, 0, sizeof(api));
612 memset(&p, 0, sizeof(struct prefix_ipv6));
613 memset(&nexthop, 0, sizeof(nexthop));
614 ifindex = 0;
615
616 api.type = stream_getc(stream);
617 api.flags = stream_getl(stream);
618 api.message = stream_getc(stream);
619
620 p.family = AF_INET6;
621 p.prefixlen = stream_getc(stream);
622 stream_get(&p.prefix, stream, PSIZE(p.prefixlen));
623
624 if (CHECK_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP))
625 {
626 api.nexthop_num = stream_getc(stream); /* this is always 1 */
627 stream_get(&nexthop, stream, sizeof(nexthop));
628 }
629 if (CHECK_FLAG(api.message, ZAPI_MESSAGE_IFINDEX))
630 {
631 api.ifindex_num = stream_getc(stream);
632 ifindex = stream_getl(stream);
633 }
634 if (CHECK_FLAG(api.message, ZAPI_MESSAGE_DISTANCE))
635 api.distance = stream_getc(stream);
636 if (CHECK_FLAG(api.message, ZAPI_MESSAGE_METRIC))
637 api.metric = stream_getl(stream);
638
639 /*
640 * Avoid advertising a false default reachability. (A default
641 * route installed by IS-IS gets redistributed from zebra back
642 * into IS-IS causing us to start advertising default reachabity
643 * without this check)
644 */
645 if (p.prefixlen == 0 && api.type == ZEBRA_ROUTE_ISIS)
646 command = ZEBRA_IPV6_ROUTE_DELETE;
647
648 if (command == ZEBRA_IPV6_ROUTE_ADD)
649 isis_redist_add(api.type, p_generic, api.distance, api.metric);
650 else
651 isis_redist_delete(api.type, p_generic);
652
653 return 0;
654 }
655
656 int
657 isis_distribute_list_update (int routetype)
658 {
659 return 0;
660 }
661
662 void
663 isis_zebra_redistribute_set(int type)
664 {
665 if (type == DEFAULT_ROUTE)
666 zclient_redistribute_default(ZEBRA_REDISTRIBUTE_DEFAULT_ADD, zclient, VRF_DEFAULT);
667 else
668 zclient_redistribute(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, type, 0, VRF_DEFAULT);
669 }
670
671 void
672 isis_zebra_redistribute_unset(int type)
673 {
674 if (type == DEFAULT_ROUTE)
675 zclient_redistribute_default(ZEBRA_REDISTRIBUTE_DEFAULT_DELETE, zclient, VRF_DEFAULT);
676 else
677 zclient_redistribute(ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP, type, 0, VRF_DEFAULT);
678 }
679
680 static void
681 isis_zebra_connected (struct zclient *zclient)
682 {
683 zclient_send_reg_requests (zclient, VRF_DEFAULT);
684 }
685
686 void
687 isis_zebra_init (struct thread_master *master)
688 {
689 zclient = zclient_new (master);
690 zclient_init (zclient, ZEBRA_ROUTE_ISIS, 0);
691 zclient->zebra_connected = isis_zebra_connected;
692 zclient->router_id_update = isis_router_id_update_zebra;
693 zclient->interface_add = isis_zebra_if_add;
694 zclient->interface_delete = isis_zebra_if_del;
695 zclient->interface_up = isis_zebra_if_state_up;
696 zclient->interface_down = isis_zebra_if_state_down;
697 zclient->interface_address_add = isis_zebra_if_address_add;
698 zclient->interface_address_delete = isis_zebra_if_address_del;
699 zclient->interface_link_params = isis_zebra_link_params;
700 zclient->redistribute_route_ipv4_add = isis_zebra_read_ipv4;
701 zclient->redistribute_route_ipv4_del = isis_zebra_read_ipv4;
702 zclient->redistribute_route_ipv6_add = isis_zebra_read_ipv6;
703 zclient->redistribute_route_ipv6_del = isis_zebra_read_ipv6;
704
705 return;
706 }