]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospfd/ospfd.c
Merge pull request #5549 from donaldsharp/automated
[mirror_frr.git] / ospfd / ospfd.c
index a64ddbc3b7df06426a2ca2caaeab9e5e804eba70..6a4e63372aedeab31919ccedc4981963b0ac9ab8 100644 (file)
@@ -91,7 +91,6 @@ void ospf_router_id_update(struct ospf *ospf)
        struct ospf_interface *oi;
        struct interface *ifp;
        struct listnode *node;
-       int type;
 
        if (!ospf->oi_running) {
                if (IS_DEBUG_OSPF_EVENT)
@@ -135,24 +134,6 @@ void ospf_router_id_update(struct ospf *ospf)
                        ospf_nbr_self_reset(oi, router_id);
                }
 
-               /* If AS-external-LSA is queued, then flush those LSAs. */
-               if (router_id_old.s_addr == 0 && ospf->external_origin) {
-                       /* Originate each redistributed external route. */
-                       for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
-                               if (ospf->external_origin & (1 << type))
-                                       thread_add_event(
-                                               master,
-                                               ospf_external_lsa_originate_timer,
-                                               ospf, type, NULL);
-                       /* Originate Deafult. */
-                       if (ospf->external_origin & (1 << ZEBRA_ROUTE_MAX))
-                               thread_add_event(master,
-                                                ospf_default_originate_timer,
-                                                ospf, 0, NULL);
-
-                       ospf->external_origin = 0;
-               }
-
                /* Flush (inline) all external LSAs based on the OSPF_LSA_SELF
                 * flag */
                if (ospf->lsdb) {
@@ -196,20 +177,14 @@ void ospf_router_id_update(struct ospf *ospf)
                        }
                }
 
-               /* Originate each redistributed external route. */
-               for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
-                       thread_add_event(master,
-                                        ospf_external_lsa_originate_timer,
-                                        ospf, type, NULL);
-               thread_add_event(master, ospf_default_originate_timer, ospf, 0,
-                                NULL);
-
                /* update router-lsa's for each area */
                ospf_router_lsa_update(ospf);
 
                /* update ospf_interface's */
                FOR_ALL_INTERFACES (vrf, ifp)
                        ospf_if_update(ospf, ifp);
+
+               ospf_external_lsa_rid_change(ospf);
        }
 }
 
@@ -318,11 +293,6 @@ static struct ospf *ospf_new(unsigned short instance, const char *name)
        new->oi_write_q = list_new();
        new->write_oi_count = OSPF_WRITE_INTERFACE_COUNT_DEFAULT;
 
-/* Enable "log-adjacency-changes" */
-#if DFLT_OSPF_LOG_ADJACENCY_CHANGES
-       SET_FLAG(new->config, OSPF_LOG_ADJACENCY_CHANGES);
-#endif
-
        QOBJ_REG(new, ospf);
 
        new->fd = -1;
@@ -393,7 +363,7 @@ struct ospf *ospf_lookup_by_inst_name(unsigned short instance, const char *name)
        return NULL;
 }
 
-struct ospf *ospf_get(unsigned short instance, const char *name)
+struct ospf *ospf_get(unsigned short instance, const char *name, bool *created)
 {
        struct ospf *ospf;
 
@@ -404,6 +374,7 @@ struct ospf *ospf_get(unsigned short instance, const char *name)
        else
                ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
 
+       *created = (ospf == NULL);
        if (ospf == NULL) {
                ospf = ospf_new(instance, name);
                ospf_add(ospf);
@@ -417,27 +388,18 @@ struct ospf *ospf_get(unsigned short instance, const char *name)
        return ospf;
 }
 
-struct ospf *ospf_get_instance(unsigned short instance)
+struct ospf *ospf_get_instance(unsigned short instance, bool *created)
 {
        struct ospf *ospf;
 
        ospf = ospf_lookup_instance(instance);
+       *created = (ospf == NULL);
        if (ospf == NULL) {
                ospf = ospf_new(instance, NULL /* VRF_DEFAULT*/);
                ospf_add(ospf);
 
-               if (ospf->router_id_static.s_addr == 0) {
-                       if (vrf_lookup_by_id(ospf->vrf_id))
-                               ospf_router_id_update(ospf);
-                       else {
-                               if (IS_DEBUG_OSPF_EVENT)
-                                       zlog_debug(
-                                               "%s: ospf VRF (id %d) is not active yet, skip router id update",
-                                               __PRETTY_FUNCTION__,
-                                               ospf->vrf_id);
-                       }
+               if (ospf->router_id_static.s_addr == 0)
                        ospf_router_id_update(ospf);
-               }
 
                ospf_opaque_type11_lsa_init(ospf);
        }
@@ -609,7 +571,6 @@ static void ospf_finish_final(struct ospf *ospf)
        struct ospf_vl_data *vl_data;
        struct listnode *node, *nnode;
        int i;
-       unsigned short instance = 0;
 
        QOBJ_UNREG(ospf);
 
@@ -633,7 +594,7 @@ static void ospf_finish_final(struct ospf *ospf)
                        ospf_redist_del(ospf, i, red->instance);
                }
        }
