]> git.proxmox.com Git - mirror_frr.git/commitdiff
ospfd: kill totally misnamed "timers"
authorDavid Lamparter <equinox@diac24.net>
Mon, 29 Jul 2019 10:27:25 +0000 (12:27 +0200)
committerDavid Lamparter <equinox@diac24.net>
Fri, 2 Aug 2019 09:29:03 +0000 (11:29 +0200)
Neither ospf_external_lsa_originate_timer() nor
ospf_default_originate_timer() are actually timers.  They're only
executed on router-ID changes to refresh a particular LSA type.

Signed-off-by: David Lamparter <equinox@diac24.net>
ospfd/ospf_lsa.c
ospfd/ospf_lsa.h
ospfd/ospf_zebra.c
ospfd/ospfd.c
ospfd/ospfd.h

index dd9d0ca27a8eda35db63a5cea8e760265f89b9be..c5e2c44275761f28439a1f93a4ee647cd01e9628 100644 (file)
@@ -2019,48 +2019,6 @@ struct ospf_lsa *ospf_external_lsa_originate(struct ospf *ospf,
        return new;
 }
 
-/* Originate AS-external-LSA from external info with initial flag. */
-int ospf_external_lsa_originate_timer(struct thread *thread)
-{
-       struct ospf *ospf = THREAD_ARG(thread);
-       struct route_node *rn;
-       struct external_info *ei;
-       struct route_table *rt;
-       int type = THREAD_VAL(thread);
-       struct list *ext_list;
-       struct listnode *node;
-       struct ospf_external *ext;
-
-       ext_list = ospf->external[type];
-       if (!ext_list)
-               return 0;
-
-       for (ALL_LIST_ELEMENTS_RO(ext_list, node, ext)) {
-               /* Originate As-external-LSA from all type of distribute source.
-                */
-               rt = ext->external_info;
-               if (!rt)
-                       continue;
-
-               for (rn = route_top(rt); rn; rn = route_next(rn)) {
-                       ei = rn->info;
-
-                       if (!ei)
-                               continue;
-
-                       if (is_prefix_default((struct prefix_ipv4 *)&ei->p))
-                               continue;
-
-                       if (!ospf_external_lsa_originate(ospf, ei))
-                               flog_warn(
-                                       EC_OSPF_LSA_INSTALL_FAILURE,
-                                       "LSA: AS-external-LSA was not originated.");
-               }
-       }
-
-       return 0;
-}
-
 static struct external_info *ospf_default_external_info(struct ospf *ospf)
 {
        int type;
@@ -2100,31 +2058,52 @@ static struct external_info *ospf_default_external_info(struct ospf *ospf)
        return NULL;
 }
 
-int ospf_default_originate_timer(struct thread *thread)
+void ospf_external_lsa_rid_change(struct ospf *ospf)
 {
-       struct prefix_ipv4 p;
-       struct in_addr nexthop;
        struct external_info *ei;
-       struct ospf *ospf;
+       int type;
 
-       ospf = THREAD_ARG(thread);
+       for (type = 0; type < ZEBRA_ROUTE_MAX; type++) {
+               struct route_node *rn;
+               struct route_table *rt;
+               struct list *ext_list;
+               struct listnode *node;
+               struct ospf_external *ext;
 
-       p.family = AF_INET;
-       p.prefix.s_addr = 0;
-       p.prefixlen = 0;
+               ext_list = ospf->external[type];
+               if (!ext_list)
+                       continue;
 
-       if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS) {
-               /* If there is no default route via redistribute,
-                  then originate AS-external-LSA with nexthop 0 (self). */
-               nexthop.s_addr = 0;
-               ospf_external_info_add(ospf, DEFAULT_ROUTE, 0, p, 0, nexthop,
-                                      0);
-       }
+               for (ALL_LIST_ELEMENTS_RO(ext_list, node, ext)) {
+                       /* Originate As-external-LSA from all type of
+                        * distribute source.
+                        */
+                       rt = ext->external_info;
+                       if (!rt)
+                               continue;
 
-       if ((ei = ospf_default_external_info(ospf)))
-               ospf_external_lsa_originate(ospf, ei);
+                       for (rn = route_top(rt); rn; rn = route_next(rn)) {
+                               ei = rn->info;
 
-       return 0;
+                               if (!ei)
+                                       continue;
+
+                               if (is_prefix_default(
+                                               (struct prefix_ipv4 *)&ei->p))
+                                       continue;
+
+                               if (!ospf_external_lsa_originate(ospf, ei))
+                                       flog_warn(EC_OSPF_LSA_INSTALL_FAILURE,
+                                               "LSA: AS-external-LSA was not originated.");
+                       }
+               }
+       }
+
+       ei = ospf_default_external_info(ospf);
+       if (ei && !ospf_external_lsa_originate(ospf, ei)) {
+               flog_warn(EC_OSPF_LSA_INSTALL_FAILURE,
+                       "LSA: AS-external-LSA for default route was not originated.");
+       }
 }
 
 /* Flush any NSSA LSAs for given prefix */
