3 * Copyright (C) 2018 Network Device Education Foundation, Inc. ("NetDEF")
5 * FRR is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2, or (at your option) any
10 * FRR is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with FRR; see the file COPYING. If not, write to the Free
17 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23 #include "lib/command.h"
30 #ifndef VTYSH_EXTRACT_PL
31 #include "bfdd/bfdd_vty_clippy.c"
35 * Commands help string definitions.
37 #define PEER_STR "Configure peer\n"
38 #define INTERFACE_NAME_STR "Configure interface name to use\n"
39 #define PEER_IPV4_STR "IPv4 peer address\n"
40 #define PEER_IPV6_STR "IPv6 peer address\n"
41 #define MHOP_STR "Configure multihop\n"
42 #define LOCAL_STR "Configure local address\n"
43 #define LOCAL_IPV4_STR "IPv4 local address\n"
44 #define LOCAL_IPV6_STR "IPv6 local address\n"
45 #define LOCAL_INTF_STR "Configure local interface name to use\n"
46 #define VRF_STR "Configure VRF\n"
47 #define VRF_NAME_STR "Configure VRF name\n"
52 static int bfdd_write_config(struct vty
*vty
);
53 static int bfdd_peer_write_config(struct vty
*vty
);
54 static void _bfdd_peer_write_config(struct hash_backet
*hb
, void *arg
);
55 static int bfd_configure_peer(struct bfd_peer_cfg
*bpc
, bool mhop
,
56 const struct sockaddr_any
*peer
,
57 const struct sockaddr_any
*local
,
58 const char *ifname
, const char *vrfname
,
59 char *ebuf
, size_t ebuflen
);
61 static struct json_object
*__display_peer_json(struct bfd_session
*bs
);
62 static void _display_peer_json(struct vty
*vty
, struct bfd_session
*bs
);
63 static void _display_peer(struct vty
*vty
, struct bfd_session
*bs
);
64 static void _display_all_peers(struct vty
*vty
, bool use_json
);
65 static void _display_peer_iter(struct hash_backet
*hb
, void *arg
);
66 static void _display_peer_json_iter(struct hash_backet
*hb
, void *arg
);
70 * Commands definition.
72 DEFUN_NOSH(bfd_enter
, bfd_enter_cmd
, "bfd", "Configure BFD peers\n")
79 bfd_peer_enter
, bfd_peer_enter_cmd
,
80 "peer <A.B.C.D|X:X::X:X> [{multihop|local-address <A.B.C.D|X:X::X:X>|interface IFNAME|vrf NAME}]",
81 PEER_STR PEER_IPV4_STR PEER_IPV6_STR
83 LOCAL_STR LOCAL_IPV4_STR LOCAL_IPV6_STR
90 struct bfd_session
*bs
;
91 const char *peer
, *ifname
, *local
, *vrfname
;
92 struct bfd_peer_cfg bpc
;
93 struct sockaddr_any psa
, lsa
, *lsap
;
96 vrfname
= peer
= ifname
= local
= NULL
;
98 /* Gather all provided information. */
102 mhop
= argv_find(argv
, argc
, "multihop", &idx
);
105 if (argv_find(argv
, argc
, "interface", &idx
))
106 ifname
= argv
[idx
+ 1]->arg
;
109 if (argv_find(argv
, argc
, "local-address", &idx
))
110 local
= argv
[idx
+ 1]->arg
;
113 if (argv_find(argv
, argc
, "vrf", &idx
))
114 vrfname
= argv
[idx
+ 1]->arg
;
116 if (vrfname
&& ifname
) {
117 vty_out(vty
, "%% VRF is not mixable with interface\n");
118 return CMD_WARNING_CONFIG_FAILED
;
123 strtosa(local
, &lsa
);
128 if (bfd_configure_peer(&bpc
, mhop
, &psa
, lsap
, ifname
, vrfname
,
129 errormsg
, sizeof(errormsg
))
131 vty_out(vty
, "%% Invalid peer configuration: %s\n", errormsg
);
132 return CMD_WARNING_CONFIG_FAILED
;
135 bs
= bs_peer_find(&bpc
);
137 bs
= ptm_bfd_sess_new(&bpc
);
139 vty_out(vty
, "%% Failed to add peer.\n");
140 return CMD_WARNING_CONFIG_FAILED
;
144 VTY_PUSH_CONTEXT(BFD_PEER_NODE
, bs
);
149 DEFPY(bfd_peer_detectmultiplier
, bfd_peer_detectmultiplier_cmd
,
150 "detect-multiplier (2-255)$multiplier",
151 "Configure peer detection multiplier\n"
152 "Configure peer detection multiplier value\n")
154 struct bfd_session
*bs
;
156 bs
= VTY_GET_CONTEXT(bfd_session
);
157 bs
->detect_mult
= multiplier
;
162 DEFPY(bfd_peer_recvinterval
, bfd_peer_recvinterval_cmd
,
163 "receive-interval (10-60000)$interval",
164 "Configure peer receive interval\n"
165 "Configure peer receive interval value in milliseconds\n")
167 struct bfd_session
*bs
;
169 bs
= VTY_GET_CONTEXT(bfd_session
);
170 bs
->timers
.required_min_rx
= interval
* 1000;
175 DEFPY(bfd_peer_txinterval
, bfd_peer_txinterval_cmd
,
176 "transmit-interval (10-60000)$interval",
177 "Configure peer transmit interval\n"
178 "Configure peer transmit interval value in milliseconds\n")
180 struct bfd_session
*bs
;
182 bs
= VTY_GET_CONTEXT(bfd_session
);
183 bs
->up_min_tx
= interval
* 1000;
188 DEFPY(bfd_peer_echointerval
, bfd_peer_echointerval_cmd
,
189 "echo-interval (10-60000)$interval",
190 "Configure peer echo interval\n"
191 "Configure peer echo interval value in milliseconds\n")
193 struct bfd_session
*bs
;
195 bs
= VTY_GET_CONTEXT(bfd_session
);
196 bs
->timers
.required_min_echo
= interval
* 1000;
201 DEFPY(bfd_peer_shutdown
, bfd_peer_shutdown_cmd
, "[no] shutdown",
202 NO_STR
"Disable BFD peer")
204 struct bfd_session
*bs
;
206 bs
= VTY_GET_CONTEXT(bfd_session
);
208 if (!BFD_CHECK_FLAG(bs
->flags
, BFD_SESS_FLAG_SHUTDOWN
))
211 BFD_UNSET_FLAG(bs
->flags
, BFD_SESS_FLAG_SHUTDOWN
);
213 /* Change and notify state change. */
214 bs
->ses_state
= PTM_BFD_DOWN
;
217 /* Enable all timers. */
218 bfd_recvtimer_update(bs
);
219 bfd_xmttimer_update(bs
, bs
->xmt_TO
);
220 if (BFD_CHECK_FLAG(bs
->flags
, BFD_SESS_FLAG_ECHO
)) {
221 bfd_echo_recvtimer_update(bs
);
222 bfd_echo_xmttimer_update(bs
, bs
->echo_xmt_TO
);
225 if (BFD_CHECK_FLAG(bs
->flags
, BFD_SESS_FLAG_SHUTDOWN
))
228 BFD_SET_FLAG(bs
->flags
, BFD_SESS_FLAG_SHUTDOWN
);
230 /* Disable all events. */
231 bfd_recvtimer_delete(bs
);
232 bfd_echo_recvtimer_delete(bs
);
233 bfd_xmttimer_delete(bs
);
234 bfd_echo_xmttimer_delete(bs
);
236 /* Change and notify state change. */
237 bs
->ses_state
= PTM_BFD_ADM_DOWN
;
246 DEFPY(bfd_peer_echo
, bfd_peer_echo_cmd
, "[no] echo-mode",
247 NO_STR
"Configure echo mode\n")
249 struct bfd_session
*bs
;
251 bs
= VTY_GET_CONTEXT(bfd_session
);
253 if (!BFD_CHECK_FLAG(bs
->flags
, BFD_SESS_FLAG_ECHO
))
256 BFD_UNSET_FLAG(bs
->flags
, BFD_SESS_FLAG_ECHO
);
257 ptm_bfd_echo_stop(bs
, 0);
259 if (BFD_CHECK_FLAG(bs
->flags
, BFD_SESS_FLAG_ECHO
))
262 BFD_SET_FLAG(bs
->flags
, BFD_SESS_FLAG_ECHO
);
263 /* Apply setting immediately. */
264 if (!BFD_CHECK_FLAG(bs
->flags
, BFD_SESS_FLAG_SHUTDOWN
)) {
265 ptm_bfd_echo_start(bs
);
266 bfd_echo_recvtimer_update(bs
);
273 DEFPY(bfd_peer_label
, bfd_peer_label_cmd
, "label WORD$label",
274 "Register peer label\n"
275 "Register peer label identification\n")
277 struct bfd_session
*bs
;
279 /* Validate label length. */
280 if (strlen(label
) >= MAXNAMELEN
) {
281 vty_out(vty
, "%% Label name is too long\n");
282 return CMD_WARNING_CONFIG_FAILED
;
285 bs
= VTY_GET_CONTEXT(bfd_session
);
286 if (bfd_session_update_label(bs
, label
) == -1) {
287 vty_out(vty
, "%% Failed to update peer label.\n");
288 return CMD_WARNING_CONFIG_FAILED
;
294 DEFPY(bfd_no_peer
, bfd_no_peer_cmd
,
295 "no peer <A.B.C.D|X:X::X:X>$peer [{multihop|local-address <A.B.C.D|X:X::X:X>$local|interface IFNAME$ifname|vrf NAME$vrfname}]",
297 PEER_STR PEER_IPV4_STR PEER_IPV6_STR
299 LOCAL_STR LOCAL_IPV4_STR LOCAL_IPV6_STR
302 VRF_STR VRF_NAME_STR
)
306 struct bfd_peer_cfg bpc
;
307 struct sockaddr_any psa
, lsa
, *lsap
;
310 strtosa(peer_str
, &psa
);
312 strtosa(local_str
, &lsa
);
319 mhop
= argv_find(argv
, argc
, "multihop", &idx
);
321 if (bfd_configure_peer(&bpc
, mhop
, &psa
, lsap
, ifname
, vrfname
,
322 errormsg
, sizeof(errormsg
))
324 vty_out(vty
, "%% Invalid peer configuration: %s\n", errormsg
);
325 return CMD_WARNING_CONFIG_FAILED
;
328 if (ptm_bfd_ses_del(&bpc
) != 0) {
329 vty_out(vty
, "%% Failed to remove peer.\n");
330 return CMD_WARNING_CONFIG_FAILED
;
338 * Show commands helper functions
340 static void _display_peer(struct vty
*vty
, struct bfd_session
*bs
)
345 if (BFD_CHECK_FLAG(bs
->flags
, BFD_SESS_FLAG_MH
)) {
346 vty_out(vty
, "\tpeer %s", satostr(&bs
->mhop
.peer
));
347 vty_out(vty
, " multihop");
348 vty_out(vty
, " local-address %s", satostr(&bs
->mhop
.local
));
349 if (bs
->mhop
.vrf_name
[0])
350 vty_out(vty
, " vrf %s", bs
->mhop
.vrf_name
);
353 vty_out(vty
, "\tpeer %s", satostr(&bs
->mhop
.peer
));
354 if (bs
->shop
.port_name
[0])
355 vty_out(vty
, " interface %s", bs
->shop
.port_name
);
360 vty_out(vty
, "\t\tlabel: %s\n", bs
->pl
->pl_label
);
362 vty_out(vty
, "\t\tID: %u\n", bs
->discrs
.my_discr
);
363 vty_out(vty
, "\t\tRemote ID: %u\n", bs
->discrs
.remote_discr
);
365 vty_out(vty
, "\t\tStatus: ");
366 switch (bs
->ses_state
) {
367 case PTM_BFD_ADM_DOWN
:
368 vty_out(vty
, "shutdown\n");
371 vty_out(vty
, "down\n");
373 now
= monotime(NULL
);
374 integer2timestr(now
- bs
->uptime
.tv_sec
, buf
, sizeof(buf
));
375 vty_out(vty
, "\t\tDowntime: %s\n", buf
);
378 vty_out(vty
, "init\n");
381 vty_out(vty
, "up\n");
383 now
= monotime(NULL
);
384 integer2timestr(now
- bs
->uptime
.tv_sec
, buf
, sizeof(buf
));
385 vty_out(vty
, "\t\tUptime: %s\n", buf
);
389 vty_out(vty
, "unknown\n");
393 vty_out(vty
, "\t\tDiagnostics: %s\n", diag2str(bs
->local_diag
));
394 vty_out(vty
, "\t\tRemote diagnostics: %s\n", diag2str(bs
->remote_diag
));
396 vty_out(vty
, "\t\tLocal timers:\n");
397 vty_out(vty
, "\t\t\tReceive interval: %" PRIu32
"ms\n",
398 bs
->timers
.required_min_rx
/ 1000);
399 vty_out(vty
, "\t\t\tTransmission interval: %" PRIu32
"ms\n",
400 bs
->timers
.desired_min_tx
/ 1000);
402 vty_out(vty
, "\t\t\tEcho transmission interval: ");
403 if (BFD_CHECK_FLAG(bs
->flags
, BFD_SESS_FLAG_ECHO
))
404 vty_out(vty
, "%" PRIu32
"ms\n",
405 bs
->timers
.required_min_echo
/ 1000);
407 vty_out(vty
, "disabled\n");
409 vty_out(vty
, "\t\tRemote timers:\n");
410 vty_out(vty
, "\t\t\tReceive interval: %" PRIu32
"ms\n",
411 bs
->remote_timers
.required_min_rx
/ 1000);
412 vty_out(vty
, "\t\t\tTransmission interval: %" PRIu32
"ms\n",
413 bs
->remote_timers
.desired_min_tx
/ 1000);
414 vty_out(vty
, "\t\t\tEcho transmission interval: %" PRIu32
"ms\n",
415 bs
->remote_timers
.required_min_echo
/ 1000);
420 static struct json_object
*__display_peer_json(struct bfd_session
*bs
)
422 struct json_object
*jo
= json_object_new_object();
424 if (BFD_CHECK_FLAG(bs
->flags
, BFD_SESS_FLAG_MH
)) {
425 json_object_boolean_true_add(jo
, "multihop");
426 json_object_string_add(jo
, "peer", satostr(&bs
->mhop
.peer
));
427 json_object_string_add(jo
, "local", satostr(&bs
->mhop
.local
));
428 if (bs
->mhop
.vrf_name
[0])
429 json_object_string_add(jo
, "vrf", bs
->mhop
.vrf_name
);
431 json_object_boolean_false_add(jo
, "multihop");
432 json_object_string_add(jo
, "peer", satostr(&bs
->shop
.peer
));
433 if (bs
->shop
.port_name
[0])
434 json_object_string_add(jo
, "interface",
439 json_object_string_add(jo
, "label", bs
->pl
->pl_label
);
441 json_object_int_add(jo
, "id", bs
->discrs
.my_discr
);
442 json_object_int_add(jo
, "remote-id", bs
->discrs
.remote_discr
);
444 switch (bs
->ses_state
) {
445 case PTM_BFD_ADM_DOWN
:
446 json_object_string_add(jo
, "status", "shutdown");
449 json_object_string_add(jo
, "status", "down");
450 json_object_int_add(jo
, "downtime",
451 monotime(NULL
) - bs
->uptime
.tv_sec
);
454 json_object_string_add(jo
, "status", "init");
457 json_object_string_add(jo
, "status", "up");
458 json_object_int_add(jo
, "uptime",
459 monotime(NULL
) - bs
->uptime
.tv_sec
);
463 json_object_string_add(jo
, "status", "unknown");
467 json_object_string_add(jo
, "diagnostic", diag2str(bs
->local_diag
));
468 json_object_string_add(jo
, "remote-diagnostic",
469 diag2str(bs
->remote_diag
));
471 json_object_int_add(jo
, "receive-interval",
472 bs
->timers
.required_min_rx
/ 1000);
473 json_object_int_add(jo
, "transmit-interval",
474 bs
->timers
.desired_min_tx
/ 1000);
475 if (BFD_CHECK_FLAG(bs
->flags
, BFD_SESS_FLAG_ECHO
))
476 json_object_int_add(jo
, "echo-interval",
477 bs
->timers
.required_min_echo
/ 1000);
479 json_object_int_add(jo
, "echo-interval", 0);
481 json_object_int_add(jo
, "remote-receive-interval",
482 bs
->remote_timers
.required_min_rx
/ 1000);
483 json_object_int_add(jo
, "remote-transmit-interval",
484 bs
->remote_timers
.desired_min_tx
/ 1000);
485 json_object_int_add(jo
, "remote-echo-interval",
486 bs
->remote_timers
.required_min_echo
/ 1000);
491 static void _display_peer_json(struct vty
*vty
, struct bfd_session
*bs
)
493 struct json_object
*jo
= __display_peer_json(bs
);
495 vty_out(vty
, "%s\n", json_object_to_json_string_ext(jo
, 0));
496 json_object_free(jo
);
499 static void _display_peer_iter(struct hash_backet
*hb
, void *arg
)
501 struct vty
*vty
= arg
;
502 struct bfd_session
*bs
= hb
->data
;
504 _display_peer(vty
, bs
);
507 static void _display_peer_json_iter(struct hash_backet
*hb
, void *arg
)
509 struct json_object
*jo
= arg
, *jon
= NULL
;
510 struct bfd_session
*bs
= hb
->data
;
512 jon
= __display_peer_json(bs
);
514 log_warning("%s: not enough memory", __func__
);
518 json_object_array_add(jo
, jon
);
521 static void _display_all_peers(struct vty
*vty
, bool use_json
)
523 struct json_object
*jo
;
525 if (use_json
== false) {
526 bfd_id_iterate(_display_peer_iter
, vty
);
530 jo
= json_object_new_array();
531 bfd_id_iterate(_display_peer_json_iter
, jo
);
533 vty_out(vty
, "%s\n", json_object_to_json_string_ext(jo
, 0));
534 json_object_free(jo
);
537 DEFPY(bfd_show_peers
, bfd_show_peers_cmd
, "show bfd peers [json]",
539 "Bidirection Forwarding Detection\n"
543 bool json
= use_json(argc
, argv
);
546 _display_all_peers(vty
, true);
548 vty_out(vty
, "BFD Peers:\n");
549 _display_all_peers(vty
, false);
555 DEFPY(bfd_show_peer
, bfd_show_peer_cmd
,
556 "show bfd peer <WORD$label|<A.B.C.D|X:X::X:X>$peer [{multihop|local-address <A.B.C.D|X:X::X:X>$local|interface IFNAME$ifname|vrf NAME$vrfname}]> [json]",
558 "Bidirection Forwarding Detection\n"
561 PEER_IPV4_STR PEER_IPV6_STR
563 LOCAL_STR LOCAL_IPV4_STR LOCAL_IPV6_STR
571 struct bfd_session
*bs
= NULL
;
572 struct peer_label
*pl
;
573 struct bfd_peer_cfg bpc
;
574 struct sockaddr_any psa
, lsa
, *lsap
;
577 /* Look up the BFD peer. */
583 strtosa(peer_str
, &psa
);
585 strtosa(local_str
, &lsa
);
591 mhop
= argv_find(argv
, argc
, "multihop", &idx
);
593 if (bfd_configure_peer(&bpc
, mhop
, &psa
, lsap
, ifname
, vrfname
,
594 errormsg
, sizeof(errormsg
))
596 vty_out(vty
, "%% Invalid peer configuration: %s\n",
598 return CMD_WARNING_CONFIG_FAILED
;
601 bs
= bs_peer_find(&bpc
);
604 /* Find peer data. */
606 vty_out(vty
, "%% Unable to find 'peer %s",
607 label
? label
: peer_str
);
609 vty_out(vty
, " interface %s", ifname
);
611 vty_out(vty
, " local-address %s", local_str
);
613 vty_out(vty
, " vrf %s", vrfname
);
616 return CMD_WARNING_CONFIG_FAILED
;
619 if (use_json(argc
, argv
)) {
620 _display_peer_json(vty
, bs
);
622 vty_out(vty
, "BFD Peer:\n");
623 _display_peer(vty
, bs
);
631 * Function definitions.
635 * Configuration rules:
638 * peer + (optional vxlan or interface name)
641 * peer + local + (optional vrf)
643 * Anything else is misconfiguration.
645 static int bfd_configure_peer(struct bfd_peer_cfg
*bpc
, bool mhop
,
646 const struct sockaddr_any
*peer
,
647 const struct sockaddr_any
*local
,
648 const char *ifname
, const char *vrfname
,
649 char *ebuf
, size_t ebuflen
)
651 memset(bpc
, 0, sizeof(*bpc
));
654 bpc
->bpc_shutdown
= true;
655 bpc
->bpc_detectmultiplier
= BPC_DEF_DETECTMULTIPLIER
;
656 bpc
->bpc_recvinterval
= BPC_DEF_RECEIVEINTERVAL
;
657 bpc
->bpc_txinterval
= BPC_DEF_TRANSMITINTERVAL
;
658 bpc
->bpc_echointerval
= BPC_DEF_ECHOINTERVAL
;
659 bpc
->bpc_lastevent
= monotime(NULL
);
661 /* Safety check: when no error buf is provided len must be zero. */
665 /* Peer is always mandatory. */
667 snprintf(ebuf
, ebuflen
, "peer must not be empty");
671 /* Validate address families. */
672 if (peer
->sa_sin
.sin_family
== AF_INET
) {
673 if (local
&& local
->sa_sin
.sin_family
!= AF_INET
) {
674 snprintf(ebuf
, ebuflen
,
675 "local is IPv6, but peer is IPv4");
679 bpc
->bpc_ipv4
= true;
680 } else if (peer
->sa_sin
.sin_family
== AF_INET6
) {
681 if (local
&& local
->sa_sin
.sin_family
!= AF_INET6
) {
682 snprintf(ebuf
, ebuflen
,
683 "local is IPv4, but peer is IPv6");
687 bpc
->bpc_ipv4
= false;
689 snprintf(ebuf
, ebuflen
, "invalid peer address family");
693 /* Copy local and/or peer addresses. */
695 bpc
->bpc_local
= *local
;
698 bpc
->bpc_peer
= *peer
;
700 /* Peer configuration is mandatory. */
701 snprintf(ebuf
, ebuflen
, "no peer configured");
705 bpc
->bpc_mhop
= mhop
;
708 /* Handle VxLAN configuration. */
710 if (vxlan
> ((1 << 24) - 1)) {
711 snprintf(ebuf
, ebuflen
, "invalid VxLAN %d", vxlan
);
715 snprintf(ebuf
, ebuflen
,
716 "multihop doesn't accept VxLAN");
720 bpc
->bpc_vxlan
= vxlan
;
724 /* Handle interface specification configuration. */
727 snprintf(ebuf
, ebuflen
,
728 "multihop doesn't accept interface names");
732 bpc
->bpc_has_localif
= true;
733 if (strlcpy(bpc
->bpc_localif
, ifname
, sizeof(bpc
->bpc_localif
))
734 > sizeof(bpc
->bpc_localif
)) {
735 snprintf(ebuf
, ebuflen
, "interface name too long");
740 /* Handle VRF configuration. */
742 bpc
->bpc_has_vrfname
= true;
743 if (strlcpy(bpc
->bpc_vrfname
, vrfname
, sizeof(bpc
->bpc_vrfname
))
744 > sizeof(bpc
->bpc_vrfname
)) {
745 snprintf(ebuf
, ebuflen
, "vrf name too long");
752 static int bfdd_write_config(struct vty
*vty
)
754 vty_out(vty
, "bfd\n");
759 static void _bfdd_peer_write_config(struct hash_backet
*hb
, void *arg
)
761 struct vty
*vty
= arg
;
762 struct bfd_session
*bs
= hb
->data
;
764 if (BFD_CHECK_FLAG(bs
->flags
, BFD_SESS_FLAG_MH
)) {
765 vty_out(vty
, " peer %s", satostr(&bs
->mhop
.peer
));
766 vty_out(vty
, " multihop");
767 vty_out(vty
, " local-address %s", satostr(&bs
->mhop
.local
));
768 if (bs
->mhop
.vrf_name
[0])
769 vty_out(vty
, " vrf %s", bs
->mhop
.vrf_name
);
772 vty_out(vty
, " peer %s", satostr(&bs
->shop
.peer
));
773 if (bs
->local_address
.sa_sin
.sin_family
!= AF_UNSPEC
)
774 vty_out(vty
, " local-address %s",
775 satostr(&bs
->local_address
));
776 if (bs
->shop
.port_name
[0])
777 vty_out(vty
, " interface %s", bs
->shop
.port_name
);
781 if (bs
->detect_mult
!= BPC_DEF_DETECTMULTIPLIER
)
782 vty_out(vty
, " detect-multiplier %d\n", bs
->detect_mult
);
783 if (bs
->timers
.required_min_rx
!= (BPC_DEF_RECEIVEINTERVAL
* 1000))
784 vty_out(vty
, " receive-interval %" PRIu32
"\n",
785 bs
->timers
.required_min_rx
/ 1000);
786 if (bs
->timers
.desired_min_tx
!= (BPC_DEF_TRANSMITINTERVAL
* 1000))
787 vty_out(vty
, " transmit-interval %" PRIu32
"\n",
788 bs
->timers
.desired_min_tx
/ 1000);
789 if (bs
->timers
.required_min_echo
!= (BPC_DEF_ECHOINTERVAL
* 1000))
790 vty_out(vty
, " echo-interval %" PRIu32
"\n",
791 bs
->timers
.required_min_echo
/ 1000);
793 vty_out(vty
, " label %s\n", bs
->pl
->pl_label
);
794 if (BFD_CHECK_FLAG(bs
->flags
, BFD_SESS_FLAG_ECHO
))
795 vty_out(vty
, " echo-mode\n");
797 vty_out(vty
, " %sshutdown\n",
798 BFD_CHECK_FLAG(bs
->flags
, BFD_SESS_FLAG_SHUTDOWN
) ? "" : "no ");
800 vty_out(vty
, " !\n");
803 static int bfdd_peer_write_config(struct vty
*vty
)
805 bfd_id_iterate(_bfdd_peer_write_config
, vty
);
809 struct cmd_node bfd_node
= {
815 struct cmd_node bfd_peer_node
= {
817 "%s(config-bfd-peer)# ",
821 void bfdd_vty_init(void)
823 install_element(ENABLE_NODE
, &bfd_show_peers_cmd
);
824 install_element(ENABLE_NODE
, &bfd_show_peer_cmd
);
825 install_element(CONFIG_NODE
, &bfd_enter_cmd
);
827 /* Install BFD node and commands. */
828 install_node(&bfd_node
, bfdd_write_config
);
829 install_default(BFD_NODE
);
830 install_element(BFD_NODE
, &bfd_peer_enter_cmd
);
831 install_element(BFD_NODE
, &bfd_no_peer_cmd
);
833 /* Install BFD peer node. */
834 install_node(&bfd_peer_node
, bfdd_peer_write_config
);
835 install_default(BFD_PEER_NODE
);
836 install_element(BFD_PEER_NODE
, &bfd_peer_detectmultiplier_cmd
);
837 install_element(BFD_PEER_NODE
, &bfd_peer_recvinterval_cmd
);
838 install_element(BFD_PEER_NODE
, &bfd_peer_txinterval_cmd
);
839 install_element(BFD_PEER_NODE
, &bfd_peer_echointerval_cmd
);
840 install_element(BFD_PEER_NODE
, &bfd_peer_shutdown_cmd
);
841 install_element(BFD_PEER_NODE
, &bfd_peer_echo_cmd
);
842 install_element(BFD_PEER_NODE
, &bfd_peer_label_cmd
);