From cd980d0375a45dc885a1781d00a6654e58f4396b Mon Sep 17 00:00:00 2001 From: Igor Ryzhov Date: Thu, 9 Jul 2020 19:20:32 +0300 Subject: [PATCH] vtysh: return success from "no vrf" when VRF doesn't exist It is possible that the same VRF exists in one daemon and doesn't exist in another. In this case, "no vrf NAME" command execution will stop on the first daemon without the VRF and it won't be possible to delete the VRF from other daemons. Such behavior can be reproduced with the following steps: ``` # ip link add test type vrf table 1 # vtysh -c "conf t" -c "vrf test" -c "ip route 1.1.1.1/32 blackhole" # vtysh -c "show run" ... vrf test ip route 1.1.1.1/32 blackhole exit-vrf ! ... # ip link del test # vtysh -c "conf t" -c "no vrf test" % VRF test does not exist # vtysh -c "show run" ... vrf test ip route 1.1.1.1/32 blackhole exit-vrf ! ... ``` This commit fixes the issue by returning success from "no vrf" command when VRF doesn't exist. Signed-off-by: Igor Ryzhov --- lib/vrf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/vrf.c b/lib/vrf.c index 9df5d19516..a0b2c4bfe1 100644 --- a/lib/vrf.c +++ b/lib/vrf.c @@ -758,10 +758,8 @@ DEFUN (no_vrf, vrfp = vrf_lookup_by_name(vrfname); - if (vrfp == NULL) { - vty_out(vty, "%% VRF %s does not exist\n", vrfname); - return CMD_WARNING_CONFIG_FAILED; - } + if (vrfp == NULL) + return CMD_SUCCESS; if (CHECK_FLAG(vrfp->status, VRF_ACTIVE)) { vty_out(vty, "%% Only inactive VRFs can be deleted\n"); -- 2.39.5