-       ospf_redistribute_default_unset(ospf);
+       ospf_redistribute_default_set(ospf, DEFAULT_ORIGINATE_NONE, 0, 0);
 
        for (ALL_LIST_ELEMENTS(ospf->areas, node, nnode, area))
                ospf_remove_vls_through_area(ospf, area);
@@ -702,7 +663,6 @@ static void ospf_finish_final(struct ospf *ospf)
        /* Cancel all timers. */
        OSPF_TIMER_OFF(ospf->t_read);
        OSPF_TIMER_OFF(ospf->t_write);
-       OSPF_TIMER_OFF(ospf->t_external_lsa);
        OSPF_TIMER_OFF(ospf->t_spf_calc);
        OSPF_TIMER_OFF(ospf->t_ase_calc);
        OSPF_TIMER_OFF(ospf->t_maxage);
@@ -781,9 +741,6 @@ static void ospf_finish_final(struct ospf *ospf)
        ospf_distance_reset(ospf);
        route_table_finish(ospf->distance_table);
 
-       if (!CHECK_FLAG(om->options, OSPF_MASTER_SHUTDOWN))
-               instance = ospf->instance;
-
        list_delete(&ospf->areas);
        list_delete(&ospf->oi_write_q);
 
@@ -804,9 +761,6 @@ static void ospf_finish_final(struct ospf *ospf)
        }
 
        XFREE(MTYPE_OSPF_TOP, ospf);
-
-       if (!CHECK_FLAG(om->options, OSPF_MASTER_SHUTDOWN))
-               ospf_get_instance(instance);
 }
 
 
@@ -1365,6 +1319,7 @@ void ospf_if_update(struct ospf *ospf, struct interface *ifp)
 
        /* Update connected redistribute. */
        update_redistributed(ospf, 1);
+
 }
 
 void ospf_remove_vls_through_area(struct ospf *ospf, struct ospf_area *area)
@@ -2123,7 +2078,7 @@ static int ospf_vrf_enable(struct vrf *vrf)
                                old_vrf_id);
 
                if (old_vrf_id != ospf->vrf_id) {
-                       frr_elevate_privs(&ospfd_privs) {
+                       frr_with_privs(&ospfd_privs) {
                                /* stop zebra redist to us for old vrf */
                                zclient_send_dereg_requests(zclient,
                                                            old_vrf_id);
@@ -2184,7 +2139,7 @@ static int ospf_vrf_disable(struct vrf *vrf)
 void ospf_vrf_init(void)
 {
        vrf_init(ospf_vrf_new, ospf_vrf_enable, ospf_vrf_disable,
-                ospf_vrf_delete, NULL);
+                ospf_vrf_delete, ospf_vrf_enable);
 }
 
 void ospf_vrf_terminate(void)
@@ -2198,3 +2153,11 @@ const char *ospf_vrf_id_to_name(vrf_id_t vrf_id)
 
        return vrf ? vrf->name : "NIL";
 }
+
+const char *ospf_get_name(const struct ospf *ospf)
+{
+       if (ospf->name)
+               return ospf->name;
+       else
+               return VRF_DEFAULT_NAME;
+}