Commit a827c7d50f for frr
commit a827c7d50f6c50fe8601d00a4986520b880c8d00
Author: Philippe Guibert <philippe.guibert@6wind.com>
Date: Tue Nov 10 17:56:40 2026 +0100
bfdd, yang: accept a peer keychain that is not configured yet
A BFD peer refuses a keychain that does not exist yet, while a BFD
profile accepts it:
> north(config-bfd-peer)# authentication key-chain AAEE
> % Configuration failed.
>
> Error type: validation
> Error description: YANG error(s):
> Path: Data location "/frr-bfdd:bfdd/bfd/sessions/single-hop[dest-addr='5.5.5.5'][interface='*'][vrf='default']/authentication-key-chain".
> Error: Invalid leafref value "AAEE" - no target instance "/key-chain:key-chains/key-chain:key-chain/key-chain:name" with the same value.
The peer leaf is a key-chain-ref, a leafref whose target instance is
required, whereas the profile leaf is a plain string. bfdd itself does
not need the keychain to exist: the peer only stores its name,
bfd_session_apply() falls back to the profile keychain when that name
is not found, and the keychain hooks attach the session to the keychain
once it gets a key.
Do not require the keychain instance in the peer leaf, so that a peer
can be configured before its keychain, and the keychain removed while
a peer still refers to it. Since such a peer silently uses the profile
keychain, or no authentication at all, warn about it when the session
configuration is applied, and document it.
Fixes: 28ddfe7fe8 ("bfdd, yang: northbound sessions sbfd,(single,multi)-hop keychain")
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
diff --git a/bfdd/bfd.c b/bfdd/bfd.c
index ffaa06ffc4..56127f6e5e 100644
--- a/bfdd/bfd.c
+++ b/bfdd/bfd.c
@@ -268,6 +268,17 @@ void bfd_session_apply(struct bfd_session *bs)
bs->auth_meticulous = bs->peer_profile.auth_config.meticulous ||
(bs->profile && bs->profile->auth_config.meticulous);
+ if (bs->peer_profile.auth_config.key_chain_name[0] != '\0' &&
+ !bfd_session_auth_config_takes_precedence_over_profile(bs)) {
+ if (bs->kc)
+ zlog_warn("BFD: session [%s] keychain %s does not exist; using keychain %s of profile %s",
+ bs_to_string(bs), bs->peer_profile.auth_config.key_chain_name,
+ bs->kc->name, bs->profile->name);
+ else
+ zlog_warn("BFD: session [%s] keychain %s does not exist; the session will not authenticate",
+ bs_to_string(bs), bs->peer_profile.auth_config.key_chain_name);
+ }
+
/*
* Warn here rather than per packet. A keychain that holds nothing
* this session can use now keeps the session down instead of
diff --git a/doc/user/bfd.rst b/doc/user/bfd.rst
index e285eedfdc..b49f1d52bd 100644
--- a/doc/user/bfd.rst
+++ b/doc/user/bfd.rst
@@ -282,6 +282,10 @@ BFD peers and profiles share the same BFD session configuration commands.
distinguishes the two: authentication is reported as enabled once a
key is in effect, and as configured when only the key-chain is.
+ A peer may refer to a key-chain that is not configured yet. Until it
+ is, the peer uses the key-chain of its profile if any, and is not
+ authenticated otherwise.
+
.. clicmd:: authentication algorithm meticulous
Configure peer or profile to use meticulous mode when the key-chain
diff --git a/yang/frr-bfdd.yang b/yang/frr-bfdd.yang
index a927fc5596..6f898e0dff 100644
--- a/yang/frr-bfdd.yang
+++ b/yang/frr-bfdd.yang
@@ -168,7 +168,9 @@ module frr-bfdd {
grouping auth-config {
leaf authentication-key-chain {
- type kc:key-chain-ref;
+ type kc:key-chain-ref {
+ require-instance false;
+ }
description "Reference to the key chain for authentication";
}