]> git.proxmox.com Git - mirror_frr.git/blob - ospf6d/ospf6_zebra.c
Merge pull request #8938 from volta-networks/fix_no_path_retries
[mirror_frr.git] / ospf6d / ospf6_zebra.c
1 /*
2 * Copyright (C) 2003 Yasuhiro Ohara
3 *
4 * This file is part of GNU Zebra.
5 *
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
9 * later version.
10 *
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.
15 *
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
19 */
20
21 #include <zebra.h>
22
23 #include "log.h"
24 #include "vty.h"
25 #include "command.h"
26 #include "prefix.h"
27 #include "stream.h"
28 #include "zclient.h"
29 #include "memory.h"
30 #include "lib/bfd.h"
31 #include "lib_errors.h"
32
33 #include "ospf6_proto.h"
34 #include "ospf6_top.h"
35 #include "ospf6_interface.h"
36 #include "ospf6_route.h"
37 #include "ospf6_lsa.h"
38 #include "ospf6_lsdb.h"
39 #include "ospf6_asbr.h"
40 #include "ospf6_zebra.h"
41 #include "ospf6d.h"
42 #include "ospf6_area.h"
43 #include "lib/json.h"
44
45 DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_DISTANCE, "OSPF6 distance");
46
47 unsigned char conf_debug_ospf6_zebra = 0;
48
49 /* information about zebra. */
50 struct zclient *zclient = NULL;
51
52 void ospf6_zebra_vrf_register(struct ospf6 *ospf6)
53 {
54 if (!zclient || zclient->sock < 0 || !ospf6)
55 return;
56
57 if (ospf6->vrf_id != VRF_UNKNOWN) {
58 if (IS_OSPF6_DEBUG_ZEBRA(RECV)) {
59 zlog_debug("%s: Register VRF %s id %u", __func__,
60 ospf6_vrf_id_to_name(ospf6->vrf_id),
61 ospf6->vrf_id);
62 }
63 zclient_send_reg_requests(zclient, ospf6->vrf_id);
64 }
65 }
66
67 void ospf6_zebra_vrf_deregister(struct ospf6 *ospf6)
68 {
69 if (!zclient || zclient->sock < 0 || !ospf6)
70 return;
71
72 if (ospf6->vrf_id != VRF_DEFAULT && ospf6->vrf_id != VRF_UNKNOWN) {
73 if (IS_OSPF6_DEBUG_ZEBRA(RECV)) {
74 zlog_debug("%s: De-Register VRF %s id %u to Zebra.",
75 __func__,
76 ospf6_vrf_id_to_name(ospf6->vrf_id),
77 ospf6->vrf_id);
78 }
79 /* Deregister for router-id, interfaces,
80 * redistributed routes. */
81 zclient_send_dereg_requests(zclient, ospf6->vrf_id);
82 }
83 }
84
85 /* Router-id update message from zebra. */
86 static int ospf6_router_id_update_zebra(ZAPI_CALLBACK_ARGS)
87 {
88 struct prefix router_id;
89 struct ospf6 *o;
90
91 zebra_router_id_update_read(zclient->ibuf, &router_id);
92
93 if (IS_OSPF6_DEBUG_ZEBRA(RECV))
94 zlog_debug("Zebra router-id update %pI4 vrf %s id %u",
95 &router_id.u.prefix4, ospf6_vrf_id_to_name(vrf_id),
96 vrf_id);
97
98 o = ospf6_lookup_by_vrf_id(vrf_id);
99 if (o == NULL)
100 return 0;
101
102 o->router_id_zebra = router_id.u.prefix4.s_addr;
103
104 ospf6_router_id_update(o);
105
106 return 0;
107 }
108
109 /* redistribute function */
110 void ospf6_zebra_redistribute(int type, vrf_id_t vrf_id)
111 {
112 if (vrf_bitmap_check(zclient->redist[AFI_IP6][type], vrf_id))
113 return;
114 vrf_bitmap_set(zclient->redist[AFI_IP6][type], vrf_id);
115
116 if (zclient->sock > 0)
117 zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient,
118 AFI_IP6, type, 0, vrf_id);
119 }
120
121 void ospf6_zebra_no_redistribute(int type, vrf_id_t vrf_id)
122 {
123 if (!vrf_bitmap_check(zclient->redist[AFI_IP6][type], vrf_id))
124 return;
125 vrf_bitmap_unset(zclient->redist[AFI_IP6][type], vrf_id);
126 if (zclient->sock > 0)
127 zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, zclient,
128 AFI_IP6, type, 0, vrf_id);
129 }
130
131 static int ospf6_zebra_if_address_update_add(ZAPI_CALLBACK_ARGS)
132 {
133 struct connected *c;
134 struct ospf6_interface *oi;
135 int ipv6_count = 0;
136
137 c = zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_ADD,
138 zclient->ibuf, vrf_id);
139 if (c == NULL)
140 return 0;
141
142 oi = (struct ospf6_interface *)c->ifp->info;
143 if (oi == NULL)
144 oi = ospf6_interface_create(c->ifp);
145 assert(oi);
146
147 if (IS_OSPF6_DEBUG_ZEBRA(RECV))
148 zlog_debug("Zebra Interface address add: %s %5s %pFX",
149 c->ifp->name, prefix_family_str(c->address),
150 c->address);
151
152 ipv6_count = connected_count_by_family(c->ifp, AF_INET6);
153 if (oi->ifmtu == OSPF6_DEFAULT_MTU && ipv6_count > OSPF6_MAX_IF_ADDRS) {
154 zlog_warn(
155 "Zebra Interface : %s has too many interface addresses %d only support %d, increase MTU",
156 c->ifp->name, ipv6_count, OSPF6_MAX_IF_ADDRS);
157 return 0;
158 } else if (oi->ifmtu >= OSPF6_JUMBO_MTU
159 && ipv6_count > OSPF6_MAX_IF_ADDRS_JUMBO) {
160 zlog_warn(
161 "Zebra Interface : %s has too many interface addresses %d only support %d",
162 c->ifp->name, ipv6_count, OSPF6_MAX_IF_ADDRS_JUMBO);
163 return 0;
164 }
165
166 if (c->address->family == AF_INET6) {
167 ospf6_interface_state_update(c->ifp);
168 ospf6_interface_connected_route_update(c->ifp);
169 }
170 return 0;
171 }
172
173 static int ospf6_zebra_if_address_update_delete(ZAPI_CALLBACK_ARGS)
174 {
175 struct connected *c;
176
177 c = zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_DELETE,
178 zclient->ibuf, vrf_id);
179 if (c == NULL)
180 return 0;
181
182 if (IS_OSPF6_DEBUG_ZEBRA(RECV))
183 zlog_debug("Zebra Interface address delete: %s %5s %pFX",
184 c->ifp->name, prefix_family_str(c->address),
185 c->address);
186
187 if (c->address->family == AF_INET6) {
188 ospf6_interface_connected_route_update(c->ifp);
189 ospf6_interface_state_update(c->ifp);
190 }
191
192 connected_free(&c);
193
194 return 0;
195 }
196
197 static int is_prefix_default(struct prefix_ipv6 *p)
198 {
199 struct prefix_ipv6 q = {};
200
201 q.family = AF_INET6;
202 q.prefixlen = 0;
203
204 return prefix_same((struct prefix *)p, (struct prefix *)&q);
205 }
206
207 static int ospf6_zebra_read_route(ZAPI_CALLBACK_ARGS)
208 {
209 struct zapi_route api;
210 unsigned long ifindex;
211 struct in6_addr *nexthop;
212 struct ospf6 *ospf6;
213 struct prefix_ipv6 p;
214
215 ospf6 = ospf6_lookup_by_vrf_id(vrf_id);
216
217 if (ospf6 == NULL)
218 return 0;
219
220 if (zapi_route_decode(zclient->ibuf, &api) < 0)
221 return -1;
222
223 /* we completely ignore srcdest routes for now. */
224 if (CHECK_FLAG(api.message, ZAPI_MESSAGE_SRCPFX))
225 return 0;
226
227 if (IN6_IS_ADDR_LINKLOCAL(&api.prefix.u.prefix6))
228 return 0;
229
230 ifindex = api.nexthops[0].ifindex;
231 nexthop = &api.nexthops[0].gate.ipv6;
232
233 if (IS_OSPF6_DEBUG_ZEBRA(RECV))
234 zlog_debug(
235 "Zebra Receive route %s: %s %pFX nexthop %pI6 ifindex %ld tag %" ROUTE_TAG_PRI,
236 (cmd == ZEBRA_REDISTRIBUTE_ROUTE_ADD ? "add"
237 : "delete"),
238 zebra_route_string(api.type), &api.prefix, nexthop,
239 ifindex, api.tag);
240
241 memcpy(&p, &api.prefix, sizeof(p));
242 if (is_prefix_default(&p))
243 api.type = DEFAULT_ROUTE;
244
245 if (cmd == ZEBRA_REDISTRIBUTE_ROUTE_ADD)
246 ospf6_asbr_redistribute_add(api.type, ifindex, &api.prefix,
247 api.nexthop_num, nexthop, api.tag,
248 ospf6);
249 else
250 ospf6_asbr_redistribute_remove(api.type, ifindex, &api.prefix,
251 ospf6);
252
253 return 0;
254 }
255
256 DEFUN(show_zebra,
257 show_ospf6_zebra_cmd,
258 "show ipv6 ospf6 zebra [json]",
259 SHOW_STR
260 IPV6_STR
261 OSPF6_STR
262 ZEBRA_STR
263 JSON_STR)
264 {
265 int i;
266 bool uj = use_json(argc, argv);
267 json_object *json;
268 json_object *json_zebra;
269 json_object *json_array;
270
271 if (zclient == NULL) {
272 vty_out(vty, "Not connected to zebra\n");
273 return CMD_SUCCESS;
274 }
275
276 if (uj) {
277 json = json_object_new_object();
278 json_zebra = json_object_new_object();
279 json_array = json_object_new_array();
280
281 json_object_int_add(json_zebra, "fail", zclient->fail);
282 json_object_int_add(
283 json_zebra, "redistributeDefault",
284 vrf_bitmap_check(zclient->default_information[AFI_IP6],
285 VRF_DEFAULT));
286 for (i = 0; i < ZEBRA_ROUTE_MAX; i++) {
287 if (vrf_bitmap_check(zclient->redist[AFI_IP6][i],
288 VRF_DEFAULT))
289 json_object_array_add(
290 json_array,
291 json_object_new_string(
292 zebra_route_string(i)));
293 }
294 json_object_object_add(json_zebra, "redistribute", json_array);
295 json_object_object_add(json, "zebraInformation", json_zebra);
296
297 vty_out(vty, "%s\n",
298 json_object_to_json_string_ext(
299 json, JSON_C_TO_STRING_PRETTY));
300 } else {
301 vty_out(vty, "Zebra Infomation\n");
302 vty_out(vty, " fail: %d\n", zclient->fail);
303 vty_out(vty, " redistribute default: %d\n",
304 vrf_bitmap_check(zclient->default_information[AFI_IP6],
305 VRF_DEFAULT));
306 vty_out(vty, " redistribute:");
307 for (i = 0; i < ZEBRA_ROUTE_MAX; i++) {
308 if (vrf_bitmap_check(zclient->redist[AFI_IP6][i],
309 VRF_DEFAULT))
310 vty_out(vty, " %s", zebra_route_string(i));
311 }
312 vty_out(vty, "\n");
313 }
314 return CMD_SUCCESS;
315 }
316
317 #define ADD 0
318 #define REM 1
319 static void ospf6_zebra_route_update(int type, struct ospf6_route *request,
320 struct ospf6 *ospf6)
321 {
322 struct zapi_route api;
323 int nhcount;
324 int ret = 0;
325 struct prefix *dest;
326
327 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
328 zlog_debug("Zebra Send %s route: %pFX",
329 (type == REM ? "remove" : "add"), &request->prefix);
330
331 if (zclient->sock < 0) {
332 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
333 zlog_debug(" Not connected to Zebra");
334 return;
335 }
336
337 if (request->path.origin.adv_router == ospf6->router_id
338 && (request->path.type == OSPF6_PATH_TYPE_EXTERNAL1
339 || request->path.type == OSPF6_PATH_TYPE_EXTERNAL2)) {
340 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
341 zlog_debug(" Ignore self-originated external route");
342 return;
343 }
344
345 /* If removing is the best path and if there's another path,
346 treat this request as add the secondary path */
347 if (type == REM && ospf6_route_is_best(request) && request->next
348 && ospf6_route_is_same(request, request->next)) {
349 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
350 zlog_debug(
351 " Best-path removal resulted Secondary addition");
352 type = ADD;
353 request = request->next;
354 }
355
356 /* Only the best path will be sent to zebra. */
357 if (!ospf6_route_is_best(request)) {
358 /* this is not preferred best route, ignore */
359 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
360 zlog_debug(" Ignore non-best route");
361 return;
362 }
363
364 nhcount = ospf6_route_num_nexthops(request);
365 if (nhcount == 0) {
366 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
367 zlog_debug(" No nexthop, ignore");
368 return;
369 }
370
371 dest = &request->prefix;
372
373 memset(&api, 0, sizeof(api));
374 api.vrf_id = ospf6->vrf_id;
375 api.type = ZEBRA_ROUTE_OSPF6;
376 api.safi = SAFI_UNICAST;
377 api.prefix = *dest;
378 SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
379
380 if (nhcount > ospf6->max_multipath) {
381 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
382 zlog_debug(
383 " Nexthop count is greater than configured maximum-path, hence ignore the extra nexthops");
384 }
385 api.nexthop_num = MIN(nhcount, ospf6->max_multipath);
386
387 ospf6_route_zebra_copy_nexthops(request, api.nexthops, api.nexthop_num,
388 api.vrf_id);
389 SET_FLAG(api.message, ZAPI_MESSAGE_METRIC);
390 api.metric = (request->path.metric_type == 2 ? request->path.u.cost_e2
391 : request->path.cost);
392 if (request->path.tag) {
393 SET_FLAG(api.message, ZAPI_MESSAGE_TAG);
394 api.tag = request->path.tag;
395 }
396
397 SET_FLAG(api.message, ZAPI_MESSAGE_DISTANCE);
398 api.distance = ospf6_distance_apply((struct prefix_ipv6 *)dest, request,
399 ospf6);
400
401 if (type == REM)
402 ret = zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api);
403 else
404 ret = zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api);
405
406 if (ret == ZCLIENT_SEND_FAILURE)
407 flog_err(EC_LIB_ZAPI_SOCKET,
408 "zclient_route_send() %s failed: %s",
409 (type == REM ? "delete" : "add"),
410 safe_strerror(errno));
411
412 return;
413 }
414
415 void ospf6_zebra_route_update_add(struct ospf6_route *request,
416 struct ospf6 *ospf6)
417 {
418 ospf6_zebra_route_update(ADD, request, ospf6);
419 }
420
421 void ospf6_zebra_route_update_remove(struct ospf6_route *request,
422 struct ospf6 *ospf6)
423 {
424 ospf6_zebra_route_update(REM, request, ospf6);
425 }
426
427 void ospf6_zebra_add_discard(struct ospf6_route *request, struct ospf6 *ospf6)
428 {
429 struct zapi_route api;
430 struct prefix *dest = &request->prefix;
431
432 if (!CHECK_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED)) {
433 memset(&api, 0, sizeof(api));
434 api.vrf_id = ospf6->vrf_id;
435 api.type = ZEBRA_ROUTE_OSPF6;
436 api.safi = SAFI_UNICAST;
437 api.prefix = *dest;
438 zapi_route_set_blackhole(&api, BLACKHOLE_NULL);
439
440 zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api);
441
442 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
443 zlog_debug("Zebra: Route add discard %pFX", dest);
444
445 SET_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED);
446 } else {
447 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
448 zlog_debug(
449 "Zebra: Blackhole route present already %pFX",
450 dest);
451 }
452 }
453
454 void ospf6_zebra_delete_discard(struct ospf6_route *request,
455 struct ospf6 *ospf6)
456 {
457 struct zapi_route api;
458 struct prefix *dest = &request->prefix;
459
460 if (CHECK_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED)) {
461 memset(&api, 0, sizeof(api));
462 api.vrf_id = ospf6->vrf_id;
463 api.type = ZEBRA_ROUTE_OSPF6;
464 api.safi = SAFI_UNICAST;
465 api.prefix = *dest;
466 zapi_route_set_blackhole(&api, BLACKHOLE_NULL);
467
468 zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api);
469
470 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
471 zlog_debug("Zebra: Route delete discard %pFX", dest);
472
473 UNSET_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED);
474 } else {
475 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
476 zlog_debug(
477 "Zebra: Blackhole route already deleted %pFX",
478 dest);
479 }
480 }
481
482 static struct ospf6_distance *ospf6_distance_new(void)
483 {
484 return XCALLOC(MTYPE_OSPF6_DISTANCE, sizeof(struct ospf6_distance));
485 }
486
487 static void ospf6_distance_free(struct ospf6_distance *odistance)
488 {
489 XFREE(MTYPE_OSPF6_DISTANCE, odistance);
490 }
491
492 int ospf6_distance_set(struct vty *vty, struct ospf6 *o,
493 const char *distance_str, const char *ip_str,
494 const char *access_list_str)
495 {
496 int ret;
497 struct prefix_ipv6 p;
498 uint8_t distance;
499 struct route_node *rn;
500 struct ospf6_distance *odistance;
501
502 ret = str2prefix_ipv6(ip_str, &p);
503 if (ret == 0) {
504 vty_out(vty, "Malformed prefix\n");
505 return CMD_WARNING_CONFIG_FAILED;
506 }
507
508 distance = atoi(distance_str);
509
510 /* Get OSPF6 distance node. */
511 rn = route_node_get(o->distance_table, (struct prefix *)&p);
512 if (rn->info) {
513 odistance = rn->info;
514 route_unlock_node(rn);
515 } else {
516 odistance = ospf6_distance_new();
517 rn->info = odistance;
518 }
519
520 /* Set distance value. */
521 odistance->distance = distance;
522
523 /* Reset access-list configuration. */
524 if (odistance->access_list) {
525 free(odistance->access_list);
526 odistance->access_list = NULL;
527 }
528 if (access_list_str)
529 odistance->access_list = strdup(access_list_str);
530
531 return CMD_SUCCESS;
532 }
533
534 int ospf6_distance_unset(struct vty *vty, struct ospf6 *o,
535 const char *distance_str, const char *ip_str,
536 const char *access_list_str)
537 {
538 int ret;
539 struct prefix_ipv6 p;
540 struct route_node *rn;
541 struct ospf6_distance *odistance;
542
543 ret = str2prefix_ipv6(ip_str, &p);
544 if (ret == 0) {
545 vty_out(vty, "Malformed prefix\n");
546 return CMD_WARNING_CONFIG_FAILED;
547 }
548
549 rn = route_node_lookup(o->distance_table, (struct prefix *)&p);
550 if (!rn) {
551 vty_out(vty, "Cant't find specified prefix\n");
552 return CMD_WARNING_CONFIG_FAILED;
553 }
554
555 odistance = rn->info;
556
557 if (odistance->access_list)
558 free(odistance->access_list);
559 ospf6_distance_free(odistance);
560
561 rn->info = NULL;
562 route_unlock_node(rn);
563 route_unlock_node(rn);
564
565 return CMD_SUCCESS;
566 }
567
568 void ospf6_distance_reset(struct ospf6 *o)
569 {
570 struct route_node *rn;
571 struct ospf6_distance *odistance;
572
573 for (rn = route_top(o->distance_table); rn; rn = route_next(rn))
574 if ((odistance = rn->info) != NULL) {
575 if (odistance->access_list)
576 free(odistance->access_list);
577 ospf6_distance_free(odistance);
578 rn->info = NULL;
579 route_unlock_node(rn);
580 }
581 }
582
583 uint8_t ospf6_distance_apply(struct prefix_ipv6 *p, struct ospf6_route * or,
584 struct ospf6 *ospf6)
585 {
586 struct ospf6 *o;
587
588 o = ospf6;
589 if (o == NULL)
590 return 0;
591
592 if (o->distance_intra)
593 if (or->path.type == OSPF6_PATH_TYPE_INTRA)
594 return o->distance_intra;
595
596 if (o->distance_inter)
597 if (or->path.type == OSPF6_PATH_TYPE_INTER)
598 return o->distance_inter;
599
600 if (o->distance_external)
601 if (or->path.type == OSPF6_PATH_TYPE_EXTERNAL1 ||
602 or->path.type == OSPF6_PATH_TYPE_EXTERNAL2)
603 return o->distance_external;
604
605 if (o->distance_all)
606 return o->distance_all;
607
608 return 0;
609 }
610
611 static void ospf6_zebra_connected(struct zclient *zclient)
612 {
613 /* Send the client registration */
614 bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER, VRF_DEFAULT);
615
616 zclient_send_reg_requests(zclient, VRF_DEFAULT);
617 }
618
619 void ospf6_zebra_init(struct thread_master *master)
620 {
621 /* Allocate zebra structure. */
622 zclient = zclient_new(master, &zclient_options_default);
623 zclient_init(zclient, ZEBRA_ROUTE_OSPF6, 0, &ospf6d_privs);
624 zclient->zebra_connected = ospf6_zebra_connected;
625 zclient->router_id_update = ospf6_router_id_update_zebra;
626 zclient->interface_address_add = ospf6_zebra_if_address_update_add;
627 zclient->interface_address_delete =
628 ospf6_zebra_if_address_update_delete;
629 zclient->redistribute_route_add = ospf6_zebra_read_route;
630 zclient->redistribute_route_del = ospf6_zebra_read_route;
631
632 /* Install command element for zebra node. */
633 install_element(VIEW_NODE, &show_ospf6_zebra_cmd);
634 }
635
636 /* Debug */
637
638 DEFUN (debug_ospf6_zebra_sendrecv,
639 debug_ospf6_zebra_sendrecv_cmd,
640 "debug ospf6 zebra [<send|recv>]",
641 DEBUG_STR
642 OSPF6_STR
643 "Debug connection between zebra\n"
644 "Debug Sending zebra\n"
645 "Debug Receiving zebra\n"
646 )
647 {
648 int idx_send_recv = 3;
649 unsigned char level = 0;
650
651 if (argc == 4) {
652 if (strmatch(argv[idx_send_recv]->text, "send"))
653 level = OSPF6_DEBUG_ZEBRA_SEND;
654 else if (strmatch(argv[idx_send_recv]->text, "recv"))
655 level = OSPF6_DEBUG_ZEBRA_RECV;
656 } else
657 level = OSPF6_DEBUG_ZEBRA_SEND | OSPF6_DEBUG_ZEBRA_RECV;
658
659 OSPF6_DEBUG_ZEBRA_ON(level);
660 return CMD_SUCCESS;
661 }
662
663 DEFUN (no_debug_ospf6_zebra_sendrecv,
664 no_debug_ospf6_zebra_sendrecv_cmd,
665 "no debug ospf6 zebra [<send|recv>]",
666 NO_STR
667 DEBUG_STR
668 OSPF6_STR
669 "Debug connection between zebra\n"
670 "Debug Sending zebra\n"
671 "Debug Receiving zebra\n"
672 )
673 {
674 int idx_send_recv = 4;
675 unsigned char level = 0;
676
677 if (argc == 5) {
678 if (strmatch(argv[idx_send_recv]->text, "send"))
679 level = OSPF6_DEBUG_ZEBRA_SEND;
680 else if (strmatch(argv[idx_send_recv]->text, "recv"))
681 level = OSPF6_DEBUG_ZEBRA_RECV;
682 } else
683 level = OSPF6_DEBUG_ZEBRA_SEND | OSPF6_DEBUG_ZEBRA_RECV;
684
685 OSPF6_DEBUG_ZEBRA_OFF(level);
686 return CMD_SUCCESS;
687 }
688
689
690 int config_write_ospf6_debug_zebra(struct vty *vty)
691 {
692 if (IS_OSPF6_DEBUG_ZEBRA(SEND) && IS_OSPF6_DEBUG_ZEBRA(RECV))
693 vty_out(vty, "debug ospf6 zebra\n");
694 else {
695 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
696 vty_out(vty, "debug ospf6 zebra send\n");
697 if (IS_OSPF6_DEBUG_ZEBRA(RECV))
698 vty_out(vty, "debug ospf6 zebra recv\n");
699 }
700 return 0;
701 }
702
703 void install_element_ospf6_debug_zebra(void)
704 {
705 install_element(ENABLE_NODE, &debug_ospf6_zebra_sendrecv_cmd);
706 install_element(ENABLE_NODE, &no_debug_ospf6_zebra_sendrecv_cmd);
707 install_element(CONFIG_NODE, &debug_ospf6_zebra_sendrecv_cmd);
708 install_element(CONFIG_NODE, &no_debug_ospf6_zebra_sendrecv_cmd);
709 }