summaryrefslogtreecommitdiffstats
path: root/bfdd
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2021-10-14 20:06:38 +0200
committerIgor Ryzhov <iryzhov@nfware.com>2021-10-15 02:42:52 +0200
commit33fc8bc7f30646fa7a4cee324d26e6979aa60400 (patch)
tree737f6fcd813d22446f804b55147a6fd8b8a024a5 /bfdd
parentMerge pull request #9817 from donaldsharp/link_type_ordering (diff)
downloadfrr-33fc8bc7f30646fa7a4cee324d26e6979aa60400.tar.xz
frr-33fc8bc7f30646fa7a4cee324d26e6979aa60400.zip
bfdd: cleanup bfd_session_enable
Well, there are some weird and duplicated checks there... All we need is two simple checks: - VRF existence. We must have it to enable the session. - Interface existence. If it's configured for the session, we have to bind the session to the interface. This commit implements these checks and removes unnecessary duplication. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'bfdd')
-rw-r--r--bfdd/bfd.c31
1 files changed, 7 insertions, 24 deletions
diff --git a/bfdd/bfd.c b/bfdd/bfd.c
index c66fccb85..a4091534f 100644
--- a/bfdd/bfd.c
+++ b/bfdd/bfd.c
@@ -315,45 +315,28 @@ int bfd_session_enable(struct bfd_session *bs)
vrf = vrf_lookup_by_name(bs->key.vrfname);
if (vrf == NULL) {
zlog_err(
- "session-enable: specified VRF doesn't exists.");
+ "session-enable: specified VRF %s doesn't exists.",
+ bs->key.vrfname);
return 0;
}
+ } else {
+ vrf = vrf_lookup_by_id(VRF_DEFAULT);
}
- if (!vrf_is_backend_netns() && vrf && vrf->vrf_id != VRF_DEFAULT
- && !if_lookup_by_name(vrf->name, vrf->vrf_id)) {
- zlog_err("session-enable: vrf interface %s not available yet",
- vrf->name);
- return 0;
- }
+ assert(vrf);
if (bs->key.ifname[0]) {
- if (vrf)
- ifp = if_lookup_by_name(bs->key.ifname, vrf->vrf_id);
- else
- ifp = if_lookup_by_name_all_vrf(bs->key.ifname);
+ ifp = if_lookup_by_name(bs->key.ifname, vrf->vrf_id);
if (ifp == NULL) {
zlog_err(
"session-enable: specified interface %s (VRF %s) doesn't exist.",
- bs->key.ifname, vrf ? vrf->name : "<all>");
+ bs->key.ifname, vrf->name);
return 0;
}
- if (bs->key.ifname[0] && !vrf) {
- vrf = vrf_lookup_by_id(ifp->vrf_id);
- if (vrf == NULL) {
- zlog_err(
- "session-enable: specified VRF %u doesn't exist.",
- ifp->vrf_id);
- return 0;
- }
- }
}
/* Assign interface/VRF pointers. */
bs->vrf = vrf;
- if (bs->vrf == NULL)
- bs->vrf = vrf_lookup_by_id(VRF_DEFAULT);
- assert(bs->vrf);
/* Assign interface pointer (if any). */
bs->ifp = ifp;