2013-09-10 10:09:36 +00:00
|
|
|
/*
|
|
|
|
* BIRD -- Router Advertisement Configuration
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
|
|
|
*/
|
|
|
|
|
|
|
|
CF_HDR
|
|
|
|
|
|
|
|
#include "proto/bfd/bfd.h"
|
|
|
|
|
|
|
|
CF_DEFINES
|
|
|
|
|
|
|
|
#define BFD_CFG ((struct bfd_config *) this_proto)
|
2013-11-19 21:33:48 +00:00
|
|
|
#define BFD_IFACE ((struct bfd_iface_config *) this_ipatt)
|
2013-09-10 10:09:36 +00:00
|
|
|
#define BFD_NEIGHBOR this_bfd_neighbor
|
|
|
|
|
|
|
|
static struct bfd_neighbor *this_bfd_neighbor;
|
|
|
|
|
2013-11-19 21:33:48 +00:00
|
|
|
extern struct bfd_config *bfd_cf;
|
2013-09-10 10:09:36 +00:00
|
|
|
|
|
|
|
CF_DECLS
|
|
|
|
|
2013-11-19 21:33:48 +00:00
|
|
|
CF_KEYWORDS(BFD, MIN, IDLE, RX, TX, INTERVAL, MULTIPLIER, PASSIVE,
|
2016-10-30 22:51:23 +00:00
|
|
|
INTERFACE, MULTIHOP, NEIGHBOR, DEV, LOCAL, AUTHENTICATION,
|
2022-04-07 17:33:40 +00:00
|
|
|
NONE, SIMPLE, METICULOUS, KEYED, MD5, SHA1, IPV4, IPV6, DIRECT,
|
|
|
|
STRICT, BIND)
|
2013-09-10 10:09:36 +00:00
|
|
|
|
|
|
|
%type <iface> bfd_neigh_iface
|
|
|
|
%type <a> bfd_neigh_local
|
2016-10-30 22:51:23 +00:00
|
|
|
%type <i> bfd_neigh_multihop bfd_auth_type
|
2013-09-10 10:09:36 +00:00
|
|
|
|
|
|
|
CF_GRAMMAR
|
|
|
|
|
2018-06-26 12:29:03 +00:00
|
|
|
proto: bfd_proto ;
|
2013-09-10 10:09:36 +00:00
|
|
|
|
|
|
|
bfd_proto_start: proto_start BFD
|
|
|
|
{
|
2015-02-21 20:08:23 +00:00
|
|
|
this_proto = proto_config_new(&proto_bfd, $1);
|
2021-06-19 18:50:18 +00:00
|
|
|
this_proto->loop_order = DOMAIN_ORDER(proto);
|
2023-04-17 09:37:29 +00:00
|
|
|
this_proto->loop_max_latency = 10 MS_;
|
2013-11-19 21:33:48 +00:00
|
|
|
init_list(&BFD_CFG->patt_list);
|
2013-09-16 21:57:40 +00:00
|
|
|
init_list(&BFD_CFG->neigh_list);
|
2020-01-28 17:07:25 +00:00
|
|
|
BFD_CFG->accept_ipv4 = BFD_CFG->accept_ipv6 = 1;
|
|
|
|
BFD_CFG->accept_direct = BFD_CFG->accept_multihop = 1;
|
2013-09-10 10:09:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
bfd_proto_item:
|
|
|
|
proto_item
|
2020-01-28 17:07:25 +00:00
|
|
|
| ACCEPT bfd_accept
|
2013-11-19 21:33:48 +00:00
|
|
|
| INTERFACE bfd_iface
|
|
|
|
| MULTIHOP bfd_multihop
|
|
|
|
| NEIGHBOR bfd_neighbor
|
2022-04-07 17:33:40 +00:00
|
|
|
| STRICT BIND bool { BFD_CFG->strict_bind = $3; }
|
2013-09-10 10:09:36 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
bfd_proto_opts:
|
|
|
|
/* empty */
|
|
|
|
| bfd_proto_opts bfd_proto_item ';'
|
|
|
|
;
|
|
|
|
|
|
|
|
bfd_proto:
|
|
|
|
bfd_proto_start proto_name '{' bfd_proto_opts '}';
|
|
|
|
|
|
|
|
|
2020-01-28 17:07:25 +00:00
|
|
|
bfd_accept_item:
|
|
|
|
IPV4 { BFD_CFG->accept_ipv4 = 1; BFD_CFG->accept_ipv6 = 0; }
|
|
|
|
| IPV6 { BFD_CFG->accept_ipv4 = 0; BFD_CFG->accept_ipv6 = 1; }
|
|
|
|
| DIRECT { BFD_CFG->accept_direct = 1; BFD_CFG->accept_multihop = 0; }
|
|
|
|
| MULTIHOP { BFD_CFG->accept_direct = 0; BFD_CFG->accept_multihop = 1; }
|
|
|
|
;
|
|
|
|
|
|
|
|
bfd_accept:
|
|
|
|
{
|
|
|
|
BFD_CFG->accept_ipv4 = BFD_CFG->accept_ipv6 = 1;
|
|
|
|
BFD_CFG->accept_direct = BFD_CFG->accept_multihop = 1;
|
|
|
|
}
|
|
|
|
| bfd_accept bfd_accept_item
|
|
|
|
|
|
|
|
|
2013-11-19 21:33:48 +00:00
|
|
|
bfd_iface_start:
|
2013-09-10 10:09:36 +00:00
|
|
|
{
|
2013-11-19 21:33:48 +00:00
|
|
|
this_ipatt = cfg_allocz(sizeof(struct bfd_iface_config));
|
2016-10-30 22:51:23 +00:00
|
|
|
add_tail(&BFD_CFG->patt_list, NODE this_ipatt);
|
2013-11-19 21:33:48 +00:00
|
|
|
init_list(&this_ipatt->ipn_list);
|
2013-09-10 10:09:36 +00:00
|
|
|
|
2013-11-19 21:33:48 +00:00
|
|
|
BFD_IFACE->min_rx_int = BFD_DEFAULT_MIN_RX_INT;
|
|
|
|
BFD_IFACE->min_tx_int = BFD_DEFAULT_MIN_TX_INT;
|
|
|
|
BFD_IFACE->idle_tx_int = BFD_DEFAULT_IDLE_TX_INT;
|
|
|
|
BFD_IFACE->multiplier = BFD_DEFAULT_MULTIPLIER;
|
2016-10-30 22:51:23 +00:00
|
|
|
|
|
|
|
reset_passwords();
|
|
|
|
};
|
|
|
|
|
|
|
|
bfd_iface_finish:
|
|
|
|
{
|
|
|
|
BFD_IFACE->passwords = get_passwords();
|
|
|
|
|
|
|
|
if (!BFD_IFACE->auth_type != !BFD_IFACE->passwords)
|
2023-06-16 20:11:03 +00:00
|
|
|
cf_warn("Authentication and password options should be used together");
|
2016-10-30 22:51:23 +00:00
|
|
|
|
|
|
|
if (BFD_IFACE->passwords)
|
|
|
|
{
|
|
|
|
struct password_item *pass;
|
|
|
|
WALK_LIST(pass, *BFD_IFACE->passwords)
|
|
|
|
{
|
|
|
|
if (pass->alg)
|
|
|
|
cf_error("Password algorithm option not available in BFD protocol");
|
|
|
|
|
|
|
|
pass->alg = bfd_auth_type_to_hash_alg[BFD_IFACE->auth_type];
|
|
|
|
}
|
|
|
|
}
|
2013-09-10 10:09:36 +00:00
|
|
|
};
|
|
|
|
|
2013-11-19 21:33:48 +00:00
|
|
|
bfd_iface_item:
|
|
|
|
INTERVAL expr_us { BFD_IFACE->min_rx_int = BFD_IFACE->min_tx_int = $2; }
|
|
|
|
| MIN RX INTERVAL expr_us { BFD_IFACE->min_rx_int = $4; }
|
|
|
|
| MIN TX INTERVAL expr_us { BFD_IFACE->min_tx_int = $4; }
|
|
|
|
| IDLE TX INTERVAL expr_us { BFD_IFACE->idle_tx_int = $4; }
|
|
|
|
| MULTIPLIER expr { BFD_IFACE->multiplier = $2; }
|
|
|
|
| PASSIVE bool { BFD_IFACE->passive = $2; }
|
2016-10-30 22:51:23 +00:00
|
|
|
| AUTHENTICATION bfd_auth_type { BFD_IFACE->auth_type = $2; }
|
|
|
|
| password_list {}
|
|
|
|
;
|
|
|
|
|
|
|
|
bfd_auth_type:
|
|
|
|
NONE { $$ = BFD_AUTH_NONE; }
|
|
|
|
| SIMPLE { $$ = BFD_AUTH_SIMPLE; }
|
|
|
|
| KEYED MD5 { $$ = BFD_AUTH_KEYED_MD5; }
|
|
|
|
| KEYED SHA1 { $$ = BFD_AUTH_KEYED_SHA1; }
|
|
|
|
| METICULOUS KEYED MD5 { $$ = BFD_AUTH_METICULOUS_KEYED_MD5; }
|
|
|
|
| METICULOUS KEYED SHA1 { $$ = BFD_AUTH_METICULOUS_KEYED_SHA1; }
|
2013-09-10 10:09:36 +00:00
|
|
|
;
|
|
|
|
|
2013-11-19 21:33:48 +00:00
|
|
|
bfd_iface_opts:
|
2013-09-10 10:09:36 +00:00
|
|
|
/* empty */
|
2013-11-19 21:33:48 +00:00
|
|
|
| bfd_iface_opts bfd_iface_item ';'
|
2013-09-10 10:09:36 +00:00
|
|
|
;
|
|
|
|
|
2013-11-19 21:33:48 +00:00
|
|
|
bfd_iface_opt_list:
|
2013-09-10 10:09:36 +00:00
|
|
|
/* empty */
|
2013-11-19 21:33:48 +00:00
|
|
|
| '{' bfd_iface_opts '}'
|
2013-09-10 10:09:36 +00:00
|
|
|
;
|
|
|
|
|
2016-10-30 22:51:23 +00:00
|
|
|
bfd_iface:
|
|
|
|
bfd_iface_start iface_patt_list_nopx bfd_iface_opt_list bfd_iface_finish;
|
2013-11-19 21:33:48 +00:00
|
|
|
|
2016-10-30 22:51:23 +00:00
|
|
|
bfd_multihop:
|
|
|
|
bfd_iface_start bfd_iface_opt_list bfd_iface_finish
|
2013-11-19 21:33:48 +00:00
|
|
|
{ BFD_CFG->multihop = BFD_IFACE; };
|
2013-09-10 10:09:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
bfd_neigh_iface:
|
|
|
|
/* empty */ { $$ = NULL; }
|
2019-01-30 13:03:47 +00:00
|
|
|
| '%' symbol { $$ = if_get_by_name($2->name); }
|
2014-05-29 21:05:03 +00:00
|
|
|
| DEV text { $$ = if_get_by_name($2); }
|
2013-09-10 10:09:36 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
bfd_neigh_local:
|
|
|
|
/* empty */ { $$ = IPA_NONE; }
|
|
|
|
| LOCAL ipa { $$ = $2; }
|
|
|
|
;
|
|
|
|
|
2013-11-19 21:33:48 +00:00
|
|
|
bfd_neigh_multihop:
|
|
|
|
/* empty */ { $$ = 0; }
|
|
|
|
| MULTIHOP bool { $$ = $2; }
|
|
|
|
;
|
|
|
|
|
|
|
|
bfd_neighbor: ipa bfd_neigh_iface bfd_neigh_local bfd_neigh_multihop
|
2013-09-10 10:09:36 +00:00
|
|
|
{
|
|
|
|
this_bfd_neighbor = cfg_allocz(sizeof(struct bfd_neighbor));
|
2013-09-16 21:57:40 +00:00
|
|
|
add_tail(&BFD_CFG->neigh_list, NODE this_bfd_neighbor);
|
2013-09-10 10:09:36 +00:00
|
|
|
|
2013-11-19 21:33:48 +00:00
|
|
|
BFD_NEIGHBOR->addr = $1;
|
|
|
|
BFD_NEIGHBOR->local = $3;
|
|
|
|
BFD_NEIGHBOR->iface = $2;
|
|
|
|
BFD_NEIGHBOR->multihop = $4;
|
|
|
|
|
|
|
|
if ($4 && $2)
|
|
|
|
cf_error("Neighbor cannot set both interface and multihop");
|
|
|
|
|
|
|
|
if ($4 && ipa_zero($3))
|
|
|
|
cf_error("Multihop neighbor requires specified local address");
|
2013-09-10 10:09:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-04-02 18:09:37 +00:00
|
|
|
CF_CLI_HELP(SHOW BFD, ..., [[Show information about BFD protocol]]);
|
2019-01-30 13:03:47 +00:00
|
|
|
CF_CLI(SHOW BFD SESSIONS, optproto, [<name>], [[Show information about BFD sessions]])
|
2020-05-14 01:48:17 +00:00
|
|
|
{ PROTO_WALK_CMD($4, &proto_bfd, p) bfd_show_sessions(p); };
|
2013-09-16 21:57:40 +00:00
|
|
|
|
2013-09-10 10:09:36 +00:00
|
|
|
CF_CODE
|
|
|
|
|
|
|
|
CF_END
|