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