]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospfd: Prevent crash if transferring config amongst instances
authorDonald Sharp <sharpd@nvidia.com>
Tue, 13 Oct 2020 12:16:15 +0000 (08:16 -0400)
committerIgor Ryzhov <iryzhov@nfware.com>
Wed, 28 Oct 2020 18:35:48 +0000 (21:35 +0300)
If we enter:

int eth0
  ip ospf area 0
  ip ospf 10 area 0
!

This will crash ospf.  Prevent this from happening.

OSPF instances:

a) Cannot be mixed with non-instance
b) Are their own process.

Since in multi-instance world ospf instances are their own process,
when an ospf processes receives an instance command we must remove
our config( if present ) and allow the new config to be active
in the new process.  The problem here is that if you have not
done a `router ospf` above the lookup of the ospf pointer will
fail and we will just crash.  Put some code in to prevent a crash
in this case.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
ospfd/ospf_vty.c

index 5d7eee3f7b6ba055dea1a465d374e960631237b7..0ecd8b91ca7c49bf59ca534b618c1baa48bd1cd3 100644 (file)
@@ -8065,12 +8065,25 @@ DEFUN (ip_ospf_area,
                ospf = ospf_lookup_instance(instance);
 
        if (instance && ospf == NULL) {
+               /*
+                * At this point we know we have received
+                * an instance and there is no ospf instance
+                * associated with it.  This means we are
+                * in a situation where we have an
+                * ospf command that is setup for a different
+                * process(instance).  We need to safely
+                * remove the command from ourselves and
+                * allow the other instance(process) handle
+                * the configuration command.
+                */
                params = IF_DEF_PARAMS(ifp);
                if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) {
                        UNSET_IF_PARAM(params, if_area);
                        ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
-                       ospf_interface_area_unset(ospf, ifp);
-                       ospf->if_ospf_cli_count--;
+                       if (ospf) {
+                               ospf_interface_area_unset(ospf, ifp);
+                               ospf->if_ospf_cli_count--;
+                       }
                }
                return CMD_NOT_MY_INSTANCE;
        }