]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_bfd.c
Merge pull request #808 from qlyoung/vtysh-termcols
[mirror_frr.git] / bgpd / bgp_bfd.c
1 /**
2 * bgp_bfd.c: BGP BFD handling routines
3 *
4 * @copyright Copyright (C) 2015 Cumulus Networks, Inc.
5 *
6 * This file is part of GNU Zebra.
7 *
8 * GNU Zebra is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2, or (at your option) any
11 * later version.
12 *
13 * GNU Zebra is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; see the file COPYING; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #include <zebra.h>
24
25 #include "command.h"
26 #include "linklist.h"
27 #include "memory.h"
28 #include "prefix.h"
29 #include "thread.h"
30 #include "buffer.h"
31 #include "stream.h"
32 #include "zclient.h"
33 #include "bfd.h"
34 #include "lib/json.h"
35 #include "filter.h"
36
37 #include "bgpd/bgpd.h"
38 #include "bgp_fsm.h"
39 #include "bgpd/bgp_bfd.h"
40 #include "bgpd/bgp_debug.h"
41 #include "bgpd/bgp_vty.h"
42
43 extern struct zclient *zclient;
44
45 /*
46 * bgp_bfd_peer_group2peer_copy - Copy the BFD information from peer group template
47 * to peer.
48 */
49 void
50 bgp_bfd_peer_group2peer_copy(struct peer *conf, struct peer *peer)
51 {
52 struct bfd_info *bfd_info;
53 struct bfd_info *conf_bfd_info;
54
55 if (!conf->bfd_info)
56 return;
57
58 conf_bfd_info = (struct bfd_info *)conf->bfd_info;
59 if (!peer->bfd_info)
60 peer->bfd_info = bfd_info_create();
61
62 bfd_info = (struct bfd_info *)peer->bfd_info;
63
64 /* Copy BFD parameter values */
65 bfd_info->required_min_rx = conf_bfd_info->required_min_rx;
66 bfd_info->desired_min_tx = conf_bfd_info->desired_min_tx;
67 bfd_info->detect_mult = conf_bfd_info->detect_mult;
68 bfd_info->type = conf_bfd_info->type;
69 }
70
71 /*
72 * bgp_bfd_is_peer_multihop - returns whether BFD peer is multi-hop or single hop.
73 */
74 int
75 bgp_bfd_is_peer_multihop(struct peer *peer)
76 {
77 struct bfd_info *bfd_info;
78
79 bfd_info = (struct bfd_info *)peer->bfd_info;
80
81 if (!bfd_info)
82 return 0;
83
84 if((bfd_info->type == BFD_TYPE_MULTIHOP) ||
85 ((peer->sort == BGP_PEER_IBGP) && !peer->shared_network) ||
86 is_ebgp_multihop_configured(peer))
87 return 1;
88 else
89 return 0;
90 }
91
92 /*
93 * bgp_bfd_peer_sendmsg - Format and send a Peer register/Unregister
94 * command to Zebra to be forwarded to BFD
95 */
96 static void
97 bgp_bfd_peer_sendmsg (struct peer *peer, int command)
98 {
99 struct bfd_info *bfd_info;
100 vrf_id_t vrf_id = VRF_DEFAULT;
101 int multihop;
102
103 bfd_info = (struct bfd_info *)peer->bfd_info;
104
105 if (peer->bgp && (peer->bgp->inst_type == BGP_INSTANCE_TYPE_VRF))
106 vrf_id = peer->bgp->vrf_id;
107
108 if (command == ZEBRA_BFD_DEST_DEREGISTER)
109 {
110 multihop = CHECK_FLAG(bfd_info->flags, BFD_FLAG_BFD_TYPE_MULTIHOP);
111 UNSET_FLAG(bfd_info->flags, BFD_FLAG_BFD_TYPE_MULTIHOP);
112 }
113 else
114 {
115 multihop = bgp_bfd_is_peer_multihop(peer);
116 if ((command == ZEBRA_BFD_DEST_REGISTER) && multihop)
117 SET_FLAG(bfd_info->flags, BFD_FLAG_BFD_TYPE_MULTIHOP);
118 }
119
120 if (peer->su.sa.sa_family == AF_INET)
121 bfd_peer_sendmsg (zclient, bfd_info, AF_INET,
122 &peer->su.sin.sin_addr,
123 (peer->su_local) ? &peer->su_local->sin.sin_addr : NULL,
124 (peer->nexthop.ifp) ? peer->nexthop.ifp->name : NULL,
125 peer->ttl, multihop, command, 1, vrf_id);
126 else if (peer->su.sa.sa_family == AF_INET6)
127 bfd_peer_sendmsg (zclient, bfd_info, AF_INET6,
128 &peer->su.sin6.sin6_addr,
129 (peer->su_local) ? &peer->su_local->sin6.sin6_addr : NULL,
130 (peer->nexthop.ifp) ? peer->nexthop.ifp->name : NULL,
131 peer->ttl, multihop, command, 1, vrf_id);
132 }
133
134 /*
135 * bgp_bfd_register_peer - register a peer with BFD through zebra
136 * for monitoring the peer rechahability.
137 */
138 void
139 bgp_bfd_register_peer (struct peer *peer)
140 {
141 struct bfd_info *bfd_info;
142
143 if (!peer->bfd_info)
144 return;
145 bfd_info = (struct bfd_info *)peer->bfd_info;
146
147 /* Check if BFD is enabled and peer has already been registered with BFD */
148 if (CHECK_FLAG(bfd_info->flags, BFD_FLAG_BFD_REG))
149 return;
150
151 bgp_bfd_peer_sendmsg(peer, ZEBRA_BFD_DEST_REGISTER);
152 }
153
154 /**
155 * bgp_bfd_deregister_peer - deregister a peer with BFD through zebra
156 * for stopping the monitoring of the peer
157 * rechahability.
158 */
159 void
160 bgp_bfd_deregister_peer (struct peer *peer)
161 {
162 struct bfd_info *bfd_info;
163
164 if (!peer->bfd_info)
165 return;
166 bfd_info = (struct bfd_info *)peer->bfd_info;
167
168 /* Check if BFD is eanbled and peer has not been registered */
169 if (!CHECK_FLAG(bfd_info->flags, BFD_FLAG_BFD_REG))
170 return;
171
172 bfd_info->status = BFD_STATUS_DOWN;
173 bfd_info->last_update = bgp_clock();
174
175 bgp_bfd_peer_sendmsg(peer, ZEBRA_BFD_DEST_DEREGISTER);
176 }
177
178 /*
179 * bgp_bfd_update_peer - update peer with BFD with new BFD paramters
180 * through zebra.
181 */
182 static void
183 bgp_bfd_update_peer (struct peer *peer)
184 {
185 struct bfd_info *bfd_info;
186
187 if (!peer->bfd_info)
188 return;
189 bfd_info = (struct bfd_info *)peer->bfd_info;
190
191 /* Check if the peer has been registered with BFD*/
192 if (!CHECK_FLAG(bfd_info->flags, BFD_FLAG_BFD_REG))
193 return;
194
195 bgp_bfd_peer_sendmsg(peer, ZEBRA_BFD_DEST_UPDATE);
196 }
197
198 /*
199 * bgp_bfd_update_type - update session type with BFD through zebra.
200 */
201 static void
202 bgp_bfd_update_type (struct peer *peer)
203 {
204 struct bfd_info *bfd_info;
205 int multihop;
206
207 if (!peer->bfd_info)
208 return;
209 bfd_info = (struct bfd_info *)peer->bfd_info;
210
211 /* Check if the peer has been registered with BFD*/
212 if (!CHECK_FLAG(bfd_info->flags, BFD_FLAG_BFD_REG))
213 return;
214
215 if (bfd_info->type == BFD_TYPE_NOT_CONFIGURED)
216 {
217 multihop = bgp_bfd_is_peer_multihop(peer);
218 if ((multihop && !CHECK_FLAG(bfd_info->flags, BFD_FLAG_BFD_TYPE_MULTIHOP)) ||
219 (!multihop && CHECK_FLAG(bfd_info->flags, BFD_FLAG_BFD_TYPE_MULTIHOP)))
220 {
221 bgp_bfd_peer_sendmsg(peer, ZEBRA_BFD_DEST_DEREGISTER);
222 bgp_bfd_peer_sendmsg(peer, ZEBRA_BFD_DEST_REGISTER);
223 }
224 }
225 else
226 {
227 if ((bfd_info->type == BFD_TYPE_MULTIHOP &&
228 !CHECK_FLAG(bfd_info->flags, BFD_FLAG_BFD_TYPE_MULTIHOP)) ||
229 (bfd_info->type == BFD_TYPE_SINGLEHOP &&
230 CHECK_FLAG(bfd_info->flags, BFD_FLAG_BFD_TYPE_MULTIHOP)))
231 {
232 bgp_bfd_peer_sendmsg(peer, ZEBRA_BFD_DEST_DEREGISTER);
233 bgp_bfd_peer_sendmsg(peer, ZEBRA_BFD_DEST_REGISTER);
234 }
235 }
236 }
237
238 /*
239 * bgp_bfd_dest_replay - Replay all the peers that have BFD enabled
240 * to zebra
241 */
242 static int
243 bgp_bfd_dest_replay (int command, struct zclient *client, zebra_size_t length,
244 vrf_id_t vrf_id)
245 {
246 struct listnode *mnode, *node, *nnode;
247 struct bgp *bgp;
248 struct peer *peer;
249
250 if (BGP_DEBUG (zebra, ZEBRA))
251 zlog_debug("Zebra: BFD Dest replay request");
252
253 /* Send the client registration */
254 bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER);
255
256 /* Replay the peer, if BFD is enabled in BGP */
257
258 for (ALL_LIST_ELEMENTS_RO (bm->bgp, mnode, bgp))
259 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
260 {
261 bgp_bfd_update_peer(peer);
262 }
263
264 return 0;
265 }
266
267 /*
268 * bgp_bfd_peer_status_update - Update the BFD status if it has changed. Bring
269 * down the peer if the BFD session went down from * up.
270 */
271 static void
272 bgp_bfd_peer_status_update (struct peer *peer, int status)
273 {
274 struct bfd_info *bfd_info;
275 int old_status;
276
277 bfd_info = (struct bfd_info *)peer->bfd_info;
278
279 if (bfd_info->status == status)
280 return;
281
282 old_status = bfd_info->status;
283 bfd_info->status = status;
284 bfd_info->last_update = bgp_clock();
285
286 if ((status == BFD_STATUS_DOWN) && (old_status == BFD_STATUS_UP))
287 {
288 peer->last_reset = PEER_DOWN_BFD_DOWN;
289 BGP_EVENT_ADD (peer, BGP_Stop);
290 }
291 }
292
293 /*
294 * bgp_bfd_dest_update - Find the peer for which the BFD status
295 * has changed and bring down the peer
296 * connectivity if the BFD session went down.
297 */
298 static int
299 bgp_bfd_dest_update (int command, struct zclient *zclient,
300 zebra_size_t length, vrf_id_t vrf_id)
301 {
302 struct interface *ifp;
303 struct prefix dp;
304 struct prefix sp;
305 int status;
306
307 ifp = bfd_get_peer_info (zclient->ibuf, &dp, &sp, &status, vrf_id);
308
309 if (BGP_DEBUG (zebra, ZEBRA))
310 {
311 char buf[2][PREFIX2STR_BUFFER];
312 prefix2str(&dp, buf[0], sizeof(buf[0]));
313 if (ifp)
314 {
315 zlog_debug("Zebra: vrf %d interface %s bfd destination %s %s",
316 vrf_id, ifp->name, buf[0], bfd_get_status_str(status));
317 }
318 else
319 {
320 prefix2str(&sp, buf[1], sizeof(buf[1]));
321 zlog_debug("Zebra: vrf %d source %s bfd destination %s %s",
322 vrf_id, buf[1], buf[0], bfd_get_status_str(status));
323 }
324 }
325
326 /* Bring the peer down if BFD is enabled in BGP */
327 {
328 struct listnode *mnode, *node, *nnode;
329 struct bgp *bgp;
330 struct peer *peer;
331
332 for (ALL_LIST_ELEMENTS_RO (bm->bgp, mnode, bgp))
333 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
334 {
335 if (!peer->bfd_info)
336 continue;
337
338 if ((dp.family == AF_INET) && (peer->su.sa.sa_family == AF_INET))
339 {
340 if (dp.u.prefix4.s_addr != peer->su.sin.sin_addr.s_addr)
341 continue;
342 }
343 else if ((dp.family == AF_INET6) &&
344 (peer->su.sa.sa_family == AF_INET6))
345 {
346 if (memcmp(&dp.u.prefix6, &peer->su.sin6.sin6_addr,
347 sizeof (struct in6_addr)))
348 continue;
349 }
350 else
351 continue;
352
353 if (ifp && (ifp == peer->nexthop.ifp))
354 {
355 bgp_bfd_peer_status_update(peer, status);
356 }
357 else
358 {
359 if (!peer->su_local)
360 continue;
361
362 if ((sp.family == AF_INET) &&
363 (peer->su_local->sa.sa_family == AF_INET))
364 {
365 if (sp.u.prefix4.s_addr != peer->su_local->sin.sin_addr.s_addr)
366 continue;
367 }
368 else if ((sp.family == AF_INET6) &&
369 (peer->su_local->sa.sa_family == AF_INET6))
370 {
371 if (memcmp(&sp.u.prefix6, &peer->su_local->sin6.sin6_addr,
372 sizeof (struct in6_addr)))
373 continue;
374 }
375 else
376 continue;
377
378 if ((vrf_id != VRF_DEFAULT) && (peer->bgp->vrf_id != vrf_id))
379 continue;
380
381 bgp_bfd_peer_status_update(peer, status);
382 }
383 }
384 }
385
386 return 0;
387 }
388
389 /*
390 * bgp_bfd_peer_param_set - Set the configured BFD paramter values for peer.
391 */
392 static int
393 bgp_bfd_peer_param_set (struct peer *peer, u_int32_t min_rx, u_int32_t min_tx,
394 u_int8_t detect_mult, int defaults)
395 {
396 struct peer_group *group;
397 struct listnode *node, *nnode;
398 int command = 0;
399
400 bfd_set_param((struct bfd_info **)&(peer->bfd_info), min_rx, min_tx,
401 detect_mult, defaults, &command);
402
403 if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
404 {
405 group = peer->group;
406 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
407 {
408 command = 0;
409 bfd_set_param((struct bfd_info **)&(peer->bfd_info), min_rx, min_tx,
410 detect_mult, defaults, &command);
411
412 if ((peer->status == Established) &&
413 (command == ZEBRA_BFD_DEST_REGISTER))
414 bgp_bfd_register_peer(peer);
415 else if (command == ZEBRA_BFD_DEST_UPDATE)
416 bgp_bfd_update_peer(peer);
417 }
418 }
419 else
420 {
421 if ((peer->status == Established) &&
422 (command == ZEBRA_BFD_DEST_REGISTER))
423 bgp_bfd_register_peer(peer);
424 else if (command == ZEBRA_BFD_DEST_UPDATE)
425 bgp_bfd_update_peer(peer);
426 }
427 return 0;
428 }
429
430 /*
431 * bgp_bfd_peer_param_unset - Delete the configured BFD paramter values for peer.
432 */
433 static int
434 bgp_bfd_peer_param_unset (struct peer *peer)
435 {
436 struct peer_group *group;
437 struct listnode *node, *nnode;
438
439 if (!peer->bfd_info)
440 return 0;
441
442 if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
443 {
444 bfd_info_free(&(peer->bfd_info));
445 group = peer->group;
446 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
447 {
448 bgp_bfd_deregister_peer(peer);
449 bfd_info_free(&(peer->bfd_info));
450 }
451 }
452 else
453 {
454 bgp_bfd_deregister_peer(peer);
455 bfd_info_free(&(peer->bfd_info));
456 }
457 return 0;
458 }
459
460 /*
461 * bgp_bfd_peer_param_type_set - set the BFD session type (multihop or singlehop)
462 */
463 static int
464 bgp_bfd_peer_param_type_set (struct peer *peer, enum bfd_sess_type type)
465 {
466 struct peer_group *group;
467 struct listnode *node, *nnode;
468 int command = 0;
469 struct bfd_info *bfd_info;
470
471 if (!peer->bfd_info)
472 bfd_set_param((struct bfd_info **)&(peer->bfd_info), BFD_DEF_MIN_RX,
473 BFD_DEF_MIN_TX, BFD_DEF_DETECT_MULT, 1, &command);
474
475 bfd_info = (struct bfd_info *)peer->bfd_info;
476 bfd_info->type = type;
477
478 if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
479 {
480 group = peer->group;
481 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
482 {
483 command = 0;
484 if (!peer->bfd_info)
485 bfd_set_param((struct bfd_info **)&(peer->bfd_info),
486 BFD_DEF_MIN_RX, BFD_DEF_MIN_TX,
487 BFD_DEF_DETECT_MULT, 1, &command);
488
489 bfd_info = (struct bfd_info *)peer->bfd_info;
490 bfd_info->type = type;
491
492 if (peer->status == Established)
493 {
494 if (command == ZEBRA_BFD_DEST_REGISTER)
495 bgp_bfd_register_peer(peer);
496 else
497 bgp_bfd_update_type(peer);
498 }
499 }
500 }
501 else
502 {
503 if (peer->status == Established)
504 {
505 if (command == ZEBRA_BFD_DEST_REGISTER)
506 bgp_bfd_register_peer(peer);
507 else
508 bgp_bfd_update_type(peer);
509 }
510 }
511
512 return 0;
513 }
514
515 /*
516 * bgp_bfd_peer_config_write - Write the peer BFD configuration.
517 */
518 void
519 bgp_bfd_peer_config_write(struct vty *vty, struct peer *peer, char *addr)
520 {
521 struct bfd_info *bfd_info;
522
523 if (!peer->bfd_info)
524 return;
525
526 bfd_info = (struct bfd_info *)peer->bfd_info;
527
528 if (CHECK_FLAG (bfd_info->flags, BFD_FLAG_PARAM_CFG))
529 vty_outln (vty, " neighbor %s bfd %d %d %d", addr,
530 bfd_info->detect_mult, bfd_info->required_min_rx,
531 bfd_info->desired_min_tx);
532
533 if (bfd_info->type != BFD_TYPE_NOT_CONFIGURED)
534 vty_outln (vty, " neighbor %s bfd %s", addr,
535 (bfd_info->type == BFD_TYPE_MULTIHOP) ? "multihop" : "singlehop");
536
537 if (!CHECK_FLAG (bfd_info->flags, BFD_FLAG_PARAM_CFG) &&
538 (bfd_info->type == BFD_TYPE_NOT_CONFIGURED))
539 vty_outln (vty, " neighbor %s bfd", addr);
540 }
541
542 /*
543 * bgp_bfd_show_info - Show the peer BFD information.
544 */
545 void
546 bgp_bfd_show_info(struct vty *vty, struct peer *peer, u_char use_json, json_object *json_neigh)
547 {
548 bfd_show_info(vty, (struct bfd_info *)peer->bfd_info,
549 bgp_bfd_is_peer_multihop(peer), 0, use_json, json_neigh);
550 }
551
552 DEFUN (neighbor_bfd,
553 neighbor_bfd_cmd,
554 "neighbor <A.B.C.D|X:X::X:X|WORD> bfd",
555 NEIGHBOR_STR
556 NEIGHBOR_ADDR_STR2
557 "Enables BFD support\n")
558 {
559 int idx_peer = 1;
560 struct peer *peer;
561 int ret;
562
563 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
564 if (! peer)
565 return CMD_WARNING_CONFIG_FAILED;
566
567 ret = bgp_bfd_peer_param_set (peer, BFD_DEF_MIN_RX, BFD_DEF_MIN_TX,
568 BFD_DEF_DETECT_MULT, 1);
569 if (ret != 0)
570 return bgp_vty_return (vty, ret);
571
572 return CMD_SUCCESS;
573
574 }
575
576 DEFUN (neighbor_bfd_param,
577 neighbor_bfd_param_cmd,
578 "neighbor <A.B.C.D|X:X::X:X|WORD> bfd (2-255) (50-60000) (50-60000)",
579 NEIGHBOR_STR
580 NEIGHBOR_ADDR_STR2
581 "Enables BFD support\n"
582 "Detect Multiplier\n"
583 "Required min receive interval\n"
584 "Desired min transmit interval\n")
585 {
586 int idx_peer = 1;
587 int idx_number_1 = 3;
588 int idx_number_2 = 4;
589 int idx_number_3 = 5;
590 struct peer *peer;
591 u_int32_t rx_val;
592 u_int32_t tx_val;
593 u_int8_t dm_val;
594 int ret;
595
596 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
597 if (!peer)
598 return CMD_WARNING_CONFIG_FAILED;
599
600 if ((ret = bfd_validate_param (vty, argv[idx_number_1]->arg, argv[idx_number_2]->arg, argv[idx_number_3]->arg, &dm_val,
601 &rx_val, &tx_val)) != CMD_SUCCESS)
602 return ret;
603
604 ret = bgp_bfd_peer_param_set (peer, rx_val, tx_val, dm_val, 0);
605 if (ret != 0)
606 return bgp_vty_return (vty, ret);
607
608 return CMD_SUCCESS;
609
610 }
611
612 DEFUN_HIDDEN (neighbor_bfd_type,
613 neighbor_bfd_type_cmd,
614 "neighbor <A.B.C.D|X:X::X:X|WORD> bfd <multihop|singlehop>",
615 NEIGHBOR_STR
616 NEIGHBOR_ADDR_STR2
617 "Enables BFD support\n"
618 "Multihop session\n"
619 "Single hop session\n")
620 {
621 int idx_peer = 1;
622 int idx_hop = 3;
623 struct peer *peer;
624 enum bfd_sess_type type;
625 int ret;
626
627 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
628 if (!peer)
629 return CMD_WARNING_CONFIG_FAILED;
630
631 if (strmatch(argv[idx_hop]->text, "singlehop"))
632 type = BFD_TYPE_SINGLEHOP;
633 else if (strmatch(argv[idx_hop]->text, "multihop"))
634 type = BFD_TYPE_MULTIHOP;
635 else
636 return CMD_WARNING_CONFIG_FAILED;
637
638 ret = bgp_bfd_peer_param_type_set (peer, type);
639 if (ret != 0)
640 return bgp_vty_return (vty, ret);
641
642 return CMD_SUCCESS;
643 }
644
645 DEFUN (no_neighbor_bfd,
646 no_neighbor_bfd_cmd,
647 "no neighbor <A.B.C.D|X:X::X:X|WORD> bfd [(2-255) (50-60000) (50-60000)]",
648 NO_STR
649 NEIGHBOR_STR
650 NEIGHBOR_ADDR_STR2
651 "Disables BFD support\n"
652 "Detect Multiplier\n"
653 "Required min receive interval\n"
654 "Desired min transmit interval\n")
655 {
656 int idx_peer = 2;
657 struct peer *peer;
658 int ret;
659
660 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
661 if (! peer)
662 return CMD_WARNING_CONFIG_FAILED;
663
664 ret = bgp_bfd_peer_param_unset(peer);
665 if (ret != 0)
666 return bgp_vty_return (vty, ret);
667
668 return CMD_SUCCESS;
669 }
670
671
672 DEFUN_HIDDEN (no_neighbor_bfd_type,
673 no_neighbor_bfd_type_cmd,
674 "no neighbor <A.B.C.D|X:X::X:X|WORD> bfd <multihop|singlehop>",
675 NO_STR
676 NEIGHBOR_STR
677 NEIGHBOR_ADDR_STR2
678 "Disables BFD support\n"
679 "Multihop session\n"
680 "Singlehop session\n")
681 {
682 int idx_peer = 2;
683 struct peer *peer;
684 int ret;
685
686 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
687 if (! peer)
688 return CMD_WARNING_CONFIG_FAILED;
689
690 if (!peer->bfd_info)
691 return 0;
692
693 ret = bgp_bfd_peer_param_type_set(peer, BFD_TYPE_NOT_CONFIGURED);
694 if (ret != 0)
695 return bgp_vty_return (vty, ret);
696
697 return CMD_SUCCESS;
698 }
699
700 void
701 bgp_bfd_init(void)
702 {
703 bfd_gbl_init();
704
705 /* Initialize BFD client functions */
706 zclient->interface_bfd_dest_update = bgp_bfd_dest_update;
707 zclient->bfd_dest_replay = bgp_bfd_dest_replay;
708
709 /* "neighbor bfd" commands. */
710 install_element (BGP_NODE, &neighbor_bfd_cmd);
711 install_element (BGP_NODE, &neighbor_bfd_param_cmd);
712 install_element (BGP_NODE, &neighbor_bfd_type_cmd);
713 install_element (BGP_NODE, &no_neighbor_bfd_cmd);
714 install_element (BGP_NODE, &no_neighbor_bfd_type_cmd);
715 }