]> git.proxmox.com Git - mirror_frr.git/blob - ospfd/ospf_zebra.c
Merge pull request #1034 from dwalton76/bgpd-mpls-fec-allocate
[mirror_frr.git] / ospfd / ospf_zebra.c
1 /*
2 * Zebra connect library for OSPFd
3 * Copyright (C) 1997, 98, 99, 2000 Kunihiro Ishiguro, Toshiaki Takada
4 *
5 * This file is part of GNU Zebra.
6 *
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include <zebra.h>
23
24 #include "thread.h"
25 #include "command.h"
26 #include "network.h"
27 #include "prefix.h"
28 #include "routemap.h"
29 #include "table.h"
30 #include "stream.h"
31 #include "memory.h"
32 #include "zclient.h"
33 #include "filter.h"
34 #include "plist.h"
35 #include "log.h"
36 #include "lib/bfd.h"
37 #include "nexthop.h"
38
39 #include "ospfd/ospfd.h"
40 #include "ospfd/ospf_interface.h"
41 #include "ospfd/ospf_ism.h"
42 #include "ospfd/ospf_asbr.h"
43 #include "ospfd/ospf_asbr.h"
44 #include "ospfd/ospf_abr.h"
45 #include "ospfd/ospf_lsa.h"
46 #include "ospfd/ospf_dump.h"
47 #include "ospfd/ospf_route.h"
48 #include "ospfd/ospf_lsdb.h"
49 #include "ospfd/ospf_neighbor.h"
50 #include "ospfd/ospf_nsm.h"
51 #include "ospfd/ospf_zebra.h"
52 #include "ospfd/ospf_te.h"
53
54 DEFINE_MTYPE_STATIC(OSPFD, OSPF_EXTERNAL, "OSPF External route table")
55 DEFINE_MTYPE_STATIC(OSPFD, OSPF_REDISTRIBUTE, "OSPF Redistriute")
56
57 DEFINE_HOOK(ospf_if_update, (struct interface * ifp), (ifp))
58 DEFINE_HOOK(ospf_if_delete, (struct interface * ifp), (ifp))
59
60 /* Zebra structure to hold current status. */
61 struct zclient *zclient = NULL;
62
63 /* For registering threads. */
64 extern struct thread_master *master;
65 struct in_addr router_id_zebra;
66
67 /* Router-id update message from zebra. */
68 static int ospf_router_id_update_zebra(int command, struct zclient *zclient,
69 zebra_size_t length, vrf_id_t vrf_id)
70 {
71 struct ospf *ospf;
72 struct prefix router_id;
73 zebra_router_id_update_read(zclient->ibuf, &router_id);
74
75 if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE)) {
76 char buf[PREFIX2STR_BUFFER];
77 prefix2str(&router_id, buf, sizeof(buf));
78 zlog_debug("Zebra rcvd: router id update %s", buf);
79 }
80
81 router_id_zebra = router_id.u.prefix4;
82
83 ospf = ospf_lookup();
84
85 if (ospf != NULL)
86 ospf_router_id_update(ospf);
87
88 return 0;
89 }
90
91 /* Inteface addition message from zebra. */
92 static int ospf_interface_add(int command, struct zclient *zclient,
93 zebra_size_t length, vrf_id_t vrf_id)
94 {
95 struct interface *ifp;
96
97 ifp = zebra_interface_add_read(zclient->ibuf, vrf_id);
98
99 if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE))
100 zlog_debug(
101 "Zebra: interface add %s[%u] index %d flags %llx metric %d mtu %d",
102 ifp->name, ifp->vrf_id, ifp->ifindex,
103 (unsigned long long)ifp->flags, ifp->metric, ifp->mtu);
104
105 assert(ifp->info);
106
107 if (!OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp), type)) {
108 SET_IF_PARAM(IF_DEF_PARAMS(ifp), type);
109 IF_DEF_PARAMS(ifp)->type = ospf_default_iftype(ifp);
110 }
111
112 ospf_if_update(NULL, ifp);
113
114 hook_call(ospf_if_update, ifp);
115
116 return 0;
117 }
118
119 static int ospf_interface_delete(int command, struct zclient *zclient,
120 zebra_size_t length, vrf_id_t vrf_id)
121 {
122 struct interface *ifp;
123 struct stream *s;
124 struct route_node *rn;
125
126 s = zclient->ibuf;
127 /* zebra_interface_state_read() updates interface structure in iflist */
128 ifp = zebra_interface_state_read(s, vrf_id);
129
130 if (ifp == NULL)
131 return 0;
132
133 if (if_is_up(ifp))
134 zlog_warn("Zebra: got delete of %s, but interface is still up",
135 ifp->name);
136
137 if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE))
138 zlog_debug(
139 "Zebra: interface delete %s[%u] index %d flags %llx metric %d mtu %d",
140 ifp->name, ifp->vrf_id, ifp->ifindex,
141 (unsigned long long)ifp->flags, ifp->metric, ifp->mtu);
142
143 hook_call(ospf_if_delete, ifp);
144
145 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn))
146 if (rn->info)
147 ospf_if_free((struct ospf_interface *)rn->info);
148
149 ifp->ifindex = IFINDEX_DELETED;
150 return 0;
151 }
152
153 static struct interface *zebra_interface_if_lookup(struct stream *s,
154 vrf_id_t vrf_id)
155 {
156 char ifname_tmp[INTERFACE_NAMSIZ];
157
158 /* Read interface name. */
159 stream_get(ifname_tmp, s, INTERFACE_NAMSIZ);
160
161 /* And look it up. */
162 return if_lookup_by_name_len(
163 ifname_tmp, strnlen(ifname_tmp, INTERFACE_NAMSIZ), VRF_DEFAULT);
164 }
165
166 static int ospf_interface_state_up(int command, struct zclient *zclient,
167 zebra_size_t length, vrf_id_t vrf_id)
168 {
169 struct interface *ifp;
170 struct ospf_interface *oi;
171 struct route_node *rn;
172
173 ifp = zebra_interface_if_lookup(zclient->ibuf, vrf_id);
174
175 if (ifp == NULL)
176 return 0;
177
178 /* Interface is already up. */
179 if (if_is_operative(ifp)) {
180 /* Temporarily keep ifp values. */
181 struct interface if_tmp;
182 memcpy(&if_tmp, ifp, sizeof(struct interface));
183
184 zebra_interface_if_set_value(zclient->ibuf, ifp);
185
186 if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE))
187 zlog_debug(
188 "Zebra: Interface[%s] state update speed %u -> %u, bw %d -> %d",
189 ifp->name, if_tmp.speed, ifp->speed,
190 if_tmp.bandwidth, ifp->bandwidth);
191
192 ospf_if_recalculate_output_cost(ifp);
193
194 if (if_tmp.mtu != ifp->mtu) {
195 if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE))
196 zlog_debug(
197 "Zebra: Interface[%s] MTU change %u -> %u.",
198 ifp->name, if_tmp.mtu, ifp->mtu);
199
200 /* Must reset the interface (simulate down/up) when MTU
201 * changes. */
202 ospf_if_reset(ifp);
203 }
204 return 0;
205 }
206
207 zebra_interface_if_set_value(zclient->ibuf, ifp);
208
209 if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE))
210 zlog_debug("Zebra: Interface[%s] state change to up.",
211 ifp->name);
212
213 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn)) {
214 if ((oi = rn->info) == NULL)
215 continue;
216
217 ospf_if_up(oi);
218 }
219
220 return 0;
221 }
222
223 static int ospf_interface_state_down(int command, struct zclient *zclient,
224 zebra_size_t length, vrf_id_t vrf_id)
225 {
226 struct interface *ifp;
227 struct ospf_interface *oi;
228 struct route_node *node;
229
230 ifp = zebra_interface_state_read(zclient->ibuf, vrf_id);
231
232 if (ifp == NULL)
233 return 0;
234
235 if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE))
236 zlog_debug("Zebra: Interface[%s] state change to down.",
237 ifp->name);
238
239 for (node = route_top(IF_OIFS(ifp)); node; node = route_next(node)) {
240 if ((oi = node->info) == NULL)
241 continue;
242 ospf_if_down(oi);
243 }
244
245 return 0;
246 }
247
248 static int ospf_interface_address_add(int command, struct zclient *zclient,
249 zebra_size_t length, vrf_id_t vrf_id)
250 {
251 struct connected *c;
252
253 c = zebra_interface_address_read(command, zclient->ibuf, vrf_id);
254
255 if (c == NULL)
256 return 0;
257
258 if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE)) {
259 char buf[PREFIX2STR_BUFFER];
260 prefix2str(c->address, buf, sizeof(buf));
261 zlog_debug("Zebra: interface %s address add %s", c->ifp->name,
262 buf);
263 }
264
265 ospf_if_update(NULL, c->ifp);
266
267 hook_call(ospf_if_update, c->ifp);
268
269 return 0;
270 }
271
272 static int ospf_interface_address_delete(int command, struct zclient *zclient,
273 zebra_size_t length, vrf_id_t vrf_id)
274 {
275 struct connected *c;
276 struct interface *ifp;
277 struct ospf_interface *oi;
278 struct route_node *rn;
279 struct prefix p;
280
281 c = zebra_interface_address_read(command, zclient->ibuf, vrf_id);
282
283 if (c == NULL)
284 return 0;
285
286 if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE)) {
287 char buf[PREFIX2STR_BUFFER];
288 prefix2str(c->address, buf, sizeof(buf));
289 zlog_debug("Zebra: interface %s address delete %s",
290 c->ifp->name, buf);
291 }
292
293 ifp = c->ifp;
294 p = *c->address;
295 p.prefixlen = IPV4_MAX_PREFIXLEN;
296
297 rn = route_node_lookup(IF_OIFS(ifp), &p);
298 if (!rn) {
299 connected_free(c);
300 return 0;
301 }
302
303 assert(rn->info);
304 oi = rn->info;
305 route_unlock_node(rn);
306
307 /* Call interface hook functions to clean up */
308 ospf_if_free(oi);
309
310 hook_call(ospf_if_update, c->ifp);
311
312 connected_free(c);
313
314 return 0;
315 }
316
317 static int ospf_interface_link_params(int command, struct zclient *zclient,
318 zebra_size_t length)
319 {
320 struct interface *ifp;
321
322 ifp = zebra_interface_link_params_read(zclient->ibuf);
323
324 if (ifp == NULL)
325 return 0;
326
327 /* Update TE TLV */
328 ospf_mpls_te_update_if(ifp);
329
330 return 0;
331 }
332
333
334 void ospf_zebra_add(struct prefix_ipv4 *p, struct ospf_route * or)
335 {
336 struct zapi_route api;
337 struct zapi_nexthop *api_nh;
338 u_char distance;
339 struct ospf_path *path;
340 struct listnode *node;
341 struct ospf *ospf = ospf_lookup();
342 int count = 0;
343
344 memset(&api, 0, sizeof(api));
345 api.vrf_id = VRF_DEFAULT;
346 api.type = ZEBRA_ROUTE_OSPF;
347 api.instance = ospf->instance;
348 api.safi = SAFI_UNICAST;
349
350 memcpy(&api.prefix, p, sizeof(*p));
351 SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
352 api.nexthop_num = or->paths->count;
353
354 /* Metric value. */
355 SET_FLAG(api.message, ZAPI_MESSAGE_METRIC);
356 if (or->path_type == OSPF_PATH_TYPE1_EXTERNAL)
357 api.metric = or->cost + or->u.ext.type2_cost;
358 else if (or->path_type == OSPF_PATH_TYPE2_EXTERNAL)
359 api.metric = or->u.ext.type2_cost;
360 else
361 api.metric = or->cost;
362
363 /* Check if path type is ASE */
364 if (((or->path_type == OSPF_PATH_TYPE1_EXTERNAL)
365 || (or->path_type == OSPF_PATH_TYPE2_EXTERNAL))
366 && (or->u.ext.tag > 0) && (or->u.ext.tag <= ROUTE_TAG_MAX)) {
367 SET_FLAG(api.message, ZAPI_MESSAGE_TAG);
368 api.tag = or->u.ext.tag;
369 }
370
371 /* Distance value. */
372 distance = ospf_distance_apply(p, or);
373 if (distance) {
374 SET_FLAG(api.message, ZAPI_MESSAGE_DISTANCE);
375 api.distance = distance;
376 }
377
378 /* Nexthop, ifindex, distance and metric information. */
379 for (ALL_LIST_ELEMENTS_RO(or->paths, node, path)) {
380 api_nh = &api.nexthops[count];
381 #ifdef HAVE_NETLINK
382 if (path->unnumbered || (path->nexthop.s_addr != INADDR_ANY
383 && path->ifindex != 0)) {
384 #else /* HAVE_NETLINK */
385 if (path->nexthop.s_addr != INADDR_ANY && path->ifindex != 0) {
386 #endif /* HAVE_NETLINK */
387 api_nh->gate.ipv4 = path->nexthop;
388 api_nh->ifindex = path->ifindex;
389 api_nh->type = NEXTHOP_TYPE_IPV4_IFINDEX;
390 } else if (path->nexthop.s_addr != INADDR_ANY) {
391 api_nh->gate.ipv4 = path->nexthop;
392 api_nh->type = NEXTHOP_TYPE_IPV4;
393 } else {
394 api_nh->ifindex = path->ifindex;
395 api_nh->type = NEXTHOP_TYPE_IFINDEX;
396 }
397 count++;
398
399 if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) {
400 char buf[2][INET_ADDRSTRLEN];
401 zlog_debug(
402 "Zebra: Route add %s/%d nexthop %s, ifindex=%d",
403 inet_ntop(AF_INET, &p->prefix, buf[0],
404 sizeof(buf[0])),
405 p->prefixlen, inet_ntop(AF_INET, &path->nexthop,
406 buf[1], sizeof(buf[1])),
407 path->ifindex);
408 }
409 }
410
411 zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api);
412 }
413
414 void ospf_zebra_delete(struct prefix_ipv4 *p, struct ospf_route * or)
415 {
416 struct zapi_route api;
417 struct ospf *ospf = ospf_lookup();
418
419 memset(&api, 0, sizeof(api));
420 api.vrf_id = VRF_DEFAULT;
421 api.type = ZEBRA_ROUTE_OSPF;
422 api.instance = ospf->instance;
423 api.safi = SAFI_UNICAST;
424 memcpy(&api.prefix, p, sizeof(*p));
425
426 if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) {
427 char buf[INET_ADDRSTRLEN];
428 zlog_debug("Zebra: Route delete %s/%d",
429 inet_ntop(AF_INET, &p->prefix, buf, sizeof(buf[0])),
430 p->prefixlen);
431 }
432
433 zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api);
434 }
435
436 void ospf_zebra_add_discard(struct prefix_ipv4 *p)
437 {
438 struct zapi_route api;
439 struct ospf *ospf = ospf_lookup();
440
441 memset(&api, 0, sizeof(api));
442 api.vrf_id = VRF_DEFAULT;
443 api.type = ZEBRA_ROUTE_OSPF;
444 api.instance = ospf->instance;
445 api.flags = ZEBRA_FLAG_BLACKHOLE;
446 api.safi = SAFI_UNICAST;
447 memcpy(&api.prefix, p, sizeof(*p));
448
449 zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api);
450
451 if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE))
452 zlog_debug("Zebra: Route add discard %s/%d",
453 inet_ntoa(p->prefix), p->prefixlen);
454 }
455
456 void ospf_zebra_delete_discard(struct prefix_ipv4 *p)
457 {
458 struct zapi_route api;
459 struct ospf *ospf = ospf_lookup();
460
461 memset(&api, 0, sizeof(api));
462 api.vrf_id = VRF_DEFAULT;
463 api.type = ZEBRA_ROUTE_OSPF;
464 api.instance = ospf->instance;
465 api.flags = ZEBRA_FLAG_BLACKHOLE;
466 api.safi = SAFI_UNICAST;
467 memcpy(&api.prefix, p, sizeof(*p));
468
469 zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api);
470
471 if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE))
472 zlog_debug("Zebra: Route delete discard %s/%d",
473 inet_ntoa(p->prefix), p->prefixlen);
474 }
475
476 struct ospf_external *ospf_external_lookup(u_char type, u_short instance)
477 {
478 struct list *ext_list;
479 struct listnode *node;
480 struct ospf_external *ext;
481
482 ext_list = om->external[type];
483 if (!ext_list)
484 return (NULL);
485
486 for (ALL_LIST_ELEMENTS_RO(ext_list, node, ext))
487 if (ext->instance == instance)
488 return ext;
489
490 return NULL;
491 }
492
493 struct ospf_external *ospf_external_add(u_char type, u_short instance)
494 {
495 struct list *ext_list;
496 struct ospf_external *ext;
497
498 ext = ospf_external_lookup(type, instance);
499 if (ext)
500 return ext;
501
502 if (!om->external[type])
503 om->external[type] = list_new();
504
505 ext_list = om->external[type];
506 ext = (struct ospf_external *)XCALLOC(MTYPE_OSPF_EXTERNAL,
507 sizeof(struct ospf_external));
508 ext->instance = instance;
509 EXTERNAL_INFO(ext) = route_table_init();
510
511 listnode_add(ext_list, ext);
512
513 return ext;
514 }
515
516 void ospf_external_del(u_char type, u_short instance)
517 {
518 struct ospf_external *ext;
519
520 ext = ospf_external_lookup(type, instance);
521
522 if (ext) {
523 if (EXTERNAL_INFO(ext))
524 route_table_finish(EXTERNAL_INFO(ext));
525
526 listnode_delete(om->external[type], ext);
527 if (!om->external[type]->count) {
528 list_free(om->external[type]);
529 om->external[type] = NULL;
530 }
531 XFREE(MTYPE_OSPF_EXTERNAL, ext);
532 }
533 }
534
535 struct ospf_redist *ospf_redist_lookup(struct ospf *ospf, u_char type,
536 u_short instance)
537 {
538 struct list *red_list;
539 struct listnode *node;
540 struct ospf_redist *red;
541
542 red_list = ospf->redist[type];
543 if (!red_list)
544 return (NULL);
545
546 for (ALL_LIST_ELEMENTS_RO(red_list, node, red))
547 if (red->instance == instance)
548 return red;
549
550 return NULL;
551 }
552
553 struct ospf_redist *ospf_redist_add(struct ospf *ospf, u_char type,
554 u_short instance)
555 {
556 struct list *red_list;
557 struct ospf_redist *red;
558
559 red = ospf_redist_lookup(ospf, type, instance);
560 if (red)
561 return red;
562
563 if (!ospf->redist[type])
564 ospf->redist[type] = list_new();
565
566 red_list = ospf->redist[type];
567 red = (struct ospf_redist *)XCALLOC(MTYPE_OSPF_REDISTRIBUTE,
568 sizeof(struct ospf_redist));
569 red->instance = instance;
570 red->dmetric.type = -1;
571 red->dmetric.value = -1;
572
573 listnode_add(red_list, red);
574
575 return red;
576 }
577
578 void ospf_redist_del(struct ospf *ospf, u_char type, u_short instance)
579 {
580 struct ospf_redist *red;
581
582 red = ospf_redist_lookup(ospf, type, instance);
583
584 if (red) {
585 listnode_delete(ospf->redist[type], red);
586 if (!ospf->redist[type]->count) {
587 list_free(ospf->redist[type]);
588 ospf->redist[type] = NULL;
589 }
590 ospf_routemap_unset(red);
591 XFREE(MTYPE_OSPF_REDISTRIBUTE, red);
592 }
593 }
594
595
596 int ospf_is_type_redistributed(int type, u_short instance)
597 {
598 return (DEFAULT_ROUTE_TYPE(type)
599 ? vrf_bitmap_check(zclient->default_information,
600 VRF_DEFAULT)
601 : ((instance
602 && redist_check_instance(
603 &zclient->mi_redist[AFI_IP][type],
604 instance))
605 || (!instance
606 && vrf_bitmap_check(
607 zclient->redist[AFI_IP][type],
608 VRF_DEFAULT))));
609 }
610
611 int ospf_redistribute_set(struct ospf *ospf, int type, u_short instance,
612 int mtype, int mvalue)
613 {
614 int force = 0;
615 struct ospf_redist *red;
616
617 red = ospf_redist_lookup(ospf, type, instance);
618 if (ospf_is_type_redistributed(type, instance)) {
619 if (mtype != red->dmetric.type) {
620 red->dmetric.type = mtype;
621 force = LSA_REFRESH_FORCE;
622 }
623 if (mvalue != red->dmetric.value) {
624 red->dmetric.value = mvalue;
625 force = LSA_REFRESH_FORCE;
626 }
627
628 ospf_external_lsa_refresh_type(ospf, type, instance, force);
629
630 if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE))
631 zlog_debug(
632 "Redistribute[%s][%d]: Refresh Type[%d], Metric[%d]",
633 ospf_redist_string(type), instance,
634 metric_type(ospf, type, instance),
635 metric_value(ospf, type, instance));
636
637 return CMD_SUCCESS;
638 }
639
640 red->dmetric.type = mtype;
641 red->dmetric.value = mvalue;
642
643 ospf_external_add(type, instance);
644
645 zclient_redistribute(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, type,
646 instance, VRF_DEFAULT);
647
648 if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE))
649 zlog_debug("Redistribute[%s][%d]: Start Type[%d], Metric[%d]",
650 ospf_redist_string(type), instance,
651 metric_type(ospf, type, instance),
652 metric_value(ospf, type, instance));
653
654 ospf_asbr_status_update(ospf, ++ospf->redistribute);
655
656 return CMD_SUCCESS;
657 }
658
659 int ospf_redistribute_unset(struct ospf *ospf, int type, u_short instance)
660 {
661 if (type == zclient->redist_default && instance == zclient->instance)
662 return CMD_SUCCESS;
663
664 if (!ospf_is_type_redistributed(type, instance))
665 return CMD_SUCCESS;
666
667 zclient_redistribute(ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP, type,
668 instance, VRF_DEFAULT);
669
670 if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE))
671 zlog_debug("Redistribute[%s][%d]: Stop",
672 ospf_redist_string(type), instance);
673
674 ospf_redist_del(ospf, type, instance);
675
676 /* Remove the routes from OSPF table. */
677 ospf_redistribute_withdraw(ospf, type, instance);
678
679 ospf_external_del(type, instance);
680
681 ospf_asbr_status_update(ospf, --ospf->redistribute);
682
683 return CMD_SUCCESS;
684 }
685
686 int ospf_redistribute_default_set(struct ospf *ospf, int originate, int mtype,
687 int mvalue)
688 {
689 struct ospf_redist *red;
690
691 ospf->default_originate = originate;
692
693 red = ospf_redist_add(ospf, DEFAULT_ROUTE, 0);
694 red->dmetric.type = mtype;
695 red->dmetric.value = mvalue;
696
697 ospf_external_add(DEFAULT_ROUTE, 0);
698
699 if (ospf_is_type_redistributed(DEFAULT_ROUTE, 0)) {
700 /* if ospf->default_originate changes value, is calling
701 ospf_external_lsa_refresh_default sufficient to implement
702 the change? */
703 ospf_external_lsa_refresh_default(ospf);
704
705 if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE))
706 zlog_debug(
707 "Redistribute[%s]: Refresh Type[%d], Metric[%d]",
708 ospf_redist_string(DEFAULT_ROUTE),
709 metric_type(ospf, DEFAULT_ROUTE, 0),
710 metric_value(ospf, DEFAULT_ROUTE, 0));
711 return CMD_SUCCESS;
712 }
713
714 zclient_redistribute_default(ZEBRA_REDISTRIBUTE_DEFAULT_ADD, zclient,
715 VRF_DEFAULT);
716
717 if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE))
718 zlog_debug("Redistribute[DEFAULT]: Start Type[%d], Metric[%d]",
719 metric_type(ospf, DEFAULT_ROUTE, 0),
720 metric_value(ospf, DEFAULT_ROUTE, 0));
721
722 if (ospf->router_id.s_addr == 0)
723 ospf->external_origin |= (1 << DEFAULT_ROUTE);
724 else
725 thread_add_timer(master, ospf_default_originate_timer, ospf, 1,
726 NULL);
727
728 ospf_asbr_status_update(ospf, ++ospf->redistribute);
729
730 return CMD_SUCCESS;
731 }
732
733 int ospf_redistribute_default_unset(struct ospf *ospf)
734 {
735 if (!ospf_is_type_redistributed(DEFAULT_ROUTE, 0))
736 return CMD_SUCCESS;
737
738 ospf->default_originate = DEFAULT_ORIGINATE_NONE;
739 ospf_redist_del(ospf, DEFAULT_ROUTE, 0);
740
741 zclient_redistribute_default(ZEBRA_REDISTRIBUTE_DEFAULT_DELETE, zclient,
742 VRF_DEFAULT);
743
744 if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE))
745 zlog_debug("Redistribute[DEFAULT]: Stop");
746
747 // Pending: how does the external_info cleanup work in this case?
748
749 ospf_asbr_status_update(ospf, --ospf->redistribute);
750
751 return CMD_SUCCESS;
752 }
753
754 static int ospf_external_lsa_originate_check(struct ospf *ospf,
755 struct external_info *ei)
756 {
757 /* If prefix is multicast, then do not originate LSA. */
758 if (IN_MULTICAST(htonl(ei->p.prefix.s_addr))) {
759 zlog_info(
760 "LSA[Type5:%s]: Not originate AS-external-LSA, "
761 "Prefix belongs multicast",
762 inet_ntoa(ei->p.prefix));
763 return 0;
764 }
765
766 /* Take care of default-originate. */
767 if (is_prefix_default(&ei->p))
768 if (ospf->default_originate == DEFAULT_ORIGINATE_NONE) {
769 zlog_info(
770 "LSA[Type5:0.0.0.0]: Not originate AS-external-LSA "
771 "for default");
772 return 0;
773 }
774
775 return 1;
776 }
777
778 /* If connected prefix is OSPF enable interface, then do not announce. */
779 int ospf_distribute_check_connected(struct ospf *ospf, struct external_info *ei)
780 {
781 struct listnode *node;
782 struct ospf_interface *oi;
783
784
785 for (ALL_LIST_ELEMENTS_RO(ospf->oiflist, node, oi))
786 if (prefix_match(oi->address, (struct prefix *)&ei->p))
787 return 0;
788 return 1;
789 }
790
791 /* return 1 if external LSA must be originated, 0 otherwise */
792 int ospf_redistribute_check(struct ospf *ospf, struct external_info *ei,
793 int *changed)
794 {
795 struct route_map_set_values save_values;
796 struct prefix_ipv4 *p = &ei->p;
797 struct ospf_redist *red;
798 u_char type = is_prefix_default(&ei->p) ? DEFAULT_ROUTE : ei->type;
799 u_short instance = is_prefix_default(&ei->p) ? 0 : ei->instance;
800
801 if (changed)
802 *changed = 0;
803
804 if (!ospf_external_lsa_originate_check(ospf, ei))
805 return 0;
806
807 /* Take care connected route. */
808 if (type == ZEBRA_ROUTE_CONNECT
809 && !ospf_distribute_check_connected(ospf, ei))
810 return 0;
811
812 if (!DEFAULT_ROUTE_TYPE(type) && DISTRIBUTE_NAME(ospf, type))
813 /* distirbute-list exists, but access-list may not? */
814 if (DISTRIBUTE_LIST(ospf, type))
815 if (access_list_apply(DISTRIBUTE_LIST(ospf, type), p)
816 == FILTER_DENY) {
817 if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE))
818 zlog_debug(
819 "Redistribute[%s]: %s/%d filtered by ditribute-list.",
820 ospf_redist_string(type),
821 inet_ntoa(p->prefix),
822 p->prefixlen);
823 return 0;
824 }
825
826 save_values = ei->route_map_set;
827 ospf_reset_route_map_set_values(&ei->route_map_set);
828
829 /* apply route-map if needed */
830 red = ospf_redist_lookup(ospf, type, instance);
831 if (red && ROUTEMAP_NAME(red)) {
832 int ret;
833
834 ret = route_map_apply(ROUTEMAP(red), (struct prefix *)p,
835 RMAP_OSPF, ei);
836
837 if (ret == RMAP_DENYMATCH) {
838 ei->route_map_set = save_values;
839 if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE))
840 zlog_debug(
841 "Redistribute[%s]: %s/%d filtered by route-map.",
842 ospf_redist_string(type),
843 inet_ntoa(p->prefix), p->prefixlen);
844 return 0;
845 }
846
847 /* check if 'route-map set' changed something */
848 if (changed)
849 *changed = !ospf_route_map_set_compare(
850 &ei->route_map_set, &save_values);
851 }
852
853 return 1;
854 }
855
856 /* OSPF route-map set for redistribution */
857 void ospf_routemap_set(struct ospf_redist *red, const char *name)
858 {
859 if (ROUTEMAP_NAME(red))
860 free(ROUTEMAP_NAME(red));
861
862 ROUTEMAP_NAME(red) = strdup(name);
863 ROUTEMAP(red) = route_map_lookup_by_name(name);
864 }
865
866 void ospf_routemap_unset(struct ospf_redist *red)
867 {
868 if (ROUTEMAP_NAME(red))
869 free(ROUTEMAP_NAME(red));
870
871 ROUTEMAP_NAME(red) = NULL;
872 ROUTEMAP(red) = NULL;
873 }
874
875 /* Zebra route add and delete treatment. */
876 static int ospf_zebra_read_route(int command, struct zclient *zclient,
877 zebra_size_t length, vrf_id_t vrf_id)
878 {
879 struct zapi_route api;
880 struct prefix_ipv4 p;
881 unsigned long ifindex;
882 struct in_addr nexthop;
883 struct external_info *ei;
884 struct ospf *ospf;
885 int i;
886
887 ospf = ospf_lookup();
888 if (ospf == NULL)
889 return 0;
890
891 if (zapi_route_decode(zclient->ibuf, &api) < 0)
892 return -1;
893
894 ifindex = api.nexthops[0].ifindex;
895 nexthop = api.nexthops[0].gate.ipv4;
896
897 memcpy(&p, &api.prefix, sizeof(p));
898 if (IPV4_NET127(ntohl(p.prefix.s_addr)))
899 return 0;
900
901 if (command == ZEBRA_REDISTRIBUTE_ROUTE_ADD) {
902 /* XXX|HACK|TODO|FIXME:
903 * Maybe we should ignore reject/blackhole routes? Testing shows
904 * that
905 * there is no problems though and this is only way to
906 * "summarize"
907 * routes in ASBR at the moment. Maybe we need just a better
908 * generalised
909 * solution for these types?
910 *
911 * if ( CHECK_FLAG (api.flags, ZEBRA_FLAG_BLACKHOLE)
912 * || CHECK_FLAG (api.flags, ZEBRA_FLAG_REJECT))
913 * return 0;
914 */
915
916 /* Protocol tag overwrites all other tag value sent by zebra */
917 if (ospf->dtag[api.type] > 0)
918 api.tag = ospf->dtag[api.type];
919
920 /*
921 * Given zebra sends update for a prefix via ADD message, it
922 * should
923 * be considered as an implicit DEL for that prefix with other
924 * source
925 * types.
926 */
927 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
928 if (i != api.type)
929 ospf_external_info_delete(i, api.instance, p);
930
931 ei = ospf_external_info_add(api.type, api.instance, p, ifindex,
932 nexthop, api.tag);
933 if (ei == NULL) {
934 /* Nothing has changed, so nothing to do; return */
935 return 0;
936 }
937 if (ospf->router_id.s_addr == 0)
938 /* Set flags to generate AS-external-LSA originate event
939 for each redistributed protocols later. */
940 ospf->external_origin |= (1 << api.type);
941 else {
942 if (ei) {
943 if (is_prefix_default(&p))
944 ospf_external_lsa_refresh_default(ospf);
945 else {
946 struct ospf_lsa *current;
947
948 current = ospf_external_info_find_lsa(
949 ospf, &ei->p);
950 if (!current)
951 ospf_external_lsa_originate(
952 ospf, ei);
953 else {
954 if (IS_DEBUG_OSPF(
955 zebra,
956 ZEBRA_REDISTRIBUTE))
957 zlog_debug(
958 "ospf_zebra_read_route() : %s refreshing LSA",
959 inet_ntoa(
960 p.prefix));
961 ospf_external_lsa_refresh(
962 ospf, current, ei,
963 LSA_REFRESH_FORCE);
964 }
965 }
966 }
967 }
968 } else /* if (command == ZEBRA_REDISTRIBUTE_ROUTE_DEL) */
969 {
970 ospf_external_info_delete(api.type, api.instance, p);
971 if (is_prefix_default(&p))
972 ospf_external_lsa_refresh_default(ospf);
973 else
974 ospf_external_lsa_flush(ospf, api.type, &p,
975 ifindex /*, nexthop */);
976 }
977
978 return 0;
979 }
980
981
982 int ospf_distribute_list_out_set(struct ospf *ospf, int type, const char *name)
983 {
984 /* Lookup access-list for distribute-list. */
985 DISTRIBUTE_LIST(ospf, type) = access_list_lookup(AFI_IP, name);
986
987 /* Clear previous distribute-name. */
988 if (DISTRIBUTE_NAME(ospf, type))
989 free(DISTRIBUTE_NAME(ospf, type));
990
991 /* Set distribute-name. */
992 DISTRIBUTE_NAME(ospf, type) = strdup(name);
993
994 /* If access-list have been set, schedule update timer. */
995 if (DISTRIBUTE_LIST(ospf, type))
996 ospf_distribute_list_update(ospf, type, 0);
997
998 return CMD_SUCCESS;
999 }
1000
1001 int ospf_distribute_list_out_unset(struct ospf *ospf, int type,
1002 const char *name)
1003 {
1004 /* Schedule update timer. */
1005 if (DISTRIBUTE_LIST(ospf, type))
1006 ospf_distribute_list_update(ospf, type, 0);
1007
1008 /* Unset distribute-list. */
1009 DISTRIBUTE_LIST(ospf, type) = NULL;
1010
1011 /* Clear distribute-name. */
1012 if (DISTRIBUTE_NAME(ospf, type))
1013 free(DISTRIBUTE_NAME(ospf, type));
1014
1015 DISTRIBUTE_NAME(ospf, type) = NULL;
1016
1017 return CMD_SUCCESS;
1018 }
1019
1020 /* distribute-list update timer. */
1021 static int ospf_distribute_list_update_timer(struct thread *thread)
1022 {
1023 struct route_node *rn;
1024 struct external_info *ei;
1025 struct route_table *rt;
1026 struct ospf_lsa *lsa;
1027 int type, default_refresh = 0;
1028 struct ospf *ospf;
1029
1030 ospf = ospf_lookup();
1031 if (ospf == NULL)
1032 return 0;
1033
1034 ospf->t_distribute_update = NULL;
1035
1036 zlog_info("Zebra[Redistribute]: distribute-list update timer fired!");
1037
1038 /* foreach all external info. */
1039 for (type = 0; type <= ZEBRA_ROUTE_MAX; type++) {
1040 struct list *ext_list;
1041 struct listnode *node;
1042 struct ospf_external *ext;
1043
1044 ext_list = om->external[type];
1045 if (!ext_list)
1046 continue;
1047
1048 for (ALL_LIST_ELEMENTS_RO(ext_list, node, ext)) {
1049 rt = ext->external_info;
1050 if (!rt)
1051 continue;
1052 for (rn = route_top(rt); rn; rn = route_next(rn))
1053 if ((ei = rn->info) != NULL) {
1054 if (is_prefix_default(&ei->p))
1055 default_refresh = 1;
1056 else if (
1057 (lsa = ospf_external_info_find_lsa(
1058 ospf, &ei->p)))
1059 ospf_external_lsa_refresh(
1060 ospf, lsa, ei,
1061 LSA_REFRESH_IF_CHANGED);
1062 else
1063 ospf_external_lsa_originate(
1064 ospf, ei);
1065 }
1066 }
1067 }
1068 if (default_refresh)
1069 ospf_external_lsa_refresh_default(ospf);
1070 return 0;
1071 }
1072
1073 /* Update distribute-list and set timer to apply access-list. */
1074 void ospf_distribute_list_update(struct ospf *ospf, uintptr_t type,
1075 u_short instance)
1076 {
1077 struct route_table *rt;
1078 struct ospf_external *ext;
1079
1080 /* External info does not exist. */
1081 ext = ospf_external_lookup(type, instance);
1082 if (!ext || !(rt = EXTERNAL_INFO(ext)))
1083 return;
1084
1085 /* If exists previously invoked thread, then let it continue. */
1086 if (ospf->t_distribute_update)
1087 return;
1088
1089 /* Set timer. */
1090 ospf->t_distribute_update = NULL;
1091 thread_add_timer_msec(master, ospf_distribute_list_update_timer,
1092 (void *)type, ospf->min_ls_interval,
1093 &ospf->t_distribute_update);
1094 }
1095
1096 /* If access-list is updated, apply some check. */
1097 static void ospf_filter_update(struct access_list *access)
1098 {
1099 struct ospf *ospf;
1100 int type;
1101 int abr_inv = 0;
1102 struct ospf_area *area;
1103 struct listnode *node;
1104
1105 /* If OSPF instance does not exist, return right now. */
1106 ospf = ospf_lookup();
1107 if (ospf == NULL)
1108 return;
1109
1110 /* Update distribute-list, and apply filter. */
1111 for (type = 0; type <= ZEBRA_ROUTE_MAX; type++) {
1112 struct list *red_list;
1113 struct listnode *node;
1114 struct ospf_redist *red;
1115
1116 red_list = ospf->redist[type];
1117 if (red_list)
1118 for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) {
1119 if (ROUTEMAP(red)) {
1120 /* if route-map is not NULL it may be
1121 * using this access list */
1122 ospf_distribute_list_update(
1123 ospf, type, red->instance);
1124 }
1125 }
1126
1127 /* There is place for route-map for default-information
1128 * (ZEBRA_ROUTE_MAX),
1129 * but no distribute list. */
1130 if (type == ZEBRA_ROUTE_MAX)
1131 break;
1132
1133 if (DISTRIBUTE_NAME(ospf, type)) {
1134 /* Keep old access-list for distribute-list. */
1135 struct access_list *old = DISTRIBUTE_LIST(ospf, type);
1136
1137 /* Update access-list for distribute-list. */
1138 DISTRIBUTE_LIST(ospf, type) = access_list_lookup(
1139 AFI_IP, DISTRIBUTE_NAME(ospf, type));
1140
1141 /* No update for this distribute type. */
1142 if (old == NULL && DISTRIBUTE_LIST(ospf, type) == NULL)
1143 continue;
1144
1145 /* Schedule distribute-list update timer. */
1146 if (DISTRIBUTE_LIST(ospf, type) == NULL
1147 || strcmp(DISTRIBUTE_NAME(ospf, type), access->name)
1148 == 0)
1149 ospf_distribute_list_update(ospf, type, 0);
1150 }
1151 }
1152
1153 /* Update Area access-list. */
1154 for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) {
1155 if (EXPORT_NAME(area)) {
1156 EXPORT_LIST(area) = NULL;
1157 abr_inv++;
1158 }
1159
1160 if (IMPORT_NAME(area)) {
1161 IMPORT_LIST(area) = NULL;
1162 abr_inv++;
1163 }
1164 }
1165
1166 /* Schedule ABR tasks -- this will be changed -- takada. */
1167 if (IS_OSPF_ABR(ospf) && abr_inv)
1168 ospf_schedule_abr_task(ospf);
1169 }
1170
1171 /* If prefix-list is updated, do some updates. */
1172 void ospf_prefix_list_update(struct prefix_list *plist)
1173 {
1174 struct ospf *ospf;
1175 int type;
1176 int abr_inv = 0;
1177 struct ospf_area *area;
1178 struct listnode *node;
1179
1180 /* If OSPF instatnce does not exist, return right now. */
1181 ospf = ospf_lookup();
1182 if (ospf == NULL)
1183 return;
1184
1185 /* Update all route-maps which are used as redistribution filters.
1186 * They might use prefix-list.
1187 */
1188 for (type = 0; type <= ZEBRA_ROUTE_MAX; type++) {
1189 struct list *red_list;
1190 struct listnode *node;
1191 struct ospf_redist *red;
1192
1193 red_list = ospf->redist[type];
1194 if (red_list)
1195 for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) {
1196 if (ROUTEMAP(red)) {
1197 /* if route-map is not NULL it may be
1198 * using this prefix list */
1199 ospf_distribute_list_update(
1200 ospf, type, red->instance);
1201 }
1202 }
1203 }
1204
1205 /* Update area filter-lists. */
1206 for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) {
1207 /* Update filter-list in. */
1208 if (PREFIX_NAME_IN(area))
1209 if (strcmp(PREFIX_NAME_IN(area),
1210 prefix_list_name(plist))
1211 == 0) {
1212 PREFIX_LIST_IN(area) = prefix_list_lookup(
1213 AFI_IP, PREFIX_NAME_IN(area));
1214 abr_inv++;
1215 }
1216
1217 /* Update filter-list out. */
1218 if (PREFIX_NAME_OUT(area))
1219 if (strcmp(PREFIX_NAME_OUT(area),
1220 prefix_list_name(plist))
1221 == 0) {
1222 PREFIX_LIST_IN(area) = prefix_list_lookup(
1223 AFI_IP, PREFIX_NAME_OUT(area));
1224 abr_inv++;
1225 }
1226 }
1227
1228 /* Schedule ABR task. */
1229 if (IS_OSPF_ABR(ospf) && abr_inv)
1230 ospf_schedule_abr_task(ospf);
1231 }
1232
1233 static struct ospf_distance *ospf_distance_new(void)
1234 {
1235 return XCALLOC(MTYPE_OSPF_DISTANCE, sizeof(struct ospf_distance));
1236 }
1237
1238 static void ospf_distance_free(struct ospf_distance *odistance)
1239 {
1240 XFREE(MTYPE_OSPF_DISTANCE, odistance);
1241 }
1242
1243 int ospf_distance_set(struct vty *vty, struct ospf *ospf,
1244 const char *distance_str, const char *ip_str,
1245 const char *access_list_str)
1246 {
1247 int ret;
1248 struct prefix_ipv4 p;
1249 u_char distance;
1250 struct route_node *rn;
1251 struct ospf_distance *odistance;
1252
1253 ret = str2prefix_ipv4(ip_str, &p);
1254 if (ret == 0) {
1255 vty_out(vty, "Malformed prefix\n");
1256 return CMD_WARNING_CONFIG_FAILED;
1257 }
1258
1259 distance = atoi(distance_str);
1260
1261 /* Get OSPF distance node. */
1262 rn = route_node_get(ospf->distance_table, (struct prefix *)&p);
1263 if (rn->info) {
1264 odistance = rn->info;
1265 route_unlock_node(rn);
1266 } else {
1267 odistance = ospf_distance_new();
1268 rn->info = odistance;
1269 }
1270
1271 /* Set distance value. */
1272 odistance->distance = distance;
1273
1274 /* Reset access-list configuration. */
1275 if (odistance->access_list) {
1276 free(odistance->access_list);
1277 odistance->access_list = NULL;
1278 }
1279 if (access_list_str)
1280 odistance->access_list = strdup(access_list_str);
1281
1282 return CMD_SUCCESS;
1283 }
1284
1285 int ospf_distance_unset(struct vty *vty, struct ospf *ospf,
1286 const char *distance_str, const char *ip_str,
1287 char const *access_list_str)
1288 {
1289 int ret;
1290 struct prefix_ipv4 p;
1291 struct route_node *rn;
1292 struct ospf_distance *odistance;
1293
1294 ret = str2prefix_ipv4(ip_str, &p);
1295 if (ret == 0) {
1296 vty_out(vty, "Malformed prefix\n");
1297 return CMD_WARNING_CONFIG_FAILED;
1298 }
1299
1300 rn = route_node_lookup(ospf->distance_table, (struct prefix *)&p);
1301 if (!rn) {
1302 vty_out(vty, "Can't find specified prefix\n");
1303 return CMD_WARNING_CONFIG_FAILED;
1304 }
1305
1306 odistance = rn->info;
1307
1308 if (odistance->access_list)
1309 free(odistance->access_list);
1310 ospf_distance_free(odistance);
1311
1312 rn->info = NULL;
1313 route_unlock_node(rn);
1314 route_unlock_node(rn);
1315
1316 return CMD_SUCCESS;
1317 }
1318
1319 void ospf_distance_reset(struct ospf *ospf)
1320 {
1321 struct route_node *rn;
1322 struct ospf_distance *odistance;
1323
1324 for (rn = route_top(ospf->distance_table); rn; rn = route_next(rn))
1325 if ((odistance = rn->info) != NULL) {
1326 if (odistance->access_list)
1327 free(odistance->access_list);
1328 ospf_distance_free(odistance);
1329 rn->info = NULL;
1330 route_unlock_node(rn);
1331 }
1332 }
1333
1334 u_char ospf_distance_apply(struct prefix_ipv4 *p, struct ospf_route * or)
1335 {
1336 struct ospf *ospf;
1337
1338 ospf = ospf_lookup();
1339 if (ospf == NULL)
1340 return 0;
1341
1342 if (ospf->distance_intra)
1343 if (or->path_type == OSPF_PATH_INTRA_AREA)
1344 return ospf->distance_intra;
1345
1346 if (ospf->distance_inter)
1347 if (or->path_type == OSPF_PATH_INTER_AREA)
1348 return ospf->distance_inter;
1349
1350 if (ospf->distance_external)
1351 if (or->path_type == OSPF_PATH_TYPE1_EXTERNAL ||
1352 or->path_type == OSPF_PATH_TYPE2_EXTERNAL)
1353 return ospf->distance_external;
1354
1355 if (ospf->distance_all)
1356 return ospf->distance_all;
1357
1358 return 0;
1359 }
1360
1361 static void ospf_zebra_connected(struct zclient *zclient)
1362 {
1363 /* Send the client registration */
1364 bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER);
1365
1366 zclient_send_reg_requests(zclient, VRF_DEFAULT);
1367 }
1368
1369 void ospf_zebra_init(struct thread_master *master, u_short instance)
1370 {
1371 /* Allocate zebra structure. */
1372 zclient = zclient_new(master);
1373 zclient_init(zclient, ZEBRA_ROUTE_OSPF, instance);
1374 zclient->zebra_connected = ospf_zebra_connected;
1375 zclient->router_id_update = ospf_router_id_update_zebra;
1376 zclient->interface_add = ospf_interface_add;
1377 zclient->interface_delete = ospf_interface_delete;
1378 zclient->interface_up = ospf_interface_state_up;
1379 zclient->interface_down = ospf_interface_state_down;
1380 zclient->interface_address_add = ospf_interface_address_add;
1381 zclient->interface_address_delete = ospf_interface_address_delete;
1382 zclient->interface_link_params = ospf_interface_link_params;
1383
1384 zclient->redistribute_route_add = ospf_zebra_read_route;
1385 zclient->redistribute_route_del = ospf_zebra_read_route;
1386
1387 access_list_add_hook(ospf_filter_update);
1388 access_list_delete_hook(ospf_filter_update);
1389 prefix_list_add_hook(ospf_prefix_list_update);
1390 prefix_list_delete_hook(ospf_prefix_list_update);
1391 }