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;
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 */
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);
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)) {
/* 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);
struct ospf_interface *oi;
struct interface *ifp;
struct listnode *node;
- int type;
if (!ospf->oi_running) {
if (IS_DEBUG_OSPF_EVENT)
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) {
}
}
- /* 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);
}
}
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 */