]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospfd: fix crash when creating vlink in unknown vrf 9853/head
authorIgor Ryzhov <iryzhov@nfware.com>
Mon, 18 Oct 2021 14:16:35 +0000 (17:16 +0300)
committermergify-bot <noreply@mergify.io>
Tue, 19 Oct 2021 21:58:41 +0000 (21:58 +0000)
if_create_name crashes when vrf_id is VRF_UNKNOWN:
```
nfware# conf t
nfware(config)# router ospf vrf doesnt-exist
nfware(config-router)# area 1.1.1.1 virtual-link 2.2.2.2
vtysh: error reading from ospfd: Success (0)Warning: closing connection to ospfd because of an I/O error!
```

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
(cherry picked from commit 9f4ffd809a24b55da45198e07e7232679dd75a8c)

ospfd/ospf_interface.c
ospfd/ospf_vty.c

index b3aba247dfb4f0b399aa9dabc53782ad6506ed36..1c1c38a87976159541cb49c367f17d838bab4ea1 100644 (file)
@@ -909,6 +909,13 @@ struct ospf_interface *ospf_vl_new(struct ospf *ospf,
                return NULL;
        }
 
+       if (ospf->vrf_id == VRF_UNKNOWN) {
+               if (IS_DEBUG_OSPF_EVENT)
+                       zlog_debug(
+                               "ospf_vl_new(): Alarm: cannot create pseudo interface in unknown VRF");
+               return NULL;
+       }
+
        if (IS_DEBUG_OSPF_EVENT)
                zlog_debug(
                        "ospf_vl_new(): creating pseudo zebra interface vrf id %u",
index 881355a84b75f80d0ed920415250b211cbc0186b..a796c6547a02336b3423ba43a7e296fc89c8206a 100644 (file)
@@ -892,6 +892,12 @@ ospf_find_vl_data(struct ospf *ospf, struct ospf_vl_config_data *vl_config)
                vl_data = ospf_vl_data_new(area, vl_config->vl_peer);
                if (vl_data->vl_oi == NULL) {
                        vl_data->vl_oi = ospf_vl_new(ospf, vl_data);
+                       if (!vl_data->vl_oi) {
+                               ospf_vl_data_free(vl_data);
+                               vty_out(vty,
+                                       "Can't create VL, check logs for more information\n");
+                               return NULL;
+                       }
                        ospf_vl_add(ospf, vl_data);
                        ospf_spf_calculate_schedule(ospf,
                                                    SPF_FLAG_CONFIG_CHANGE);