]> git.proxmox.com Git - mirror_frr.git/blob - ospfd/ospf_zebra.c
Merge pull request #1078 from dwalton76/ospfd-network-cmd-warning
[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.safi = SAFI_UNICAST;
446 memcpy(&api.prefix, p, sizeof(*p));
447 zapi_route_set_blackhole(&api, BLACKHOLE_NULL);
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.safi = SAFI_UNICAST;
466 memcpy(&api.prefix, p, sizeof(*p));
467 zapi_route_set_blackhole(&api, BLACKHOLE_NULL);
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
904 * shows that there is no problems though and this is only way
905 * to "summarize" routes in ASBR at the moment. Maybe we need
906 * just a better generalised solution for these types?
907 */
908
909 /* Protocol tag overwrites all other tag value sent by zebra */
910 if (ospf->dtag[api.type] > 0)
911 api.tag = ospf->dtag[api.type];
912
913 /*
914 * Given zebra sends update for a prefix via ADD message, it
915 * should
916 * be considered as an implicit DEL for that prefix with other
917 * source
918 * types.
919 */
920 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
921 if (i != api.type)
922 ospf_external_info_delete(i, api.instance, p);
923
924 ei = ospf_external_info_add(api.type, api.instance, p, ifindex,
925 nexthop, api.tag);
926 if (ei == NULL) {
927 /* Nothing has changed, so nothing to do; return */
928 return 0;
929 }
930 if (ospf->router_id.s_addr == 0)
931 /* Set flags to generate AS-external-LSA originate event
932 for each redistributed protocols later. */
933 ospf->external_origin |= (1 << api.type);
934 else {
935 if (ei) {
936 if (is_prefix_default(&p))
937 ospf_external_lsa_refresh_default(ospf);
938 else {
939 struct ospf_lsa *current;
940
941 current = ospf_external_info_find_lsa(
942 ospf, &ei->p);
943 if (!current)
944 ospf_external_lsa_originate(
945 ospf, ei);
946 else {
947 if (IS_DEBUG_OSPF(
948 zebra,
949 ZEBRA_REDISTRIBUTE))
950 zlog_debug(
951 "ospf_zebra_read_route() : %s refreshing LSA",
952 inet_ntoa(
953 p.prefix));
954 ospf_external_lsa_refresh(
955 ospf, current, ei,
956 LSA_REFRESH_FORCE);
957 }
958 }
959 }
960 }
961 } else /* if (command == ZEBRA_REDISTRIBUTE_ROUTE_DEL) */
962 {
963 ospf_external_info_delete(api.type, api.instance, p);
964 if (is_prefix_default(&p))
965 ospf_external_lsa_refresh_default(ospf);
966 else
967 ospf_external_lsa_flush(ospf, api.type, &p,
968 ifindex /*, nexthop */);
969 }
970
971 return 0;
972 }
973
974
975 int ospf_distribute_list_out_set(struct ospf *ospf, int type, const char *name)
976 {
977 /* Lookup access-list for distribute-list. */
978 DISTRIBUTE_LIST(ospf, type) = access_list_lookup(AFI_IP, name);
979
980 /* Clear previous distribute-name. */
981 if (DISTRIBUTE_NAME(ospf, type))
982 free(DISTRIBUTE_NAME(ospf, type));
983
984 /* Set distribute-name. */
985 DISTRIBUTE_NAME(ospf, type) = strdup(name);
986
987 /* If access-list have been set, schedule update timer. */
988 if (DISTRIBUTE_LIST(ospf, type))
989 ospf_distribute_list_update(ospf, type, 0);
990
991 return CMD_SUCCESS;
992 }
993
994 int ospf_distribute_list_out_unset(struct ospf *ospf, int type,
995 const char *name)
996 {
997 /* Schedule update timer. */
998 if (DISTRIBUTE_LIST(ospf, type))
999 ospf_distribute_list_update(ospf, type, 0);
1000
1001 /* Unset distribute-list. */
1002 DISTRIBUTE_LIST(ospf, type) = NULL;
1003
1004 /* Clear distribute-name. */
1005 if (DISTRIBUTE_NAME(ospf, type))
1006 free(DISTRIBUTE_NAME(ospf, type));
1007
1008 DISTRIBUTE_NAME(ospf, type) = NULL;
1009
1010 return CMD_SUCCESS;
1011 }
1012
1013 /* distribute-list update timer. */
1014 static int ospf_distribute_list_update_timer(struct thread *thread)
1015 {
1016 struct route_node *rn;
1017 struct external_info *ei;
1018 struct route_table *rt;
1019 struct ospf_lsa *lsa;
1020 int type, default_refresh = 0;
1021 struct ospf *ospf;
1022
1023 ospf = ospf_lookup();
1024 if (ospf == NULL)
1025 return 0;
1026
1027 ospf->t_distribute_update = NULL;
1028
1029 zlog_info("Zebra[Redistribute]: distribute-list update timer fired!");
1030
1031 /* foreach all external info. */
1032 for (type = 0; type <= ZEBRA_ROUTE_MAX; type++) {
1033 struct list *ext_list;
1034 struct listnode *node;
1035 struct ospf_external *ext;
1036
1037 ext_list = om->external[type];
1038 if (!ext_list)
1039 continue;
1040
1041 for (ALL_LIST_ELEMENTS_RO(ext_list, node, ext)) {
1042 rt = ext->external_info;
1043 if (!rt)
1044 continue;
1045 for (rn = route_top(rt); rn; rn = route_next(rn))
1046 if ((ei = rn->info) != NULL) {
1047 if (is_prefix_default(&ei->p))
1048 default_refresh = 1;
1049 else if (
1050 (lsa = ospf_external_info_find_lsa(
1051 ospf, &ei->p)))
1052 ospf_external_lsa_refresh(
1053 ospf, lsa, ei,
1054 LSA_REFRESH_IF_CHANGED);
1055 else
1056 ospf_external_lsa_originate(
1057 ospf, ei);
1058 }
1059 }
1060 }
1061 if (default_refresh)
1062 ospf_external_lsa_refresh_default(ospf);
1063 return 0;
1064 }
1065
1066 /* Update distribute-list and set timer to apply access-list. */
1067 void ospf_distribute_list_update(struct ospf *ospf, uintptr_t type,
1068 u_short instance)
1069 {
1070 struct route_table *rt;
1071 struct ospf_external *ext;
1072
1073 /* External info does not exist. */
1074 ext = ospf_external_lookup(type, instance);
1075 if (!ext || !(rt = EXTERNAL_INFO(ext)))
1076 return;
1077
1078 /* If exists previously invoked thread, then let it continue. */
1079 if (ospf->t_distribute_update)
1080 return;
1081
1082 /* Set timer. */
1083 ospf->t_distribute_update = NULL;
1084 thread_add_timer_msec(master, ospf_distribute_list_update_timer,
1085 (void *)type, ospf->min_ls_interval,
1086 &ospf->t_distribute_update);
1087 }
1088
1089 /* If access-list is updated, apply some check. */
1090 static void ospf_filter_update(struct access_list *access)
1091 {
1092 struct ospf *ospf;
1093 int type;
1094 int abr_inv = 0;
1095 struct ospf_area *area;
1096 struct listnode *node;
1097
1098 /* If OSPF instance does not exist, return right now. */
1099 ospf = ospf_lookup();
1100 if (ospf == NULL)
1101 return;
1102
1103 /* Update distribute-list, and apply filter. */
1104 for (type = 0; type <= ZEBRA_ROUTE_MAX; type++) {
1105 struct list *red_list;
1106 struct listnode *node;
1107 struct ospf_redist *red;
1108
1109 red_list = ospf->redist[type];
1110 if (red_list)
1111 for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) {
1112 if (ROUTEMAP(red)) {
1113 /* if route-map is not NULL it may be
1114 * using this access list */
1115 ospf_distribute_list_update(
1116 ospf, type, red->instance);
1117 }
1118 }
1119
1120 /* There is place for route-map for default-information
1121 * (ZEBRA_ROUTE_MAX),
1122 * but no distribute list. */
1123 if (type == ZEBRA_ROUTE_MAX)
1124 break;
1125
1126 if (DISTRIBUTE_NAME(ospf, type)) {
1127 /* Keep old access-list for distribute-list. */
1128 struct access_list *old = DISTRIBUTE_LIST(ospf, type);
1129
1130 /* Update access-list for distribute-list. */
1131 DISTRIBUTE_LIST(ospf, type) = access_list_lookup(
1132 AFI_IP, DISTRIBUTE_NAME(ospf, type));
1133
1134 /* No update for this distribute type. */
1135 if (old == NULL && DISTRIBUTE_LIST(ospf, type) == NULL)
1136 continue;
1137
1138 /* Schedule distribute-list update timer. */
1139 if (DISTRIBUTE_LIST(ospf, type) == NULL
1140 || strcmp(DISTRIBUTE_NAME(ospf, type), access->name)
1141 == 0)
1142 ospf_distribute_list_update(ospf, type, 0);
1143 }
1144 }
1145
1146 /* Update Area access-list. */
1147 for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) {
1148 if (EXPORT_NAME(area)) {
1149 EXPORT_LIST(area) = NULL;
1150 abr_inv++;
1151 }
1152
1153 if (IMPORT_NAME(area)) {
1154 IMPORT_LIST(area) = NULL;
1155 abr_inv++;
1156 }
1157 }
1158
1159 /* Schedule ABR tasks -- this will be changed -- takada. */
1160 if (IS_OSPF_ABR(ospf) && abr_inv)
1161 ospf_schedule_abr_task(ospf);
1162 }
1163
1164 /* If prefix-list is updated, do some updates. */
1165 void ospf_prefix_list_update(struct prefix_list *plist)
1166 {
1167 struct ospf *ospf;
1168 int type;
1169 int abr_inv = 0;
1170 struct ospf_area *area;
1171 struct listnode *node;
1172
1173 /* If OSPF instatnce does not exist, return right now. */
1174 ospf = ospf_lookup();
1175 if (ospf == NULL)
1176 return;
1177
1178 /* Update all route-maps which are used as redistribution filters.
1179 * They might use prefix-list.
1180 */
1181 for (type = 0; type <= ZEBRA_ROUTE_MAX; type++) {
1182 struct list *red_list;
1183 struct listnode *node;
1184 struct ospf_redist *red;
1185
1186 red_list = ospf->redist[type];
1187 if (red_list)
1188 for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) {
1189 if (ROUTEMAP(red)) {
1190 /* if route-map is not NULL it may be
1191 * using this prefix list */
1192 ospf_distribute_list_update(
1193 ospf, type, red->instance);
1194 }
1195 }
1196 }
1197
1198 /* Update area filter-lists. */
1199 for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) {
1200 /* Update filter-list in. */
1201 if (PREFIX_NAME_IN(area))
1202 if (strcmp(PREFIX_NAME_IN(area),
1203 prefix_list_name(plist))
1204 == 0) {
1205 PREFIX_LIST_IN(area) = prefix_list_lookup(
1206 AFI_IP, PREFIX_NAME_IN(area));
1207 abr_inv++;
1208 }
1209
1210 /* Update filter-list out. */
1211 if (PREFIX_NAME_OUT(area))
1212 if (strcmp(PREFIX_NAME_OUT(area),
1213 prefix_list_name(plist))
1214 == 0) {
1215 PREFIX_LIST_IN(area) = prefix_list_lookup(
1216 AFI_IP, PREFIX_NAME_OUT(area));
1217 abr_inv++;
1218 }
1219 }
1220
1221 /* Schedule ABR task. */
1222 if (IS_OSPF_ABR(ospf) && abr_inv)
1223 ospf_schedule_abr_task(ospf);
1224 }
1225
1226 static struct ospf_distance *ospf_distance_new(void)
1227 {
1228 return XCALLOC(MTYPE_OSPF_DISTANCE, sizeof(struct ospf_distance));
1229 }
1230
1231 static void ospf_distance_free(struct ospf_distance *odistance)
1232 {
1233 XFREE(MTYPE_OSPF_DISTANCE, odistance);
1234 }
1235
1236 int ospf_distance_set(struct vty *vty, struct ospf *ospf,
1237 const char *distance_str, const char *ip_str,
1238 const char *access_list_str)
1239 {
1240 int ret;
1241 struct prefix_ipv4 p;
1242 u_char distance;
1243 struct route_node *rn;
1244 struct ospf_distance *odistance;
1245
1246 ret = str2prefix_ipv4(ip_str, &p);
1247 if (ret == 0) {
1248 vty_out(vty, "Malformed prefix\n");
1249 return CMD_WARNING_CONFIG_FAILED;
1250 }
1251
1252 distance = atoi(distance_str);
1253
1254 /* Get OSPF distance node. */
1255 rn = route_node_get(ospf->distance_table, (struct prefix *)&p);
1256 if (rn->info) {
1257 odistance = rn->info;
1258 route_unlock_node(rn);
1259 } else {
1260 odistance = ospf_distance_new();
1261 rn->info = odistance;
1262 }
1263
1264 /* Set distance value. */
1265 odistance->distance = distance;
1266
1267 /* Reset access-list configuration. */
1268 if (odistance->access_list) {
1269 free(odistance->access_list);
1270 odistance->access_list = NULL;
1271 }
1272 if (access_list_str)
1273 odistance->access_list = strdup(access_list_str);
1274
1275 return CMD_SUCCESS;
1276 }
1277
1278 int ospf_distance_unset(struct vty *vty, struct ospf *ospf,
1279 const char *distance_str, const char *ip_str,
1280 char const *access_list_str)
1281 {
1282 int ret;
1283 struct prefix_ipv4 p;
1284 struct route_node *rn;
1285 struct ospf_distance *odistance;
1286
1287 ret = str2prefix_ipv4(ip_str, &p);
1288 if (ret == 0) {
1289 vty_out(vty, "Malformed prefix\n");
1290 return CMD_WARNING_CONFIG_FAILED;
1291 }
1292
1293 rn = route_node_lookup(ospf->distance_table, (struct prefix *)&p);
1294 if (!rn) {
1295 vty_out(vty, "Can't find specified prefix\n");
1296 return CMD_WARNING_CONFIG_FAILED;
1297 }
1298
1299 odistance = rn->info;
1300
1301 if (odistance->access_list)
1302 free(odistance->access_list);
1303 ospf_distance_free(odistance);
1304
1305 rn->info = NULL;
1306 route_unlock_node(rn);
1307 route_unlock_node(rn);
1308
1309 return CMD_SUCCESS;
1310 }
1311
1312 void ospf_distance_reset(struct ospf *ospf)
1313 {
1314 struct route_node *rn;
1315 struct ospf_distance *odistance;
1316
1317 for (rn = route_top(ospf->distance_table); rn; rn = route_next(rn))
1318 if ((odistance = rn->info) != NULL) {
1319 if (odistance->access_list)
1320 free(odistance->access_list);
1321 ospf_distance_free(odistance);
1322 rn->info = NULL;
1323 route_unlock_node(rn);
1324 }
1325 }
1326
1327 u_char ospf_distance_apply(struct prefix_ipv4 *p, struct ospf_route * or)
1328 {
1329 struct ospf *ospf;
1330
1331 ospf = ospf_lookup();
1332 if (ospf == NULL)
1333 return 0;
1334
1335 if (ospf->distance_intra)
1336 if (or->path_type == OSPF_PATH_INTRA_AREA)
1337 return ospf->distance_intra;
1338
1339 if (ospf->distance_inter)
1340 if (or->path_type == OSPF_PATH_INTER_AREA)
1341 return ospf->distance_inter;
1342
1343 if (ospf->distance_external)
1344 if (or->path_type == OSPF_PATH_TYPE1_EXTERNAL ||
1345 or->path_type == OSPF_PATH_TYPE2_EXTERNAL)
1346 return ospf->distance_external;
1347
1348 if (ospf->distance_all)
1349 return ospf->distance_all;
1350
1351 return 0;
1352 }
1353
1354 static void ospf_zebra_connected(struct zclient *zclient)
1355 {
1356 /* Send the client registration */
1357 bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER);
1358
1359 zclient_send_reg_requests(zclient, VRF_DEFAULT);
1360 }
1361
1362 void ospf_zebra_init(struct thread_master *master, u_short instance)
1363 {
1364 /* Allocate zebra structure. */
1365 zclient = zclient_new(master);
1366 zclient_init(zclient, ZEBRA_ROUTE_OSPF, instance);
1367 zclient->zebra_connected = ospf_zebra_connected;
1368 zclient->router_id_update = ospf_router_id_update_zebra;
1369 zclient->interface_add = ospf_interface_add;
1370 zclient->interface_delete = ospf_interface_delete;
1371 zclient->interface_up = ospf_interface_state_up;
1372 zclient->interface_down = ospf_interface_state_down;
1373 zclient->interface_address_add = ospf_interface_address_add;
1374 zclient->interface_address_delete = ospf_interface_address_delete;
1375 zclient->interface_link_params = ospf_interface_link_params;
1376
1377 zclient->redistribute_route_add = ospf_zebra_read_route;
1378 zclient->redistribute_route_del = ospf_zebra_read_route;
1379
1380 access_list_add_hook(ospf_filter_update);
1381 access_list_delete_hook(ospf_filter_update);
1382 prefix_list_add_hook(ospf_prefix_list_update);
1383 prefix_list_delete_hook(ospf_prefix_list_update);
1384 }