2 * Zebra connect library for OSPFd
3 * Copyright (C) 1997, 98, 99, 2000 Kunihiro Ishiguro, Toshiaki Takada
5 * This file is part of GNU Zebra.
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
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.
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
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"
54 DEFINE_MTYPE_STATIC(OSPFD
, OSPF_EXTERNAL
, "OSPF External route table")
55 DEFINE_MTYPE_STATIC(OSPFD
, OSPF_REDISTRIBUTE
, "OSPF Redistriute")
56 DEFINE_MTYPE_STATIC(OSPFD
, OSPF_DIST_ARGS
, "OSPF Distribute arguments")
58 DEFINE_HOOK(ospf_if_update
, (struct interface
* ifp
), (ifp
))
59 DEFINE_HOOK(ospf_if_delete
, (struct interface
* ifp
), (ifp
))
61 /* Zebra structure to hold current status. */
62 struct zclient
*zclient
= NULL
;
64 /* For registering threads. */
65 extern struct thread_master
*master
;
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
)
71 struct ospf
*ospf
= NULL
;
72 struct prefix router_id
;
73 zebra_router_id_update_read(zclient
->ibuf
, &router_id
);
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 vrf %s id %u", buf
,
79 ospf_vrf_id_to_name(vrf_id
), vrf_id
);
82 ospf
= ospf_lookup_by_vrf_id(vrf_id
);
85 ospf
->router_id_zebra
= router_id
.u
.prefix4
;
86 ospf_router_id_update(ospf
);
88 if (IS_DEBUG_OSPF_EVENT
) {
89 char buf
[PREFIX2STR_BUFFER
];
91 prefix2str(&router_id
, buf
, sizeof(buf
));
93 "%s: ospf instance not found for vrf %s id %u router_id %s",
95 ospf_vrf_id_to_name(vrf_id
), vrf_id
, buf
);
101 /* Inteface addition message from zebra. */
102 static int ospf_interface_add(int command
, struct zclient
*zclient
,
103 zebra_size_t length
, vrf_id_t vrf_id
)
105 struct interface
*ifp
= NULL
;
106 struct ospf
*ospf
= NULL
;
108 ifp
= zebra_interface_add_read(zclient
->ibuf
, vrf_id
);
112 if (IS_DEBUG_OSPF(zebra
, ZEBRA_INTERFACE
))
114 "Zebra: interface add %s vrf %s[%u] index %d flags %llx metric %d mtu %d speed %u",
115 ifp
->name
, ospf_vrf_id_to_name(ifp
->vrf_id
),
116 ifp
->vrf_id
, ifp
->ifindex
,
117 (unsigned long long)ifp
->flags
, ifp
->metric
, ifp
->mtu
,
122 if (IF_DEF_PARAMS(ifp
)
123 && !OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp
), type
)) {
124 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), type
);
125 IF_DEF_PARAMS(ifp
)->type
= ospf_default_iftype(ifp
);
128 ospf
= ospf_lookup_by_vrf_id(vrf_id
);
132 ospf_if_recalculate_output_cost(ifp
);
134 ospf_if_update(ospf
, ifp
);
136 hook_call(ospf_if_update
, ifp
);
141 static int ospf_interface_delete(int command
, struct zclient
*zclient
,
142 zebra_size_t length
, vrf_id_t vrf_id
)
144 struct interface
*ifp
;
146 struct route_node
*rn
;
149 /* zebra_interface_state_read() updates interface structure in iflist */
150 ifp
= zebra_interface_state_read(s
, vrf_id
);
156 zlog_warn("Zebra: got delete of %s, but interface is still up",
159 if (IS_DEBUG_OSPF(zebra
, ZEBRA_INTERFACE
))
161 "Zebra: interface delete %s vrf %s[%u] index %d flags %llx metric %d mtu %d",
162 ifp
->name
, ospf_vrf_id_to_name(ifp
->vrf_id
),
163 ifp
->vrf_id
, ifp
->ifindex
,
164 (unsigned long long)ifp
->flags
, ifp
->metric
, ifp
->mtu
);
166 hook_call(ospf_if_delete
, ifp
);
168 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
))
170 ospf_if_free((struct ospf_interface
*)rn
->info
);
172 if_set_index(ifp
, IFINDEX_INTERNAL
);
176 static struct interface
*zebra_interface_if_lookup(struct stream
*s
,
179 char ifname_tmp
[INTERFACE_NAMSIZ
];
181 /* Read interface name. */
182 stream_get(ifname_tmp
, s
, INTERFACE_NAMSIZ
);
184 /* And look it up. */
185 return if_lookup_by_name(ifname_tmp
, vrf_id
);
188 static int ospf_interface_state_up(int command
, struct zclient
*zclient
,
189 zebra_size_t length
, vrf_id_t vrf_id
)
191 struct interface
*ifp
;
192 struct ospf_interface
*oi
;
193 struct route_node
*rn
;
195 ifp
= zebra_interface_if_lookup(zclient
->ibuf
, vrf_id
);
200 /* Interface is already up. */
201 if (if_is_operative(ifp
)) {
202 /* Temporarily keep ifp values. */
203 struct interface if_tmp
;
204 memcpy(&if_tmp
, ifp
, sizeof(struct interface
));
206 zebra_interface_if_set_value(zclient
->ibuf
, ifp
);
208 if (IS_DEBUG_OSPF(zebra
, ZEBRA_INTERFACE
))
210 "Zebra: Interface[%s] state update speed %u -> %u, bw %d -> %d",
211 ifp
->name
, if_tmp
.speed
, ifp
->speed
,
212 if_tmp
.bandwidth
, ifp
->bandwidth
);
214 ospf_if_recalculate_output_cost(ifp
);
216 if (if_tmp
.mtu
!= ifp
->mtu
) {
217 if (IS_DEBUG_OSPF(zebra
, ZEBRA_INTERFACE
))
219 "Zebra: Interface[%s] MTU change %u -> %u.",
220 ifp
->name
, if_tmp
.mtu
, ifp
->mtu
);
222 /* Must reset the interface (simulate down/up) when MTU
229 zebra_interface_if_set_value(zclient
->ibuf
, ifp
);
231 if (IS_DEBUG_OSPF(zebra
, ZEBRA_INTERFACE
))
232 zlog_debug("Zebra: Interface[%s] state change to up.",
235 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
236 if ((oi
= rn
->info
) == NULL
)
245 static int ospf_interface_state_down(int command
, struct zclient
*zclient
,
246 zebra_size_t length
, vrf_id_t vrf_id
)
248 struct interface
*ifp
;
249 struct ospf_interface
*oi
;
250 struct route_node
*node
;
252 ifp
= zebra_interface_state_read(zclient
->ibuf
, vrf_id
);
257 if (IS_DEBUG_OSPF(zebra
, ZEBRA_INTERFACE
))
258 zlog_debug("Zebra: Interface[%s] state change to down.",
261 for (node
= route_top(IF_OIFS(ifp
)); node
; node
= route_next(node
)) {
262 if ((oi
= node
->info
) == NULL
)
270 static int ospf_interface_address_add(int command
, struct zclient
*zclient
,
271 zebra_size_t length
, vrf_id_t vrf_id
)
274 struct ospf
*ospf
= NULL
;
277 c
= zebra_interface_address_read(command
, zclient
->ibuf
, vrf_id
);
282 if (IS_DEBUG_OSPF(zebra
, ZEBRA_INTERFACE
)) {
283 char buf
[PREFIX2STR_BUFFER
];
284 prefix2str(c
->address
, buf
, sizeof(buf
));
285 zlog_debug("Zebra: interface %s address add %s vrf %s id %u",
286 c
->ifp
->name
, buf
, ospf_vrf_id_to_name(vrf_id
),
290 ospf
= ospf_lookup_by_vrf_id(vrf_id
);
294 ospf_if_update(ospf
, c
->ifp
);
296 hook_call(ospf_if_update
, c
->ifp
);
301 static int ospf_interface_address_delete(int command
, struct zclient
*zclient
,
302 zebra_size_t length
, vrf_id_t vrf_id
)
305 struct interface
*ifp
;
306 struct ospf_interface
*oi
;
307 struct route_node
*rn
;
310 c
= zebra_interface_address_read(command
, zclient
->ibuf
, vrf_id
);
315 if (IS_DEBUG_OSPF(zebra
, ZEBRA_INTERFACE
)) {
316 char buf
[PREFIX2STR_BUFFER
];
317 prefix2str(c
->address
, buf
, sizeof(buf
));
318 zlog_debug("Zebra: interface %s address delete %s",
324 p
.prefixlen
= IPV4_MAX_PREFIXLEN
;
326 rn
= route_node_lookup(IF_OIFS(ifp
), &p
);
334 route_unlock_node(rn
);
336 /* Call interface hook functions to clean up */
339 hook_call(ospf_if_update
, c
->ifp
);
346 static int ospf_interface_link_params(int command
, struct zclient
*zclient
,
349 struct interface
*ifp
;
351 ifp
= zebra_interface_link_params_read(zclient
->ibuf
);
357 ospf_mpls_te_update_if(ifp
);
362 /* VRF update for an interface. */
363 static int ospf_interface_vrf_update(int command
, struct zclient
*zclient
,
364 zebra_size_t length
, vrf_id_t vrf_id
)
366 struct interface
*ifp
= NULL
;
369 ifp
= zebra_interface_vrf_update_read(zclient
->ibuf
, vrf_id
,
374 if (IS_DEBUG_OSPF_EVENT
)
376 "%s: Rx Interface %s VRF change vrf_id %u New vrf %s id %u",
377 __PRETTY_FUNCTION__
, ifp
->name
, vrf_id
,
378 ospf_vrf_id_to_name(new_vrf_id
), new_vrf_id
);
380 /*if_update(ifp, ifp->name, strlen(ifp->name), new_vrf_id);*/
381 if_update_to_new_vrf(ifp
, new_vrf_id
);
386 void ospf_zebra_add(struct ospf
*ospf
, struct prefix_ipv4
*p
,
387 struct ospf_route
* or)
389 struct zapi_route api
;
390 struct zapi_nexthop
*api_nh
;
392 struct ospf_path
*path
;
393 struct listnode
*node
;
396 memset(&api
, 0, sizeof(api
));
397 api
.vrf_id
= ospf
->vrf_id
;
398 api
.type
= ZEBRA_ROUTE_OSPF
;
399 api
.instance
= ospf
->instance
;
400 api
.safi
= SAFI_UNICAST
;
402 memcpy(&api
.prefix
, p
, sizeof(*p
));
403 SET_FLAG(api
.message
, ZAPI_MESSAGE_NEXTHOP
);
406 SET_FLAG(api
.message
, ZAPI_MESSAGE_METRIC
);
407 if (or->path_type
== OSPF_PATH_TYPE1_EXTERNAL
)
408 api
.metric
= or->cost
+ or->u
.ext
.type2_cost
;
409 else if (or->path_type
== OSPF_PATH_TYPE2_EXTERNAL
)
410 api
.metric
= or->u
.ext
.type2_cost
;
412 api
.metric
= or->cost
;
414 /* Check if path type is ASE */
415 if (((or->path_type
== OSPF_PATH_TYPE1_EXTERNAL
)
416 || (or->path_type
== OSPF_PATH_TYPE2_EXTERNAL
))
417 && (or->u
.ext
.tag
> 0) && (or->u
.ext
.tag
<= ROUTE_TAG_MAX
)) {
418 SET_FLAG(api
.message
, ZAPI_MESSAGE_TAG
);
419 api
.tag
= or->u
.ext
.tag
;
422 /* Distance value. */
423 distance
= ospf_distance_apply(ospf
, p
, or);
425 SET_FLAG(api
.message
, ZAPI_MESSAGE_DISTANCE
);
426 api
.distance
= distance
;
429 /* Nexthop, ifindex, distance and metric information. */
430 for (ALL_LIST_ELEMENTS_RO(or->paths
, node
, path
)) {
431 if (count
>= MULTIPATH_NUM
)
433 api_nh
= &api
.nexthops
[count
];
435 if (path
->unnumbered
|| (path
->nexthop
.s_addr
!= INADDR_ANY
436 && path
->ifindex
!= 0)) {
437 #else /* HAVE_NETLINK */
438 if (path
->nexthop
.s_addr
!= INADDR_ANY
&& path
->ifindex
!= 0) {
439 #endif /* HAVE_NETLINK */
440 api_nh
->gate
.ipv4
= path
->nexthop
;
441 api_nh
->ifindex
= path
->ifindex
;
442 api_nh
->type
= NEXTHOP_TYPE_IPV4_IFINDEX
;
443 } else if (path
->nexthop
.s_addr
!= INADDR_ANY
) {
444 api_nh
->gate
.ipv4
= path
->nexthop
;
445 api_nh
->type
= NEXTHOP_TYPE_IPV4
;
447 api_nh
->ifindex
= path
->ifindex
;
448 api_nh
->type
= NEXTHOP_TYPE_IFINDEX
;
450 api_nh
->vrf_id
= ospf
->vrf_id
;
453 if (IS_DEBUG_OSPF(zebra
, ZEBRA_REDISTRIBUTE
)) {
454 char buf
[2][INET_ADDRSTRLEN
];
455 struct interface
*ifp
;
457 ifp
= if_lookup_by_index(path
->ifindex
, ospf
->vrf_id
);
460 "Zebra: Route add %s nexthop %s, ifindex=%d %s",
461 prefix2str(p
, buf
[0], sizeof(buf
[0])),
462 inet_ntop(AF_INET
, &path
->nexthop
,
463 buf
[1], sizeof(buf
[1])),
464 path
->ifindex
, ifp
? ifp
->name
: " ");
467 api
.nexthop_num
= count
;
469 zclient_route_send(ZEBRA_ROUTE_ADD
, zclient
, &api
);
472 void ospf_zebra_delete(struct ospf
*ospf
, struct prefix_ipv4
*p
,
473 struct ospf_route
* or)
475 struct zapi_route api
;
477 memset(&api
, 0, sizeof(api
));
478 api
.vrf_id
= ospf
->vrf_id
;
479 api
.type
= ZEBRA_ROUTE_OSPF
;
480 api
.instance
= ospf
->instance
;
481 api
.safi
= SAFI_UNICAST
;
482 memcpy(&api
.prefix
, p
, sizeof(*p
));
484 if (IS_DEBUG_OSPF(zebra
, ZEBRA_REDISTRIBUTE
)) {
485 char buf
[PREFIX2STR_BUFFER
];
486 zlog_debug("Zebra: Route delete %s",
487 prefix2str(p
, buf
, sizeof(buf
)));
490 zclient_route_send(ZEBRA_ROUTE_DELETE
, zclient
, &api
);
493 void ospf_zebra_add_discard(struct ospf
*ospf
, struct prefix_ipv4
*p
)
495 struct zapi_route api
;
497 memset(&api
, 0, sizeof(api
));
498 api
.vrf_id
= ospf
->vrf_id
;
499 api
.type
= ZEBRA_ROUTE_OSPF
;
500 api
.instance
= ospf
->instance
;
501 api
.safi
= SAFI_UNICAST
;
502 memcpy(&api
.prefix
, p
, sizeof(*p
));
503 zapi_route_set_blackhole(&api
, BLACKHOLE_NULL
);
505 zclient_route_send(ZEBRA_ROUTE_ADD
, zclient
, &api
);
507 if (IS_DEBUG_OSPF(zebra
, ZEBRA_REDISTRIBUTE
)) {
508 char buf
[PREFIX2STR_BUFFER
];
509 zlog_debug("Zebra: Route add discard %s",
510 prefix2str(p
, buf
, sizeof(buf
)));
514 void ospf_zebra_delete_discard(struct ospf
*ospf
, struct prefix_ipv4
*p
)
516 struct zapi_route api
;
518 memset(&api
, 0, sizeof(api
));
519 api
.vrf_id
= ospf
->vrf_id
;
520 api
.type
= ZEBRA_ROUTE_OSPF
;
521 api
.instance
= ospf
->instance
;
522 api
.safi
= SAFI_UNICAST
;
523 memcpy(&api
.prefix
, p
, sizeof(*p
));
524 zapi_route_set_blackhole(&api
, BLACKHOLE_NULL
);
526 zclient_route_send(ZEBRA_ROUTE_DELETE
, zclient
, &api
);
528 if (IS_DEBUG_OSPF(zebra
, ZEBRA_REDISTRIBUTE
)) {
529 char buf
[PREFIX2STR_BUFFER
];
530 zlog_debug("Zebra: Route delete discard %s",
531 prefix2str(p
, buf
, sizeof(buf
)));
535 struct ospf_external
*ospf_external_lookup(struct ospf
*ospf
, uint8_t type
,
536 unsigned short instance
)
538 struct list
*ext_list
;
539 struct listnode
*node
;
540 struct ospf_external
*ext
;
542 ext_list
= ospf
->external
[type
];
546 for (ALL_LIST_ELEMENTS_RO(ext_list
, node
, ext
))
547 if (ext
->instance
== instance
)
553 struct ospf_external
*ospf_external_add(struct ospf
*ospf
, uint8_t type
,
554 unsigned short instance
)
556 struct list
*ext_list
;
557 struct ospf_external
*ext
;
559 ext
= ospf_external_lookup(ospf
, type
, instance
);
563 if (!ospf
->external
[type
])
564 ospf
->external
[type
] = list_new();
566 ext_list
= ospf
->external
[type
];
567 ext
= (struct ospf_external
*)XCALLOC(MTYPE_OSPF_EXTERNAL
,
568 sizeof(struct ospf_external
));
569 ext
->instance
= instance
;
570 EXTERNAL_INFO(ext
) = route_table_init();
572 listnode_add(ext_list
, ext
);
577 void ospf_external_del(struct ospf
*ospf
, uint8_t type
, unsigned short instance
)
579 struct ospf_external
*ext
;
581 ext
= ospf_external_lookup(ospf
, type
, instance
);
584 if (EXTERNAL_INFO(ext
))
585 route_table_finish(EXTERNAL_INFO(ext
));
587 listnode_delete(ospf
->external
[type
], ext
);
589 if (!ospf
->external
[type
]->count
)
590 list_delete_and_null(&ospf
->external
[type
]);
592 XFREE(MTYPE_OSPF_EXTERNAL
, ext
);
596 struct ospf_redist
*ospf_redist_lookup(struct ospf
*ospf
, uint8_t type
,
597 unsigned short instance
)
599 struct list
*red_list
;
600 struct listnode
*node
;
601 struct ospf_redist
*red
;
603 red_list
= ospf
->redist
[type
];
607 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
))
608 if (red
->instance
== instance
)
614 struct ospf_redist
*ospf_redist_add(struct ospf
*ospf
, uint8_t type
,
615 unsigned short instance
)
617 struct list
*red_list
;
618 struct ospf_redist
*red
;
620 red
= ospf_redist_lookup(ospf
, type
, instance
);
624 if (!ospf
->redist
[type
])
625 ospf
->redist
[type
] = list_new();
627 red_list
= ospf
->redist
[type
];
628 red
= (struct ospf_redist
*)XCALLOC(MTYPE_OSPF_REDISTRIBUTE
,
629 sizeof(struct ospf_redist
));
630 red
->instance
= instance
;
631 red
->dmetric
.type
= -1;
632 red
->dmetric
.value
= -1;
634 listnode_add(red_list
, red
);
639 void ospf_redist_del(struct ospf
*ospf
, uint8_t type
, unsigned short instance
)
641 struct ospf_redist
*red
;
643 red
= ospf_redist_lookup(ospf
, type
, instance
);
646 listnode_delete(ospf
->redist
[type
], red
);
647 if (!ospf
->redist
[type
]->count
) {
648 list_delete_and_null(&ospf
->redist
[type
]);
650 ospf_routemap_unset(red
);
651 XFREE(MTYPE_OSPF_REDISTRIBUTE
, red
);
656 int ospf_is_type_redistributed(struct ospf
*ospf
, int type
,
657 unsigned short instance
)
659 return (DEFAULT_ROUTE_TYPE(type
)
660 ? vrf_bitmap_check(zclient
->default_information
,
663 && redist_check_instance(
664 &zclient
->mi_redist
[AFI_IP
][type
],
668 zclient
->redist
[AFI_IP
][type
],
672 int ospf_redistribute_set(struct ospf
*ospf
, int type
, unsigned short instance
,
673 int mtype
, int mvalue
)
676 struct ospf_redist
*red
;
678 red
= ospf_redist_lookup(ospf
, type
, instance
);
682 "Redistribute[%s][%d]: Lookup failed Type[%d] , Metric[%d]",
683 ospf_redist_string(type
), instance
,
684 metric_type(ospf
, type
, instance
),
685 metric_value(ospf
, type
, instance
));
686 return CMD_WARNING_CONFIG_FAILED
;
689 if (ospf_is_type_redistributed(ospf
, type
, instance
)) {
690 if (mtype
!= red
->dmetric
.type
) {
691 red
->dmetric
.type
= mtype
;
692 force
= LSA_REFRESH_FORCE
;
694 if (mvalue
!= red
->dmetric
.value
) {
695 red
->dmetric
.value
= mvalue
;
696 force
= LSA_REFRESH_FORCE
;
699 ospf_external_lsa_refresh_type(ospf
, type
, instance
, force
);
701 if (IS_DEBUG_OSPF(zebra
, ZEBRA_REDISTRIBUTE
))
703 "Redistribute[%s][%d]: Refresh Type[%d], Metric[%d]",
704 ospf_redist_string(type
), instance
,
705 metric_type(ospf
, type
, instance
),
706 metric_value(ospf
, type
, instance
));
711 red
->dmetric
.type
= mtype
;
712 red
->dmetric
.value
= mvalue
;
714 ospf_external_add(ospf
, type
, instance
);
716 zclient_redistribute(ZEBRA_REDISTRIBUTE_ADD
, zclient
, AFI_IP
, type
,
717 instance
, ospf
->vrf_id
);
719 if (IS_DEBUG_OSPF(zebra
, ZEBRA_REDISTRIBUTE
))
721 "Redistribute[%s][%d] vrf id %u: Start Type[%d], Metric[%d]",
722 ospf_redist_string(type
), instance
, ospf
->vrf_id
,
723 metric_type(ospf
, type
, instance
),
724 metric_value(ospf
, type
, instance
));
726 ospf_asbr_status_update(ospf
, ++ospf
->redistribute
);
731 int ospf_redistribute_unset(struct ospf
*ospf
, int type
,
732 unsigned short instance
)
734 if (type
== zclient
->redist_default
&& instance
== zclient
->instance
)
737 if (!ospf_is_type_redistributed(ospf
, type
, instance
))
740 zclient_redistribute(ZEBRA_REDISTRIBUTE_DELETE
, zclient
, AFI_IP
, type
,
741 instance
, ospf
->vrf_id
);
743 if (IS_DEBUG_OSPF(zebra
, ZEBRA_REDISTRIBUTE
))
744 zlog_debug("Redistribute[%s][%d] vrf id %u: Stop",
745 ospf_redist_string(type
), instance
, ospf
->vrf_id
);
747 ospf_redist_del(ospf
, type
, instance
);
749 /* Remove the routes from OSPF table. */
750 ospf_redistribute_withdraw(ospf
, type
, instance
);
752 ospf_external_del(ospf
, type
, instance
);
754 ospf_asbr_status_update(ospf
, --ospf
->redistribute
);
759 int ospf_redistribute_default_set(struct ospf
*ospf
, int originate
, int mtype
,
762 struct ospf_redist
*red
;
764 ospf
->default_originate
= originate
;
766 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
767 red
->dmetric
.type
= mtype
;
768 red
->dmetric
.value
= mvalue
;
770 ospf_external_add(ospf
, DEFAULT_ROUTE
, 0);
772 if (ospf_is_type_redistributed(ospf
, DEFAULT_ROUTE
, 0)) {
773 /* if ospf->default_originate changes value, is calling
774 ospf_external_lsa_refresh_default sufficient to implement
776 ospf_external_lsa_refresh_default(ospf
);
778 if (IS_DEBUG_OSPF(zebra
, ZEBRA_REDISTRIBUTE
))
780 "Redistribute[%s]: Refresh Type[%d], Metric[%d]",
781 ospf_redist_string(DEFAULT_ROUTE
),
782 metric_type(ospf
, DEFAULT_ROUTE
, 0),
783 metric_value(ospf
, DEFAULT_ROUTE
, 0));
787 zclient_redistribute_default(ZEBRA_REDISTRIBUTE_DEFAULT_ADD
, zclient
,
790 if (IS_DEBUG_OSPF(zebra
, ZEBRA_REDISTRIBUTE
))
791 zlog_debug("Redistribute[DEFAULT]: Start Type[%d], Metric[%d]",
792 metric_type(ospf
, DEFAULT_ROUTE
, 0),
793 metric_value(ospf
, DEFAULT_ROUTE
, 0));
795 if (ospf
->router_id
.s_addr
== 0)
796 ospf
->external_origin
|= (1 << DEFAULT_ROUTE
);
798 thread_add_timer(master
, ospf_default_originate_timer
, ospf
, 1,
801 ospf_asbr_status_update(ospf
, ++ospf
->redistribute
);
806 int ospf_redistribute_default_unset(struct ospf
*ospf
)
808 if (!ospf_is_type_redistributed(ospf
, DEFAULT_ROUTE
, 0))
811 ospf
->default_originate
= DEFAULT_ORIGINATE_NONE
;
812 ospf_redist_del(ospf
, DEFAULT_ROUTE
, 0);
814 zclient_redistribute_default(ZEBRA_REDISTRIBUTE_DEFAULT_DELETE
, zclient
,
817 if (IS_DEBUG_OSPF(zebra
, ZEBRA_REDISTRIBUTE
))
818 zlog_debug("Redistribute[DEFAULT]: Stop");
820 // Pending: how does the external_info cleanup work in this case?
822 ospf_asbr_status_update(ospf
, --ospf
->redistribute
);
827 static int ospf_external_lsa_originate_check(struct ospf
*ospf
,
828 struct external_info
*ei
)
830 /* If prefix is multicast, then do not originate LSA. */
831 if (IN_MULTICAST(htonl(ei
->p
.prefix
.s_addr
))) {
833 "LSA[Type5:%s]: Not originate AS-external-LSA, "
834 "Prefix belongs multicast",
835 inet_ntoa(ei
->p
.prefix
));
839 /* Take care of default-originate. */
840 if (is_prefix_default(&ei
->p
))
841 if (ospf
->default_originate
== DEFAULT_ORIGINATE_NONE
) {
843 "LSA[Type5:0.0.0.0]: Not originate AS-external-LSA "
851 /* If connected prefix is OSPF enable interface, then do not announce. */
852 int ospf_distribute_check_connected(struct ospf
*ospf
, struct external_info
*ei
)
854 struct listnode
*node
;
855 struct ospf_interface
*oi
;
858 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
))
859 if (prefix_match(oi
->address
, (struct prefix
*)&ei
->p
))
864 /* return 1 if external LSA must be originated, 0 otherwise */
865 int ospf_redistribute_check(struct ospf
*ospf
, struct external_info
*ei
,
868 struct route_map_set_values save_values
;
869 struct prefix_ipv4
*p
= &ei
->p
;
870 struct ospf_redist
*red
;
871 uint8_t type
= is_prefix_default(&ei
->p
) ? DEFAULT_ROUTE
: ei
->type
;
872 unsigned short instance
= is_prefix_default(&ei
->p
) ? 0 : ei
->instance
;
877 if (!ospf_external_lsa_originate_check(ospf
, ei
))
880 /* Take care connected route. */
881 if (type
== ZEBRA_ROUTE_CONNECT
882 && !ospf_distribute_check_connected(ospf
, ei
))
885 if (!DEFAULT_ROUTE_TYPE(type
) && DISTRIBUTE_NAME(ospf
, type
))
886 /* distirbute-list exists, but access-list may not? */
887 if (DISTRIBUTE_LIST(ospf
, type
))
888 if (access_list_apply(DISTRIBUTE_LIST(ospf
, type
), p
)
890 if (IS_DEBUG_OSPF(zebra
, ZEBRA_REDISTRIBUTE
)) {
891 char buf
[PREFIX2STR_BUFFER
];
893 "Redistribute[%s]: %s filtered by distribute-list.",
894 ospf_redist_string(type
),
895 prefix2str(p
, buf
, sizeof(buf
)));
900 save_values
= ei
->route_map_set
;
901 ospf_reset_route_map_set_values(&ei
->route_map_set
);
903 /* apply route-map if needed */
904 red
= ospf_redist_lookup(ospf
, type
, instance
);
905 if (red
&& ROUTEMAP_NAME(red
)) {
908 ret
= route_map_apply(ROUTEMAP(red
), (struct prefix
*)p
,
911 if (ret
== RMAP_DENYMATCH
) {
912 ei
->route_map_set
= save_values
;
913 if (IS_DEBUG_OSPF(zebra
, ZEBRA_REDISTRIBUTE
)) {
914 char buf
[PREFIX2STR_BUFFER
];
916 "Redistribute[%s]: %s filtered by route-map.",
917 ospf_redist_string(type
),
918 prefix2str(p
, buf
, sizeof(buf
)));
923 /* check if 'route-map set' changed something */
925 *changed
= !ospf_route_map_set_compare(
926 &ei
->route_map_set
, &save_values
);
932 /* OSPF route-map set for redistribution */
933 void ospf_routemap_set(struct ospf_redist
*red
, const char *name
)
935 if (ROUTEMAP_NAME(red
))
936 free(ROUTEMAP_NAME(red
));
938 ROUTEMAP_NAME(red
) = strdup(name
);
939 ROUTEMAP(red
) = route_map_lookup_by_name(name
);
942 void ospf_routemap_unset(struct ospf_redist
*red
)
944 if (ROUTEMAP_NAME(red
))
945 free(ROUTEMAP_NAME(red
));
947 ROUTEMAP_NAME(red
) = NULL
;
948 ROUTEMAP(red
) = NULL
;
951 /* Zebra route add and delete treatment. */
952 static int ospf_zebra_read_route(int command
, struct zclient
*zclient
,
953 zebra_size_t length
, vrf_id_t vrf_id
)
955 struct zapi_route api
;
956 struct prefix_ipv4 p
;
957 unsigned long ifindex
;
958 struct in_addr nexthop
;
959 struct external_info
*ei
;
963 ospf
= ospf_lookup_by_vrf_id(vrf_id
);
967 if (zapi_route_decode(zclient
->ibuf
, &api
) < 0)
970 ifindex
= api
.nexthops
[0].ifindex
;
971 nexthop
= api
.nexthops
[0].gate
.ipv4
;
973 memcpy(&p
, &api
.prefix
, sizeof(p
));
974 if (IPV4_NET127(ntohl(p
.prefix
.s_addr
)))
977 if (IS_DEBUG_OSPF(zebra
, ZEBRA_REDISTRIBUTE
)) {
978 char buf_prefix
[PREFIX_STRLEN
];
979 prefix2str(&api
.prefix
, buf_prefix
, sizeof(buf_prefix
));
981 zlog_debug("%s: from client %s: vrf_id %d, p %s", __func__
,
982 zebra_route_string(api
.type
), vrf_id
, buf_prefix
);
985 if (command
== ZEBRA_REDISTRIBUTE_ROUTE_ADD
) {
986 /* XXX|HACK|TODO|FIXME:
987 * Maybe we should ignore reject/blackhole routes? Testing
988 * shows that there is no problems though and this is only way
989 * to "summarize" routes in ASBR at the moment. Maybe we need
990 * just a better generalised solution for these types?
993 /* Protocol tag overwrites all other tag value sent by zebra */
994 if (ospf
->dtag
[api
.type
] > 0)
995 api
.tag
= ospf
->dtag
[api
.type
];
998 * Given zebra sends update for a prefix via ADD message, it
1000 * be considered as an implicit DEL for that prefix with other
1004 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++)
1006 ospf_external_info_delete(ospf
, i
, api
.instance
,
1009 ei
= ospf_external_info_add(ospf
, api
.type
, api
.instance
, p
,
1010 ifindex
, nexthop
, api
.tag
);
1012 /* Nothing has changed, so nothing to do; return */
1015 if (ospf
->router_id
.s_addr
== 0)
1016 /* Set flags to generate AS-external-LSA originate event
1017 for each redistributed protocols later. */
1018 ospf
->external_origin
|= (1 << api
.type
);
1021 if (is_prefix_default(&p
))
1022 ospf_external_lsa_refresh_default(ospf
);
1024 struct ospf_lsa
*current
;
1026 current
= ospf_external_info_find_lsa(
1029 ospf_external_lsa_originate(
1034 ZEBRA_REDISTRIBUTE
))
1036 "ospf_zebra_read_route() : %s refreshing LSA",
1039 ospf_external_lsa_refresh(
1046 } else /* if (command == ZEBRA_REDISTRIBUTE_ROUTE_DEL) */
1048 ospf_external_info_delete(ospf
, api
.type
, api
.instance
, p
);
1049 if (is_prefix_default(&p
))
1050 ospf_external_lsa_refresh_default(ospf
);
1052 ospf_external_lsa_flush(ospf
, api
.type
, &p
,
1053 ifindex
/*, nexthop */);
1060 int ospf_distribute_list_out_set(struct ospf
*ospf
, int type
, const char *name
)
1062 /* Lookup access-list for distribute-list. */
1063 DISTRIBUTE_LIST(ospf
, type
) = access_list_lookup(AFI_IP
, name
);
1065 /* Clear previous distribute-name. */
1066 if (DISTRIBUTE_NAME(ospf
, type
))
1067 free(DISTRIBUTE_NAME(ospf
, type
));
1069 /* Set distribute-name. */
1070 DISTRIBUTE_NAME(ospf
, type
) = strdup(name
);
1072 /* If access-list have been set, schedule update timer. */
1073 if (DISTRIBUTE_LIST(ospf
, type
))
1074 ospf_distribute_list_update(ospf
, type
, 0);
1079 int ospf_distribute_list_out_unset(struct ospf
*ospf
, int type
,
1082 /* Schedule update timer. */
1083 if (DISTRIBUTE_LIST(ospf
, type
))
1084 ospf_distribute_list_update(ospf
, type
, 0);
1086 /* Unset distribute-list. */
1087 DISTRIBUTE_LIST(ospf
, type
) = NULL
;
1089 /* Clear distribute-name. */
1090 if (DISTRIBUTE_NAME(ospf
, type
))
1091 free(DISTRIBUTE_NAME(ospf
, type
));
1093 DISTRIBUTE_NAME(ospf
, type
) = NULL
;
1098 /* distribute-list update timer. */
1099 static int ospf_distribute_list_update_timer(struct thread
*thread
)
1101 struct route_node
*rn
;
1102 struct external_info
*ei
;
1103 struct route_table
*rt
;
1104 struct ospf_lsa
*lsa
;
1105 int type
, default_refresh
= 0, arg_type
;
1106 struct ospf
*ospf
= NULL
;
1107 void **arg
= THREAD_ARG(thread
);
1109 ospf
= (struct ospf
*)arg
[0];
1110 arg_type
= (int)(intptr_t)arg
[1];
1115 ospf
->t_distribute_update
= NULL
;
1117 zlog_info("Zebra[Redistribute]: distribute-list update timer fired!");
1119 if (IS_DEBUG_OSPF_EVENT
) {
1121 "%s: ospf distribute-list update arg_type %d vrf %s id %d",
1122 __PRETTY_FUNCTION__
, arg_type
,
1123 ospf_vrf_id_to_name(ospf
->vrf_id
), ospf
->vrf_id
);
1126 /* foreach all external info. */
1127 for (type
= 0; type
<= ZEBRA_ROUTE_MAX
; type
++) {
1128 struct list
*ext_list
;
1129 struct listnode
*node
;
1130 struct ospf_external
*ext
;
1132 ext_list
= ospf
->external
[type
];
1136 for (ALL_LIST_ELEMENTS_RO(ext_list
, node
, ext
)) {
1137 rt
= ext
->external_info
;
1140 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
))
1141 if ((ei
= rn
->info
) != NULL
) {
1142 if (is_prefix_default(&ei
->p
))
1143 default_refresh
= 1;
1145 (lsa
= ospf_external_info_find_lsa(
1147 ospf_external_lsa_refresh(
1149 LSA_REFRESH_IF_CHANGED
);
1151 ospf_external_lsa_originate(
1156 if (default_refresh
)
1157 ospf_external_lsa_refresh_default(ospf
);
1159 XFREE(MTYPE_OSPF_DIST_ARGS
, arg
);
1163 /* Update distribute-list and set timer to apply access-list. */
1164 void ospf_distribute_list_update(struct ospf
*ospf
, int type
,
1165 unsigned short instance
)
1167 struct route_table
*rt
;
1168 struct ospf_external
*ext
;
1169 void **args
= XCALLOC(MTYPE_OSPF_DIST_ARGS
, sizeof(void *) * 2);
1172 args
[1] = (void *)((ptrdiff_t)type
);
1174 /* External info does not exist. */
1175 ext
= ospf_external_lookup(ospf
, type
, instance
);
1176 if (!ext
|| !(rt
= EXTERNAL_INFO(ext
))) {
1177 XFREE(MTYPE_OSPF_DIST_ARGS
, args
);
1181 /* If exists previously invoked thread, then let it continue. */
1182 if (ospf
->t_distribute_update
) {
1183 XFREE(MTYPE_OSPF_DIST_ARGS
, args
);
1188 ospf
->t_distribute_update
= NULL
;
1189 thread_add_timer_msec(master
, ospf_distribute_list_update_timer
,
1190 (void **)args
, ospf
->min_ls_interval
,
1191 &ospf
->t_distribute_update
);
1194 /* If access-list is updated, apply some check. */
1195 static void ospf_filter_update(struct access_list
*access
)
1200 struct ospf_area
*area
;
1201 struct listnode
*node
, *n1
;
1203 /* If OSPF instance does not exist, return right now. */
1204 if (listcount(om
->ospf
) == 0)
1207 /* Iterate all ospf [VRF] instances */
1208 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, n1
, ospf
)) {
1209 /* Update distribute-list, and apply filter. */
1210 for (type
= 0; type
<= ZEBRA_ROUTE_MAX
; type
++) {
1211 struct list
*red_list
;
1212 struct listnode
*node
;
1213 struct ospf_redist
*red
;
1215 red_list
= ospf
->redist
[type
];
1217 for (ALL_LIST_ELEMENTS_RO(red_list
, node
,
1219 if (ROUTEMAP(red
)) {
1220 /* if route-map is not NULL it
1222 * using this access list */
1223 ospf_distribute_list_update(
1229 /* There is place for route-map for default-information
1230 * (ZEBRA_ROUTE_MAX),
1231 * but no distribute list. */
1232 if (type
== ZEBRA_ROUTE_MAX
)
1235 if (DISTRIBUTE_NAME(ospf
, type
)) {
1236 /* Keep old access-list for distribute-list. */
1237 struct access_list
*old
=
1238 DISTRIBUTE_LIST(ospf
, type
);
1240 /* Update access-list for distribute-list. */
1241 DISTRIBUTE_LIST(ospf
, type
) =
1244 DISTRIBUTE_NAME(ospf
, type
));
1246 /* No update for this distribute type. */
1248 && DISTRIBUTE_LIST(ospf
, type
) == NULL
)
1251 /* Schedule distribute-list update timer. */
1252 if (DISTRIBUTE_LIST(ospf
, type
) == NULL
1253 || strcmp(DISTRIBUTE_NAME(ospf
, type
),
1256 ospf_distribute_list_update(ospf
, type
,
1261 /* Update Area access-list. */
1262 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
1263 if (EXPORT_NAME(area
)) {
1264 EXPORT_LIST(area
) = NULL
;
1268 if (IMPORT_NAME(area
)) {
1269 IMPORT_LIST(area
) = NULL
;
1274 /* Schedule ABR tasks -- this will be changed -- takada. */
1275 if (IS_OSPF_ABR(ospf
) && abr_inv
)
1276 ospf_schedule_abr_task(ospf
);
1280 /* If prefix-list is updated, do some updates. */
1281 void ospf_prefix_list_update(struct prefix_list
*plist
)
1283 struct ospf
*ospf
= NULL
;
1286 struct ospf_area
*area
;
1287 struct listnode
*node
, *n1
;
1289 /* If OSPF instatnce does not exist, return right now. */
1290 if (listcount(om
->ospf
) == 0)
1293 /* Iterate all ospf [VRF] instances */
1294 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, n1
, ospf
)) {
1296 /* Update all route-maps which are used
1297 * as redistribution filters.
1298 * They might use prefix-list.
1300 for (type
= 0; type
<= ZEBRA_ROUTE_MAX
; type
++) {
1301 struct list
*red_list
;
1302 struct listnode
*node
;
1303 struct ospf_redist
*red
;
1305 red_list
= ospf
->redist
[type
];
1307 for (ALL_LIST_ELEMENTS_RO(red_list
, node
,
1309 if (ROUTEMAP(red
)) {
1310 /* if route-map is not NULL
1312 * this prefix list */
1313 ospf_distribute_list_update(
1321 /* Update area filter-lists. */
1322 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
1323 /* Update filter-list in. */
1324 if (PREFIX_NAME_IN(area
))
1325 if (strcmp(PREFIX_NAME_IN(area
),
1326 prefix_list_name(plist
))
1328 PREFIX_LIST_IN(area
) =
1331 PREFIX_NAME_IN(area
));
1335 /* Update filter-list out. */
1336 if (PREFIX_NAME_OUT(area
))
1337 if (strcmp(PREFIX_NAME_OUT(area
),
1338 prefix_list_name(plist
))
1340 PREFIX_LIST_IN(area
) =
1343 PREFIX_NAME_OUT(area
));
1348 /* Schedule ABR task. */
1349 if (IS_OSPF_ABR(ospf
) && abr_inv
)
1350 ospf_schedule_abr_task(ospf
);
1354 static struct ospf_distance
*ospf_distance_new(void)
1356 return XCALLOC(MTYPE_OSPF_DISTANCE
, sizeof(struct ospf_distance
));
1359 static void ospf_distance_free(struct ospf_distance
*odistance
)
1361 XFREE(MTYPE_OSPF_DISTANCE
, odistance
);
1364 int ospf_distance_set(struct vty
*vty
, struct ospf
*ospf
,
1365 const char *distance_str
, const char *ip_str
,
1366 const char *access_list_str
)
1369 struct prefix_ipv4 p
;
1371 struct route_node
*rn
;
1372 struct ospf_distance
*odistance
;
1374 ret
= str2prefix_ipv4(ip_str
, &p
);
1376 vty_out(vty
, "Malformed prefix\n");
1377 return CMD_WARNING_CONFIG_FAILED
;
1380 distance
= atoi(distance_str
);
1382 /* Get OSPF distance node. */
1383 rn
= route_node_get(ospf
->distance_table
, (struct prefix
*)&p
);
1385 odistance
= rn
->info
;
1386 route_unlock_node(rn
);
1388 odistance
= ospf_distance_new();
1389 rn
->info
= odistance
;
1392 /* Set distance value. */
1393 odistance
->distance
= distance
;
1395 /* Reset access-list configuration. */
1396 if (odistance
->access_list
) {
1397 free(odistance
->access_list
);
1398 odistance
->access_list
= NULL
;
1400 if (access_list_str
)
1401 odistance
->access_list
= strdup(access_list_str
);
1406 int ospf_distance_unset(struct vty
*vty
, struct ospf
*ospf
,
1407 const char *distance_str
, const char *ip_str
,
1408 char const *access_list_str
)
1411 struct prefix_ipv4 p
;
1412 struct route_node
*rn
;
1413 struct ospf_distance
*odistance
;
1415 ret
= str2prefix_ipv4(ip_str
, &p
);
1417 vty_out(vty
, "Malformed prefix\n");
1418 return CMD_WARNING_CONFIG_FAILED
;
1421 rn
= route_node_lookup(ospf
->distance_table
, (struct prefix
*)&p
);
1423 vty_out(vty
, "Can't find specified prefix\n");
1424 return CMD_WARNING_CONFIG_FAILED
;
1427 odistance
= rn
->info
;
1429 if (odistance
->access_list
)
1430 free(odistance
->access_list
);
1431 ospf_distance_free(odistance
);
1434 route_unlock_node(rn
);
1435 route_unlock_node(rn
);
1440 void ospf_distance_reset(struct ospf
*ospf
)
1442 struct route_node
*rn
;
1443 struct ospf_distance
*odistance
;
1445 for (rn
= route_top(ospf
->distance_table
); rn
; rn
= route_next(rn
))
1446 if ((odistance
= rn
->info
) != NULL
) {
1447 if (odistance
->access_list
)
1448 free(odistance
->access_list
);
1449 ospf_distance_free(odistance
);
1451 route_unlock_node(rn
);
1455 uint8_t ospf_distance_apply(struct ospf
*ospf
, struct prefix_ipv4
*p
,
1456 struct ospf_route
* or)
1462 if (ospf
->distance_intra
)
1463 if (or->path_type
== OSPF_PATH_INTRA_AREA
)
1464 return ospf
->distance_intra
;
1466 if (ospf
->distance_inter
)
1467 if (or->path_type
== OSPF_PATH_INTER_AREA
)
1468 return ospf
->distance_inter
;
1470 if (ospf
->distance_external
)
1471 if (or->path_type
== OSPF_PATH_TYPE1_EXTERNAL
||
1472 or->path_type
== OSPF_PATH_TYPE2_EXTERNAL
)
1473 return ospf
->distance_external
;
1475 if (ospf
->distance_all
)
1476 return ospf
->distance_all
;
1481 void ospf_zebra_vrf_register(struct ospf
*ospf
)
1483 if (!zclient
|| zclient
->sock
< 0 || !ospf
)
1486 if (ospf
->vrf_id
!= VRF_UNKNOWN
) {
1487 if (IS_DEBUG_OSPF_EVENT
)
1488 zlog_debug("%s: Register VRF %s id %u",
1489 __PRETTY_FUNCTION__
,
1490 ospf_vrf_id_to_name(ospf
->vrf_id
),
1492 zclient_send_reg_requests(zclient
, ospf
->vrf_id
);
1496 void ospf_zebra_vrf_deregister(struct ospf
*ospf
)
1498 if (!zclient
|| zclient
->sock
< 0 || !ospf
)
1501 if (ospf
->vrf_id
!= VRF_DEFAULT
&& ospf
->vrf_id
!= VRF_UNKNOWN
) {
1502 if (IS_DEBUG_OSPF_EVENT
)
1503 zlog_debug("%s: De-Register VRF %s id %u to Zebra.",
1504 __PRETTY_FUNCTION__
,
1505 ospf_vrf_id_to_name(ospf
->vrf_id
),
1507 /* Deregister for router-id, interfaces,
1508 * redistributed routes. */
1509 zclient_send_dereg_requests(zclient
, ospf
->vrf_id
);
1512 static void ospf_zebra_connected(struct zclient
*zclient
)
1514 /* Send the client registration */
1515 bfd_client_sendmsg(zclient
, ZEBRA_BFD_CLIENT_REGISTER
);
1517 zclient_send_reg_requests(zclient
, VRF_DEFAULT
);
1520 void ospf_zebra_init(struct thread_master
*master
, unsigned short instance
)
1522 /* Allocate zebra structure. */
1523 zclient
= zclient_new_notify(master
, &zclient_options_default
);
1524 zclient_init(zclient
, ZEBRA_ROUTE_OSPF
, instance
, &ospfd_privs
);
1525 zclient
->zebra_connected
= ospf_zebra_connected
;
1526 zclient
->router_id_update
= ospf_router_id_update_zebra
;
1527 zclient
->interface_add
= ospf_interface_add
;
1528 zclient
->interface_delete
= ospf_interface_delete
;
1529 zclient
->interface_up
= ospf_interface_state_up
;
1530 zclient
->interface_down
= ospf_interface_state_down
;
1531 zclient
->interface_address_add
= ospf_interface_address_add
;
1532 zclient
->interface_address_delete
= ospf_interface_address_delete
;
1533 zclient
->interface_link_params
= ospf_interface_link_params
;
1534 zclient
->interface_vrf_update
= ospf_interface_vrf_update
;
1536 zclient
->redistribute_route_add
= ospf_zebra_read_route
;
1537 zclient
->redistribute_route_del
= ospf_zebra_read_route
;
1539 access_list_add_hook(ospf_filter_update
);
1540 access_list_delete_hook(ospf_filter_update
);
1541 prefix_list_add_hook(ospf_prefix_list_update
);
1542 prefix_list_delete_hook(ospf_prefix_list_update
);