index 5e3dabc27a1f3db41ccb5f129993f2403983021d..4551b83d755da359b433f11d7d4049e0e1585a7f 100644 (file)
@@ -275,8 +275,7 @@ extern struct in_addr ospf_get_ip_from_ifp(struct ospf_interface *);
 
 extern struct ospf_lsa *ospf_external_lsa_originate(struct ospf *,
                                                    struct external_info *);
-extern int ospf_external_lsa_originate_timer(struct thread *);
-extern int ospf_default_originate_timer(struct thread *);
+extern void ospf_external_lsa_rid_change(struct ospf *ospf);
 extern struct ospf_lsa *ospf_lsa_lookup(struct ospf *ospf, struct ospf_area *,
                                        uint32_t, struct in_addr,
                                        struct in_addr);
index 951402f47fa7b36530104e5f17037244d019563e..c72e5c2d3735e9de3ceb40ecd8cb8cdd47d432be 100644 (file)
@@ -765,8 +765,6 @@ int ospf_redistribute_default_set(struct ospf *ospf, int originate, int mtype,
                        metric_type(ospf, DEFAULT_ROUTE, 0),
                        metric_value(ospf, DEFAULT_ROUTE, 0));
 
-               if (ospf->router_id.s_addr == 0)
-                       ospf->external_origin |= (1 << DEFAULT_ROUTE);
                if ((originate == DEFAULT_ORIGINATE_ALWAYS)
                          && (ospf->router_id.s_addr)) {
 
@@ -1067,11 +1065,7 @@ static int ospf_zebra_read_route(ZAPI_CALLBACK_ARGS)
                        /* Nothing has changed, so nothing to do; return */
                        return 0;
                }
-               if (ospf->router_id.s_addr == 0)
-                       /* Set flags to generate AS-external-LSA originate event
-                          for each redistributed protocols later. */
-                       ospf->external_origin |= (1 << rt_type);
-               else {
+               if (ospf->router_id.s_addr != 0) {
                        if (ei) {
                                if (is_prefix_default(&p))
                                        ospf_external_lsa_refresh_default(ospf);
index 0325b7ba1b35013389a3177ee86df0bd9a2e4b53..739cb280a68cb6ab7a506000a44255d6b8aba999 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);
        }
 }
 
index 38d4752cbeffc96cb01448949ef53f90eeae85c9..b31ad303758d175f4e80abfa0f986da016a1ef69 100644 (file)
@@ -202,7 +202,6 @@ struct ospf {
        struct ospf_lsdb *lsdb;
 
        /* Flags. */
-       int external_origin; /* AS-external-LSA origin flag. */
        int ase_calc;   /* ASE calculation flag. */
 
        struct list *opaque_lsa_self; /* Type-11 Opaque-LSAs */