2 * Copyright (C) 2003 Yasuhiro Ohara
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 #include "route_opaque.h"
32 #include "lib_errors.h"
34 #include "ospf6_proto.h"
35 #include "ospf6_top.h"
36 #include "ospf6_interface.h"
37 #include "ospf6_route.h"
38 #include "ospf6_lsa.h"
39 #include "ospf6_lsdb.h"
40 #include "ospf6_asbr.h"
41 #include "ospf6_nssa.h"
42 #include "ospf6_zebra.h"
44 #include "ospf6_area.h"
48 DEFINE_MTYPE_STATIC(OSPF6D
, OSPF6_DISTANCE
, "OSPF6 distance");
50 unsigned char conf_debug_ospf6_zebra
= 0;
52 /* information about zebra. */
53 struct zclient
*zclient
= NULL
;
55 void ospf6_zebra_vrf_register(struct ospf6
*ospf6
)
57 if (!zclient
|| zclient
->sock
< 0 || !ospf6
)
60 if (ospf6
->vrf_id
!= VRF_UNKNOWN
) {
61 if (IS_OSPF6_DEBUG_ZEBRA(RECV
)) {
62 zlog_debug("%s: Register VRF %s id %u", __func__
,
63 ospf6_vrf_id_to_name(ospf6
->vrf_id
),
66 zclient_send_reg_requests(zclient
, ospf6
->vrf_id
);
70 void ospf6_zebra_vrf_deregister(struct ospf6
*ospf6
)
72 if (!zclient
|| zclient
->sock
< 0 || !ospf6
)
75 if (ospf6
->vrf_id
!= VRF_DEFAULT
&& ospf6
->vrf_id
!= VRF_UNKNOWN
) {
76 if (IS_OSPF6_DEBUG_ZEBRA(RECV
)) {
77 zlog_debug("%s: De-Register VRF %s id %u to Zebra.",
79 ospf6_vrf_id_to_name(ospf6
->vrf_id
),
82 /* Deregister for router-id, interfaces,
83 * redistributed routes. */
84 zclient_send_dereg_requests(zclient
, ospf6
->vrf_id
);
88 /* Router-id update message from zebra. */
89 static int ospf6_router_id_update_zebra(ZAPI_CALLBACK_ARGS
)
91 struct prefix router_id
;
94 zebra_router_id_update_read(zclient
->ibuf
, &router_id
);
96 if (IS_OSPF6_DEBUG_ZEBRA(RECV
))
97 zlog_debug("Zebra router-id update %pI4 vrf %s id %u",
98 &router_id
.u
.prefix4
, ospf6_vrf_id_to_name(vrf_id
),
101 o
= ospf6_lookup_by_vrf_id(vrf_id
);
105 o
->router_id_zebra
= router_id
.u
.prefix4
.s_addr
;
107 ospf6_router_id_update(o
, false);
112 /* redistribute function */
113 void ospf6_zebra_redistribute(int type
, vrf_id_t vrf_id
)
115 if (vrf_bitmap_check(zclient
->redist
[AFI_IP6
][type
], vrf_id
))
117 vrf_bitmap_set(zclient
->redist
[AFI_IP6
][type
], vrf_id
);
119 if (zclient
->sock
> 0)
120 zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD
, zclient
,
121 AFI_IP6
, type
, 0, vrf_id
);
124 void ospf6_zebra_no_redistribute(int type
, vrf_id_t vrf_id
)
126 if (!vrf_bitmap_check(zclient
->redist
[AFI_IP6
][type
], vrf_id
))
128 vrf_bitmap_unset(zclient
->redist
[AFI_IP6
][type
], vrf_id
);
129 if (zclient
->sock
> 0)
130 zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE
, zclient
,
131 AFI_IP6
, type
, 0, vrf_id
);
134 void ospf6_zebra_import_default_route(struct ospf6
*ospf6
, bool unreg
)
136 struct prefix prefix
= {};
139 if (zclient
->sock
< 0) {
140 if (IS_OSPF6_DEBUG_ZEBRA(SEND
))
141 zlog_debug(" Not connected to Zebra");
145 prefix
.family
= AF_INET6
;
146 prefix
.prefixlen
= 0;
149 command
= ZEBRA_NEXTHOP_UNREGISTER
;
151 command
= ZEBRA_NEXTHOP_REGISTER
;
153 if (IS_OSPF6_DEBUG_ZEBRA(SEND
))
154 zlog_debug("%s: sending cmd %s for %pFX (vrf %u)", __func__
,
155 zserv_command_string(command
), &prefix
,
158 if (zclient_send_rnh(zclient
, command
, &prefix
, SAFI_UNICAST
, false,
160 == ZCLIENT_SEND_FAILURE
)
161 flog_err(EC_LIB_ZAPI_SOCKET
, "%s: zclient_send_rnh() failed",
165 static int ospf6_zebra_import_check_update(ZAPI_CALLBACK_ARGS
)
168 struct zapi_route nhr
;
169 struct prefix matched
;
171 ospf6
= ospf6_lookup_by_vrf_id(vrf_id
);
172 if (ospf6
== NULL
|| !IS_OSPF6_ASBR(ospf6
))
175 if (!zapi_nexthop_update_decode(zclient
->ibuf
, &matched
, &nhr
)) {
176 zlog_err("%s[%u]: Failure to decode route", __func__
,
181 if (matched
.family
!= AF_INET6
|| matched
.prefixlen
!= 0 ||
182 nhr
.type
== ZEBRA_ROUTE_OSPF6
)
185 ospf6
->nssa_default_import_check
.status
= !!nhr
.nexthop_num
;
186 ospf6_abr_nssa_type_7_defaults(ospf6
);
191 static int ospf6_zebra_if_address_update_add(ZAPI_CALLBACK_ARGS
)
195 c
= zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_ADD
,
196 zclient
->ibuf
, vrf_id
);
200 if (IS_OSPF6_DEBUG_ZEBRA(RECV
))
201 zlog_debug("Zebra Interface address add: %s %5s %pFX",
202 c
->ifp
->name
, prefix_family_str(c
->address
),
205 if (c
->address
->family
== AF_INET6
) {
206 ospf6_interface_state_update(c
->ifp
);
207 ospf6_interface_connected_route_update(c
->ifp
);
212 static int ospf6_zebra_if_address_update_delete(ZAPI_CALLBACK_ARGS
)
216 c
= zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_DELETE
,
217 zclient
->ibuf
, vrf_id
);
221 if (IS_OSPF6_DEBUG_ZEBRA(RECV
))
222 zlog_debug("Zebra Interface address delete: %s %5s %pFX",
223 c
->ifp
->name
, prefix_family_str(c
->address
),
226 if (c
->address
->family
== AF_INET6
) {
227 ospf6_interface_connected_route_update(c
->ifp
);
228 ospf6_interface_state_update(c
->ifp
);
236 static int ospf6_zebra_gr_update(struct ospf6
*ospf6
, int command
,
241 if (!zclient
|| zclient
->sock
< 0 || !ospf6
)
244 memset(&api
, 0, sizeof(api
));
246 api
.stale_removal_time
= stale_time
;
247 api
.vrf_id
= ospf6
->vrf_id
;
249 (void)zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES
, zclient
,
255 int ospf6_zebra_gr_enable(struct ospf6
*ospf6
, uint32_t stale_time
)
257 return ospf6_zebra_gr_update(ospf6
, ZEBRA_CLIENT_GR_CAPABILITIES
,
261 int ospf6_zebra_gr_disable(struct ospf6
*ospf6
)
263 return ospf6_zebra_gr_update(ospf6
, ZEBRA_CLIENT_GR_DISABLE
, 0);
266 static int ospf6_zebra_read_route(ZAPI_CALLBACK_ARGS
)
268 struct zapi_route api
;
269 unsigned long ifindex
;
270 struct in6_addr
*nexthop
;
272 struct prefix_ipv6 p
;
274 ospf6
= ospf6_lookup_by_vrf_id(vrf_id
);
279 if (zapi_route_decode(zclient
->ibuf
, &api
) < 0)
282 /* we completely ignore srcdest routes for now. */
283 if (CHECK_FLAG(api
.message
, ZAPI_MESSAGE_SRCPFX
))
286 if (IN6_IS_ADDR_LINKLOCAL(&api
.prefix
.u
.prefix6
))
289 ifindex
= api
.nexthops
[0].ifindex
;
290 nexthop
= &api
.nexthops
[0].gate
.ipv6
;
292 if (IS_OSPF6_DEBUG_ZEBRA(RECV
))
294 "Zebra Receive route %s: %s %pFX nexthop %pI6 ifindex %ld tag %" ROUTE_TAG_PRI
,
295 (cmd
== ZEBRA_REDISTRIBUTE_ROUTE_ADD
? "add"
297 zebra_route_string(api
.type
), &api
.prefix
, nexthop
,
300 memcpy(&p
, &api
.prefix
, sizeof(p
));
301 if (is_default_prefix6(&p
))
302 api
.type
= DEFAULT_ROUTE
;
304 if (cmd
== ZEBRA_REDISTRIBUTE_ROUTE_ADD
)
305 ospf6_asbr_redistribute_add(api
.type
, ifindex
, &api
.prefix
,
306 api
.nexthop_num
, nexthop
, api
.tag
,
309 ospf6_asbr_redistribute_remove(api
.type
, ifindex
, &api
.prefix
,
316 show_ospf6_zebra_cmd
,
317 "show ipv6 ospf6 zebra [json]",
325 bool uj
= use_json(argc
, argv
);
327 json_object
*json_zebra
;
328 json_object
*json_array
;
330 if (zclient
== NULL
) {
331 vty_out(vty
, "Not connected to zebra\n");
336 json
= json_object_new_object();
337 json_zebra
= json_object_new_object();
338 json_array
= json_object_new_array();
340 json_object_int_add(json_zebra
, "fail", zclient
->fail
);
342 json_zebra
, "redistributeDefault",
343 vrf_bitmap_check(zclient
->default_information
[AFI_IP6
],
345 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
346 if (vrf_bitmap_check(zclient
->redist
[AFI_IP6
][i
],
348 json_object_array_add(
350 json_object_new_string(
351 zebra_route_string(i
)));
353 json_object_object_add(json_zebra
, "redistribute", json_array
);
354 json_object_object_add(json
, "zebraInformation", json_zebra
);
358 vty_out(vty
, "Zebra Information\n");
359 vty_out(vty
, " fail: %d\n", zclient
->fail
);
360 vty_out(vty
, " redistribute default: %d\n",
361 vrf_bitmap_check(zclient
->default_information
[AFI_IP6
],
363 vty_out(vty
, " redistribute:");
364 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
365 if (vrf_bitmap_check(zclient
->redist
[AFI_IP6
][i
],
367 vty_out(vty
, " %s", zebra_route_string(i
));
374 static void ospf6_zebra_append_opaque_attr(struct ospf6_route
*request
,
375 struct zapi_route
*api
)
377 struct ospf_zebra_opaque ospf_opaque
= {};
380 snprintf(ospf_opaque
.path_type
, sizeof(ospf_opaque
.path_type
), "%s",
381 OSPF6_PATH_TYPE_NAME(request
->path
.type
));
383 switch (request
->path
.type
) {
384 case OSPF6_PATH_TYPE_INTRA
:
385 case OSPF6_PATH_TYPE_INTER
:
387 (void)inet_ntop(AF_INET
, &request
->path
.area_id
,
389 sizeof(ospf_opaque
.area_id
));
391 case OSPF6_PATH_TYPE_EXTERNAL1
:
392 case OSPF6_PATH_TYPE_EXTERNAL2
:
394 snprintf(ospf_opaque
.tag
, sizeof(ospf_opaque
.tag
), "%u",
401 SET_FLAG(api
->message
, ZAPI_MESSAGE_OPAQUE
);
402 api
->opaque
.length
= sizeof(struct ospf_zebra_opaque
);
403 memcpy(api
->opaque
.data
, &ospf_opaque
, api
->opaque
.length
);
408 static void ospf6_zebra_route_update(int type
, struct ospf6_route
*request
,
411 struct zapi_route api
;
416 if (IS_OSPF6_DEBUG_ZEBRA(SEND
))
417 zlog_debug("Zebra Send %s route: %pFX",
418 (type
== REM
? "remove" : "add"), &request
->prefix
);
420 if (zclient
->sock
< 0) {
421 if (IS_OSPF6_DEBUG_ZEBRA(SEND
))
422 zlog_debug(" Not connected to Zebra");
426 if (request
->path
.origin
.adv_router
== ospf6
->router_id
427 && (request
->path
.type
== OSPF6_PATH_TYPE_EXTERNAL1
428 || request
->path
.type
== OSPF6_PATH_TYPE_EXTERNAL2
)) {
429 if (IS_OSPF6_DEBUG_ZEBRA(SEND
))
430 zlog_debug(" Ignore self-originated external route");
434 /* If removing is the best path and if there's another path,
435 treat this request as add the secondary path */
436 if (type
== REM
&& ospf6_route_is_best(request
) && request
->next
437 && ospf6_route_is_same(request
, request
->next
)) {
438 if (IS_OSPF6_DEBUG_ZEBRA(SEND
))
440 " Best-path removal resulted Secondary addition");
442 request
= request
->next
;
445 /* Only the best path will be sent to zebra. */
446 if (!ospf6_route_is_best(request
)) {
447 /* this is not preferred best route, ignore */
448 if (IS_OSPF6_DEBUG_ZEBRA(SEND
))
449 zlog_debug(" Ignore non-best route");
453 nhcount
= ospf6_route_num_nexthops(request
);
455 if (IS_OSPF6_DEBUG_ZEBRA(SEND
))
456 zlog_debug(" No nexthop, ignore");
460 dest
= &request
->prefix
;
462 memset(&api
, 0, sizeof(api
));
463 api
.vrf_id
= ospf6
->vrf_id
;
464 api
.type
= ZEBRA_ROUTE_OSPF6
;
465 api
.safi
= SAFI_UNICAST
;
467 SET_FLAG(api
.message
, ZAPI_MESSAGE_NEXTHOP
);
469 if (nhcount
> ospf6
->max_multipath
) {
470 if (IS_OSPF6_DEBUG_ZEBRA(SEND
))
472 " Nexthop count is greater than configured maximum-path, hence ignore the extra nexthops");
474 api
.nexthop_num
= MIN(nhcount
, ospf6
->max_multipath
);
476 ospf6_route_zebra_copy_nexthops(request
, api
.nexthops
, api
.nexthop_num
,
478 SET_FLAG(api
.message
, ZAPI_MESSAGE_METRIC
);
479 api
.metric
= (request
->path
.metric_type
== 2 ? request
->path
.u
.cost_e2
480 : request
->path
.cost
);
481 if (request
->path
.tag
) {
482 SET_FLAG(api
.message
, ZAPI_MESSAGE_TAG
);
483 api
.tag
= request
->path
.tag
;
486 SET_FLAG(api
.message
, ZAPI_MESSAGE_DISTANCE
);
487 api
.distance
= ospf6_distance_apply((struct prefix_ipv6
*)dest
, request
,
491 && CHECK_FLAG(ospf6
->config_flags
, OSPF6_SEND_EXTRA_DATA_TO_ZEBRA
))
492 ospf6_zebra_append_opaque_attr(request
, &api
);
495 ret
= zclient_route_send(ZEBRA_ROUTE_DELETE
, zclient
, &api
);
497 ret
= zclient_route_send(ZEBRA_ROUTE_ADD
, zclient
, &api
);
499 if (ret
== ZCLIENT_SEND_FAILURE
)
500 flog_err(EC_LIB_ZAPI_SOCKET
,
501 "zclient_route_send() %s failed: %s",
502 (type
== REM
? "delete" : "add"),
503 safe_strerror(errno
));
508 void ospf6_zebra_route_update_add(struct ospf6_route
*request
,
511 if (ospf6
->gr_info
.restart_in_progress
512 || ospf6
->gr_info
.prepare_in_progress
) {
513 if (IS_DEBUG_OSPF6_GR
)
515 "Zebra: Graceful Restart in progress -- not installing %pFX",
520 ospf6_zebra_route_update(ADD
, request
, ospf6
);
523 void ospf6_zebra_route_update_remove(struct ospf6_route
*request
,
526 if (ospf6
->gr_info
.restart_in_progress
527 || ospf6
->gr_info
.prepare_in_progress
) {
528 if (IS_DEBUG_OSPF6_GR
)
530 "Zebra: Graceful Restart in progress -- not uninstalling %pFX",
535 ospf6_zebra_route_update(REM
, request
, ospf6
);
538 void ospf6_zebra_add_discard(struct ospf6_route
*request
, struct ospf6
*ospf6
)
540 struct zapi_route api
;
541 struct prefix
*dest
= &request
->prefix
;
543 if (ospf6
->gr_info
.restart_in_progress
544 || ospf6
->gr_info
.prepare_in_progress
) {
545 if (IS_DEBUG_OSPF6_GR
)
547 "Zebra: Graceful Restart in progress -- not installing %pFX",
552 if (!CHECK_FLAG(request
->flag
, OSPF6_ROUTE_BLACKHOLE_ADDED
)) {
553 memset(&api
, 0, sizeof(api
));
554 api
.vrf_id
= ospf6
->vrf_id
;
555 api
.type
= ZEBRA_ROUTE_OSPF6
;
556 api
.safi
= SAFI_UNICAST
;
558 zapi_route_set_blackhole(&api
, BLACKHOLE_NULL
);
560 zclient_route_send(ZEBRA_ROUTE_ADD
, zclient
, &api
);
562 if (IS_OSPF6_DEBUG_ZEBRA(SEND
))
563 zlog_debug("Zebra: Route add discard %pFX", dest
);
565 SET_FLAG(request
->flag
, OSPF6_ROUTE_BLACKHOLE_ADDED
);
567 if (IS_OSPF6_DEBUG_ZEBRA(SEND
))
569 "Zebra: Blackhole route present already %pFX",
574 void ospf6_zebra_delete_discard(struct ospf6_route
*request
,
577 struct zapi_route api
;
578 struct prefix
*dest
= &request
->prefix
;
580 if (ospf6
->gr_info
.restart_in_progress
581 || ospf6
->gr_info
.prepare_in_progress
) {
582 if (IS_DEBUG_OSPF6_GR
)
584 "Zebra: Graceful Restart in progress -- not uninstalling %pFX",
589 if (CHECK_FLAG(request
->flag
, OSPF6_ROUTE_BLACKHOLE_ADDED
)) {
590 memset(&api
, 0, sizeof(api
));
591 api
.vrf_id
= ospf6
->vrf_id
;
592 api
.type
= ZEBRA_ROUTE_OSPF6
;
593 api
.safi
= SAFI_UNICAST
;
595 zapi_route_set_blackhole(&api
, BLACKHOLE_NULL
);
597 zclient_route_send(ZEBRA_ROUTE_DELETE
, zclient
, &api
);
599 if (IS_OSPF6_DEBUG_ZEBRA(SEND
))
600 zlog_debug("Zebra: Route delete discard %pFX", dest
);
602 UNSET_FLAG(request
->flag
, OSPF6_ROUTE_BLACKHOLE_ADDED
);
604 if (IS_OSPF6_DEBUG_ZEBRA(SEND
))
606 "Zebra: Blackhole route already deleted %pFX",
611 static struct ospf6_distance
*ospf6_distance_new(void)
613 return XCALLOC(MTYPE_OSPF6_DISTANCE
, sizeof(struct ospf6_distance
));
616 static void ospf6_distance_free(struct ospf6_distance
*odistance
)
618 XFREE(MTYPE_OSPF6_DISTANCE
, odistance
);
621 int ospf6_distance_set(struct vty
*vty
, struct ospf6
*o
,
622 const char *distance_str
, const char *ip_str
,
623 const char *access_list_str
)
626 struct prefix_ipv6 p
;
628 struct route_node
*rn
;
629 struct ospf6_distance
*odistance
;
631 ret
= str2prefix_ipv6(ip_str
, &p
);
633 vty_out(vty
, "Malformed prefix\n");
634 return CMD_WARNING_CONFIG_FAILED
;
637 distance
= atoi(distance_str
);
639 /* Get OSPF6 distance node. */
640 rn
= route_node_get(o
->distance_table
, (struct prefix
*)&p
);
642 odistance
= rn
->info
;
643 route_unlock_node(rn
);
645 odistance
= ospf6_distance_new();
646 rn
->info
= odistance
;
649 /* Set distance value. */
650 odistance
->distance
= distance
;
652 /* Reset access-list configuration. */
653 if (odistance
->access_list
) {
654 free(odistance
->access_list
);
655 odistance
->access_list
= NULL
;
658 odistance
->access_list
= strdup(access_list_str
);
663 int ospf6_distance_unset(struct vty
*vty
, struct ospf6
*o
,
664 const char *distance_str
, const char *ip_str
,
665 const char *access_list_str
)
668 struct prefix_ipv6 p
;
669 struct route_node
*rn
;
670 struct ospf6_distance
*odistance
;
672 ret
= str2prefix_ipv6(ip_str
, &p
);
674 vty_out(vty
, "Malformed prefix\n");
675 return CMD_WARNING_CONFIG_FAILED
;
678 rn
= route_node_lookup(o
->distance_table
, (struct prefix
*)&p
);
680 vty_out(vty
, "Cant't find specified prefix\n");
681 return CMD_WARNING_CONFIG_FAILED
;
684 odistance
= rn
->info
;
686 if (odistance
->access_list
)
687 free(odistance
->access_list
);
688 ospf6_distance_free(odistance
);
691 route_unlock_node(rn
);
692 route_unlock_node(rn
);
697 void ospf6_distance_reset(struct ospf6
*o
)
699 struct route_node
*rn
;
700 struct ospf6_distance
*odistance
;
702 for (rn
= route_top(o
->distance_table
); rn
; rn
= route_next(rn
))
703 if ((odistance
= rn
->info
) != NULL
) {
704 if (odistance
->access_list
)
705 free(odistance
->access_list
);
706 ospf6_distance_free(odistance
);
708 route_unlock_node(rn
);
712 uint8_t ospf6_distance_apply(struct prefix_ipv6
*p
, struct ospf6_route
* or,
721 if (o
->distance_intra
)
722 if (or->path
.type
== OSPF6_PATH_TYPE_INTRA
)
723 return o
->distance_intra
;
725 if (o
->distance_inter
)
726 if (or->path
.type
== OSPF6_PATH_TYPE_INTER
)
727 return o
->distance_inter
;
729 if (o
->distance_external
)
730 if (or->path
.type
== OSPF6_PATH_TYPE_EXTERNAL1
||
731 or->path
.type
== OSPF6_PATH_TYPE_EXTERNAL2
)
732 return o
->distance_external
;
735 return o
->distance_all
;
740 static void ospf6_zebra_connected(struct zclient
*zclient
)
742 /* Send the client registration */
743 bfd_client_sendmsg(zclient
, ZEBRA_BFD_CLIENT_REGISTER
, VRF_DEFAULT
);
745 zclient_send_reg_requests(zclient
, VRF_DEFAULT
);
748 static zclient_handler
*const ospf6_handlers
[] = {
749 [ZEBRA_ROUTER_ID_UPDATE
] = ospf6_router_id_update_zebra
,
750 [ZEBRA_INTERFACE_ADDRESS_ADD
] = ospf6_zebra_if_address_update_add
,
751 [ZEBRA_INTERFACE_ADDRESS_DELETE
] = ospf6_zebra_if_address_update_delete
,
752 [ZEBRA_REDISTRIBUTE_ROUTE_ADD
] = ospf6_zebra_read_route
,
753 [ZEBRA_REDISTRIBUTE_ROUTE_DEL
] = ospf6_zebra_read_route
,
754 [ZEBRA_NEXTHOP_UPDATE
] = ospf6_zebra_import_check_update
,
757 void ospf6_zebra_init(struct thread_master
*master
)
759 /* Allocate zebra structure. */
760 zclient
= zclient_new(master
, &zclient_options_default
, ospf6_handlers
,
761 array_size(ospf6_handlers
));
762 zclient_init(zclient
, ZEBRA_ROUTE_OSPF6
, 0, &ospf6d_privs
);
763 zclient
->zebra_connected
= ospf6_zebra_connected
;
765 /* Install command element for zebra node. */
766 install_element(VIEW_NODE
, &show_ospf6_zebra_cmd
);
771 DEFUN (debug_ospf6_zebra_sendrecv
,
772 debug_ospf6_zebra_sendrecv_cmd
,
773 "debug ospf6 zebra [<send|recv>]",
776 "Debug connection between zebra\n"
777 "Debug Sending zebra\n"
778 "Debug Receiving zebra\n"
781 int idx_send_recv
= 3;
782 unsigned char level
= 0;
785 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
786 level
= OSPF6_DEBUG_ZEBRA_SEND
;
787 else if (strmatch(argv
[idx_send_recv
]->text
, "recv"))
788 level
= OSPF6_DEBUG_ZEBRA_RECV
;
790 level
= OSPF6_DEBUG_ZEBRA_SEND
| OSPF6_DEBUG_ZEBRA_RECV
;
792 OSPF6_DEBUG_ZEBRA_ON(level
);
796 DEFUN (no_debug_ospf6_zebra_sendrecv
,
797 no_debug_ospf6_zebra_sendrecv_cmd
,
798 "no debug ospf6 zebra [<send|recv>]",
802 "Debug connection between zebra\n"
803 "Debug Sending zebra\n"
804 "Debug Receiving zebra\n"
807 int idx_send_recv
= 4;
808 unsigned char level
= 0;
811 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
812 level
= OSPF6_DEBUG_ZEBRA_SEND
;
813 else if (strmatch(argv
[idx_send_recv
]->text
, "recv"))
814 level
= OSPF6_DEBUG_ZEBRA_RECV
;
816 level
= OSPF6_DEBUG_ZEBRA_SEND
| OSPF6_DEBUG_ZEBRA_RECV
;
818 OSPF6_DEBUG_ZEBRA_OFF(level
);
823 int config_write_ospf6_debug_zebra(struct vty
*vty
)
825 if (IS_OSPF6_DEBUG_ZEBRA(SEND
) && IS_OSPF6_DEBUG_ZEBRA(RECV
))
826 vty_out(vty
, "debug ospf6 zebra\n");
828 if (IS_OSPF6_DEBUG_ZEBRA(SEND
))
829 vty_out(vty
, "debug ospf6 zebra send\n");
830 if (IS_OSPF6_DEBUG_ZEBRA(RECV
))
831 vty_out(vty
, "debug ospf6 zebra recv\n");
836 void install_element_ospf6_debug_zebra(void)
838 install_element(ENABLE_NODE
, &debug_ospf6_zebra_sendrecv_cmd
);
839 install_element(ENABLE_NODE
, &no_debug_ospf6_zebra_sendrecv_cmd
);
840 install_element(CONFIG_NODE
, &debug_ospf6_zebra_sendrecv_cmd
);
841 install_element(CONFIG_NODE
, &no_debug_ospf6_zebra_sendrecv_cmd
);