From 218afa3671382f60d8b62c286739afd6f77cd2c6 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Mon, 25 Mar 2019 17:20:35 +0100 Subject: [PATCH] bfdd: permit to configure both iface and vrf it is possible to configure both iface and vrfname. also, the appropriate vrf is used, in case an iface is given. Signed-off-by: Philippe Guibert --- bfdd/bfd.c | 30 +++++++++++++++++------------- bfdd/bfdd_vty.c | 5 ----- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/bfdd/bfd.c b/bfdd/bfd.c index 477bc492ce..517fed1a41 100644 --- a/bfdd/bfd.c +++ b/bfdd/bfd.c @@ -128,15 +128,8 @@ int bfd_session_enable(struct bfd_session *bs) * If the interface or VRF doesn't exist, then we must register * the session but delay its start. */ - if (bs->key.ifname[0]) { - ifp = if_lookup_by_name_all_vrf(bs->key.ifname); - if (ifp == NULL) { - log_error( - "session-enable: specified interface doesn't exists."); - return 0; - } - - vrf = vrf_lookup_by_id(ifp->vrf_id); + if (bs->key.vrfname[0]) { + vrf = vrf_lookup_by_name(bs->key.vrfname); if (vrf == NULL) { log_error( "session-enable: specified VRF doesn't exists."); @@ -144,13 +137,24 @@ int bfd_session_enable(struct bfd_session *bs) } } - if (bs->key.vrfname[0]) { - vrf = vrf_lookup_by_name(bs->key.vrfname); - if (vrf == NULL) { + 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); + if (ifp == NULL) { log_error( - "session-enable: specified VRF doesn't exists."); + "session-enable: specified interface doesn't exists."); return 0; } + if (bs->key.ifname[0] && !vrf) { + vrf = vrf_lookup_by_id(ifp->vrf_id); + if (vrf == NULL) { + log_error( + "session-enable: specified VRF doesn't exists."); + return 0; + } + } } /* Assign interface/VRF pointers. */ diff --git a/bfdd/bfdd_vty.c b/bfdd/bfdd_vty.c index 95b2dc2548..129894b691 100644 --- a/bfdd/bfdd_vty.c +++ b/bfdd/bfdd_vty.c @@ -126,11 +126,6 @@ DEFUN_NOSH( if (argv_find(argv, argc, "vrf", &idx)) vrfname = argv[idx + 1]->arg; - if (vrfname && ifname) { - vty_out(vty, "%% VRF is not mixable with interface\n"); - return CMD_WARNING_CONFIG_FAILED; - } - strtosa(peer, &psa); if (local) { strtosa(local, &lsa); -- 2.39.5