u8 passive;
u8 passive_set;
u8 mode;
+ u8 auth_type; /* Authentication type (BFD_AUTH_*) */
+ list *passwords; /* Passwords for authentication */
};
struct bfd_request {
| MULTIPLIER expr { this_bfd_opts->multiplier = $2; }
| PASSIVE bool { this_bfd_opts->passive = $2; this_bfd_opts->passive_set = 1; }
| GRACEFUL { this_bfd_opts->mode = BGP_BFD_GRACEFUL; }
+ | AUTHENTICATION bfd_auth_type { this_bfd_opts->auth_type = $2; }
+ | password_list {}
;
bfd_items:
| bfd_items bfd_item ';'
;
+bfd_opts_start:
+{ reset_passwords(); } ;
+
+bfd_opts_end:
+{
+ this_bfd_opts->passwords = get_passwords();
+
+ if (!this_bfd_opts->auth_type != !this_bfd_opts->passwords)
+ cf_warn("Authentication and password options should be used together");
+
+ if (this_bfd_opts->passwords)
+ {
+ struct password_item *pass;
+ WALK_LIST(pass, *this_bfd_opts->passwords)
+ {
+ if (pass->alg)
+ cf_error("Password algorithm option not available in BFD protocol");
+
+ pass->alg = bfd_auth_type_to_hash_alg[this_bfd_opts->auth_type];
+ }
+ }
+};
+
bfd_opts:
- '{' bfd_items '}'
+ bfd_opts_start '{' bfd_items '}' bfd_opts_end
;
+
/* Core commands */
CF_CLI_HELP(SHOW, ..., [[Show status information]])
.idle_tx_int = opts->idle_tx_int ?: cf->idle_tx_int,
.multiplier = opts->multiplier ?: cf->multiplier,
.passive = opts->passive_set ? opts->passive : cf->passive,
+ .auth_type = opts->auth_type ?: cf->auth_type,
+ .passwords = opts->passwords ?: cf->passwords,
};
}
const char *ifname = (s->ifa && s->ifa->iface) ? s->ifa->iface->name : "---";
btime tx_int = s->last_tx ? MAX(s->des_min_tx_int, s->rem_min_rx_int) : 0;
btime timeout = (btime) MAX(s->req_min_rx_int, s->rem_min_tx_int) * s->rem_detect_mult;
- u8 auth_type = s->ifa->cf->auth_type;
+ u8 auth_type = s->cf.auth_type;
loc_state = (loc_state < 4) ? loc_state : 0;
rem_state = (rem_state < 4) ? rem_state : 0;
u32 idle_tx_int;
u8 multiplier;
u8 passive;
+ u8 auth_type; /* Authentication type (BFD_AUTH_*) */
+ list *passwords; /* Passwords for authentication */
};
struct bfd_neighbor
static void
bfd_fill_authentication(struct bfd_proto *p, struct bfd_session *s, struct bfd_ctl_packet *pkt)
{
- struct bfd_iface_config *cf = s->ifa->cf;
+ struct bfd_session_config *cf = &s->cf;
struct password_item *pass = password_find(cf->passwords, 0);
uint meticulous = 0;
static int
bfd_check_authentication(struct bfd_proto *p, struct bfd_session *s, struct bfd_ctl_packet *pkt)
{
- struct bfd_iface_config *cf = s->ifa->cf;
+ struct bfd_session_config *cf = &s->cf;
const char *err_dsc = NULL;
uint err_val = 0;
uint auth_type = 0;
else if (s->poll_active)
pkt->flags |= BFD_FLAG_POLL;
- if (s->ifa->cf->auth_type)
+ if (s->cf.auth_type)
bfd_fill_authentication(p, s, pkt);
if (sk->tbuf != sk->tpos)