]> git.proxmox.com Git - mirror_frr.git/commitdiff
ospfd: prevent passive interface cmd crash
authorChirag Shah <chirag@cumulusnetworks.com>
Fri, 8 Dec 2017 17:33:53 +0000 (09:33 -0800)
committerChirag Shah <chirag@cumulusnetworks.com>
Sat, 9 Dec 2017 01:02:54 +0000 (17:02 -0800)
Current OSPF VRF configuration are allow pre-provisining even if
VRF is not configured. In such case ospf->vrf_id would VRF_UNKNOWN,
when passive interface configuration done under such ospf instance,
it would lookup all vrf_device and try to create ifp with unknown
vrf_id.

for passive interface config command lookup ifp for vrf_id is within range.

Ticket:CM-19156
Testing Done:
Configure
Cumulus#: router ospf vrf vrf1
Cumulus(config-router)#: passive interface swp16
 interface swp16 not found.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
ospfd/ospf_vty.c

index c4289fb3ce4a576f2a6d463506e7e75d0ea4ab93..a5ea14793a8e8ace5237f4f6bc5d970d6fcacc2c 100644 (file)
@@ -449,7 +449,7 @@ DEFUN (ospf_passive_interface,
 {
        VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
        int idx_ipv4 = 2;
-       struct interface *ifp;
+       struct interface *ifp = NULL;
        struct in_addr addr = {.s_addr = INADDR_ANY};
        int ret;
        struct ospf_if_params *params;
@@ -459,12 +459,13 @@ DEFUN (ospf_passive_interface,
                ospf_passive_interface_default(ospf, OSPF_IF_PASSIVE);
                return CMD_SUCCESS;
        }
+       if (ospf->vrf_id != VRF_UNKNOWN)
+               ifp = if_get_by_name(argv[1]->arg, ospf->vrf_id, 0);
 
-       ifp = if_get_by_name(argv[1]->arg, ospf->vrf_id, 0);
        if (ifp == NULL) {
                vty_out(vty, "interface %s not found.\n",
                        (char *)argv[1]->arg);
-               return CMD_WARNING;
+               return CMD_WARNING_CONFIG_FAILED;
        }
 
        params = IF_DEF_PARAMS(ifp);
@@ -521,7 +522,7 @@ DEFUN (no_ospf_passive_interface,
 {
        VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
        int idx_ipv4 = 3;
-       struct interface *ifp;
+       struct interface *ifp = NULL;
        struct in_addr addr = {.s_addr = INADDR_ANY};
        struct ospf_if_params *params;
        int ret;
@@ -532,11 +533,13 @@ DEFUN (no_ospf_passive_interface,
                return CMD_SUCCESS;
        }
 
-       ifp = if_get_by_name(argv[2]->arg, ospf->vrf_id, 0);
+       if (ospf->vrf_id != VRF_UNKNOWN)
+               ifp = if_get_by_name(argv[1]->arg, ospf->vrf_id, 0);
+
        if (ifp == NULL) {
                vty_out(vty, "interface %s not found.\n",
                        (char *)argv[1]->arg);
-               return CMD_WARNING;
+               return CMD_WARNING_CONFIG_FAILED;
        }
 
        params = IF_DEF_PARAMS(ifp);